From 36f60e6c1afad0e9cf6b571348f243ffe3ef7f4b Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 26 Sep 2023 21:37:52 +0000 Subject: [PATCH 01/11] Start reworking JNI methods such that they pass void pointers from Java to C instead of passing their strongly-typed wrappers, as that is reportedly significantly faster than passing the wrapper objects to C and extracting the pointers there. There are still many, many functions left to rework for this. FossilOrigin-Name: 66c814dd473731703ee00e1ff610acfdccf09d1b87dd2355795ed697d4ed5d3e --- ext/jni/src/c/sqlite3-jni.c | 48 ++++++------------- ext/jni/src/c/sqlite3-jni.h | 16 +++---- .../org/sqlite/jni/NativePointerHolder.java | 13 +++++ ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 40 +++++++++++----- manifest | 23 +++++---- manifest.uuid | 2 +- 6 files changed, 77 insertions(+), 65 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index a35d9b81cf..15223b2f56 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -1441,26 +1441,9 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, #define PtrGet_sqlite3_stmt(OBJ) PtrGet_T(sqlite3_stmt, OBJ) #define PtrGet_sqlite3_value(OBJ) PtrGet_T(sqlite3_value, OBJ) -#if 0 -/* -** Enters the S3JniDb mutex and PtrGet_sqlite3()'s jObj. If that's -** NULL then it leaves the mutex, else the mutex is still entered -** when this returns and the caller is obligated to leave it. -*/ -static sqlite3* PtrGet__sqlite3_lock(JNIEnv * const env, jobject jObj){ - sqlite3 *rv; - S3JniDb_mutex_enter; - rv = PtrGet_sqlite3(jObj); - if( !rv ){ S3JniDb_mutex_leave; } - return rv; -} -#undef PtrGet_sqlite3 -#define PtrGet_sqlite3(JOBJ) PtrGet__sqlite3_lock(env, (JOBJ)) -#endif - /* ** Extracts the new S3JniDb instance from the free-list, or allocates -** one if needed, associats it with pDb, and returns. Returns NULL on +** one if needed, associates it with pDb, and returns. Returns NULL on ** OOM. pDb MUST, on success of the calling operation, subsequently be ** associated with jDb via NativePointerHolder_set(). */ @@ -1475,7 +1458,7 @@ static S3JniDb * S3JniDb_alloc(JNIEnv * const env, jobject jDb){ } S3JniDb_mutex_leave; if( 0==rv ){ - rv = s3jni_malloc( sizeof(S3JniDb)); + rv = s3jni_malloc(sizeof(S3JniDb)); if( rv ){ s3jni_incr( &SJG.metrics.nPdbAlloc ); } @@ -3408,13 +3391,12 @@ S3JniApi(sqlite3_extended_result_codes(),jboolean,1extended_1result_1codes)( } S3JniApi(sqlite3_finalize(),jint,1finalize)( - JniArgsEnvClass, jobject jpStmt + JniArgsEnvClass, jlong jpStmt ){ int rc = 0; - sqlite3_stmt * const pStmt = PtrGet_sqlite3_stmt(jpStmt); - if( pStmt ){ + if( jpStmt ){ + sqlite3_stmt * const pStmt = (void*)jpStmt; rc = sqlite3_finalize(pStmt); - NativePointerHolder_set(S3JniNph(sqlite3_stmt), jpStmt, 0); } return rc; } @@ -3637,7 +3619,7 @@ S3JniApi(sqlite3_open_v2(),jint,1open_1v2)( /* Proxy for the sqlite3_prepare[_v2/3]() family. */ jint sqlite3_jni_prepare_v123( int prepVersion, JNIEnv * const env, jclass self, - jobject jDb, jbyteArray baSql, + jlong jpDb, jbyteArray baSql, jint nMax, jint prepFlags, jobject jOutStmt, jobject outTail){ sqlite3_stmt * pStmt = 0; @@ -3656,13 +3638,13 @@ jint sqlite3_jni_prepare_v123( int prepVersion, JNIEnv * const env, jclass self, goto end; } switch( prepVersion ){ - case 1: rc = sqlite3_prepare(PtrGet_sqlite3(jDb), (const char *)pBuf, + case 1: rc = sqlite3_prepare((sqlite3*)jpDb, (const char *)pBuf, (int)nMax, &pStmt, &zTail); break; - case 2: rc = sqlite3_prepare_v2(PtrGet_sqlite3(jDb), (const char *)pBuf, + case 2: rc = sqlite3_prepare_v2((sqlite3*)jpDb, (const char *)pBuf, (int)nMax, &pStmt, &zTail); break; - case 3: rc = sqlite3_prepare_v3(PtrGet_sqlite3(jDb), (const char *)pBuf, + case 3: rc = sqlite3_prepare_v3((sqlite3*)jpDb, (const char *)pBuf, (int)nMax, (unsigned int)prepFlags, &pStmt, &zTail); break; @@ -3697,24 +3679,24 @@ end: return (jint)rc; } S3JniApi(sqlite3_prepare(),jint,1prepare)( - JNIEnv * const env, jclass self, jobject jDb, jbyteArray baSql, + JNIEnv * const env, jclass self, jlong jpDb, jbyteArray baSql, jint nMax, jobject jOutStmt, jobject outTail ){ - return sqlite3_jni_prepare_v123(1, env, self, jDb, baSql, nMax, 0, + return sqlite3_jni_prepare_v123(1, env, self, jpDb, baSql, nMax, 0, jOutStmt, outTail); } S3JniApi(sqlite3_prepare_v2(),jint,1prepare_1v2)( - JNIEnv * const env, jclass self, jobject jDb, jbyteArray baSql, + JNIEnv * const env, jclass self, jlong jpDb, jbyteArray baSql, jint nMax, jobject jOutStmt, jobject outTail ){ - return sqlite3_jni_prepare_v123(2, env, self, jDb, baSql, nMax, 0, + return sqlite3_jni_prepare_v123(2, env, self, jpDb, baSql, nMax, 0, jOutStmt, outTail); } S3JniApi(sqlite3_prepare_v3(),jint,1prepare_1v3)( - JNIEnv * const env, jclass self, jobject jDb, jbyteArray baSql, + JNIEnv * const env, jclass self, jlong jpDb, jbyteArray baSql, jint nMax, jint prepFlags, jobject jOutStmt, jobject outTail ){ - return sqlite3_jni_prepare_v123(3, env, self, jDb, baSql, nMax, + return sqlite3_jni_prepare_v123(3, env, self, jpDb, baSql, nMax, prepFlags, jOutStmt, outTail); } diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index 717a932676..7c64c48849 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -1406,10 +1406,10 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1error_1offset /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_finalize - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1finalize - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1510,26 +1510,26 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1open_1v2 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_prepare - * Signature: (Lorg/sqlite/jni/sqlite3;[BILorg/sqlite/jni/OutputPointer/sqlite3_stmt;Lorg/sqlite/jni/OutputPointer/Int32;)I + * Signature: (J[BILorg/sqlite/jni/OutputPointer/sqlite3_stmt;Lorg/sqlite/jni/OutputPointer/Int32;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1prepare - (JNIEnv *, jclass, jobject, jbyteArray, jint, jobject, jobject); + (JNIEnv *, jclass, jlong, jbyteArray, jint, jobject, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_prepare_v2 - * Signature: (Lorg/sqlite/jni/sqlite3;[BILorg/sqlite/jni/OutputPointer/sqlite3_stmt;Lorg/sqlite/jni/OutputPointer/Int32;)I + * Signature: (J[BILorg/sqlite/jni/OutputPointer/sqlite3_stmt;Lorg/sqlite/jni/OutputPointer/Int32;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1prepare_1v2 - (JNIEnv *, jclass, jobject, jbyteArray, jint, jobject, jobject); + (JNIEnv *, jclass, jlong, jbyteArray, jint, jobject, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_prepare_v3 - * Signature: (Lorg/sqlite/jni/sqlite3;[BIILorg/sqlite/jni/OutputPointer/sqlite3_stmt;Lorg/sqlite/jni/OutputPointer/Int32;)I + * Signature: (J[BIILorg/sqlite/jni/OutputPointer/sqlite3_stmt;Lorg/sqlite/jni/OutputPointer/Int32;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1prepare_1v3 - (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jobject, jobject); + (JNIEnv *, jclass, jlong, jbyteArray, jint, jint, jobject, jobject); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/NativePointerHolder.java b/ext/jni/src/org/sqlite/jni/NativePointerHolder.java index 251eb7faad..2b0e8cfbdd 100644 --- a/ext/jni/src/org/sqlite/jni/NativePointerHolder.java +++ b/ext/jni/src/org/sqlite/jni/NativePointerHolder.java @@ -29,5 +29,18 @@ package org.sqlite.jni; public class NativePointerHolder { //! Only set from JNI, where access permissions don't matter. private volatile long nativePointer = 0; + /** + For use ONLY by package-level APIs which act as proxies for + close/finalize operations. Such ops must call this to zero out + the pointer so that this object is not carrying a stale + pointer. This function returns the prior value of the pointer and + sets it to 0. + */ + final long clearNativePointer() { + final long rv = nativePointer; + nativePointer= 0; + return rv; + } + public final long getNativePointer(){ return nativePointer; } } diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 9257afbb69..5a83d642d8 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -738,7 +738,12 @@ public final class SQLite3Jni { public static native int sqlite3_error_offset(@NotNull sqlite3 db); @Canonical - public static native int sqlite3_finalize(@NotNull sqlite3_stmt stmt); + private static native int sqlite3_finalize(long ptrToStmt); + + @Canonical + public static int sqlite3_finalize(@NotNull sqlite3_stmt stmt){ + return null==stmt ? 0 : sqlite3_finalize(stmt.clearNativePointer()); + } @Canonical public static native int sqlite3_initialize(); @@ -850,7 +855,7 @@ public final class SQLite3Jni { */ @Canonical private static native int sqlite3_prepare( - @NotNull sqlite3 db, @NotNull byte[] sqlUtf8, int maxBytes, + @NotNull long ptrToDb, @NotNull byte[] sqlUtf8, int maxBytes, @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset ); @@ -869,14 +874,16 @@ public final class SQLite3Jni { @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset ){ - return sqlite3_prepare(db, sqlUtf8, sqlUtf8.length, outStmt, pTailOffset); + return sqlite3_prepare(db.getNativePointer(), sqlUtf8, sqlUtf8.length, + outStmt, pTailOffset); } public static int sqlite3_prepare( @NotNull sqlite3 db, @NotNull byte[] sqlUtf8, @NotNull OutputPointer.sqlite3_stmt outStmt ){ - return sqlite3_prepare(db, sqlUtf8, sqlUtf8.length, outStmt, null); + return sqlite3_prepare(db.getNativePointer(), sqlUtf8, sqlUtf8.length, + outStmt, null); } public static int sqlite3_prepare( @@ -884,7 +891,8 @@ public final class SQLite3Jni { @NotNull OutputPointer.sqlite3_stmt outStmt ){ final byte[] utf8 = sql.getBytes(StandardCharsets.UTF_8); - return sqlite3_prepare(db, utf8, utf8.length, outStmt, null); + return sqlite3_prepare(db.getNativePointer(), utf8, utf8.length, + outStmt, null); } /** @@ -907,7 +915,7 @@ public final class SQLite3Jni { */ @Canonical private static native int sqlite3_prepare_v2( - @NotNull sqlite3 db, @NotNull byte[] sqlUtf8, int maxBytes, + @NotNull long ptrToDb, @NotNull byte[] sqlUtf8, int maxBytes, @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset ); @@ -923,14 +931,16 @@ public final class SQLite3Jni { @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset ){ - return sqlite3_prepare_v2(db, sqlUtf8, sqlUtf8.length, outStmt, pTailOffset); + return sqlite3_prepare_v2(db.getNativePointer(), sqlUtf8, sqlUtf8.length, + outStmt, pTailOffset); } public static int sqlite3_prepare_v2( @NotNull sqlite3 db, @NotNull byte[] sqlUtf8, @NotNull OutputPointer.sqlite3_stmt outStmt ){ - return sqlite3_prepare_v2(db, sqlUtf8, sqlUtf8.length, outStmt, null); + return sqlite3_prepare_v2(db.getNativePointer(), sqlUtf8, sqlUtf8.length, + outStmt, null); } public static int sqlite3_prepare_v2( @@ -938,7 +948,8 @@ public final class SQLite3Jni { @NotNull OutputPointer.sqlite3_stmt outStmt ){ final byte[] utf8 = sql.getBytes(StandardCharsets.UTF_8); - return sqlite3_prepare_v2(db, utf8, utf8.length, outStmt, null); + return sqlite3_prepare_v2(db.getNativePointer(), utf8, utf8.length, + outStmt, null); } /** @@ -958,7 +969,7 @@ public final class SQLite3Jni { */ @Canonical private static native int sqlite3_prepare_v3( - @NotNull sqlite3 db, @NotNull byte[] sqlUtf8, int maxBytes, + @NotNull long ptrToDb, @NotNull byte[] sqlUtf8, int maxBytes, int prepFlags, @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset ); @@ -974,7 +985,8 @@ public final class SQLite3Jni { @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset ){ - return sqlite3_prepare_v3(db, sqlUtf8, sqlUtf8.length, prepFlags, outStmt, pTailOffset); + return sqlite3_prepare_v3(db.getNativePointer(), sqlUtf8, sqlUtf8.length, + prepFlags, outStmt, pTailOffset); } /** @@ -985,7 +997,8 @@ public final class SQLite3Jni { @NotNull sqlite3 db, @NotNull byte[] sqlUtf8, int prepFlags, @NotNull OutputPointer.sqlite3_stmt outStmt ){ - return sqlite3_prepare_v3(db, sqlUtf8, sqlUtf8.length, prepFlags, outStmt, null); + return sqlite3_prepare_v3(db.getNativePointer(), sqlUtf8, sqlUtf8.length, + prepFlags, outStmt, null); } /** @@ -998,7 +1011,8 @@ public final class SQLite3Jni { @NotNull OutputPointer.sqlite3_stmt outStmt ){ final byte[] utf8 = sql.getBytes(StandardCharsets.UTF_8); - return sqlite3_prepare_v3(db, utf8, utf8.length, prepFlags, outStmt, null); + return sqlite3_prepare_v3(db.getNativePointer(), utf8, utf8.length, + prepFlags, outStmt, null); } /** diff --git a/manifest b/manifest index 56def1ca67..24094aee0b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sthe\stestfixture\stesting\sutility. -D 2023-09-26T21:22:46.800 +C Start\sreworking\sJNI\smethods\ssuch\sthat\sthey\spass\svoid\spointers\sfrom\sJava\sto\sC\sinstead\sof\spassing\stheir\sstrongly-typed\swrappers,\sas\sthat\sis\sreportedly\ssignificantly\sfaster\sthan\spassing\sthe\swrapper\sobjects\sto\sC\sand\sextracting\sthe\spointers\sthere.\sThere\sare\sstill\smany,\smany\sfunctions\sleft\sto\srework\sfor\sthis. +D 2023-09-26T21:37:52.408 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 2932d4cae2b70a469a73f4a2cefa2701291e420155044d2c9e79137b65e237a1 -F ext/jni/src/c/sqlite3-jni.h 5e093f65c01050e6fe0988f559145f3b61a15c734aa3100a2b98d2a4b9d4c57a +F ext/jni/src/c/sqlite3-jni.c 14c1390d93ce1a0e48d402039fb37131cdc16ddd69d0762bdd0d05b229ea5570 +F ext/jni/src/c/sqlite3-jni.h 558b44b9dc5d88708ee6b43cac0cd61f836460f5de0458266ff25f7508ef92c7 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -251,7 +251,7 @@ F ext/jni/src/org/sqlite/jni/CollationNeededCallback.java 07df5fa161a0b811542952 F ext/jni/src/org/sqlite/jni/CommitHookCallback.java 77cf8bb4f5548113e9792978f3f8a454614f420fa0ad73939421cbff4e7776f2 F ext/jni/src/org/sqlite/jni/ConfigLogCallback.java 636ed6b89ed03f15bc2a6f6f47bf7853b8328e5a8269e52e80630708efa703a6 F ext/jni/src/org/sqlite/jni/ConfigSqllogCallback.java e3656909eab7ed0f7e457c5b82df160ca22dd5e954c0a306ec1fca61b0d266b4 -F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 564087036449a16df148dcf0a067408bd251170bf23286c655f46b5f973e8b2d +F ext/jni/src/org/sqlite/jni/NativePointerHolder.java 3eb36b5e81993a847f5ec03d23ab219a92671f817547b6a85d312667faeedd8b F ext/jni/src/org/sqlite/jni/OutputPointer.java 2f57c05672ddc9b38e3f8eed11759896cf0bf01107ffd24d5182b99f6e7254b6 F ext/jni/src/org/sqlite/jni/PrepareMultiCallback.java 878ed9cc8000def1a4e6d7113d52bba6fce0aa6733b4eb216d68dfbe096776ac F ext/jni/src/org/sqlite/jni/PreupdateHookCallback.java eccaed8dc9c6289f07ef3fc109891c6be1e7cc6c88723d90174b68706fc21cda @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 73571d69420a72fa656097925acfbc3f670bb72685882094565303dcdfed71b5 +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 732c9f55de35f3e3bc08a0187794473171ba07b8f886907d022ef2ffc9a813b5 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 25be176398cf08cb9c0879ba33fd866cb8f579729dd4d44a4065421e1b899af4 @@ -2122,8 +2122,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b633d8bbdbd43464ee03058c273e5188117b9538ed5d5148a1a3851e4adf6410 -R eced8690afdbfb647f02413884f65126 -U drh -Z 45b315c34cd6350047553b4dd70ecf3a +P 5a39a02d2dfd9ed6171cd0bd434b2bc268d0ed8ead6e1a396d1603266d9493ef +R 47a30e26f3996fa866a87a8a39a6842f +T *branch * jni-ptr-passing +T *sym-jni-ptr-passing * +T -sym-trunk * Cancelled\sby\sbranch. +U stephan +Z 219c3daa73370ae53cc699c76c54d2c3 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8dc7343078..483c7eca96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5a39a02d2dfd9ed6171cd0bd434b2bc268d0ed8ead6e1a396d1603266d9493ef \ No newline at end of file +66c814dd473731703ee00e1ff610acfdccf09d1b87dd2355795ed697d4ed5d3e \ No newline at end of file From 4632f9140328699ca5a00803623f8a864d03d36d Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 27 Sep 2023 09:58:36 +0000 Subject: [PATCH 02/11] Rework the JNI sqlite3_backup APIs to the new pointer-passing approach. FossilOrigin-Name: 48aeb1e2cdeb4aec85c4f63a1f809215cd4b473791169e72b5ddf6d6bdc2f7b7 --- ext/jni/src/c/sqlite3-jni.c | 79 +++++++++++-------- ext/jni/src/c/sqlite3-jni.h | 20 ++--- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 43 ++++++++-- ext/jni/src/org/sqlite/jni/Tester1.java | 51 ++++++------ .../src/org/sqlite/jni/sqlite3_backup.java | 8 +- manifest | 23 +++--- manifest.uuid | 2 +- 7 files changed, 133 insertions(+), 93 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 15223b2f56..39cbe0e3d1 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -1176,6 +1176,8 @@ static void S3JniHook__unref(JNIEnv * const env, S3JniHook * const s){ } S3JniUnrefGlobal(s->jObj); S3JniUnrefGlobal(s->jExtra); + }else{ + assert( !s->jExtra ); } *s = S3JniHook_empty; } @@ -1183,8 +1185,8 @@ static void S3JniHook__unref(JNIEnv * const env, S3JniHook * const s){ /* ** Allocates one blank S3JniHook object from the recycling bin, if -** available, else from the heap. Returns NULL or dies on OOM. Locks -** the global mutex. +** available, else from the heap. Returns NULL or dies on OOM, +** depending on build options. Locks on SJG.hooks.mutex. */ static S3JniHook *S3JniHook__alloc(JNIEnv * const env){ S3JniHook * p = 0; @@ -1211,7 +1213,7 @@ static S3JniHook *S3JniHook__alloc(JNIEnv * const env){ /* ** The rightful fate of all results from S3JniHook_alloc(). Locks on -** SJG>hooks.mutex. +** SJG.hook.mutex. */ static void S3JniHook__free(JNIEnv * const env, S3JniHook * const p){ if(p){ @@ -1290,10 +1292,11 @@ static void S3JniDb__set_aside(JNIEnv * const env, S3JniDb * const s){ /* ** Uncache any state for the given JNIEnv, clearing all Java ** references the cache owns. Returns true if env was cached and false -** if it was not found in the cache. Ownership of the given object is -** passed over to this function, which makes it free for re-use. +** if it was not found in the cache. Ownership of the S3JniEnv object +** associated with the given argument is transferred to this function, +** which makes it free for re-use. ** -** Requires that the Env mutex be locked. +** Requires that the env mutex be locked. */ static int S3JniEnv_uncache(JNIEnv * const env){ struct S3JniEnv * row; @@ -1307,7 +1310,7 @@ static int S3JniEnv_uncache(JNIEnv * const env){ } } if( !row ){ - return 0; + return 0; } if( pPrev) pPrev->pNext = row->pNext; else{ @@ -1432,6 +1435,13 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, ** will work, despite the incorrect macro name, so long as the ** argument is a Java sqlite3 object, as this operation only has void ** pointers to work with. +** +** PtrCast_T(X,Y) variant expects X to be an unqualified sqlite3 +** struct type name and Y to be a native pointer to such an object in +** the form of a jlong value. The jlong is simply cast to (X*). This +** approach is, as of 2023-09-27, supplanting the former approach. We +** now do the native pointer extraction in the Java side, rather than +** the C side, because it's reportedly significantly faster. */ #define PtrGet_T(T,OBJ) (T*)NativePointerHolder_get(OBJ, S3JniNph(T)) #define PtrGet_sqlite3(OBJ) PtrGet_T(sqlite3, OBJ) @@ -1440,12 +1450,14 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, #define PtrGet_sqlite3_context(OBJ) PtrGet_T(sqlite3_context, OBJ) #define PtrGet_sqlite3_stmt(OBJ) PtrGet_T(sqlite3_stmt, OBJ) #define PtrGet_sqlite3_value(OBJ) PtrGet_T(sqlite3_value, OBJ) +#define PtrCast_T(T,JLongPtr) (T*)(JLongPtr) /* ** Extracts the new S3JniDb instance from the free-list, or allocates -** one if needed, associates it with pDb, and returns. Returns NULL on -** OOM. pDb MUST, on success of the calling operation, subsequently be -** associated with jDb via NativePointerHolder_set(). +** one if needed, associates it with pDb, and returns. Returns NULL +** on OOM. The returned object MUST, on success of the calling +** operation, subsequently be associated with jDb via +** NativePointerHolder_set() or freed using S3JniDb_set_aside(). */ static S3JniDb * S3JniDb_alloc(JNIEnv * const env, jobject jDb){ S3JniDb * rv = 0; @@ -2219,19 +2231,21 @@ S3JniApi(sqlite3_auto_extension(),jint,1auto_1extension)( } S3JniApi(sqlite3_backup_finish(),jint,1backup_1finish)( - JniArgsEnvClass, jobject jBack + JniArgsEnvClass, jlong jpBack ){ - sqlite3_backup * const pB = PtrGet_sqlite3_backup(jBack); - NativePointerHolder_set(S3JniNph(sqlite3_backup), jBack, 0); - return sqlite3_backup_finish(pB); + int rc = 0; + if( jpBack!=0 ){ + rc = sqlite3_backup_finish( PtrCast_T(sqlite3_backup,jpBack) ); + } + return rc; } S3JniApi(sqlite3_backup_init(),jobject,1backup_1init)( - JniArgsEnvClass, jobject jDbDest, jstring jTDest, - jobject jDbSrc, jstring jTSrc + JniArgsEnvClass, jlong jpDbDest, jstring jTDest, + jlong jpDbSrc, jstring jTSrc ){ - sqlite3 * const pDest = PtrGet_sqlite3(jDbDest); - sqlite3 * const pSrc = PtrGet_sqlite3(jDbSrc); + sqlite3 * const pDest = PtrCast_T(sqlite3,jpDbDest); + sqlite3 * const pSrc = PtrCast_T(sqlite3,jpDbSrc); char * const zDest = s3jni_jstring_to_utf8(jTDest, 0); char * const zSrc = s3jni_jstring_to_utf8(jTSrc, 0); jobject rv = 0; @@ -2252,21 +2266,21 @@ S3JniApi(sqlite3_backup_init(),jobject,1backup_1init)( } S3JniApi(sqlite3_backup_pagecount(),jint,1backup_1pagecount)( - JniArgsEnvClass, jobject jBack + JniArgsEnvClass, jlong jpBack ){ - return sqlite3_backup_pagecount(PtrGet_sqlite3_backup(jBack)); + return sqlite3_backup_pagecount(PtrCast_T(sqlite3_backup,jpBack)); } S3JniApi(sqlite3_backup_remaining(),jint,1backup_1remaining)( - JniArgsEnvClass, jobject jBack + JniArgsEnvClass, jlong jpBack ){ - return sqlite3_backup_remaining(PtrGet_sqlite3_backup(jBack)); + return sqlite3_backup_remaining(PtrCast_T(sqlite3_backup,jpBack)); } S3JniApi(sqlite3_backup_step(),jint,1backup_1step)( - JniArgsEnvClass, jobject jBack, jint nPage + JniArgsEnvClass, jlong jpBack, jint nPage ){ - return sqlite3_backup_step(PtrGet_sqlite3_backup(jBack), (int)nPage); + return sqlite3_backup_step(PtrCast_T(sqlite3_backup,jpBack), (int)nPage); } S3JniApi(sqlite3_bind_blob(),jint,1bind_1blob)( @@ -3393,12 +3407,9 @@ S3JniApi(sqlite3_extended_result_codes(),jboolean,1extended_1result_1codes)( S3JniApi(sqlite3_finalize(),jint,1finalize)( JniArgsEnvClass, jlong jpStmt ){ - int rc = 0; - if( jpStmt ){ - sqlite3_stmt * const pStmt = (void*)jpStmt; - rc = sqlite3_finalize(pStmt); - } - return rc; + return jpStmt + ? sqlite3_finalize(PtrCast_T(sqlite3_stmt,jpStmt)) + : 0; } S3JniApi(sqlite3_get_auxdata(),jobject,1get_1auxdata)( @@ -3638,18 +3649,18 @@ jint sqlite3_jni_prepare_v123( int prepVersion, JNIEnv * const env, jclass self, goto end; } switch( prepVersion ){ - case 1: rc = sqlite3_prepare((sqlite3*)jpDb, (const char *)pBuf, + case 1: rc = sqlite3_prepare(PtrCast_T(sqlite3,jpDb), (const char *)pBuf, (int)nMax, &pStmt, &zTail); break; - case 2: rc = sqlite3_prepare_v2((sqlite3*)jpDb, (const char *)pBuf, + case 2: rc = sqlite3_prepare_v2(PtrCast_T(sqlite3,jpDb), (const char *)pBuf, (int)nMax, &pStmt, &zTail); break; - case 3: rc = sqlite3_prepare_v3((sqlite3*)jpDb, (const char *)pBuf, + case 3: rc = sqlite3_prepare_v3(PtrCast_T(sqlite3,jpDb), (const char *)pBuf, (int)nMax, (unsigned int)prepFlags, &pStmt, &zTail); break; default: - assert(0 && "Invalid prepare() version"); + assert(!"Invalid prepare() version"); } end: s3jni_jbyteArray_release(baSql,pBuf); diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index 7c64c48849..e967fb4e40 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -814,42 +814,42 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1auto_1extension /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_backup_finish - * Signature: (Lorg/sqlite/jni/sqlite3_backup;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1finish - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_backup_init - * Signature: (Lorg/sqlite/jni/sqlite3;Ljava/lang/String;Lorg/sqlite/jni/sqlite3;Ljava/lang/String;)Lorg/sqlite/jni/sqlite3_backup; + * Signature: (JLjava/lang/String;JLjava/lang/String;)Lorg/sqlite/jni/sqlite3_backup; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1init - (JNIEnv *, jclass, jobject, jstring, jobject, jstring); + (JNIEnv *, jclass, jlong, jstring, jlong, jstring); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_backup_pagecount - * Signature: (Lorg/sqlite/jni/sqlite3_backup;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1pagecount - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_backup_remaining - * Signature: (Lorg/sqlite/jni/sqlite3_backup;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1remaining - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_backup_step - * Signature: (Lorg/sqlite/jni/sqlite3_backup;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1step - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 5a83d642d8..9535ad1858 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -161,24 +161,51 @@ public final class SQLite3Jni { public static native int sqlite3_auto_extension(@NotNull AutoExtensionCallback callback); @Canonical - public static native int sqlite3_backup_finish(@NotNull sqlite3_backup b); + private static native int sqlite3_backup_finish(@NotNull long ptrToBackup); @Canonical - public static native sqlite3_backup sqlite3_backup_init( + public static int sqlite3_backup_finish(@NotNull sqlite3_backup b){ + return sqlite3_backup_finish(b.clearNativePointer()); + } + + @Canonical + private static native sqlite3_backup sqlite3_backup_init( + @NotNull long ptrToDbDest, @NotNull String destTableName, + @NotNull long ptrToDbSrc, @NotNull String srcTableName + ); + + @Canonical + public static sqlite3_backup sqlite3_backup_init( @NotNull sqlite3 dbDest, @NotNull String destTableName, @NotNull sqlite3 dbSrc, @NotNull String srcTableName - ); + ){ + return sqlite3_backup_init( dbDest.getNativePointer(), destTableName, + dbSrc.getNativePointer(), srcTableName ); + } @Canonical - public static native int sqlite3_backup_pagecount(@NotNull sqlite3_backup b); + private static native int sqlite3_backup_pagecount(@NotNull long ptrToBackup); @Canonical - public static native int sqlite3_backup_remaining(@NotNull sqlite3_backup b); + public static int sqlite3_backup_pagecount(@NotNull sqlite3_backup b){ + return sqlite3_backup_pagecount(b.getNativePointer()); + } @Canonical - public static native int sqlite3_backup_step( - @NotNull sqlite3_backup b, int nPage - ); + private static native int sqlite3_backup_remaining(@NotNull long ptrToBackup); + + @Canonical + public static int sqlite3_backup_remaining(@NotNull sqlite3_backup b){ + return sqlite3_backup_remaining(b.getNativePointer()); + } + + @Canonical + private static native int sqlite3_backup_step(@NotNull long ptrToBackup, int nPage); + + @Canonical + public static int sqlite3_backup_step(@NotNull sqlite3_backup b, int nPage){ + return sqlite3_backup_step(b.getNativePointer(), nPage); + } /** Results are undefined if data is not null and n<0 || n>=data.length. diff --git a/ext/jni/src/org/sqlite/jni/Tester1.java b/ext/jni/src/org/sqlite/jni/Tester1.java index 37125744fb..d4e8213736 100644 --- a/ext/jni/src/org/sqlite/jni/Tester1.java +++ b/ext/jni/src/org/sqlite/jni/Tester1.java @@ -1515,35 +1515,34 @@ public class Tester1 implements Runnable { } private void testBackup(){ - final sqlite3 db1 = createNewDb(); - final sqlite3 db2 = createNewDb(); + final sqlite3 dbDest = createNewDb(); - execSql(db1, new String[]{ - "pragma page_size=512; VACUUM;", - "create table t(a);", - "insert into t(a) values(1),(2),(3);" - }); - affirm( null==sqlite3_backup_init(db1,"main",db1,"main") ); - final sqlite3_backup b = sqlite3_backup_init(db2,"main",db1,"main"); - affirm( null!=b ); - affirm( b.getNativePointer()!=0 ); - int rc; - while( SQLITE_DONE!=(rc = sqlite3_backup_step(b, 1)) ){ - affirm( 0==rc ); + try (sqlite3 dbSrc = createNewDb()) { + execSql(dbSrc, new String[]{ + "pragma page_size=512; VACUUM;", + "create table t(a);", + "insert into t(a) values(1),(2),(3);" + }); + affirm( null==sqlite3_backup_init(dbSrc,"main",dbSrc,"main") ); + try (sqlite3_backup b = sqlite3_backup_init(dbDest,"main",dbSrc,"main")) { + affirm( null!=b ); + affirm( b.getNativePointer()!=0 ); + int rc; + while( SQLITE_DONE!=(rc = sqlite3_backup_step(b, 1)) ){ + affirm( 0==rc ); + } + affirm( sqlite3_backup_pagecount(b) > 0 ); + rc = sqlite3_backup_finish(b); + affirm( 0==rc ); + affirm( b.getNativePointer()==0 ); + } } - affirm( sqlite3_backup_pagecount(b) > 0 ); - rc = sqlite3_backup_finish(b); - affirm( 0==rc ); - affirm( b.getNativePointer()==0 ); - sqlite3_close_v2(db1); - - final sqlite3_stmt stmt = prepare(db2,"SELECT sum(a) from t"); - sqlite3_step(stmt); - affirm( sqlite3_column_int(stmt,0) == 6 ); - - sqlite3_finalize(stmt); - sqlite3_close_v2(db2); + try (sqlite3_stmt stmt = prepare(dbDest,"SELECT sum(a) from t")) { + sqlite3_step(stmt); + affirm( sqlite3_column_int(stmt,0) == 6 ); + } + sqlite3_close_v2(dbDest); } private void testRandomness(){ diff --git a/ext/jni/src/org/sqlite/jni/sqlite3_backup.java b/ext/jni/src/org/sqlite/jni/sqlite3_backup.java index d8ba78aec8..1e12e65cd0 100644 --- a/ext/jni/src/org/sqlite/jni/sqlite3_backup.java +++ b/ext/jni/src/org/sqlite/jni/sqlite3_backup.java @@ -19,7 +19,13 @@ package org.sqlite.jni; simply provide a type-safe way to communicate it between Java and C via JNI. */ -public final class sqlite3_backup extends NativePointerHolder { +public final class sqlite3_backup extends NativePointerHolder + implements AutoCloseable { // Only invoked from JNI. private sqlite3_backup(){} + + @Override public void close(){ + SQLite3Jni.sqlite3_backup_finish(this); + } + } diff --git a/manifest b/manifest index 24094aee0b..2393f8fa89 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Start\sreworking\sJNI\smethods\ssuch\sthat\sthey\spass\svoid\spointers\sfrom\sJava\sto\sC\sinstead\sof\spassing\stheir\sstrongly-typed\swrappers,\sas\sthat\sis\sreportedly\ssignificantly\sfaster\sthan\spassing\sthe\swrapper\sobjects\sto\sC\sand\sextracting\sthe\spointers\sthere.\sThere\sare\sstill\smany,\smany\sfunctions\sleft\sto\srework\sfor\sthis. -D 2023-09-26T21:37:52.408 +C Rework\sthe\sJNI\ssqlite3_backup\sAPIs\sto\sthe\snew\spointer-passing\sapproach. +D 2023-09-27T09:58:36.928 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 14c1390d93ce1a0e48d402039fb37131cdc16ddd69d0762bdd0d05b229ea5570 -F ext/jni/src/c/sqlite3-jni.h 558b44b9dc5d88708ee6b43cac0cd61f836460f5de0458266ff25f7508ef92c7 +F ext/jni/src/c/sqlite3-jni.c 75006d6766e33f7a747db7339609f979732b2eb89586ca6ff6486c4cfed740fa +F ext/jni/src/c/sqlite3-jni.h c5ae22c939f122fe8009fb69855951abe715058fe5575f78085608a587201c53 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,10 +259,10 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 732c9f55de35f3e3bc08a0187794473171ba07b8f886907d022ef2ffc9a813b5 +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 7d185104c1395587bf36f10492beda7d78d6686c3e43200e81f0c38b5fabdc2f F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab -F ext/jni/src/org/sqlite/jni/Tester1.java 25be176398cf08cb9c0879ba33fd866cb8f579729dd4d44a4065421e1b899af4 +F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 F ext/jni/src/org/sqlite/jni/TraceV2Callback.java beb0b064c1a5f8bfe585a324ed39a4e33edbe379a3fc60f1401661620d3ca7c0 F ext/jni/src/org/sqlite/jni/UpdateHookCallback.java 8376f4a931f2d5612b295c003c9515ba933ee76d8f95610e89c339727376e36c F ext/jni/src/org/sqlite/jni/WindowFunction.java 488980f4dbb6bdd7067d6cb9c43e4075475e51c54d9b74a5834422654b126246 @@ -283,7 +283,7 @@ F ext/jni/src/org/sqlite/jni/fts5/fts5_extension_function.java 1fe0f5692c1d67475 F ext/jni/src/org/sqlite/jni/fts5/fts5_tokenizer.java ea993738b851038c16d98576abd0db3d6028a231f075a394fb8a78c7834d0f6c F ext/jni/src/org/sqlite/jni/package-info.java a3946db2504de747a1993c4f6e8ce604bec5a8e5a134b292c3b07527bc321a99 F ext/jni/src/org/sqlite/jni/sqlite3.java 5e56a799ced58ea69e8bcad20c29a61fce32f21a7f4fb3e2702337cf8aa1a06e -F ext/jni/src/org/sqlite/jni/sqlite3_backup.java d0bb06dd6225e76999ff6b7ab20f2643b1c4d4167431b3a93ea41943e41f094b +F ext/jni/src/org/sqlite/jni/sqlite3_backup.java 12182124c4d4928d78db5a07ea285f1d7af04c7a148f0759a1972d5bfa87311e F ext/jni/src/org/sqlite/jni/sqlite3_blob.java f28a30134f2e524eb7d5ab87f57f86c90140341a6e8369ee54509ac8bb96fa82 F ext/jni/src/org/sqlite/jni/sqlite3_context.java 66ca95ce904044263a4aff684abe262d56f73e6b06bca6cf650761d79d7779ad F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 36ecee9bdde2e70c7276d1c22b48fd9c40a77412e8e0694e9c09910997d6fb4f @@ -2122,11 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5a39a02d2dfd9ed6171cd0bd434b2bc268d0ed8ead6e1a396d1603266d9493ef -R 47a30e26f3996fa866a87a8a39a6842f -T *branch * jni-ptr-passing -T *sym-jni-ptr-passing * -T -sym-trunk * Cancelled\sby\sbranch. +P 66c814dd473731703ee00e1ff610acfdccf09d1b87dd2355795ed697d4ed5d3e +R f061d70c56ee00aa5b569b2ec65f25b0 U stephan -Z 219c3daa73370ae53cc699c76c54d2c3 +Z 06b4b7e93a4be23fe9e37ef080dd1dde # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 483c7eca96..75feaf613c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -66c814dd473731703ee00e1ff610acfdccf09d1b87dd2355795ed697d4ed5d3e \ No newline at end of file +48aeb1e2cdeb4aec85c4f63a1f809215cd4b473791169e72b5ddf6d6bdc2f7b7 \ No newline at end of file From 9afd67cce748510502a59e05ecc103029cb2523b Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 27 Sep 2023 10:29:07 +0000 Subject: [PATCH 03/11] Add missing license headers to JNI annotation classes and extend the definition of @NotNull to include 0L as the equivalent of null to account for the current rework of how pointers are passed from Java to C. FossilOrigin-Name: bccdfeb9efde20410bde545893fb98ce5c0c4d04a8e7797b868ba8994120e1db --- .../org/sqlite/jni/annotation/Canonical.java | 13 +++++++++ .../org/sqlite/jni/annotation/NotNull.java | 27 ++++++++++++++++--- .../org/sqlite/jni/annotation/Nullable.java | 13 +++++++++ .../sqlite/jni/annotation/package-info.java | 15 ++++++++++- manifest | 18 ++++++------- manifest.uuid | 2 +- 6 files changed, 73 insertions(+), 15 deletions(-) diff --git a/ext/jni/src/org/sqlite/jni/annotation/Canonical.java b/ext/jni/src/org/sqlite/jni/annotation/Canonical.java index fdb157335f..ebad0a44d2 100644 --- a/ext/jni/src/org/sqlite/jni/annotation/Canonical.java +++ b/ext/jni/src/org/sqlite/jni/annotation/Canonical.java @@ -1,3 +1,16 @@ +/* +** 2023-09-27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file houses the Canonical annotaion for the sqlite3 C API. +*/ package org.sqlite.jni.annotation; /** diff --git a/ext/jni/src/org/sqlite/jni/annotation/NotNull.java b/ext/jni/src/org/sqlite/jni/annotation/NotNull.java index 49003358db..3b4c1c7af1 100644 --- a/ext/jni/src/org/sqlite/jni/annotation/NotNull.java +++ b/ext/jni/src/org/sqlite/jni/annotation/NotNull.java @@ -1,3 +1,16 @@ +/* +** 2023-09-27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file houses the NotNull annotaion for the sqlite3 C API. +*/ package org.sqlite.jni.annotation; /** @@ -20,6 +33,11 @@ package org.sqlite.jni.annotation; any parameter marked with this annoation specifically invokes undefined behavior.

+

Passing 0 (i.e. C NULL) or a negative value for any long-type + parameter marked with this annoation specifically invokes undefined + behavior. Such values are treated as C pointers in the JNI + layer.

+

Note that the C-style API does not throw any exceptions on its own because it has a no-throw policy in order to retain its C-style semantics, but it may trigger NullPointerExceptions (or similar) if @@ -29,10 +47,11 @@ package org.sqlite.jni.annotation; programmatically ensure that NotNull is conformed to in client code.

-

This annotation is solely for the use by the classes in this - package but is made public so that javadoc will link to it from the - annotated functions. It is not part of the public API and - client-level code must not rely on it.

+

This annotation is solely for the use by the classes in the + org.sqlite package and subpackages, but is made public so that + javadoc will link to it from the annotated functions. It is not + part of the public API and client-level code must not rely on + it.

*/ @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) diff --git a/ext/jni/src/org/sqlite/jni/annotation/Nullable.java b/ext/jni/src/org/sqlite/jni/annotation/Nullable.java index 7a011e33b1..ddc8502d67 100644 --- a/ext/jni/src/org/sqlite/jni/annotation/Nullable.java +++ b/ext/jni/src/org/sqlite/jni/annotation/Nullable.java @@ -1,3 +1,16 @@ +/* +** 2023-09-27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file houses the Nullable annotaion for the sqlite3 C API. +*/ package org.sqlite.jni.annotation; /** diff --git a/ext/jni/src/org/sqlite/jni/annotation/package-info.java b/ext/jni/src/org/sqlite/jni/annotation/package-info.java index 50db2a32bd..20ac7a3017 100644 --- a/ext/jni/src/org/sqlite/jni/annotation/package-info.java +++ b/ext/jni/src/org/sqlite/jni/annotation/package-info.java @@ -1,4 +1,17 @@ +/* +** 2023-09-27 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +*/ /** - This package houses annotations specific a JNI binding to the SQLite3 C API. + This package houses annotations specific to the JNI bindings of the + SQLite3 C API. */ package org.sqlite.jni.annotation; diff --git a/manifest b/manifest index 2393f8fa89..5ec6a13b35 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rework\sthe\sJNI\ssqlite3_backup\sAPIs\sto\sthe\snew\spointer-passing\sapproach. -D 2023-09-27T09:58:36.928 +C Add\smissing\slicense\sheaders\sto\sJNI\sannotation\sclasses\sand\sextend\sthe\sdefinition\sof\s@NotNull\sto\sinclude\s0L\sas\sthe\sequivalent\sof\snull\sto\saccount\sfor\sthe\scurrent\srework\sof\show\spointers\sare\spassed\sfrom\sJava\sto\sC. +D 2023-09-27T10:29:07.535 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -267,10 +267,10 @@ F ext/jni/src/org/sqlite/jni/TraceV2Callback.java beb0b064c1a5f8bfe585a324ed39a4 F ext/jni/src/org/sqlite/jni/UpdateHookCallback.java 8376f4a931f2d5612b295c003c9515ba933ee76d8f95610e89c339727376e36c F ext/jni/src/org/sqlite/jni/WindowFunction.java 488980f4dbb6bdd7067d6cb9c43e4075475e51c54d9b74a5834422654b126246 F ext/jni/src/org/sqlite/jni/XDestroyCallback.java 50c5ca124ef6c6b735a7e136e7a23a557be367e61b56d4aab5777a614ab46cc2 -F ext/jni/src/org/sqlite/jni/annotation/Canonical.java 2767daa5b3893b96729db80a0f8234d379d266d1b2c21400a057864b538a0ea5 -F ext/jni/src/org/sqlite/jni/annotation/NotNull.java d9b32956cb9fb11d1f8a562e5df70d0599820265285120c63858294dbe2b7711 -F ext/jni/src/org/sqlite/jni/annotation/Nullable.java 6f962a98c9a5c6e9d21c50ae8716b16bdfdc934a191608cbb7e12ea588ddb6af -F ext/jni/src/org/sqlite/jni/annotation/package-info.java f66bfb621c6494e67c03ed38a9e26a3bd6af99b9f9f6ef79556bcec30a025a22 +F ext/jni/src/org/sqlite/jni/annotation/Canonical.java 44ea75a3c6c39513be9052eaa845b258a953f6af59e61002d715363fa52a7175 +F ext/jni/src/org/sqlite/jni/annotation/NotNull.java a99341e88154e70447596b1af6a27c586317df41a7e0f246fd41370cd7b723b2 +F ext/jni/src/org/sqlite/jni/annotation/Nullable.java 0b1879852707f752512d4db9d7edd0d8db2f0c2612316ce1c832715e012ff6ba +F ext/jni/src/org/sqlite/jni/annotation/package-info.java 977b374aed9d5853cbf3438ba3b0940abfa2ea4574f702a2448ee143b98ac3ca F ext/jni/src/org/sqlite/jni/fts5/Fts5.java e94681023785f1eff5399f0ddc82f46b035977d350f14838db659236ebdf6b41 F ext/jni/src/org/sqlite/jni/fts5/Fts5Context.java 7058da97059b8e156c17561a47ecd7faa0fc3e2d8c2588b9a28dbff8d06202dd F ext/jni/src/org/sqlite/jni/fts5/Fts5ExtensionApi.java e2680721bd83129d0d650ba845b44d7634a9489a90a56c5ce3c54508bf470743 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 66c814dd473731703ee00e1ff610acfdccf09d1b87dd2355795ed697d4ed5d3e -R f061d70c56ee00aa5b569b2ec65f25b0 +P 48aeb1e2cdeb4aec85c4f63a1f809215cd4b473791169e72b5ddf6d6bdc2f7b7 +R a34c0eaabd3c3fa31bb3e5e381a8b931 U stephan -Z 06b4b7e93a4be23fe9e37ef080dd1dde +Z 1792595153ca7945031ea25d28fafae5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 75feaf613c..049472ccd7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48aeb1e2cdeb4aec85c4f63a1f809215cd4b473791169e72b5ddf6d6bdc2f7b7 \ No newline at end of file +bccdfeb9efde20410bde545893fb98ce5c0c4d04a8e7797b868ba8994120e1db \ No newline at end of file From a917ee705604b95100d70a408d790bf1be4fc0af Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 27 Sep 2023 11:01:32 +0000 Subject: [PATCH 04/11] Adapt JNI sqlite3_bind_...() bindings to the new pointer-passing method and correct the mapping of sqlite3_bind_zeroblob64() to use zeroblob64() instead of zeroblob(). Related internal API renaming. FossilOrigin-Name: 980d559fff6e55d1e2ef39f242a8a09313a936cfb141807db475bcceff924869 --- ext/jni/src/c/sqlite3-jni.c | 115 +++++++++-------- ext/jni/src/c/sqlite3-jni.h | 52 ++++---- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 142 +++++++++++++++------ manifest | 16 +-- manifest.uuid | 2 +- 5 files changed, 200 insertions(+), 127 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 39cbe0e3d1..e1d64f128d 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -1435,13 +1435,6 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, ** will work, despite the incorrect macro name, so long as the ** argument is a Java sqlite3 object, as this operation only has void ** pointers to work with. -** -** PtrCast_T(X,Y) variant expects X to be an unqualified sqlite3 -** struct type name and Y to be a native pointer to such an object in -** the form of a jlong value. The jlong is simply cast to (X*). This -** approach is, as of 2023-09-27, supplanting the former approach. We -** now do the native pointer extraction in the Java side, rather than -** the C side, because it's reportedly significantly faster. */ #define PtrGet_T(T,OBJ) (T*)NativePointerHolder_get(OBJ, S3JniNph(T)) #define PtrGet_sqlite3(OBJ) PtrGet_T(sqlite3, OBJ) @@ -1450,7 +1443,18 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, #define PtrGet_sqlite3_context(OBJ) PtrGet_T(sqlite3_context, OBJ) #define PtrGet_sqlite3_stmt(OBJ) PtrGet_T(sqlite3_stmt, OBJ) #define PtrGet_sqlite3_value(OBJ) PtrGet_T(sqlite3_value, OBJ) -#define PtrCast_T(T,JLongPtr) (T*)(JLongPtr) +/* +** S3JniLongPtr_T(X,Y) expects X to be an unqualified sqlite3 +** struct type name and Y to be a native pointer to such an object in +** the form of a jlong value. The jlong is simply cast to (X*). This +** approach is, as of 2023-09-27, supplanting the former approach. We +** now do the native pointer extraction in the Java side, rather than +** the C side, because it's reportedly significantly faster. +*/ +#define S3JniLongPtr_T(T,JLongPtr) (T*)(JLongPtr) +#define S3JniLongPtr_sqlite3(JLongPtr) S3JniLongPtr_T(sqlite3,JLongPtr) +#define S3JniLongPtr_sqlite3_backup(JLongPtr) S3JniLongPtr_T(sqlite3_backup,JLongPtr) +#define S3JniLongPtr_sqlite3_stmt(JLongPtr) S3JniLongPtr_T(sqlite3_stmt,JLongPtr) /* ** Extracts the new S3JniDb instance from the free-list, or allocates @@ -2031,7 +2035,6 @@ static void udf_xInverse(sqlite3_context* cx, int argc, return (jint)CName(PtrGet_sqlite3_value(jpSValue)); \ } -WRAP_INT_STMT(1bind_1parameter_1count, sqlite3_bind_parameter_count) WRAP_INT_DB(1changes, sqlite3_changes) WRAP_INT64_DB(1changes64, sqlite3_changes64) WRAP_INT_STMT(1clear_1bindings, sqlite3_clear_bindings) @@ -2235,7 +2238,7 @@ S3JniApi(sqlite3_backup_finish(),jint,1backup_1finish)( ){ int rc = 0; if( jpBack!=0 ){ - rc = sqlite3_backup_finish( PtrCast_T(sqlite3_backup,jpBack) ); + rc = sqlite3_backup_finish( S3JniLongPtr_sqlite3_backup(jpBack) ); } return rc; } @@ -2244,8 +2247,8 @@ S3JniApi(sqlite3_backup_init(),jobject,1backup_1init)( JniArgsEnvClass, jlong jpDbDest, jstring jTDest, jlong jpDbSrc, jstring jTSrc ){ - sqlite3 * const pDest = PtrCast_T(sqlite3,jpDbDest); - sqlite3 * const pSrc = PtrCast_T(sqlite3,jpDbSrc); + sqlite3 * const pDest = S3JniLongPtr_sqlite3(jpDbDest); + sqlite3 * const pSrc = S3JniLongPtr_sqlite3(jpDbSrc); char * const zDest = s3jni_jstring_to_utf8(jTDest, 0); char * const zSrc = s3jni_jstring_to_utf8(jTSrc, 0); jobject rv = 0; @@ -2268,64 +2271,65 @@ S3JniApi(sqlite3_backup_init(),jobject,1backup_1init)( S3JniApi(sqlite3_backup_pagecount(),jint,1backup_1pagecount)( JniArgsEnvClass, jlong jpBack ){ - return sqlite3_backup_pagecount(PtrCast_T(sqlite3_backup,jpBack)); + return sqlite3_backup_pagecount(S3JniLongPtr_sqlite3_backup(jpBack)); } S3JniApi(sqlite3_backup_remaining(),jint,1backup_1remaining)( JniArgsEnvClass, jlong jpBack ){ - return sqlite3_backup_remaining(PtrCast_T(sqlite3_backup,jpBack)); + return sqlite3_backup_remaining(S3JniLongPtr_sqlite3_backup(jpBack)); } S3JniApi(sqlite3_backup_step(),jint,1backup_1step)( JniArgsEnvClass, jlong jpBack, jint nPage ){ - return sqlite3_backup_step(PtrCast_T(sqlite3_backup,jpBack), (int)nPage); + return sqlite3_backup_step(S3JniLongPtr_sqlite3_backup(jpBack), (int)nPage); } S3JniApi(sqlite3_bind_blob(),jint,1bind_1blob)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax + JniArgsEnvClass, jlong jpStmt, jint ndx, jbyteArray baData, jint nMax ){ jbyte * const pBuf = baData ? s3jni_jbyteArray_bytes(baData) : 0; int rc; if( pBuf ){ - rc = sqlite3_bind_blob(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, + rc = sqlite3_bind_blob(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, pBuf, (int)nMax, SQLITE_TRANSIENT); s3jni_jbyteArray_release(baData, pBuf); }else{ rc = baData ? SQLITE_NOMEM - : sqlite3_bind_null( PtrGet_sqlite3_stmt(jpStmt), ndx ); + : sqlite3_bind_null( S3JniLongPtr_sqlite3_stmt(jpStmt), ndx ); } return (jint)rc; } S3JniApi(sqlite3_bind_double(),jint,1bind_1double)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jdouble val + JniArgsEnvClass, jlong jpStmt, jint ndx, jdouble val ){ - return (jint)sqlite3_bind_double(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (double)val); + return (jint)sqlite3_bind_double(S3JniLongPtr_sqlite3_stmt(jpStmt), + (int)ndx, (double)val); } S3JniApi(sqlite3_bind_int(),jint,1bind_1int)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jint val + JniArgsEnvClass, jlong jpStmt, jint ndx, jint val ){ - return (jint)sqlite3_bind_int(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (int)val); + return (jint)sqlite3_bind_int(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, (int)val); } S3JniApi(sqlite3_bind_int64(),jint,1bind_1int64)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jlong val + JniArgsEnvClass, jlong jpStmt, jint ndx, jlong val ){ - return (jint)sqlite3_bind_int64(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (sqlite3_int64)val); + return (jint)sqlite3_bind_int64(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, (sqlite3_int64)val); } /* ** Bind a new global ref to Object `val` using sqlite3_bind_pointer(). */ S3JniApi(sqlite3_bind_java_object(),jint,1bind_1java_1object)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jobject val + JniArgsEnvClass, jlong jpStmt, jint ndx, jobject val ){ - sqlite3_stmt * const pStmt = PtrGet_sqlite3_stmt(jpStmt); - int rc = 0; + sqlite3_stmt * const pStmt = S3JniLongPtr_sqlite3_stmt(jpStmt); + int rc = SQLITE_MISUSE; if(pStmt){ jobject const rv = val ? S3JniRefGlobal(val) : 0; @@ -2334,26 +2338,32 @@ S3JniApi(sqlite3_bind_java_object(),jint,1bind_1java_1object)( S3Jni_jobject_finalizer); }else if(val){ rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_bind_null(pStmt, ndx); } - }else{ - rc = SQLITE_MISUSE; } return rc; } S3JniApi(sqlite3_bind_null(),jint,1bind_1null)( - JniArgsEnvClass, jobject jpStmt, jint ndx + JniArgsEnvClass, jlong jpStmt, jint ndx ){ - return (jint)sqlite3_bind_null(PtrGet_sqlite3_stmt(jpStmt), (int)ndx); + return (jint)sqlite3_bind_null(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx); +} + +S3JniApi(sqlite3_bind_parameter_count(),jint,1bind_1parameter_1count)( + JniArgsEnvClass, jlong jpStmt +){ + return (jint)sqlite3_bind_parameter_count(S3JniLongPtr_sqlite3_stmt(jpStmt)); } S3JniApi(sqlite3_bind_parameter_index(),jint,1bind_1parameter_1index)( - JniArgsEnvClass, jobject jpStmt, jbyteArray jName + JniArgsEnvClass, jlong jpStmt, jbyteArray jName ){ int rc = 0; jbyte * const pBuf = s3jni_jbyteArray_bytes(jName); if( pBuf ){ - rc = sqlite3_bind_parameter_index(PtrGet_sqlite3_stmt(jpStmt), + rc = sqlite3_bind_parameter_index(S3JniLongPtr_sqlite3_stmt(jpStmt), (const char *)pBuf); s3jni_jbyteArray_release(jName, pBuf); } @@ -2361,23 +2371,18 @@ S3JniApi(sqlite3_bind_parameter_index(),jint,1bind_1parameter_1index)( } S3JniApi(sqlite3_bind_parameter_name(),jstring,1bind_1parameter_1name)( - JniArgsEnvClass, jobject jpStmt, jint ndx + JniArgsEnvClass, jlong jpStmt, jint ndx ){ - jstring rv = 0; const char *z = - sqlite3_bind_parameter_name(PtrGet_sqlite3_stmt(jpStmt), (int)ndx); - - if( z ){ - rv = s3jni_utf8_to_jstring(z, -1); - } - return rv; + sqlite3_bind_parameter_name(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx); + return z ? s3jni_utf8_to_jstring(z, -1) : 0; } S3JniApi(sqlite3_bind_text(),jint,1bind_1text)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax + JniArgsEnvClass, jlong jpStmt, jint ndx, jbyteArray baData, jint nMax ){ jbyte * const pBuf = baData ? s3jni_jbyteArray_bytes(baData) : 0; - int const rc = sqlite3_bind_text(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, + int const rc = sqlite3_bind_text(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, (const char *)pBuf, (int)nMax, SQLITE_TRANSIENT); s3jni_jbyteArray_release(baData, pBuf); @@ -2385,25 +2390,27 @@ S3JniApi(sqlite3_bind_text(),jint,1bind_1text)( } S3JniApi(sqlite3_bind_text16(),jint,1bind_1text16)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jbyteArray baData, jint nMax + JniArgsEnvClass, jlong jpStmt, jint ndx, jbyteArray baData, jint nMax ){ jbyte * const pBuf = baData ? s3jni_jbyteArray_bytes(baData) : 0; - int const rc = sqlite3_bind_text16(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, + int const rc = sqlite3_bind_text16(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx, pBuf, (int)nMax, SQLITE_TRANSIENT); s3jni_jbyteArray_release(baData, pBuf); return (jint)rc; } S3JniApi(sqlite3_bind_zeroblob(),jint,1bind_1zeroblob)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jint n + JniArgsEnvClass, jlong jpStmt, jint ndx, jint n ){ - return (jint)sqlite3_bind_zeroblob(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (int)n); + return (jint)sqlite3_bind_zeroblob(S3JniLongPtr_sqlite3_stmt(jpStmt), + (int)ndx, (int)n); } -S3JniApi(sqlite3_bind_zeroblob(),jint,1bind_1zeroblob64)( - JniArgsEnvClass, jobject jpStmt, jint ndx, jlong n +S3JniApi(sqlite3_bind_zeroblob64(),jint,1bind_1zeroblob64)( + JniArgsEnvClass, jlong jpStmt, jint ndx, jlong n ){ - return (jint)sqlite3_bind_zeroblob(PtrGet_sqlite3_stmt(jpStmt), (int)ndx, (sqlite3_uint64)n); + return (jint)sqlite3_bind_zeroblob64(S3JniLongPtr_sqlite3_stmt(jpStmt), + (int)ndx, (sqlite3_uint64)n); } S3JniApi(sqlite3_blob_bytes(),jint,1blob_1bytes)( @@ -3408,7 +3415,7 @@ S3JniApi(sqlite3_finalize(),jint,1finalize)( JniArgsEnvClass, jlong jpStmt ){ return jpStmt - ? sqlite3_finalize(PtrCast_T(sqlite3_stmt,jpStmt)) + ? sqlite3_finalize(S3JniLongPtr_sqlite3_stmt(jpStmt)) : 0; } @@ -3649,13 +3656,13 @@ jint sqlite3_jni_prepare_v123( int prepVersion, JNIEnv * const env, jclass self, goto end; } switch( prepVersion ){ - case 1: rc = sqlite3_prepare(PtrCast_T(sqlite3,jpDb), (const char *)pBuf, + case 1: rc = sqlite3_prepare(S3JniLongPtr_sqlite3(jpDb), (const char *)pBuf, (int)nMax, &pStmt, &zTail); break; - case 2: rc = sqlite3_prepare_v2(PtrCast_T(sqlite3,jpDb), (const char *)pBuf, + case 2: rc = sqlite3_prepare_v2(S3JniLongPtr_sqlite3(jpDb), (const char *)pBuf, (int)nMax, &pStmt, &zTail); break; - case 3: rc = sqlite3_prepare_v3(PtrCast_T(sqlite3,jpDb), (const char *)pBuf, + case 3: rc = sqlite3_prepare_v3(S3JniLongPtr_sqlite3(jpDb), (const char *)pBuf, (int)nMax, (unsigned int)prepFlags, &pStmt, &zTail); break; diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index e967fb4e40..ae7f8e456a 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -854,106 +854,106 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1backup_1step /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_blob - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I[BI)I + * Signature: (JI[BI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1blob - (JNIEnv *, jclass, jobject, jint, jbyteArray, jint); + (JNIEnv *, jclass, jlong, jint, jbyteArray, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_double - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;ID)I + * Signature: (JID)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1double - (JNIEnv *, jclass, jobject, jint, jdouble); + (JNIEnv *, jclass, jlong, jint, jdouble); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_int - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;II)I + * Signature: (JII)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1int - (JNIEnv *, jclass, jobject, jint, jint); + (JNIEnv *, jclass, jlong, jint, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_int64 - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;IJ)I + * Signature: (JIJ)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1int64 - (JNIEnv *, jclass, jobject, jint, jlong); + (JNIEnv *, jclass, jlong, jint, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_java_object - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;ILjava/lang/Object;)I + * Signature: (JILjava/lang/Object;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1java_1object - (JNIEnv *, jclass, jobject, jint, jobject); + (JNIEnv *, jclass, jlong, jint, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_null - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1null - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_parameter_count - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1parameter_1count - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_parameter_index - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;[B)I + * Signature: (J[B)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1parameter_1index - (JNIEnv *, jclass, jobject, jbyteArray); + (JNIEnv *, jclass, jlong, jbyteArray); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_parameter_name - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String; + * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1parameter_1name - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_text - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I[BI)I + * Signature: (JI[BI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1text - (JNIEnv *, jclass, jobject, jint, jbyteArray, jint); + (JNIEnv *, jclass, jlong, jint, jbyteArray, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_text16 - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I[BI)I + * Signature: (JI[BI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1text16 - (JNIEnv *, jclass, jobject, jint, jbyteArray, jint); + (JNIEnv *, jclass, jlong, jint, jbyteArray, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_zeroblob - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;II)I + * Signature: (JII)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1zeroblob - (JNIEnv *, jclass, jobject, jint, jint); + (JNIEnv *, jclass, jlong, jint, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_bind_zeroblob64 - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;IJ)I + * Signature: (JIJ)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1zeroblob64 - (JNIEnv *, jclass, jobject, jint, jlong); + (JNIEnv *, jclass, jlong, jint, jlong); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 9535ad1858..6f77a85892 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -207,55 +207,94 @@ public final class SQLite3Jni { return sqlite3_backup_step(b.getNativePointer(), nPage); } + @Canonical + private static native int sqlite3_bind_blob( + @NotNull long ptrToStmt, int ndx, @Nullable byte[] data, int n + ); + /** Results are undefined if data is not null and n<0 || n>=data.length. */ @Canonical - public static native int sqlite3_bind_blob( + public static int sqlite3_bind_blob( @NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data, int n - ); + ){ + return sqlite3_bind_blob(stmt.getNativePointer(), ndx, data, n); + } public static int sqlite3_bind_blob( @NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data ){ return (null==data) - ? sqlite3_bind_null(stmt, ndx) - : sqlite3_bind_blob(stmt, ndx, data, data.length); + ? sqlite3_bind_null(stmt.getNativePointer(), ndx) + : sqlite3_bind_blob(stmt.getNativePointer(), ndx, data, data.length); } @Canonical - public static native int sqlite3_bind_double( + private static native int sqlite3_bind_double( + @NotNull long ptrToStmt, int ndx, double v + ); + + @Canonical + public static int sqlite3_bind_double( @NotNull sqlite3_stmt stmt, int ndx, double v + ){ + return sqlite3_bind_double(stmt.getNativePointer(), ndx, v); + } + + @Canonical + private static native int sqlite3_bind_int( + @NotNull long ptrToStmt, int ndx, int v ); @Canonical - public static native int sqlite3_bind_int( + public static int sqlite3_bind_int( @NotNull sqlite3_stmt stmt, int ndx, int v + ){ + return sqlite3_bind_int(stmt.getNativePointer(), ndx, v); + } + + @Canonical + private static native int sqlite3_bind_int64( + @NotNull long ptrToStmt, int ndx, long v ); @Canonical - public static native int sqlite3_bind_int64( - @NotNull sqlite3_stmt stmt, int ndx, long v + public static int sqlite3_bind_int64(@NotNull sqlite3_stmt stmt, int ndx, long v){ + return sqlite3_bind_int64( stmt.getNativePointer(), ndx, v ); + } + + private static native int sqlite3_bind_java_object( + @NotNull long ptrToStmt, int ndx, @Nullable Object o ); /** - Binds the given object at the given index. + Binds the given object at the given index. If o is null then this behaves like + sqlite3_bind_null(). @see #sqlite3_result_java_object */ - public static native int sqlite3_bind_java_object( - @NotNull sqlite3_stmt cx, int ndx, @Nullable Object o - ); + public static int sqlite3_bind_java_object( + @NotNull sqlite3_stmt stmt, int ndx, @Nullable Object o + ){ + return sqlite3_bind_java_object(stmt.getNativePointer(), ndx, o); + } @Canonical - public static native int sqlite3_bind_null( - @NotNull sqlite3_stmt stmt, int ndx - ); + private static native int sqlite3_bind_null(@NotNull long ptrToStmt, int ndx); @Canonical - public static native int sqlite3_bind_parameter_count( - @NotNull sqlite3_stmt stmt - ); + public static int sqlite3_bind_null(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_bind_null(stmt.getNativePointer(), ndx); + } + + @Canonical + private static native int sqlite3_bind_parameter_count(@NotNull long ptrToStmt); + + @Canonical + public static int sqlite3_bind_parameter_count(@NotNull sqlite3_stmt stmt){ + return sqlite3_bind_parameter_count(stmt.getNativePointer()); + } /** Requires that paramName be a NUL-terminated UTF-8 string. @@ -269,7 +308,7 @@ public final class SQLite3Jni { */ @Canonical private static native int sqlite3_bind_parameter_index( - @NotNull sqlite3_stmt stmt, @NotNull byte[] paramName + @NotNull long ptrToStmt, @NotNull byte[] paramName ); @Canonical @@ -277,12 +316,22 @@ public final class SQLite3Jni { @NotNull sqlite3_stmt stmt, @NotNull String paramName ){ final byte[] utf8 = (paramName+"\0").getBytes(StandardCharsets.UTF_8); - return sqlite3_bind_parameter_index(stmt, utf8); + return sqlite3_bind_parameter_index(stmt.getNativePointer(), utf8); } @Canonical - public static native String sqlite3_bind_parameter_name( - @NotNull sqlite3_stmt stmt, int index + private static native String sqlite3_bind_parameter_name( + @NotNull long ptrToStmt, int index + ); + + @Canonical + public static String sqlite3_bind_parameter_name(@NotNull sqlite3_stmt stmt, int index){ + return sqlite3_bind_parameter_name(stmt.getNativePointer(), index); + } + + @Canonical + private static native int sqlite3_bind_text( + @NotNull long ptrToStmt, int ndx, @Nullable byte[] utf8, int maxBytes ); /** @@ -295,9 +344,11 @@ public final class SQLite3Jni { undefined if data is not null and does not contain a NUL byte. */ @Canonical - public static native int sqlite3_bind_text( + public static int sqlite3_bind_text( @NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] utf8, int maxBytes - ); + ){ + return sqlite3_bind_text(stmt.getNativePointer(), ndx, utf8, maxBytes); + } /** Converts data, if not null, to a UTF-8-encoded byte array and @@ -307,9 +358,9 @@ public final class SQLite3Jni { public static int sqlite3_bind_text( @NotNull sqlite3_stmt stmt, int ndx, @Nullable String data ){ - if(null == data) return sqlite3_bind_null(stmt, ndx); + if( null==data ) return sqlite3_bind_null(stmt.getNativePointer(), ndx); final byte[] utf8 = data.getBytes(StandardCharsets.UTF_8); - return sqlite3_bind_text(stmt, ndx, utf8, utf8.length); + return sqlite3_bind_text(stmt.getNativePointer(), ndx, utf8, utf8.length); } /** @@ -319,19 +370,26 @@ public final class SQLite3Jni { @NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] utf8 ){ return (null == utf8) - ? sqlite3_bind_null(stmt, ndx) - : sqlite3_bind_text(stmt, ndx, utf8, utf8.length); + ? sqlite3_bind_null(stmt.getNativePointer(), ndx) + : sqlite3_bind_text(stmt.getNativePointer(), ndx, utf8, utf8.length); } + @Canonical + private static native int sqlite3_bind_text16( + @NotNull long ptrToStmt, int ndx, @Nullable byte[] data, int maxBytes + ); + /** Identical to the sqlite3_bind_text() overload with the same signature but requires that its input be encoded in UTF-16 in platform byte order. */ @Canonical - public static native int sqlite3_bind_text16( + public static int sqlite3_bind_text16( @NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data, int maxBytes - ); + ){ + return sqlite3_bind_text16(stmt.getNativePointer(), ndx, data, maxBytes); + } /** Converts its string argument to UTF-16 and binds it as such, returning @@ -343,7 +401,7 @@ public final class SQLite3Jni { ){ if(null == data) return sqlite3_bind_null(stmt, ndx); final byte[] bytes = data.getBytes(StandardCharsets.UTF_16); - return sqlite3_bind_text16(stmt, ndx, bytes, bytes.length); + return sqlite3_bind_text16(stmt.getNativePointer(), ndx, bytes, bytes.length); } /** @@ -355,19 +413,27 @@ public final class SQLite3Jni { @NotNull sqlite3_stmt stmt, int ndx, @Nullable byte[] data ){ return (null == data) - ? sqlite3_bind_null(stmt, ndx) - : sqlite3_bind_text16(stmt, ndx, data, data.length); + ? sqlite3_bind_null(stmt.getNativePointer(), ndx) + : sqlite3_bind_text16(stmt.getNativePointer(), ndx, data, data.length); } @Canonical - public static native int sqlite3_bind_zeroblob( - @NotNull sqlite3_stmt stmt, int ndx, int n + private static native int sqlite3_bind_zeroblob(@NotNull long ptrToStmt, int ndx, int n); + + @Canonical + public static int sqlite3_bind_zeroblob(@NotNull sqlite3_stmt stmt, int ndx, int n){ + return sqlite3_bind_zeroblob(stmt.getNativePointer(), ndx, n); + } + + @Canonical + private static native int sqlite3_bind_zeroblob64( + @NotNull long ptrToStmt, int ndx, long n ); @Canonical - public static native int sqlite3_bind_zeroblob64( - @NotNull sqlite3_stmt stmt, int ndx, long n - ); + public static int sqlite3_bind_zeroblob64(@NotNull sqlite3_stmt stmt, int ndx, long n){ + return sqlite3_bind_zeroblob64(stmt.getNativePointer(), ndx, n); + } @Canonical public static native int sqlite3_blob_bytes(@NotNull sqlite3_blob blob); diff --git a/manifest b/manifest index 5ec6a13b35..2bad9e6801 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smissing\slicense\sheaders\sto\sJNI\sannotation\sclasses\sand\sextend\sthe\sdefinition\sof\s@NotNull\sto\sinclude\s0L\sas\sthe\sequivalent\sof\snull\sto\saccount\sfor\sthe\scurrent\srework\sof\show\spointers\sare\spassed\sfrom\sJava\sto\sC. -D 2023-09-27T10:29:07.535 +C Adapt\sJNI\ssqlite3_bind_...()\sbindings\sto\sthe\snew\spointer-passing\smethod\sand\scorrect\sthe\smapping\sof\ssqlite3_bind_zeroblob64()\sto\suse\szeroblob64()\sinstead\sof\szeroblob().\sRelated\sinternal\sAPI\srenaming. +D 2023-09-27T11:01:32.787 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 75006d6766e33f7a747db7339609f979732b2eb89586ca6ff6486c4cfed740fa -F ext/jni/src/c/sqlite3-jni.h c5ae22c939f122fe8009fb69855951abe715058fe5575f78085608a587201c53 +F ext/jni/src/c/sqlite3-jni.c 7e1e0cf2f06a1d6c813fd3b684b5712dc8cccc6927d5f5d2b89d796f75799fb1 +F ext/jni/src/c/sqlite3-jni.h d503e60cdb9ce98f19d7bdd17a8f1b911931b6dddcc80ebef10c8160a6daab0b F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 7d185104c1395587bf36f10492beda7d78d6686c3e43200e81f0c38b5fabdc2f +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 24ca37368946b4fceabac1913c7a21dbe2a4a9f5db55350b4df2b45d169b4e5f F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 48aeb1e2cdeb4aec85c4f63a1f809215cd4b473791169e72b5ddf6d6bdc2f7b7 -R a34c0eaabd3c3fa31bb3e5e381a8b931 +P bccdfeb9efde20410bde545893fb98ce5c0c4d04a8e7797b868ba8994120e1db +R 07ea1023a2462cb72e478a493540d516 U stephan -Z 1792595153ca7945031ea25d28fafae5 +Z 250cebc4fc9c64e8ca5d6b6a65662ef8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 049472ccd7..0e420f19f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bccdfeb9efde20410bde545893fb98ce5c0c4d04a8e7797b868ba8994120e1db \ No newline at end of file +980d559fff6e55d1e2ef39f242a8a09313a936cfb141807db475bcceff924869 \ No newline at end of file From 1d74432fefa80874bac2e62c50ea65ebc64441ac Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 27 Sep 2023 14:41:49 +0000 Subject: [PATCH 05/11] Adapted JNI sqlite3_blob_...() and sqlite3_close...() to the new pointer-passing mechanism. FossilOrigin-Name: 0b22c8ef93e5ccd45316099fb8575e27620158b1992c0c70fe0348cfc10147f8 --- ext/jni/src/c/sqlite3-jni.c | 60 +++++------ ext/jni/src/c/sqlite3-jni.h | 40 ++++---- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 102 +++++++++++++++---- ext/jni/src/org/sqlite/jni/sqlite3.java | 4 +- ext/jni/src/org/sqlite/jni/sqlite3_blob.java | 8 +- ext/jni/src/org/sqlite/jni/sqlite3_stmt.java | 4 +- manifest | 22 ++-- manifest.uuid | 2 +- 8 files changed, 148 insertions(+), 94 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index e1d64f128d..da457174a4 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -1454,6 +1454,7 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, #define S3JniLongPtr_T(T,JLongPtr) (T*)(JLongPtr) #define S3JniLongPtr_sqlite3(JLongPtr) S3JniLongPtr_T(sqlite3,JLongPtr) #define S3JniLongPtr_sqlite3_backup(JLongPtr) S3JniLongPtr_T(sqlite3_backup,JLongPtr) +#define S3JniLongPtr_sqlite3_blob(JLongPtr) S3JniLongPtr_T(sqlite3_blob,JLongPtr) #define S3JniLongPtr_sqlite3_stmt(JLongPtr) S3JniLongPtr_T(sqlite3_stmt,JLongPtr) /* @@ -2414,27 +2415,23 @@ S3JniApi(sqlite3_bind_zeroblob64(),jint,1bind_1zeroblob64)( } S3JniApi(sqlite3_blob_bytes(),jint,1blob_1bytes)( - JniArgsEnvClass, jobject jBlob + JniArgsEnvClass, jlong jpBlob ){ - return sqlite3_blob_bytes(PtrGet_sqlite3_blob(jBlob)); + return sqlite3_blob_bytes(S3JniLongPtr_sqlite3_blob(jpBlob)); } S3JniApi(sqlite3_blob_close(),jint,1blob_1close)( - JniArgsEnvClass, jobject jBlob + JniArgsEnvClass, jlong jpBlob ){ - sqlite3_blob * const b = PtrGet_sqlite3_blob(jBlob); - jint const rc = b ? (jint)sqlite3_blob_close(b) : SQLITE_MISUSE; - if( b ){ - NativePointerHolder_set(S3JniNph(sqlite3_blob), jBlob, 0); - } - return rc; + sqlite3_blob * const b = S3JniLongPtr_sqlite3_blob(jpBlob); + return b ? (jint)sqlite3_blob_close(b) : SQLITE_MISUSE; } S3JniApi(sqlite3_blob_open(),jint,1blob_1open)( - JniArgsEnvClass, jobject jDb, jstring jDbName, jstring jTbl, jstring jCol, + JniArgsEnvClass, jlong jpDb, jstring jDbName, jstring jTbl, jstring jCol, jlong jRowId, jint flags, jobject jOut ){ - sqlite3 * const db = PtrGet_sqlite3(jDb); + sqlite3 * const db = S3JniLongPtr_sqlite3(jpDb); sqlite3_blob * pBlob = 0; char * zDbName = 0, * zTableName = 0, * zColumnName = 0; int rc; @@ -2462,13 +2459,13 @@ S3JniApi(sqlite3_blob_open(),jint,1blob_1open)( } S3JniApi(sqlite3_blob_read(),jint,1blob_1read)( - JniArgsEnvClass, jobject jBlob, jbyteArray jTgt, jint iOffset + JniArgsEnvClass, jlong jpBlob, jbyteArray jTgt, jint iOffset ){ jbyte * const pBa = s3jni_jbyteArray_bytes(jTgt); int rc = jTgt ? (pBa ? SQLITE_MISUSE : SQLITE_NOMEM) : SQLITE_MISUSE; if( pBa ){ jsize const nTgt = (*env)->GetArrayLength(env, jTgt); - rc = sqlite3_blob_read(PtrGet_sqlite3_blob(jBlob), pBa, + rc = sqlite3_blob_read(S3JniLongPtr_sqlite3_blob(jpBlob), pBa, (int)nTgt, (int)iOffset); if( 0==rc ){ s3jni_jbyteArray_commit(jTgt, pBa); @@ -2480,16 +2477,16 @@ S3JniApi(sqlite3_blob_read(),jint,1blob_1read)( } S3JniApi(sqlite3_blob_reopen(),jint,1blob_1reopen)( - JniArgsEnvClass, jobject jBlob, jlong iNewRowId + JniArgsEnvClass, jlong jpBlob, jlong iNewRowId ){ - return (jint)sqlite3_blob_reopen(PtrGet_sqlite3_blob(jBlob), + return (jint)sqlite3_blob_reopen(S3JniLongPtr_sqlite3_blob(jpBlob), (sqlite3_int64)iNewRowId); } S3JniApi(sqlite3_blob_write(),jint,1blob_1write)( - JniArgsEnvClass, jobject jBlob, jbyteArray jBa, jint iOffset + JniArgsEnvClass, jlong jpBlob, jbyteArray jBa, jint iOffset ){ - sqlite3_blob * const b = PtrGet_sqlite3_blob(jBlob); + sqlite3_blob * const b = S3JniLongPtr_sqlite3_blob(jpBlob); jbyte * const pBuf = b ? s3jni_jbyteArray_bytes(jBa) : 0; const jsize nBa = pBuf ? (*env)->GetArrayLength(env, jBa) : 0; int rc = SQLITE_MISUSE; @@ -2507,7 +2504,7 @@ static int s3jni_busy_handler(void* pState, int n){ S3JniDeclLocal_env; S3JniHook hook; - S3JniHook_localdup(&ps->hooks.busyHandler, &hook ); + S3JniHook_localdup(&ps->hooks.busyHandler, &hook); if( hook.jObj ){ rc = (*env)->CallIntMethod(env, hook.jObj, hook.midCallback, (jint)n); @@ -2522,9 +2519,9 @@ static int s3jni_busy_handler(void* pState, int n){ } S3JniApi(sqlite3_busy_handler(),jint,1busy_1handler)( - JniArgsEnvClass, jobject jDb, jobject jBusy + JniArgsEnvClass, jlong jpDb, jobject jBusy ){ - S3JniDb * const ps = S3JniDb_from_java(jDb); + S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); S3JniHook * const pHook = ps ? &ps->hooks.busyHandler : 0; S3JniHook hook = S3JniHook_empty; int rc = 0; @@ -2567,9 +2564,9 @@ S3JniApi(sqlite3_busy_handler(),jint,1busy_1handler)( } S3JniApi(sqlite3_busy_timeout(),jint,1busy_1timeout)( - JniArgsEnvClass, jobject jDb, jint ms + JniArgsEnvClass, jlong jpDb, jint ms ){ - S3JniDb * const ps = S3JniDb_from_java(jDb); + S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); int rc = SQLITE_MISUSE; if( ps ){ S3JniDb_mutex_enter; @@ -2606,32 +2603,25 @@ S3JniApi(sqlite3_cancel_auto_extension(),jboolean,1cancel_1auto_1extension)( } /* Wrapper for sqlite3_close(_v2)(). */ -static jint s3jni_close_db(JNIEnv * const env, jobject jDb, int version){ +static jint s3jni_close_db(JNIEnv * const env, jlong jpDb, int version){ int rc = 0; - S3JniDb * const ps = S3JniDb_from_java(jDb); + S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); assert(version == 1 || version == 2); if( ps ){ rc = 1==version ? (jint)sqlite3_close(ps->pDb) : (jint)sqlite3_close_v2(ps->pDb); - if( 0==rc ){ - NativePointerHolder_set(S3JniNph(sqlite3), jDb, 0); - } } return (jint)rc; } -S3JniApi(sqlite3_close_v2(),jint,1close_1v2)( - JniArgsEnvClass, jobject pDb -){ - return s3jni_close_db(env, pDb, 2); +S3JniApi(sqlite3_close(),jint,1close)(JniArgsEnvClass, jlong pDb){ + return s3jni_close_db(env, pDb, 1); } -S3JniApi(sqlite3_close(),jint,1close)( - JniArgsEnvClass, jobject pDb -){ - return s3jni_close_db(env, pDb, 1); +S3JniApi(sqlite3_close_v2(),jint,1close_1v2)(JniArgsEnvClass, jlong pDb){ + return s3jni_close_db(env, pDb, 2); } /* diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index ae7f8e456a..9a016c2e3f 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -958,66 +958,66 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1bind_1zeroblob64 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_blob_bytes - * Signature: (Lorg/sqlite/jni/sqlite3_blob;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1blob_1bytes - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_blob_close - * Signature: (Lorg/sqlite/jni/sqlite3_blob;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1blob_1close - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_blob_open - * Signature: (Lorg/sqlite/jni/sqlite3;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JILorg/sqlite/jni/OutputPointer/sqlite3_blob;)I + * Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;JILorg/sqlite/jni/OutputPointer/sqlite3_blob;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1blob_1open - (JNIEnv *, jclass, jobject, jstring, jstring, jstring, jlong, jint, jobject); + (JNIEnv *, jclass, jlong, jstring, jstring, jstring, jlong, jint, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_blob_read - * Signature: (Lorg/sqlite/jni/sqlite3_blob;[BI)I + * Signature: (J[BI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1blob_1read - (JNIEnv *, jclass, jobject, jbyteArray, jint); + (JNIEnv *, jclass, jlong, jbyteArray, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_blob_reopen - * Signature: (Lorg/sqlite/jni/sqlite3_blob;J)I + * Signature: (JJ)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1blob_1reopen - (JNIEnv *, jclass, jobject, jlong); + (JNIEnv *, jclass, jlong, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_blob_write - * Signature: (Lorg/sqlite/jni/sqlite3_blob;[BI)I + * Signature: (J[BI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1blob_1write - (JNIEnv *, jclass, jobject, jbyteArray, jint); + (JNIEnv *, jclass, jlong, jbyteArray, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_busy_handler - * Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/BusyHandlerCallback;)I + * Signature: (JLorg/sqlite/jni/BusyHandlerCallback;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1busy_1handler - (JNIEnv *, jclass, jobject, jobject); + (JNIEnv *, jclass, jlong, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_busy_timeout - * Signature: (Lorg/sqlite/jni/sqlite3;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1busy_1timeout - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1054,18 +1054,18 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1clear_1bindings /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_close - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1close - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_close_v2 - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1close_1v2 - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 6f77a85892..d619bfefed 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -436,18 +436,38 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_blob_bytes(@NotNull sqlite3_blob blob); + private static native int sqlite3_blob_bytes(@NotNull long ptrToBlob); @Canonical - public static native int sqlite3_blob_close(@Nullable sqlite3_blob blob); + public static int sqlite3_blob_bytes(@NotNull sqlite3_blob blob){ + return sqlite3_blob_bytes(blob.getNativePointer()); + } @Canonical - public static native int sqlite3_blob_open( - @NotNull sqlite3 db, @NotNull String dbName, + static native int sqlite3_blob_close(@Nullable long ptrToBlob); + + @Canonical + public static int sqlite3_blob_close(@Nullable sqlite3_blob blob){ + return sqlite3_blob_close(blob.clearNativePointer()); + } + + @Canonical + private static native int sqlite3_blob_open( + @NotNull long ptrToDb, @NotNull String dbName, @NotNull String tableName, @NotNull String columnName, long iRow, int flags, @NotNull OutputPointer.sqlite3_blob out ); + @Canonical + public static int sqlite3_blob_open( + @NotNull sqlite3 db, @NotNull String dbName, + @NotNull String tableName, @NotNull String columnName, + long iRow, int flags, @NotNull OutputPointer.sqlite3_blob out + ){ + return sqlite3_blob_open(db.getNativePointer(), dbName, tableName, + columnName, iRow, flags, out); + } + /** Convenience overload. */ @@ -456,23 +476,48 @@ public final class SQLite3Jni { @NotNull String tableName, @NotNull String columnName, long iRow, int flags ){ final OutputPointer.sqlite3_blob out = new OutputPointer.sqlite3_blob(); - sqlite3_blob_open(db, dbName, tableName, columnName, iRow, flags, out); + sqlite3_blob_open(db.getNativePointer(), dbName, tableName, columnName, + iRow, flags, out); return out.take(); }; @Canonical - public static native int sqlite3_blob_read( + private static native int sqlite3_blob_read( + @NotNull long ptrToBlob, @NotNull byte[] target, int iOffset + ); + + @Canonical + public static int sqlite3_blob_read( @NotNull sqlite3_blob b, @NotNull byte[] target, int iOffset + ){ + return sqlite3_blob_read(b.getNativePointer(), target, iOffset); + } + + @Canonical + private static native int sqlite3_blob_reopen( + @NotNull long ptrToBlob, long newRowId ); @Canonical - public static native int sqlite3_blob_reopen( - @NotNull sqlite3_blob out, long newRowId + public static int sqlite3_blob_reopen(@NotNull sqlite3_blob b, long newRowId){ + return sqlite3_blob_reopen(b.getNativePointer(), newRowId); + } + + @Canonical + private static native int sqlite3_blob_write( + @NotNull long ptrToBlob, @NotNull byte[] bytes, int iOffset ); @Canonical - public static native int sqlite3_blob_write( - @NotNull sqlite3_blob out, @NotNull byte[] bytes, int iOffset + public static int sqlite3_blob_write( + @NotNull sqlite3_blob b, @NotNull byte[] bytes, int iOffset + ){ + return sqlite3_blob_write(b.getNativePointer(), bytes, iOffset); + } + + @Canonical + private static native int sqlite3_busy_handler( + @NotNull long ptrToDb, @Nullable BusyHandlerCallback handler ); /** @@ -481,14 +526,19 @@ public final class SQLite3Jni { function. Pass it a null handler to clear the busy handler. */ @Canonical - public static native int sqlite3_busy_handler( + public static int sqlite3_busy_handler( @NotNull sqlite3 db, @Nullable BusyHandlerCallback handler - ); + ){ + return sqlite3_busy_handler(db.getNativePointer(), handler); + } @Canonical - public static native int sqlite3_busy_timeout( - @NotNull sqlite3 db, int ms - ); + private static native int sqlite3_busy_timeout(@NotNull long ptrToDb, int ms); + + @Canonical + public static int sqlite3_busy_timeout(@NotNull sqlite3 db, int ms){ + return sqlite3_busy_timeout(db.getNativePointer(), ms); + } @Canonical public static native boolean sqlite3_cancel_auto_extension( @@ -511,14 +561,22 @@ public final class SQLite3Jni { ); @Canonical - public static native int sqlite3_close( - @Nullable sqlite3 db - ); + private static native int sqlite3_close(@Nullable long ptrToDb); @Canonical - public static native int sqlite3_close_v2( - @Nullable sqlite3 db - ); + public static int sqlite3_close(@Nullable sqlite3 db){ + final int rc = sqlite3_close(db.getNativePointer()); + if( 0==rc ) db.clearNativePointer(); + return rc; + } + + @Canonical + static native int sqlite3_close_v2(@Nullable long ptrToDb); + + @Canonical + public static int sqlite3_close_v2(@Nullable sqlite3 db){ + return sqlite3_close_v2(db.clearNativePointer()); + } @Canonical public static native byte[] sqlite3_column_blob( @@ -831,7 +889,7 @@ public final class SQLite3Jni { public static native int sqlite3_error_offset(@NotNull sqlite3 db); @Canonical - private static native int sqlite3_finalize(long ptrToStmt); + static native int sqlite3_finalize(long ptrToStmt); @Canonical public static int sqlite3_finalize(@NotNull sqlite3_stmt stmt){ diff --git a/ext/jni/src/org/sqlite/jni/sqlite3.java b/ext/jni/src/org/sqlite/jni/sqlite3.java index 3f15c45802..ba515b3f4f 100644 --- a/ext/jni/src/org/sqlite/jni/sqlite3.java +++ b/ext/jni/src/org/sqlite/jni/sqlite3.java @@ -39,10 +39,10 @@ public final class sqlite3 extends NativePointerHolder @Override protected void finalize(){ //System.out.println(this+".finalize()"); - SQLite3Jni.sqlite3_close_v2(this); + SQLite3Jni.sqlite3_close_v2(this.clearNativePointer()); } @Override public void close(){ - SQLite3Jni.sqlite3_close_v2(this); + SQLite3Jni.sqlite3_close_v2(this.clearNativePointer()); } } diff --git a/ext/jni/src/org/sqlite/jni/sqlite3_blob.java b/ext/jni/src/org/sqlite/jni/sqlite3_blob.java index e512130256..46c3c90293 100644 --- a/ext/jni/src/org/sqlite/jni/sqlite3_blob.java +++ b/ext/jni/src/org/sqlite/jni/sqlite3_blob.java @@ -19,7 +19,13 @@ package org.sqlite.jni; simply provide a type-safe way to communicate it between Java and C via JNI. */ -public final class sqlite3_blob extends NativePointerHolder { +public final class sqlite3_blob extends NativePointerHolder + implements AutoCloseable { // Only invoked from JNI. private sqlite3_blob(){} + + @Override public void close(){ + SQLite3Jni.sqlite3_blob_close(this.clearNativePointer()); + } + } diff --git a/ext/jni/src/org/sqlite/jni/sqlite3_stmt.java b/ext/jni/src/org/sqlite/jni/sqlite3_stmt.java index 567a20cfa8..d918d380c2 100644 --- a/ext/jni/src/org/sqlite/jni/sqlite3_stmt.java +++ b/ext/jni/src/org/sqlite/jni/sqlite3_stmt.java @@ -26,10 +26,10 @@ public final class sqlite3_stmt extends NativePointerHolder //For as-yet-unknown reasons, this triggers a JVM crash. //@Override protected void finalize(){ - // SQLite3Jni.sqlite3_finalize(this); + // SQLite3Jni.sqlite3_finalize(this.clearNativePointer()); //} @Override public void close(){ - SQLite3Jni.sqlite3_finalize(this); + SQLite3Jni.sqlite3_finalize(this.clearNativePointer()); } } diff --git a/manifest b/manifest index 2bad9e6801..7cde18ac53 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adapt\sJNI\ssqlite3_bind_...()\sbindings\sto\sthe\snew\spointer-passing\smethod\sand\scorrect\sthe\smapping\sof\ssqlite3_bind_zeroblob64()\sto\suse\szeroblob64()\sinstead\sof\szeroblob().\sRelated\sinternal\sAPI\srenaming. -D 2023-09-27T11:01:32.787 +C Adapted\sJNI\ssqlite3_blob_...()\sand\ssqlite3_close...()\sto\sthe\snew\spointer-passing\smechanism. +D 2023-09-27T14:41:49.881 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 7e1e0cf2f06a1d6c813fd3b684b5712dc8cccc6927d5f5d2b89d796f75799fb1 -F ext/jni/src/c/sqlite3-jni.h d503e60cdb9ce98f19d7bdd17a8f1b911931b6dddcc80ebef10c8160a6daab0b +F ext/jni/src/c/sqlite3-jni.c 2c36a16445e2e39e899b2b51f1d1b5d0f42e3008bfcd5c996fdf606d4429af72 +F ext/jni/src/c/sqlite3-jni.h 8d66d189ac58f000b1143da7631fb30abd4554461369fedaa8a7c1ac5462a530 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 24ca37368946b4fceabac1913c7a21dbe2a4a9f5db55350b4df2b45d169b4e5f +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 51a70421655f8663439037606d1cd5feb5102e032d3e851d860a3dac2dc4e6c0 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -282,11 +282,11 @@ F ext/jni/src/org/sqlite/jni/fts5/fts5_api.java e2ad9bc06a9d307e0a6221c116457838 F ext/jni/src/org/sqlite/jni/fts5/fts5_extension_function.java 1fe0f5692c1d67475d12b067f0469949073446f18c56eba5ee5da6ddd06db9b9 F ext/jni/src/org/sqlite/jni/fts5/fts5_tokenizer.java ea993738b851038c16d98576abd0db3d6028a231f075a394fb8a78c7834d0f6c F ext/jni/src/org/sqlite/jni/package-info.java a3946db2504de747a1993c4f6e8ce604bec5a8e5a134b292c3b07527bc321a99 -F ext/jni/src/org/sqlite/jni/sqlite3.java 5e56a799ced58ea69e8bcad20c29a61fce32f21a7f4fb3e2702337cf8aa1a06e +F ext/jni/src/org/sqlite/jni/sqlite3.java 5cd95c182a38b874ad973b3c16a70a69786fe82a6793abf147639803dec7ecac F ext/jni/src/org/sqlite/jni/sqlite3_backup.java 12182124c4d4928d78db5a07ea285f1d7af04c7a148f0759a1972d5bfa87311e -F ext/jni/src/org/sqlite/jni/sqlite3_blob.java f28a30134f2e524eb7d5ab87f57f86c90140341a6e8369ee54509ac8bb96fa82 +F ext/jni/src/org/sqlite/jni/sqlite3_blob.java fc631ad52feea6e3d1d62b0d0e769ac107c01bc0ddd20eb512aff07b428cda6d F ext/jni/src/org/sqlite/jni/sqlite3_context.java 66ca95ce904044263a4aff684abe262d56f73e6b06bca6cf650761d79d7779ad -F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java 36ecee9bdde2e70c7276d1c22b48fd9c40a77412e8e0694e9c09910997d6fb4f +F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java cf7f076d8b0f2a23faebbd64e12e8b3dd1977378ca828245d186f1b98458127d F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 9892797db57c6e01f0c1601b5866474b6c046f0fd6c5b64f411e5815c941040e F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bccdfeb9efde20410bde545893fb98ce5c0c4d04a8e7797b868ba8994120e1db -R 07ea1023a2462cb72e478a493540d516 +P 980d559fff6e55d1e2ef39f242a8a09313a936cfb141807db475bcceff924869 +R d927af0037b6061c9d963a62e64650b9 U stephan -Z 250cebc4fc9c64e8ca5d6b6a65662ef8 +Z 1d6d1018657afbb7fe95c6220da9d8bf # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0e420f19f1..ef260973fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -980d559fff6e55d1e2ef39f242a8a09313a936cfb141807db475bcceff924869 \ No newline at end of file +0b22c8ef93e5ccd45316099fb8575e27620158b1992c0c70fe0348cfc10147f8 \ No newline at end of file From 50b2a41330f05b6d9fe35bd0d5a6d40e298e5bef Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 28 Sep 2023 10:27:01 +0000 Subject: [PATCH 06/11] Convert the macro-generated JNI bindings which take a db pointer to the new pointer-passing mechanism. FossilOrigin-Name: 5f47fb77db4ee77afc541e680559ad88e66ba7fd04b830e70f8be92cf8d0a60c --- ext/jni/src/c/sqlite3-jni.c | 26 +++--- ext/jni/src/c/sqlite3-jni.h | 56 ++++++------- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 94 +++++++++++++++++----- manifest | 16 ++-- manifest.uuid | 2 +- 5 files changed, 123 insertions(+), 71 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index da457174a4..b631baa182 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -2012,23 +2012,23 @@ static void udf_xInverse(sqlite3_context* cx, int argc, #define WRAP_STR_STMT_INT(JniNameSuffix,CName) \ JniDecl(jstring,JniNameSuffix)(JniArgsEnvClass, jobject pStmt, jint ndx){ \ return s3jni_utf8_to_jstring( \ - CName(PtrGet_sqlite3_stmt(pStmt), (int)ndx), \ - -1); \ - } -/** Create a trivial JNI wrapper for (int CName(sqlite3*)). */ -#define WRAP_INT_DB(JniNameSuffix,CName) \ - JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jobject pDb){ \ - return (jint)CName(PtrGet_sqlite3(pDb)); \ + CName(PtrGet_sqlite3_stmt(pStmt), (int)ndx), \ + -1); \ } /** Create a trivial JNI wrapper for (boolean CName(sqlite3*)). */ -#define WRAP_BOOL_DB(JniNameSuffix,CName) \ - JniDecl(jboolean,JniNameSuffix)(JniArgsEnvClass, jobject pDb){ \ - return CName(PtrGet_sqlite3(pDb)) ? JNI_TRUE : JNI_FALSE; \ +#define WRAP_BOOL_DB(JniNameSuffix,CName) \ + JniDecl(jboolean,JniNameSuffix)(JniArgsEnvClass, jlong jpDb){ \ + return CName(S3JniLongPtr_sqlite3(jpDb)) ? JNI_TRUE : JNI_FALSE; \ + } +/** Create a trivial JNI wrapper for (int CName(sqlite3*)). */ +#define WRAP_INT_DB(JniNameSuffix,CName) \ + JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jlong jpDb){ \ + return (jint)CName(S3JniLongPtr_sqlite3(jpDb)); \ } /** Create a trivial JNI wrapper for (int64 CName(sqlite3*)). */ -#define WRAP_INT64_DB(JniNameSuffix,CName) \ - JniDecl(jlong,JniNameSuffix)(JniArgsEnvClass, jobject pDb){ \ - return (jlong)CName(PtrGet_sqlite3(pDb)); \ +#define WRAP_INT64_DB(JniNameSuffix,CName) \ + JniDecl(jlong,JniNameSuffix)(JniArgsEnvClass, jlong jpDb){ \ + return (jlong)CName(S3JniLongPtr_sqlite3(jpDb)); \ } /** Create a trivial JNI wrapper for (int CName(sqlite3_value*)). */ #define WRAP_INT_SVALUE(JniNameSuffix,CName) \ diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index 9a016c2e3f..6ead741d46 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -1030,18 +1030,18 @@ JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1cancel_1auto_ /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_changes - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1changes - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_changes64 - * Signature: (Lorg/sqlite/jni/sqlite3;)J + * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1changes64 - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1347,6 +1347,14 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errcode JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1errmsg16 (JNIEnv *, jclass, jobject); +/* + * Class: org_sqlite_jni_SQLite3Jni + * Method: sqlite3_error_offset + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1error_1offset + (JNIEnv *, jclass, jlong); + /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_errstr @@ -1366,10 +1374,10 @@ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1expanded_1sql /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_extended_errcode - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1extended_1errcode - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1382,10 +1390,10 @@ JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1extended_1res /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_get_autocommit - * Signature: (Lorg/sqlite/jni/sqlite3;)Z + * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1get_1autocommit - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1395,14 +1403,6 @@ JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1get_1autocomm JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1get_1auxdata (JNIEnv *, jclass, jobject, jint); -/* - * Class: org_sqlite_jni_SQLite3Jni - * Method: sqlite3_error_offset - * Signature: (Lorg/sqlite/jni/sqlite3;)I - */ -JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1error_1offset - (JNIEnv *, jclass, jobject); - /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_finalize @@ -1534,26 +1534,26 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1prepare_1v3 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_preupdate_blobwrite - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1blobwrite - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_preupdate_count - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1count - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_preupdate_depth - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1depth - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1886,10 +1886,10 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1strlike /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_system_errno - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1system_1errno - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1910,18 +1910,18 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1threadsafe /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_total_changes - * Signature: (Lorg/sqlite/jni/sqlite3;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1total_1changes - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_total_changes64 - * Signature: (Lorg/sqlite/jni/sqlite3;)J + * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1total_1changes64 - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index d619bfefed..516e86f39d 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -546,14 +546,20 @@ public final class SQLite3Jni { ); @Canonical - public static native int sqlite3_changes( - @NotNull sqlite3 db - ); + private static native int sqlite3_changes(@NotNull long ptrToDb); @Canonical - public static native long sqlite3_changes64( - @NotNull sqlite3 db - ); + public static int sqlite3_changes(@NotNull sqlite3 db){ + return sqlite3_changes(db.getNativePointer()); + } + + @Canonical + private static native long sqlite3_changes64(@NotNull long ptrToDb); + + @Canonical + public static long sqlite3_changes64(@NotNull sqlite3 db){ + return sqlite3_changes64(db.getNativePointer()); + } @Canonical public static native int sqlite3_clear_bindings( @@ -859,6 +865,18 @@ public final class SQLite3Jni { @Canonical public static native String sqlite3_errmsg16(@NotNull sqlite3 db); + @Canonical + private static native int sqlite3_error_offset(@NotNull long ptrToDb); + + /** + Note that the returned byte offset values assume UTF-8-encoded + inputs, so won't always match character offsets in Java Strings. + */ + @Canonical + public static int sqlite3_error_offset(@NotNull sqlite3 db){ + return sqlite3_error_offset(db.getNativePointer()); + } + @Canonical public static native String sqlite3_errstr(int resultCode); @@ -866,7 +884,12 @@ public final class SQLite3Jni { public static native String sqlite3_expanded_sql(@NotNull sqlite3_stmt stmt); @Canonical - public static native int sqlite3_extended_errcode(@NotNull sqlite3 db); + private static native int sqlite3_extended_errcode(@NotNull long ptrToDb); + + @Canonical + public static int sqlite3_extended_errcode(@NotNull sqlite3 db){ + return sqlite3_extended_errcode(db.getNativePointer()); + } @Canonical public static native boolean sqlite3_extended_result_codes( @@ -874,20 +897,18 @@ public final class SQLite3Jni { ); @Canonical - public static native boolean sqlite3_get_autocommit(@NotNull sqlite3 db); + private static native boolean sqlite3_get_autocommit(@NotNull long ptrToDb); + + @Canonical + public static boolean sqlite3_get_autocommit(@NotNull sqlite3 db){ + return sqlite3_get_autocommit(db.getNativePointer()); + } @Canonical public static native Object sqlite3_get_auxdata( @NotNull sqlite3_context cx, int n ); - /** - Note that the returned byte offset values assume UTF-8-encoded - inputs, so won't always match character offsets in Java Strings. - */ - @Canonical - public static native int sqlite3_error_offset(@NotNull sqlite3 db); - @Canonical static native int sqlite3_finalize(long ptrToStmt); @@ -1274,6 +1295,8 @@ public final class SQLite3Jni { return sqlite3_prepare_multi(db, sql, 0, p); } + @Canonical + private static native int sqlite3_preupdate_blobwrite(@NotNull long ptrToDb); /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this @@ -1281,21 +1304,35 @@ public final class SQLite3Jni { SQLITE_MISUSE with no side effects. */ @Canonical - public static native int sqlite3_preupdate_blobwrite(@NotNull sqlite3 db); + public static int sqlite3_preupdate_blobwrite(@NotNull sqlite3 db){ + return sqlite3_preupdate_blobwrite(db.getNativePointer()); + } + + @Canonical + private static native int sqlite3_preupdate_count(@NotNull long ptrToDb); + /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this acts as a proxy for C's sqlite3_preupdate_count(), else it returns SQLITE_MISUSE with no side effects. */ @Canonical - public static native int sqlite3_preupdate_count(@NotNull sqlite3 db); + public static int sqlite3_preupdate_count(@NotNull sqlite3 db){ + return sqlite3_preupdate_count(db.getNativePointer()); + } + + @Canonical + private static native int sqlite3_preupdate_depth(@NotNull long ptrToDb); + /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this acts as a proxy for C's sqlite3_preupdate_depth(), else it returns SQLITE_MISUSE with no side effects. */ @Canonical - public static native int sqlite3_preupdate_depth(@NotNull sqlite3 db); + public static int sqlite3_preupdate_depth(@NotNull sqlite3 db){ + return sqlite3_preupdate_depth(db.getNativePointer()); + } /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this @@ -1793,7 +1830,12 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_system_errno(@NotNull sqlite3 db); + private static native int sqlite3_system_errno(@NotNull long ptrToDb); + + @Canonical + public static int sqlite3_system_errno(@NotNull sqlite3 db){ + return sqlite3_system_errno(db.getNativePointer()); + } @Canonical public static native int sqlite3_table_column_metadata( @@ -1838,10 +1880,20 @@ public final class SQLite3Jni { public static native int sqlite3_threadsafe(); @Canonical - public static native int sqlite3_total_changes(@NotNull sqlite3 db); + private static native int sqlite3_total_changes(@NotNull long ptrToDb); @Canonical - public static native long sqlite3_total_changes64(@NotNull sqlite3 db); + public static int sqlite3_total_changes(@NotNull sqlite3 db){ + return sqlite3_total_changes(db.getNativePointer()); + } + + @Canonical + private static native long sqlite3_total_changes64(@NotNull long ptrToDb); + + @Canonical + public static long sqlite3_total_changes64(@NotNull sqlite3 db){ + return sqlite3_total_changes64(db.getNativePointer()); + } /** Works like C's sqlite3_trace_v2() except that the 3rd argument to that diff --git a/manifest b/manifest index 7cde18ac53..0439e98ef5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adapted\sJNI\ssqlite3_blob_...()\sand\ssqlite3_close...()\sto\sthe\snew\spointer-passing\smechanism. -D 2023-09-27T14:41:49.881 +C Convert\sthe\smacro-generated\sJNI\sbindings\swhich\stake\sa\sdb\spointer\sto\sthe\snew\spointer-passing\smechanism. +D 2023-09-28T10:27:01.146 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 2c36a16445e2e39e899b2b51f1d1b5d0f42e3008bfcd5c996fdf606d4429af72 -F ext/jni/src/c/sqlite3-jni.h 8d66d189ac58f000b1143da7631fb30abd4554461369fedaa8a7c1ac5462a530 +F ext/jni/src/c/sqlite3-jni.c 14406b8857fb1ea3ec57bf90fdd17e1dbb68937f21868b50de6a5e64555a1053 +F ext/jni/src/c/sqlite3-jni.h d1ac1b6610437291077b263cfc2ecb2dd1ccc5154e83dd45083b86aa20b34be6 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 51a70421655f8663439037606d1cd5feb5102e032d3e851d860a3dac2dc4e6c0 +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 7075a5c5de4d5b41b47587abd0fd0d82e325e1a4fc24d4422d029b9b7f0cac1e F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 980d559fff6e55d1e2ef39f242a8a09313a936cfb141807db475bcceff924869 -R d927af0037b6061c9d963a62e64650b9 +P 0b22c8ef93e5ccd45316099fb8575e27620158b1992c0c70fe0348cfc10147f8 +R 39e7f9b7ed1c60cf4f2907887eef0ed7 U stephan -Z 1d6d1018657afbb7fe95c6220da9d8bf +Z e97bf1ee3ba4dec99a48b628a72060e8 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ef260973fe..90ab0b17f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b22c8ef93e5ccd45316099fb8575e27620158b1992c0c70fe0348cfc10147f8 \ No newline at end of file +5f47fb77db4ee77afc541e680559ad88e66ba7fd04b830e70f8be92cf8d0a60c \ No newline at end of file From 5d1448d08a712d933c809f4e2d22750ffff34163 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 28 Sep 2023 10:50:26 +0000 Subject: [PATCH 07/11] Convert the remaining macro-generated JNI bindings to the new pointer-passing mechanism. FossilOrigin-Name: 250fd6ae806cf705c0f29ad30ad8fb885b12590848e7adae63bc21d874c6d3bd --- ext/jni/src/c/sqlite3-jni.c | 27 ++- ext/jni/src/c/sqlite3-jni.h | 140 ++++++++------- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 189 +++++++++++++++------ manifest | 16 +- manifest.uuid | 2 +- 5 files changed, 236 insertions(+), 138 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index b631baa182..248c12abbd 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -1456,6 +1456,7 @@ static void * NativePointerHolder__get(JNIEnv * env, jobject jNph, #define S3JniLongPtr_sqlite3_backup(JLongPtr) S3JniLongPtr_T(sqlite3_backup,JLongPtr) #define S3JniLongPtr_sqlite3_blob(JLongPtr) S3JniLongPtr_T(sqlite3_blob,JLongPtr) #define S3JniLongPtr_sqlite3_stmt(JLongPtr) S3JniLongPtr_T(sqlite3_stmt,JLongPtr) +#define S3JniLongPtr_sqlite3_value(JLongPtr) S3JniLongPtr_T(sqlite3_value,JLongPtr) /* ** Extracts the new S3JniDb instance from the free-list, or allocates @@ -1992,27 +1993,25 @@ static void udf_xInverse(sqlite3_context* cx, int argc, return rv; \ } /** Create a trivial JNI wrapper for (int CName(sqlite3_stmt*)). */ -#define WRAP_INT_STMT(JniNameSuffix,CName) \ - JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jobject jpStmt){ \ - jint const rc = (jint)CName(PtrGet_sqlite3_stmt(jpStmt)); \ - S3JniExceptionIgnore /* squelch -Xcheck:jni */; \ - return rc; \ +#define WRAP_INT_STMT(JniNameSuffix,CName) \ + JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jlong jpStmt){ \ + return (jint)CName(S3JniLongPtr_sqlite3_stmt(jpStmt)); \ } /** Create a trivial JNI wrapper for (int CName(sqlite3_stmt*,int)). */ #define WRAP_INT_STMT_INT(JniNameSuffix,CName) \ - JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jobject pStmt, jint n){ \ - return (jint)CName(PtrGet_sqlite3_stmt(pStmt), (int)n); \ + JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jlong jpStmt, jint n){ \ + return (jint)CName(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)n); \ } /** Create a trivial JNI wrapper for (boolish-int CName(sqlite3_stmt*)). */ #define WRAP_BOOL_STMT(JniNameSuffix,CName) \ - JniDecl(jboolean,JniNameSuffix)(JniArgsEnvClass, jobject pStmt){ \ - return CName(PtrGet_sqlite3_stmt(pStmt)) ? JNI_TRUE : JNI_FALSE; \ + JniDecl(jboolean,JniNameSuffix)(JniArgsEnvClass, jlong jpStmt){ \ + return CName(S3JniLongPtr_sqlite3_stmt(jpStmt)) ? JNI_TRUE : JNI_FALSE; \ } /** Create a trivial JNI wrapper for (jstring CName(sqlite3_stmt*,int)). */ -#define WRAP_STR_STMT_INT(JniNameSuffix,CName) \ - JniDecl(jstring,JniNameSuffix)(JniArgsEnvClass, jobject pStmt, jint ndx){ \ +#define WRAP_STR_STMT_INT(JniNameSuffix,CName) \ + JniDecl(jstring,JniNameSuffix)(JniArgsEnvClass, jlong jpStmt, jint ndx){ \ return s3jni_utf8_to_jstring( \ - CName(PtrGet_sqlite3_stmt(pStmt), (int)ndx), \ + CName(S3JniLongPtr_sqlite3_stmt(jpStmt), (int)ndx), \ -1); \ } /** Create a trivial JNI wrapper for (boolean CName(sqlite3*)). */ @@ -2032,8 +2031,8 @@ static void udf_xInverse(sqlite3_context* cx, int argc, } /** Create a trivial JNI wrapper for (int CName(sqlite3_value*)). */ #define WRAP_INT_SVALUE(JniNameSuffix,CName) \ - JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jobject jpSValue){ \ - return (jint)CName(PtrGet_sqlite3_value(jpSValue)); \ + JniDecl(jint,JniNameSuffix)(JniArgsEnvClass, jlong jpSValue){ \ + return (jint)CName(S3JniLongPtr_sqlite3_value(jpSValue)); \ } WRAP_INT_DB(1changes, sqlite3_changes) diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index 6ead741d46..a2e9644c8b 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -1046,10 +1046,10 @@ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1changes64 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_clear_bindings - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1clear_1bindings - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1078,26 +1078,34 @@ JNIEXPORT jbyteArray JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1blo /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_bytes - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1bytes - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_bytes16 - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1bytes16 - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_count - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1count - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); + +/* + * Class: org_sqlite_jni_SQLite3Jni + * Method: sqlite3_column_decltype + * Signature: (JI)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1decltype + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1126,34 +1134,34 @@ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1int64 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_name - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String; + * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1name - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_database_name - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String; + * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1database_1name - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_origin_name - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String; + * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1origin_1name - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_table_name - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)Ljava/lang/String; + * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1table_1name - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1174,10 +1182,10 @@ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1text16 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_column_type - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1type - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1278,10 +1286,10 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1create_1function /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_data_count - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1data_1count - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1838,26 +1846,26 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1step /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_stmt_explain - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;I)I + * Signature: (JI)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1stmt_1explain - (JNIEnv *, jclass, jobject, jint); + (JNIEnv *, jclass, jlong, jint); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_stmt_isexplain - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1stmt_1isexplain - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_stmt_readonly - * Signature: (Lorg/sqlite/jni/sqlite3_stmt;)Z + * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1stmt_1readonly - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1958,18 +1966,18 @@ JNIEXPORT jbyteArray JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1blob /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_bytes - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1bytes - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_bytes16 - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1bytes16 - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1990,10 +1998,10 @@ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1dup /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_encoding - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1encoding - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -2003,6 +2011,14 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1encoding JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1free (JNIEnv *, jclass, jobject); +/* + * Class: org_sqlite_jni_SQLite3Jni + * Method: sqlite3_value_frombind + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1frombind + (JNIEnv *, jclass, jlong); + /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_int @@ -2027,6 +2043,30 @@ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1int64 JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1java_1object (JNIEnv *, jclass, jobject); +/* + * Class: org_sqlite_jni_SQLite3Jni + * Method: sqlite3_value_nochange + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1nochange + (JNIEnv *, jclass, jlong); + +/* + * Class: org_sqlite_jni_SQLite3Jni + * Method: sqlite3_value_numeric_type + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1numeric_1type + (JNIEnv *, jclass, jlong); + +/* + * Class: org_sqlite_jni_SQLite3Jni + * Method: sqlite3_value_subtype + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1subtype + (JNIEnv *, jclass, jlong); + /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_text @@ -2046,42 +2086,10 @@ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1text16 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_type - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1type - (JNIEnv *, jclass, jobject); - -/* - * Class: org_sqlite_jni_SQLite3Jni - * Method: sqlite3_value_numeric_type - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I - */ -JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1numeric_1type - (JNIEnv *, jclass, jobject); - -/* - * Class: org_sqlite_jni_SQLite3Jni - * Method: sqlite3_value_nochange - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I - */ -JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1nochange - (JNIEnv *, jclass, jobject); - -/* - * Class: org_sqlite_jni_SQLite3Jni - * Method: sqlite3_value_frombind - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I - */ -JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1frombind - (JNIEnv *, jclass, jobject); - -/* - * Class: org_sqlite_jni_SQLite3Jni - * Method: sqlite3_value_subtype - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I - */ -JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1subtype - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 516e86f39d..9cdae6d7b6 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -562,9 +562,12 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_clear_bindings( - @NotNull sqlite3_stmt stmt - ); + public static native int sqlite3_clear_bindings(@NotNull long ptrToStmt); + + @Canonical + public static int sqlite3_clear_bindings(@NotNull sqlite3_stmt stmt){ + return sqlite3_clear_bindings(stmt.getNativePointer()); + } @Canonical private static native int sqlite3_close(@Nullable long ptrToDb); @@ -590,19 +593,36 @@ public final class SQLite3Jni { ); @Canonical - public static native int sqlite3_column_bytes( - @NotNull sqlite3_stmt stmt, int ndx - ); + private static native int sqlite3_column_bytes(@NotNull long ptrToStmt, int ndx); @Canonical - public static native int sqlite3_column_bytes16( - @NotNull sqlite3_stmt stmt, int ndx - ); + public static int sqlite3_column_bytes(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_bytes(stmt.getNativePointer(), ndx); + } @Canonical - public static native int sqlite3_column_count( - @NotNull sqlite3_stmt stmt - ); + private static native int sqlite3_column_bytes16(@NotNull long ptrToStmt, int ndx); + + @Canonical + public static int sqlite3_column_bytes16(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_bytes16(stmt.getNativePointer(), ndx); + } + + @Canonical + private static native int sqlite3_column_count(@NotNull long ptrToStmt); + + @Canonical + public static int sqlite3_column_count(@NotNull sqlite3_stmt stmt){ + return sqlite3_column_count(stmt.getNativePointer()); + } + + @Canonical + private static native String sqlite3_column_decltype(@NotNull long ptrToStmt, int ndx); + + @Canonical + public static String sqlite3_column_decltype(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_decltype(stmt.getNativePointer(), ndx); + } @Canonical public static native double sqlite3_column_double( @@ -620,24 +640,36 @@ public final class SQLite3Jni { ); @Canonical - public static native String sqlite3_column_name( - @NotNull sqlite3_stmt stmt, int ndx - ); + private static native String sqlite3_column_name(@NotNull long ptrToStmt, int ndx); @Canonical - public static native String sqlite3_column_database_name( - @NotNull sqlite3_stmt stmt, int ndx - ); + public static String sqlite3_column_name(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_name(stmt.getNativePointer(), ndx); + } @Canonical - public static native String sqlite3_column_origin_name( - @NotNull sqlite3_stmt stmt, int ndx - ); + private static native String sqlite3_column_database_name(@NotNull long ptrToStmt, int ndx); @Canonical - public static native String sqlite3_column_table_name( - @NotNull sqlite3_stmt stmt, int ndx - ); + public static String sqlite3_column_database_name(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_database_name(stmt.getNativePointer(), ndx); + } + + @Canonical + private static native String sqlite3_column_origin_name(@NotNull long ptrToStmt, int ndx); + + @Canonical + public static String sqlite3_column_origin_name(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_origin_name(stmt.getNativePointer(), ndx); + } + + @Canonical + private static native String sqlite3_column_table_name(@NotNull long ptrToStmt, int ndx); + + @Canonical + public static String sqlite3_column_table_name(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_table_name(stmt.getNativePointer(), ndx); + } /** Functions identially to the C API, and this note is just to @@ -695,9 +727,12 @@ public final class SQLite3Jni { // } @Canonical - public static native int sqlite3_column_type( - @NotNull sqlite3_stmt stmt, int ndx - ); + private static native int sqlite3_column_type(@NotNull long ptrToStmt, int ndx); + + @Canonical + public static int sqlite3_column_type(@NotNull sqlite3_stmt stmt, int ndx){ + return sqlite3_column_type(stmt.getNativePointer(), ndx); + } @Canonical public static native sqlite3_value sqlite3_column_value( @@ -816,9 +851,12 @@ public final class SQLite3Jni { ); @Canonical - public static native int sqlite3_data_count( - @NotNull sqlite3_stmt stmt - ); + private static native int sqlite3_data_count(@NotNull long ptrToStmt); + + @Canonical + public static int sqlite3_data_count(@NotNull sqlite3_stmt stmt){ + return sqlite3_data_count(stmt.getNativePointer()); + } /** Overload for sqlite3_db_config() calls which take (int,int*) @@ -1768,15 +1806,28 @@ public final class SQLite3Jni { public static native int sqlite3_step(@NotNull sqlite3_stmt stmt); @Canonical - public static native int sqlite3_stmt_explain( - @NotNull sqlite3_stmt stmt, int op - ); + private static native int sqlite3_stmt_explain(@NotNull long ptrToStmt, int op); @Canonical - public static native int sqlite3_stmt_isexplain(@NotNull sqlite3_stmt stmt); + public static int sqlite3_stmt_explain(@NotNull sqlite3_stmt stmt, int op){ + return sqlite3_stmt_explain(stmt.getNativePointer(), op); + } @Canonical - public static native boolean sqlite3_stmt_readonly(@NotNull sqlite3_stmt stmt); + private static native int sqlite3_stmt_isexplain(@NotNull long ptrToStmt); + + @Canonical + public static int sqlite3_stmt_isexplain(@NotNull sqlite3_stmt stmt){ + return sqlite3_stmt_isexplain(stmt.getNativePointer()); + } + + @Canonical + private static native boolean sqlite3_stmt_readonly(@NotNull long ptrToStmt); + + @Canonical + public static boolean sqlite3_stmt_readonly(@NotNull sqlite3_stmt stmt){ + return sqlite3_stmt_readonly(stmt.getNativePointer()); + } @Canonical public static native int sqlite3_stmt_status( @@ -1933,10 +1984,20 @@ public final class SQLite3Jni { public static native byte[] sqlite3_value_blob(@NotNull sqlite3_value v); @Canonical - public static native int sqlite3_value_bytes(@NotNull sqlite3_value v); + private static native int sqlite3_value_bytes(@NotNull long ptrToValue); @Canonical - public static native int sqlite3_value_bytes16(@NotNull sqlite3_value v); + public static int sqlite3_value_bytes(@NotNull sqlite3_value v){ + return sqlite3_value_bytes(v.getNativePointer()); + } + + @Canonical + private static native int sqlite3_value_bytes16(@NotNull long ptrToValue); + + @Canonical + public static int sqlite3_value_bytes16(@NotNull sqlite3_value v){ + return sqlite3_value_bytes16(v.getNativePointer()); + } @Canonical public static native double sqlite3_value_double(@NotNull sqlite3_value v); @@ -1947,11 +2008,24 @@ public final class SQLite3Jni { ); @Canonical - public static native int sqlite3_value_encoding(@NotNull sqlite3_value v); + private static native int sqlite3_value_encoding(@NotNull long ptrToValue); + + @Canonical + public static int sqlite3_value_encoding(@NotNull sqlite3_value v){ + return sqlite3_value_encoding(v.getNativePointer()); + } @Canonical public static native void sqlite3_value_free(@Nullable sqlite3_value v); + @Canonical + private static native int sqlite3_value_frombind(@NotNull long ptrToValue); + + @Canonical + public static int sqlite3_value_frombind(@NotNull sqlite3_value v){ + return sqlite3_value_frombind(v.getNativePointer()); + } + @Canonical public static native int sqlite3_value_int(@NotNull sqlite3_value v); @@ -1982,6 +2056,30 @@ public final class SQLite3Jni { return type.isInstance(o) ? (T)o : null; } + @Canonical + private static native int sqlite3_value_nochange(@NotNull long ptrToValue); + + @Canonical + public static int sqlite3_value_nochange(@NotNull sqlite3_value v){ + return sqlite3_value_nochange(v.getNativePointer()); + } + + @Canonical + private static native int sqlite3_value_numeric_type(@NotNull long ptrToValue); + + @Canonical + public static int sqlite3_value_numeric_type(@NotNull sqlite3_value v){ + return sqlite3_value_numeric_type(v.getNativePointer()); + } + + @Canonical + private static native int sqlite3_value_subtype(@NotNull long ptrToValue); + + @Canonical + public static int sqlite3_value_subtype(@NotNull sqlite3_value v){ + return sqlite3_value_subtype(v.getNativePointer()); + } + /** Functions identially to the C API, and this note is just to stress that the returned bytes are encoded as UTF-8. It returns @@ -1995,19 +2093,12 @@ public final class SQLite3Jni { public static native String sqlite3_value_text16(@NotNull sqlite3_value v); @Canonical - public static native int sqlite3_value_type(@NotNull sqlite3_value v); + private static native int sqlite3_value_type(@NotNull long ptrToValue); @Canonical - public static native int sqlite3_value_numeric_type(@NotNull sqlite3_value v); - - @Canonical - public static native int sqlite3_value_nochange(@NotNull sqlite3_value v); - - @Canonical - public static native int sqlite3_value_frombind(@NotNull sqlite3_value v); - - @Canonical - public static native int sqlite3_value_subtype(@NotNull sqlite3_value v); + public static int sqlite3_value_type(@NotNull sqlite3_value v){ + return sqlite3_value_type(v.getNativePointer()); + } /** This is NOT part of the public API. It exists solely as a place diff --git a/manifest b/manifest index 0439e98ef5..de6d1d2b2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Convert\sthe\smacro-generated\sJNI\sbindings\swhich\stake\sa\sdb\spointer\sto\sthe\snew\spointer-passing\smechanism. -D 2023-09-28T10:27:01.146 +C Convert\sthe\sremaining\smacro-generated\sJNI\sbindings\sto\sthe\snew\spointer-passing\smechanism. +D 2023-09-28T10:50:26.804 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 14406b8857fb1ea3ec57bf90fdd17e1dbb68937f21868b50de6a5e64555a1053 -F ext/jni/src/c/sqlite3-jni.h d1ac1b6610437291077b263cfc2ecb2dd1ccc5154e83dd45083b86aa20b34be6 +F ext/jni/src/c/sqlite3-jni.c cb456137ac67fc9859279d7c5029bf771954df5f4922abbbf2be2a79b0909116 +F ext/jni/src/c/sqlite3-jni.h ad69a8b62390c8ad5be254fa1a065c0ba48152b271d82edb84f89edf4c83669c F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 7075a5c5de4d5b41b47587abd0fd0d82e325e1a4fc24d4422d029b9b7f0cac1e +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java e03e2a3e773c95401c97f334e7389dcf9ebe65d01a9c6e0ada1a1e8618958d7f F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0b22c8ef93e5ccd45316099fb8575e27620158b1992c0c70fe0348cfc10147f8 -R 39e7f9b7ed1c60cf4f2907887eef0ed7 +P 5f47fb77db4ee77afc541e680559ad88e66ba7fd04b830e70f8be92cf8d0a60c +R 00596872cec8308548a723b66cba58cd U stephan -Z e97bf1ee3ba4dec99a48b628a72060e8 +Z f8a1bff7f7d52efaacf825af2168fc26 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 90ab0b17f4..f62f58d6ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f47fb77db4ee77afc541e680559ad88e66ba7fd04b830e70f8be92cf8d0a60c \ No newline at end of file +250fd6ae806cf705c0f29ad30ad8fb885b12590848e7adae63bc21d874c6d3bd \ No newline at end of file From 0dabcd139d1dceff596ab5f45d82a2bccba674e3 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 28 Sep 2023 11:19:37 +0000 Subject: [PATCH 08/11] Adapted the JNI bindings for the sqlite3_value_...() and (pre)update hook APIs to the new pointer-passing mechanism. FossilOrigin-Name: 4182f0275d5d65e04a130eeef4d44642a5ffeeb4b84430d240ea2605345f1404 --- ext/jni/src/c/sqlite3-jni.c | 64 ++++++------ ext/jni/src/c/sqlite3-jni.h | 52 +++++----- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 112 ++++++++++++++++----- manifest | 16 +-- manifest.uuid | 2 +- 5 files changed, 156 insertions(+), 90 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 248c12abbd..26d0647a6f 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -3792,8 +3792,8 @@ S3JniApi(sqlite3_preupdate_depth(),int,1preupdate_1depth)( ** JNI wrapper for both sqlite3_update_hook() and ** sqlite3_preupdate_hook() (if isPre is true). */ -static jobject s3jni_updatepre_hook(JNIEnv * env, int isPre, jobject jDb, jobject jHook){ - S3JniDb * const ps = S3JniDb_from_java(jDb); +static jobject s3jni_updatepre_hook(JNIEnv * env, int isPre, jlong jpDb, jobject jHook){ + S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); jclass klazz; jobject pOld = 0; jmethodID xCallback; @@ -3866,20 +3866,20 @@ end: S3JniApi(sqlite3_preupdate_hook(),jobject,1preupdate_1hook)( - JniArgsEnvClass, jobject jDb, jobject jHook + JniArgsEnvClass, jlong jpDb, jobject jHook ){ #ifdef SQLITE_ENABLE_PREUPDATE_HOOK - return s3jni_updatepre_hook(env, 1, jDb, jHook); + return s3jni_updatepre_hook(env, 1, jpDb, jHook); #else return NULL; #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ } /* Impl for sqlite3_preupdate_{new,old}(). */ -static int s3jni_preupdate_newold(JNIEnv * const env, int isNew, jobject jDb, +static int s3jni_preupdate_newold(JNIEnv * const env, int isNew, jlong jpDb, jint iCol, jobject jOut){ #ifdef SQLITE_ENABLE_PREUPDATE_HOOK - sqlite3 * const pDb = PtrGet_sqlite3(jDb); + sqlite3 * const pDb = S3JniLongPtr_sqlite3(jpDb); int rc = SQLITE_MISUSE; if( pDb ){ sqlite3_value * pOut = 0; @@ -3903,15 +3903,15 @@ static int s3jni_preupdate_newold(JNIEnv * const env, int isNew, jobject jDb, } S3JniApi(sqlite3_preupdate_new(),jint,1preupdate_1new)( - JniArgsEnvClass, jobject jDb, jint iCol, jobject jOut + JniArgsEnvClass, jlong jpDb, jint iCol, jobject jOut ){ - return s3jni_preupdate_newold(env, 1, jDb, iCol, jOut); + return s3jni_preupdate_newold(env, 1, jpDb, iCol, jOut); } S3JniApi(sqlite3_preupdate_old(),jint,1preupdate_1old)( - JniArgsEnvClass, jobject jDb, jint iCol, jobject jOut + JniArgsEnvClass, jlong jpDb, jint iCol, jobject jOut ){ - return s3jni_preupdate_newold(env, 0, jDb, iCol, jOut); + return s3jni_preupdate_newold(env, 0, jpDb, iCol, jOut); } @@ -4619,16 +4619,16 @@ S3JniApi(sqlite3_txn_state(),jint,1txn_1state)( } S3JniApi(sqlite3_update_hook(),jobject,1update_1hook)( - JniArgsEnvClass, jobject jDb, jobject jHook + JniArgsEnvClass, jlong jpDb, jobject jHook ){ - return s3jni_updatepre_hook(env, 0, jDb, jHook); + return s3jni_updatepre_hook(env, 0, jpDb, jHook); } S3JniApi(sqlite3_value_blob(),jbyteArray,1value_1blob)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - sqlite3_value * const sv = PtrGet_sqlite3_value(jpSVal); + sqlite3_value * const sv = S3JniLongPtr_sqlite3_value(jpSVal); int const nLen = sqlite3_value_bytes(sv); const jbyte * pBytes = sqlite3_value_blob(sv); @@ -4640,48 +4640,48 @@ S3JniApi(sqlite3_value_blob(),jbyteArray,1value_1blob)( S3JniApi(sqlite3_value_double(),jdouble,1value_1double)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - return (jdouble) sqlite3_value_double(PtrGet_sqlite3_value(jpSVal)); + return (jdouble) sqlite3_value_double(S3JniLongPtr_sqlite3_value(jpSVal)); } S3JniApi(sqlite3_value_dup(),jobject,1value_1dup)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - sqlite3_value * const sv = sqlite3_value_dup(PtrGet_sqlite3_value(jpSVal)); + sqlite3_value * const sv = sqlite3_value_dup(S3JniLongPtr_sqlite3_value(jpSVal)); return sv ? new_java_sqlite3_value(env, sv) : 0; } S3JniApi(sqlite3_value_free(),void,1value_1free)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - sqlite3_value_free(PtrGet_sqlite3_value(jpSVal)); + sqlite3_value_free(S3JniLongPtr_sqlite3_value(jpSVal)); } S3JniApi(sqlite3_value_int(),jint,1value_1int)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - return (jint) sqlite3_value_int(PtrGet_sqlite3_value(jpSVal)); + return (jint) sqlite3_value_int(S3JniLongPtr_sqlite3_value(jpSVal)); } S3JniApi(sqlite3_value_int64(),jlong,1value_1int64)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - return (jlong) sqlite3_value_int64(PtrGet_sqlite3_value(jpSVal)); + return (jlong) sqlite3_value_int64(S3JniLongPtr_sqlite3_value(jpSVal)); } S3JniApi(sqlite3_value_java_object(),jobject,1value_1java_1object)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - return sqlite3_value_pointer(PtrGet_sqlite3_value(jpSVal), + return sqlite3_value_pointer(S3JniLongPtr_sqlite3_value(jpSVal), ResultJavaValuePtrStr); } S3JniApi(sqlite3_value_text(),jbyteArray,1value_1text)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - sqlite3_value * const sv = PtrGet_sqlite3_value(jpSVal); + sqlite3_value * const sv = S3JniLongPtr_sqlite3_value(jpSVal); int const n = sqlite3_value_bytes(sv); const unsigned char * const p = sqlite3_value_text(sv); return p ? s3jni_new_jbyteArray(p, n) : 0; @@ -4690,9 +4690,9 @@ S3JniApi(sqlite3_value_text(),jbyteArray,1value_1text)( #if 0 // this impl might prove useful. S3JniApi(sqlite3_value_text(),jstring,1value_1text)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - sqlite3_value * const sv = PtrGet_sqlite3_value(jpSVal); + sqlite3_value * const sv = S3JniLongPtr_sqlite3_value(jpSVal); int const n = sqlite3_value_bytes(sv); const unsigned char * const p = sqlite3_value_text(sv); return p ? s3jni_utf8_to_jstring( (const char *)p, n) : 0; @@ -4700,9 +4700,9 @@ S3JniApi(sqlite3_value_text(),jstring,1value_1text)( #endif S3JniApi(sqlite3_value_text16(),jstring,1value_1text16)( - JniArgsEnvClass, jobject jpSVal + JniArgsEnvClass, jlong jpSVal ){ - sqlite3_value * const sv = PtrGet_sqlite3_value(jpSVal); + sqlite3_value * const sv = S3JniLongPtr_sqlite3_value(jpSVal); const int n = sqlite3_value_bytes16(sv); const void * const p = sqlite3_value_text16(sv); return s3jni_text16_to_jstring(env, p, n); diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index a2e9644c8b..555efed693 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -1566,26 +1566,26 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1depth /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_preupdate_hook - * Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/PreupdateHookCallback;)Lorg/sqlite/jni/PreupdateHookCallback; + * Signature: (JLorg/sqlite/jni/PreupdateHookCallback;)Lorg/sqlite/jni/PreupdateHookCallback; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1hook - (JNIEnv *, jclass, jobject, jobject); + (JNIEnv *, jclass, jlong, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_preupdate_new - * Signature: (Lorg/sqlite/jni/sqlite3;ILorg/sqlite/jni/OutputPointer/sqlite3_value;)I + * Signature: (JILorg/sqlite/jni/OutputPointer/sqlite3_value;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1new - (JNIEnv *, jclass, jobject, jint, jobject); + (JNIEnv *, jclass, jlong, jint, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_preupdate_old - * Signature: (Lorg/sqlite/jni/sqlite3;ILorg/sqlite/jni/OutputPointer/sqlite3_value;)I + * Signature: (JILorg/sqlite/jni/OutputPointer/sqlite3_value;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1preupdate_1old - (JNIEnv *, jclass, jobject, jint, jobject); + (JNIEnv *, jclass, jlong, jint, jobject); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1950,18 +1950,18 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1txn_1state /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_update_hook - * Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/UpdateHookCallback;)Lorg/sqlite/jni/UpdateHookCallback; + * Signature: (JLorg/sqlite/jni/UpdateHookCallback;)Lorg/sqlite/jni/UpdateHookCallback; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1update_1hook - (JNIEnv *, jclass, jobject, jobject); + (JNIEnv *, jclass, jlong, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_blob - * Signature: (Lorg/sqlite/jni/sqlite3_value;)[B + * Signature: (J)[B */ JNIEXPORT jbyteArray JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1blob - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1982,18 +1982,18 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1bytes16 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_double - * Signature: (Lorg/sqlite/jni/sqlite3_value;)D + * Signature: (J)D */ JNIEXPORT jdouble JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1double - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_dup - * Signature: (Lorg/sqlite/jni/sqlite3_value;)Lorg/sqlite/jni/sqlite3_value; + * Signature: (J)Lorg/sqlite/jni/sqlite3_value; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1dup - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -2006,10 +2006,10 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1encoding /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_free - * Signature: (Lorg/sqlite/jni/sqlite3_value;)V + * Signature: (J)V */ JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1free - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -2022,26 +2022,26 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1frombind /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_int - * Signature: (Lorg/sqlite/jni/sqlite3_value;)I + * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1int - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_int64 - * Signature: (Lorg/sqlite/jni/sqlite3_value;)J + * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1int64 - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_java_object - * Signature: (Lorg/sqlite/jni/sqlite3_value;)Ljava/lang/Object; + * Signature: (J)Ljava/lang/Object; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1java_1object - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni @@ -2070,18 +2070,18 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1subtype /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_text - * Signature: (Lorg/sqlite/jni/sqlite3_value;)[B + * Signature: (J)[B */ JNIEXPORT jbyteArray JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1text - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_value_text16 - * Signature: (Lorg/sqlite/jni/sqlite3_value;)Ljava/lang/String; + * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1text16 - (JNIEnv *, jclass, jobject); + (JNIEnv *, jclass, jlong); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 9cdae6d7b6..807a79d704 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -1372,15 +1372,26 @@ public final class SQLite3Jni { return sqlite3_preupdate_depth(db.getNativePointer()); } + @Canonical + private static native PreupdateHookCallback sqlite3_preupdate_hook( + @NotNull long ptrToDb, @Nullable PreupdateHookCallback hook + ); + /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this acts as a proxy for C's sqlite3_preupdate_hook(), else it returns null with no side effects. */ @Canonical - public static native PreupdateHookCallback sqlite3_preupdate_hook( + public static PreupdateHookCallback sqlite3_preupdate_hook( @NotNull sqlite3 db, @Nullable PreupdateHookCallback hook - ); + ){ + return sqlite3_preupdate_hook(db.getNativePointer(), hook); + } + + @Canonical + private static native int sqlite3_preupdate_new(@NotNull long ptrToDb, int col, + @NotNull OutputPointer.sqlite3_value out); /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, @@ -1388,8 +1399,10 @@ public final class SQLite3Jni { returns SQLITE_MISUSE with no side effects. */ @Canonical - public static native int sqlite3_preupdate_new(@NotNull sqlite3 db, int col, - @NotNull OutputPointer.sqlite3_value out); + public static int sqlite3_preupdate_new(@NotNull sqlite3 db, int col, + @NotNull OutputPointer.sqlite3_value out){ + return sqlite3_preupdate_new(db.getNativePointer(), col, out); + } /** Convenience wrapper for the 3-arg sqlite3_preupdate_new() which returns @@ -1397,18 +1410,24 @@ public final class SQLite3Jni { */ public static sqlite3_value sqlite3_preupdate_new(@NotNull sqlite3 db, int col){ final OutputPointer.sqlite3_value out = new OutputPointer.sqlite3_value(); - sqlite3_preupdate_new(db, col, out); + sqlite3_preupdate_new(db.getNativePointer(), col, out); return out.take(); } + @Canonical + private static native int sqlite3_preupdate_old(@NotNull long ptrToDb, int col, + @NotNull OutputPointer.sqlite3_value out); + /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this acts as a proxy for C's sqlite3_preupdate_old(), else it returns SQLITE_MISUSE with no side effects. */ @Canonical - public static native int sqlite3_preupdate_old(@NotNull sqlite3 db, int col, - @NotNull OutputPointer.sqlite3_value out); + public static int sqlite3_preupdate_old(@NotNull sqlite3 db, int col, + @NotNull OutputPointer.sqlite3_value out){ + return sqlite3_preupdate_old(db.getNativePointer(), col, out); + } /** Convenience wrapper for the 3-arg sqlite3_preupdate_old() which returns @@ -1416,7 +1435,7 @@ public final class SQLite3Jni { */ public static sqlite3_value sqlite3_preupdate_old(@NotNull sqlite3 db, int col){ final OutputPointer.sqlite3_value out = new OutputPointer.sqlite3_value(); - sqlite3_preupdate_old(db, col, out); + sqlite3_preupdate_old(db.getNativePointer(), col, out); return out.take(); } @@ -1966,10 +1985,17 @@ public final class SQLite3Jni { ); @Canonical - public static native UpdateHookCallback sqlite3_update_hook( - @NotNull sqlite3 db, @Nullable UpdateHookCallback hook + private static native UpdateHookCallback sqlite3_update_hook( + @NotNull long ptrToDb, @Nullable UpdateHookCallback hook ); + @Canonical + public static UpdateHookCallback sqlite3_update_hook( + @NotNull sqlite3 db, @Nullable UpdateHookCallback hook + ){ + return sqlite3_update_hook(db.getNativePointer(), hook); + } + /* Note that: @@ -1981,7 +2007,12 @@ public final class SQLite3Jni { */ @Canonical - public static native byte[] sqlite3_value_blob(@NotNull sqlite3_value v); + private static native byte[] sqlite3_value_blob(@NotNull long ptrToValue); + + @Canonical + public static byte[] sqlite3_value_blob(@NotNull sqlite3_value v){ + return sqlite3_value_blob(v.getNativePointer()); + } @Canonical private static native int sqlite3_value_bytes(@NotNull long ptrToValue); @@ -2000,12 +2031,20 @@ public final class SQLite3Jni { } @Canonical - public static native double sqlite3_value_double(@NotNull sqlite3_value v); + private static native double sqlite3_value_double(@NotNull long ptrToValue); @Canonical - public static native sqlite3_value sqlite3_value_dup( - @NotNull sqlite3_value v - ); + public static double sqlite3_value_double(@NotNull sqlite3_value v){ + return sqlite3_value_double(v.getNativePointer()); + } + + @Canonical + private static native sqlite3_value sqlite3_value_dup(@NotNull long ptrToValue); + + @Canonical + public static sqlite3_value sqlite3_value_dup(@NotNull sqlite3_value v){ + return sqlite3_value_dup(v.getNativePointer()); + } @Canonical private static native int sqlite3_value_encoding(@NotNull long ptrToValue); @@ -2016,7 +2055,12 @@ public final class SQLite3Jni { } @Canonical - public static native void sqlite3_value_free(@Nullable sqlite3_value v); + private static native void sqlite3_value_free(@Nullable long ptrToValue); + + @Canonical + public static void sqlite3_value_free(@Nullable sqlite3_value v){ + sqlite3_value_free(v.getNativePointer()); + } @Canonical private static native int sqlite3_value_frombind(@NotNull long ptrToValue); @@ -2027,10 +2071,22 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_value_int(@NotNull sqlite3_value v); + private static native int sqlite3_value_int(@NotNull long ptrToValue); @Canonical - public static native long sqlite3_value_int64(@NotNull sqlite3_value v); + public static int sqlite3_value_int(@NotNull sqlite3_value v){ + return sqlite3_value_int(v.getNativePointer()); + } + + @Canonical + private static native long sqlite3_value_int64(@NotNull long ptrToValue); + + @Canonical + public static long sqlite3_value_int64(@NotNull sqlite3_value v){ + return sqlite3_value_int64(v.getNativePointer()); + } + + private static native Object sqlite3_value_java_object(@NotNull long ptrToValue); /** If the given value was set using {@link @@ -2040,9 +2096,9 @@ public final class SQLite3Jni {

It is up to the caller to inspect the object to determine its type, and cast it if necessary. */ - public static native Object sqlite3_value_java_object( - @NotNull sqlite3_value v - ); + public static Object sqlite3_value_java_object(@NotNull sqlite3_value v){ + return sqlite3_value_java_object(v.getNativePointer()); + } /** A variant of sqlite3_value_java_object() which returns the @@ -2080,6 +2136,9 @@ public final class SQLite3Jni { return sqlite3_value_subtype(v.getNativePointer()); } + @Canonical + private static native byte[] sqlite3_value_text(@NotNull long ptrToValue); + /** Functions identially to the C API, and this note is just to stress that the returned bytes are encoded as UTF-8. It returns @@ -2087,10 +2146,17 @@ public final class SQLite3Jni { or on allocation error. */ @Canonical - public static native byte[] sqlite3_value_text(@NotNull sqlite3_value v); + public static byte[] sqlite3_value_text(@NotNull sqlite3_value v){ + return sqlite3_value_text(v.getNativePointer()); + } @Canonical - public static native String sqlite3_value_text16(@NotNull sqlite3_value v); + private static native String sqlite3_value_text16(@NotNull long ptrToValue); + + @Canonical + public static String sqlite3_value_text16(@NotNull sqlite3_value v){ + return sqlite3_value_text16(v.getNativePointer()); + } @Canonical private static native int sqlite3_value_type(@NotNull long ptrToValue); diff --git a/manifest b/manifest index de6d1d2b2b..dc7e99b904 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Convert\sthe\sremaining\smacro-generated\sJNI\sbindings\sto\sthe\snew\spointer-passing\smechanism. -D 2023-09-28T10:50:26.804 +C Adapted\sthe\sJNI\sbindings\sfor\sthe\ssqlite3_value_...()\sand\s(pre)update\shook\sAPIs\sto\sthe\snew\spointer-passing\smechanism. +D 2023-09-28T11:19:37.102 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c cb456137ac67fc9859279d7c5029bf771954df5f4922abbbf2be2a79b0909116 -F ext/jni/src/c/sqlite3-jni.h ad69a8b62390c8ad5be254fa1a065c0ba48152b271d82edb84f89edf4c83669c +F ext/jni/src/c/sqlite3-jni.c 9d5ea1bf8c7da874fdd6dc3f7cd05632c82e747fb6f4b4b3967f7aadae3ac910 +F ext/jni/src/c/sqlite3-jni.h 0c13ef53143ad6b3ed0e6b15f706f9f03e9c0c6c4f896a5846e4a68e58da83c8 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java e03e2a3e773c95401c97f334e7389dcf9ebe65d01a9c6e0ada1a1e8618958d7f +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 8dc0c48378eaf04bfc868bd8069dd5e55365b5d50d2e14b6e075c2afee1a5844 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5f47fb77db4ee77afc541e680559ad88e66ba7fd04b830e70f8be92cf8d0a60c -R 00596872cec8308548a723b66cba58cd +P 250fd6ae806cf705c0f29ad30ad8fb885b12590848e7adae63bc21d874c6d3bd +R b6214243c5615bb53c027385b902ff1b U stephan -Z f8a1bff7f7d52efaacf825af2168fc26 +Z 6486a7f1446bd02f9d2f2235b0984708 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f62f58d6ac..a0760fca51 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -250fd6ae806cf705c0f29ad30ad8fb885b12590848e7adae63bc21d874c6d3bd \ No newline at end of file +4182f0275d5d65e04a130eeef4d44642a5ffeeb4b84430d240ea2605345f1404 \ No newline at end of file From 83f62816f8d68a79d4889c406d05ddf8fa490765 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 28 Sep 2023 20:34:28 +0000 Subject: [PATCH 09/11] JNI: correct a NullPointerException triggered via SQLTester. FossilOrigin-Name: 0a873de76c0cbcd8e2eda3f0508e427f1dcb32b01798687c0545acfe10102179 --- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 9 ++++++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index 807a79d704..bebee05df1 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -574,8 +574,11 @@ public final class SQLite3Jni { @Canonical public static int sqlite3_close(@Nullable sqlite3 db){ - final int rc = sqlite3_close(db.getNativePointer()); - if( 0==rc ) db.clearNativePointer(); + int rc = 0; + if( null!=db ){ + rc = sqlite3_close(db.getNativePointer()); + if( 0==rc ) db.clearNativePointer(); + } return rc; } @@ -584,7 +587,7 @@ public final class SQLite3Jni { @Canonical public static int sqlite3_close_v2(@Nullable sqlite3 db){ - return sqlite3_close_v2(db.clearNativePointer()); + return db==null ? 0 : sqlite3_close_v2(db.clearNativePointer()); } @Canonical diff --git a/manifest b/manifest index dc7e99b904..68215ea779 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adapted\sthe\sJNI\sbindings\sfor\sthe\ssqlite3_value_...()\sand\s(pre)update\shook\sAPIs\sto\sthe\snew\spointer-passing\smechanism. -D 2023-09-28T11:19:37.102 +C JNI:\scorrect\sa\sNullPointerException\striggered\svia\sSQLTester. +D 2023-09-28T20:34:28.893 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 8dc0c48378eaf04bfc868bd8069dd5e55365b5d50d2e14b6e075c2afee1a5844 +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java bb7436bcac55480ae5c5ba62fb92861ea0e948c03bc1475ef202aa26a819ed61 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 250fd6ae806cf705c0f29ad30ad8fb885b12590848e7adae63bc21d874c6d3bd -R b6214243c5615bb53c027385b902ff1b +P 4182f0275d5d65e04a130eeef4d44642a5ffeeb4b84430d240ea2605345f1404 +R a2d8547ef3a0aabe5f166da28f6b427d U stephan -Z 6486a7f1446bd02f9d2f2235b0984708 +Z 0bc34c11fb15e6b9fa15ab1d2bacfac5 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a0760fca51..fc9cc8cadb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4182f0275d5d65e04a130eeef4d44642a5ffeeb4b84430d240ea2605345f1404 \ No newline at end of file +0a873de76c0cbcd8e2eda3f0508e427f1dcb32b01798687c0545acfe10102179 \ No newline at end of file From ebce46f02f04bf8e6450826ba3b2efa507d15556 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 30 Sep 2023 09:41:58 +0000 Subject: [PATCH 10/11] More work towards the new pointer-passing mechanism in JNI, and code-adjacent cleanups. FossilOrigin-Name: 6c63987e893357dc8b10decaa96c30fb37b75481640a303e77a0d8224354491e --- ext/jni/src/c/sqlite3-jni.c | 53 +++++++----- ext/jni/src/c/sqlite3-jni.h | 12 +-- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 94 +++++++++++++++------- manifest | 16 ++-- manifest.uuid | 2 +- 5 files changed, 113 insertions(+), 64 deletions(-) diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 26d0647a6f..37fa2cc05b 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -811,13 +811,13 @@ static void s3jni_incr( volatile unsigned int * const p ){ #endif /* Helpers for jstring and jbyteArray. */ -static const char * s3jni__jstring_to_mutf8_bytes(JNIEnv * const env, jstring v ){ +static const char * s3jni__jstring_to_mutf8(JNIEnv * const env, jstring v ){ const char *z = v ? (*env)->GetStringUTFChars(env, v, NULL) : 0; s3jni_oom_check( v ? !!z : !z ); return z; } -#define s3jni_jstring_to_mutf8(ARG) s3jni__jstring_to_mutf8_bytes(env, (ARG)) +#define s3jni_jstring_to_mutf8(ARG) s3jni__jstring_to_mutf8(env, (ARG)) #define s3jni_mutf8_release(ARG,VAR) if( VAR ) (*env)->ReleaseStringUTFChars(env, ARG, VAR) static jbyte * s3jni__jbyteArray_bytes(JNIEnv * const env, jbyteArray jBA ){ @@ -1515,6 +1515,8 @@ static void S3JniDb_xDestroy(void *p){ */ #define S3JniDb_from_c(sqlite3Ptr) \ ((sqlite3Ptr) ? S3JniDb_from_clientdata(sqlite3Ptr) : 0) +#define S3JniDb_from_jlong(sqlite3PtrAsLong) \ + S3JniDb_from_c(S3JniLongPtr_T(sqlite3,sqlite3PtrAsLong)) /* ** Unref any Java-side state in (S3JniAutoExtension*) AX and zero out @@ -2520,7 +2522,7 @@ static int s3jni_busy_handler(void* pState, int n){ S3JniApi(sqlite3_busy_handler(),jint,1busy_1handler)( JniArgsEnvClass, jlong jpDb, jobject jBusy ){ - S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); + S3JniDb * const ps = S3JniDb_from_jlong(jpDb); S3JniHook * const pHook = ps ? &ps->hooks.busyHandler : 0; S3JniHook hook = S3JniHook_empty; int rc = 0; @@ -2565,7 +2567,7 @@ S3JniApi(sqlite3_busy_handler(),jint,1busy_1handler)( S3JniApi(sqlite3_busy_timeout(),jint,1busy_1timeout)( JniArgsEnvClass, jlong jpDb, jint ms ){ - S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); + S3JniDb * const ps = S3JniDb_from_jlong(jpDb); int rc = SQLITE_MISUSE; if( ps ){ S3JniDb_mutex_enter; @@ -2604,7 +2606,7 @@ S3JniApi(sqlite3_cancel_auto_extension(),jboolean,1cancel_1auto_1extension)( /* Wrapper for sqlite3_close(_v2)(). */ static jint s3jni_close_db(JNIEnv * const env, jlong jpDb, int version){ int rc = 0; - S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); + S3JniDb * const ps = S3JniDb_from_jlong(jpDb); assert(version == 1 || version == 2); if( ps ){ @@ -2666,14 +2668,14 @@ static void s3jni_collation_needed_impl16(void *pState, sqlite3 *pDb, } S3JniApi(sqlite3_collation_needed(),jint,1collation_1needed)( - JniArgsEnvClass, jobject jDb, jobject jHook + JniArgsEnvClass, jlong jpDb, jobject jHook ){ S3JniDb * ps; S3JniCollationNeeded * pHook; int rc = 0; S3JniDb_mutex_enter; - ps = S3JniDb_from_java(jDb); + ps = S3JniDb_from_jlong(jpDb); if( !ps ){ S3JniDb_mutex_leave; return SQLITE_MISUSE; @@ -2816,13 +2818,13 @@ static void s3jni_rollback_hook_impl(void *pP){ ** sqlite3_rollback_hook(). */ static jobject s3jni_commit_rollback_hook(int isCommit, JNIEnv * const env, - jobject jDb, jobject jHook){ + jlong jpDb, jobject jHook){ S3JniDb * ps; jobject pOld = 0; /* previous hoook */ S3JniHook * pHook; /* ps->hooks.commit|rollback */ S3JniDb_mutex_enter; - ps = S3JniDb_from_java(jDb); + ps = S3JniDb_from_jlong(jpDb); if( !ps ){ s3jni_db_error(ps->pDb, SQLITE_NOMEM, 0); S3JniDb_mutex_leave; @@ -2870,9 +2872,9 @@ static jobject s3jni_commit_rollback_hook(int isCommit, JNIEnv * const env, } S3JniApi(sqlite3_commit_hook(),jobject,1commit_1hook)( - JniArgsEnvClass,jobject jDb, jobject jHook + JniArgsEnvClass, jlong jpDb, jobject jHook ){ - return s3jni_commit_rollback_hook(1, env, jDb, jHook); + return s3jni_commit_rollback_hook(1, env, jpDb, jHook); } S3JniApi(sqlite3_compileoption_get(),jstring,1compileoption_1get)( @@ -2904,12 +2906,17 @@ S3JniApi(sqlite3_complete(),int,1complete)( S3JniApi(sqlite3_compileoption_used(),jboolean,1compileoption_1used)( JniArgsEnvClass, jstring name ){ - const char *zUtf8 = s3jni_jstring_to_mutf8(name) - /* We know these to be ASCII, so MUTF-8 is fine. */; - const jboolean rc = - 0==sqlite3_compileoption_used(zUtf8) ? JNI_FALSE : JNI_TRUE; - s3jni_mutf8_release(name, zUtf8); - return rc; + if( name ){ + const char *zUtf8 = s3jni_jstring_to_mutf8(name) + /* We know these to be ASCII, so MUTF-8 is fine (and + hypothetically faster to convert). */; + const jboolean rc = + 0==sqlite3_compileoption_used(zUtf8) ? JNI_FALSE : JNI_TRUE; + s3jni_mutf8_release(name, zUtf8); + return rc; + }else{ + return JNI_FALSE; + } } S3JniApi(sqlite3_config() /*for a small subset of options.*/, @@ -3118,7 +3125,7 @@ S3JniApi(sqlite3_create_collation() sqlite3_create_collation_v2(), S3JniDb_mutex_enter; ps = S3JniDb_from_java(jDb); - if( !ps ){ + if( !ps || !name ){ rc = SQLITE_MISUSE; }else{ jclass const klazz = (*env)->GetObjectClass(env, oCollation); @@ -3164,7 +3171,9 @@ S3JniApi(sqlite3_create_function() sqlite3_create_function_v2() sqlite3 * const pDb = PtrGet_sqlite3(jDb); char * zFuncName = 0; - if( !encodingTypeIsValid(eTextRep) ){ + if( !pDb || !jFuncName ){ + return SQLITE_MISUSE; + }else if( !encodingTypeIsValid(eTextRep) ){ return s3jni_db_error(pDb, SQLITE_FORMAT, "Invalid function encoding option."); } @@ -3793,7 +3802,7 @@ S3JniApi(sqlite3_preupdate_depth(),int,1preupdate_1depth)( ** sqlite3_preupdate_hook() (if isPre is true). */ static jobject s3jni_updatepre_hook(JNIEnv * env, int isPre, jlong jpDb, jobject jHook){ - S3JniDb * const ps = S3JniDb_from_c(S3JniLongPtr_sqlite3(jpDb)); + S3JniDb * const ps = S3JniDb_from_jlong(jpDb); jclass klazz; jobject pOld = 0; jmethodID xCallback; @@ -4211,9 +4220,9 @@ S3JniApi(sqlite3_result_zeroblob64(),jint,1result_1zeroblob64)( } S3JniApi(sqlite3_rollback_hook(),jobject,1rollback_1hook)( - JniArgsEnvClass, jobject jDb, jobject jHook + JniArgsEnvClass, jlong jpDb, jobject jHook ){ - return s3jni_commit_rollback_hook(0, env, jDb, jHook); + return s3jni_commit_rollback_hook(0, env, jpDb, jHook); } /* Callback for sqlite3_set_authorizer(). */ diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index 555efed693..3b89ae7f73 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -1198,18 +1198,18 @@ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1column_1value /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_collation_needed - * Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/CollationNeededCallback;)I + * Signature: (JLorg/sqlite/jni/CollationNeededCallback;)I */ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1collation_1needed - (JNIEnv *, jclass, jobject, jobject); + (JNIEnv *, jclass, jlong, jobject); /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_commit_hook - * Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/CommitHookCallback;)Lorg/sqlite/jni/CommitHookCallback; + * Signature: (JLorg/sqlite/jni/CommitHookCallback;)Lorg/sqlite/jni/CommitHookCallback; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1commit_1hook - (JNIEnv *, jclass, jobject, jobject); + (JNIEnv *, jclass, jlong, jobject); /* * Class: org_sqlite_jni_SQLite3Jni @@ -1758,10 +1758,10 @@ JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1result_1text64 /* * Class: org_sqlite_jni_SQLite3Jni * Method: sqlite3_rollback_hook - * Signature: (Lorg/sqlite/jni/sqlite3;Lorg/sqlite/jni/RollbackHookCallback;)Lorg/sqlite/jni/RollbackHookCallback; + * Signature: (JLorg/sqlite/jni/RollbackHookCallback;)Lorg/sqlite/jni/RollbackHookCallback; */ JNIEXPORT jobject JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1rollback_1hook - (JNIEnv *, jclass, jobject, jobject); + (JNIEnv *, jclass, jlong, jobject); /* * Class: org_sqlite_jni_SQLite3Jni diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index bebee05df1..a67d9f57b8 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -92,6 +92,14 @@ public final class SQLite3Jni { //! Called from static init code. private static native void init(); + /** + Returns a nul-terminated copy of s as a byte array, or null if s + is null. + */ + private static byte[] nulTerminateUtf8(String s){ + return null==s ? null : (s+"\0").getBytes(StandardCharsets.UTF_8); + } + /** Each thread which uses the SQLite3 JNI APIs should call sqlite3_jni_uncache_thread() when it is done with the library - @@ -315,8 +323,8 @@ public final class SQLite3Jni { public static int sqlite3_bind_parameter_index( @NotNull sqlite3_stmt stmt, @NotNull String paramName ){ - final byte[] utf8 = (paramName+"\0").getBytes(StandardCharsets.UTF_8); - return sqlite3_bind_parameter_index(stmt.getNativePointer(), utf8); + final byte[] utf8 = nulTerminateUtf8(paramName); + return null==utf8 ? 0 : sqlite3_bind_parameter_index(stmt.getNativePointer(), utf8); } @Canonical @@ -742,29 +750,43 @@ public final class SQLite3Jni { @NotNull sqlite3_stmt stmt, int ndx ); + @Canonical + static native int sqlite3_collation_needed( + @NotNull long ptrToDb, @Nullable CollationNeededCallback callback + ); + /** This functions like C's sqlite3_collation_needed16() because Java's string type is inherently compatible with that interface. */ @Canonical - public static native int sqlite3_collation_needed( + public static int sqlite3_collation_needed( @NotNull sqlite3 db, @Nullable CollationNeededCallback callback + ){ + return sqlite3_collation_needed(db.getNativePointer(), callback); + } + + @Canonical + static native CommitHookCallback sqlite3_commit_hook( + @NotNull long ptrToDb, @Nullable CommitHookCallback hook ); @Canonical - public static native CommitHookCallback sqlite3_commit_hook( + public static CommitHookCallback sqlite3_commit_hook( @NotNull sqlite3 db, @Nullable CommitHookCallback hook - ); + ){ + return sqlite3_commit_hook(db.getNativePointer(), hook); + } @Canonical - public static native String sqlite3_compileoption_get( - int n - ); + public static native String sqlite3_compileoption_get(int n); + /** + Unlike the C API, returns false if its argument is NULL (as + opposed to invoking UB). + */ @Canonical - public static native boolean sqlite3_compileoption_used( - @NotNull String optName - ); + public static native boolean sqlite3_compileoption_used(String optName); /** This implementation is private because it's too easy to pass it @@ -775,12 +797,13 @@ public final class SQLite3Jni { @NotNull byte[] nulTerminatedUtf8Sql ); + /** + Unlike this C API, this returns SQLITE_MISUSE if its argument is + null (as opposed to invoking UB). + */ @Canonical() - public static int sqlite3_complete(@NotNull String sql){ - /* Design note: we don't implement this in native code because we - won't get a NUL-terminated string there unless we make our own - copy to add a terminator. That's much easier to do here. */ - return sqlite3_complete( (sql+"\0").getBytes(StandardCharsets.UTF_8) ); + public static int sqlite3_complete(String sql){ + return null==sql ? SQLITE_MISUSE : sqlite3_complete( nulTerminateUtf8(sql) ); } @@ -828,11 +851,19 @@ public final class SQLite3Jni { @Canonical(comment="Option subset: SQLITE_CONFIG_LOG") public static native int sqlite3_config( @Nullable ConfigLogCallback logger ); + /** + Unlike this C API, this returns null if its argument is + null (as opposed to invoking UB). + */ @Canonical public static native sqlite3 sqlite3_context_db_handle( @NotNull sqlite3_context cx ); + /** + Unlike this C API, this returns SQLITE_MISUSE if its db or name + arguments are null (as opposed to invoking UB). + */ @Canonical public static native int sqlite3_create_collation( @NotNull sqlite3 db, @NotNull String name, int eTextRep, @@ -846,6 +877,9 @@ public final class SQLite3Jni { depends on which methods the final argument implements. See SQLFunction's subclasses (ScalarFunction, AggregateFunction, and WindowFunction) for details. + + Unlike this C API, this returns SQLITE_MISUSE null if its db or + functionName arguments are null (as opposed to invoking UB). */ @Canonical public static native int sqlite3_create_function( @@ -865,6 +899,9 @@ public final class SQLite3Jni { Overload for sqlite3_db_config() calls which take (int,int*) variadic arguments. Returns SQLITE_MISUSE if op is not one of the SQLITE_DBCONFIG_... options which uses this call form. + + Unlike this C API, this returns SQLITE_MISUSE if its db argument + are null (as opposed to invoking UB). */ @Canonical public static native int sqlite3_db_config( @@ -1771,10 +1808,17 @@ public final class SQLite3Jni { } @Canonical - public static native RollbackHookCallback sqlite3_rollback_hook( - @NotNull sqlite3 db, @Nullable RollbackHookCallback hook + static native RollbackHookCallback sqlite3_rollback_hook( + @NotNull long ptrToDb, @Nullable RollbackHookCallback hook ); + @Canonical + public static RollbackHookCallback sqlite3_rollback_hook( + @NotNull sqlite3 db, @Nullable RollbackHookCallback hook + ){ + return sqlite3_rollback_hook(db.getNativePointer(), hook); + } + @Canonical public static native int sqlite3_set_authorizer( @NotNull sqlite3 db, @Nullable AuthorizerCallback auth @@ -1876,10 +1920,8 @@ public final class SQLite3Jni { public static int sqlite3_strglob( @NotNull String glob, @NotNull String txt ){ - return sqlite3_strglob( - (glob+"\0").getBytes(StandardCharsets.UTF_8), - (txt+"\0").getBytes(StandardCharsets.UTF_8) - ); + return sqlite3_strglob(nulTerminateUtf8(glob), + nulTerminateUtf8(txt)); } /** @@ -1895,11 +1937,9 @@ public final class SQLite3Jni { public static int sqlite3_strlike( @NotNull String glob, @NotNull String txt, char escChar ){ - return sqlite3_strlike( - (glob+"\0").getBytes(StandardCharsets.UTF_8), - (txt+"\0").getBytes(StandardCharsets.UTF_8), - (int)escChar - ); + return sqlite3_strlike(nulTerminateUtf8(glob), + nulTerminateUtf8(txt), + (int)escChar); } @Canonical diff --git a/manifest b/manifest index 68215ea779..929496c32e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C JNI:\scorrect\sa\sNullPointerException\striggered\svia\sSQLTester. -D 2023-09-28T20:34:28.893 +C More\swork\stowards\sthe\snew\spointer-passing\smechanism\sin\sJNI,\sand\scode-adjacent\scleanups. +D 2023-09-30T09:41:58.693 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -238,8 +238,8 @@ F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a3 F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 9d5ea1bf8c7da874fdd6dc3f7cd05632c82e747fb6f4b4b3967f7aadae3ac910 -F ext/jni/src/c/sqlite3-jni.h 0c13ef53143ad6b3ed0e6b15f706f9f03e9c0c6c4f896a5846e4a68e58da83c8 +F ext/jni/src/c/sqlite3-jni.c caab9e9fdb0b8d8682c730d9bbc166778971e86f443c3f6b57e70aca86236f0c +F ext/jni/src/c/sqlite3-jni.h e3ec460570ef74f1f3d7725f93a8cf89840e1fee983741a7939c5dc992971df5 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,7 +259,7 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java bb7436bcac55480ae5c5ba62fb92861ea0e948c03bc1475ef202aa26a819ed61 +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 2cce647774f7f8511c3b61cd280c19d871b49c401155e3f17c346db5d05ac824 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4182f0275d5d65e04a130eeef4d44642a5ffeeb4b84430d240ea2605345f1404 -R a2d8547ef3a0aabe5f166da28f6b427d +P 0a873de76c0cbcd8e2eda3f0508e427f1dcb32b01798687c0545acfe10102179 +R 85f58d35114ff163d0c32151ce0233f3 U stephan -Z 0bc34c11fb15e6b9fa15ab1d2bacfac5 +Z 80cc94af82e9bdc221a901efb80be260 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index fc9cc8cadb..2411bbf400 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a873de76c0cbcd8e2eda3f0508e427f1dcb32b01798687c0545acfe10102179 \ No newline at end of file +6c63987e893357dc8b10decaa96c30fb37b75481640a303e77a0d8224354491e \ No newline at end of file From d1ce2755f01d01bd6b325dc2cb8dc2803ecceda4 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 30 Sep 2023 10:31:56 +0000 Subject: [PATCH 11/11] Make all native JNI sqlite3_...() bindings package-private as a foot-shooting protective measure (higher-level pre-native-call argument validation is largely pending). Move SQLTester.java and TesterFts5.java into the org.sqlite.jni package so that they can access the being-tested methods. FossilOrigin-Name: ec82f7251acab7df40755ef5f456f36fe49b59e63a20be59bd610fc4280ba8cd --- ext/jni/GNUmakefile | 42 ++- ext/jni/src/c/sqlite3-jni.c | 22 +- ext/jni/src/c/sqlite3-jni.h | 58 ++-- .../sqlite/jni/{tester => }/SQLTester.java | 14 +- ext/jni/src/org/sqlite/jni/SQLite3Jni.java | 324 +++++++++--------- ext/jni/src/org/sqlite/jni/Tester1.java | 2 +- .../org/sqlite/jni/{fts5 => }/TesterFts5.java | 3 +- .../{tester => }/test-script-interpreter.md | 0 manifest | 26 +- manifest.uuid | 2 +- 10 files changed, 245 insertions(+), 248 deletions(-) rename ext/jni/src/org/sqlite/jni/{tester => }/SQLTester.java (99%) rename ext/jni/src/org/sqlite/jni/{fts5 => }/TesterFts5.java (99%) rename ext/jni/src/org/sqlite/jni/{tester => }/test-script-interpreter.md (100%) diff --git a/ext/jni/GNUmakefile b/ext/jni/GNUmakefile index ddf97dd8ac..e1aa06091f 100644 --- a/ext/jni/GNUmakefile +++ b/ext/jni/GNUmakefile @@ -26,8 +26,8 @@ dir.src.c := $(dir.src)/c dir.bld := $(dir.jni)/bld dir.bld.c := $(dir.bld) dir.src.jni := $(dir.src)/org/sqlite/jni -dir.src.jni.tester := $(dir.src.jni)/tester dir.src.fts5 := $(dir.src.jni)/fts5 +dir.tests := $(dir.src)/tests mkdir ?= mkdir -p $(dir.bld.c): $(mkdir) $@ @@ -46,7 +46,7 @@ DISTCLEAN_FILES := $(dir.jni)/*~ $(dir.src.c)/*~ $(dir.src.jni)/*~ sqlite3-jni.h := $(dir.src.c)/sqlite3-jni.h .NOTPARALLEL: $(sqlite3-jni.h) SQLite3Jni.java := src/org/sqlite/jni/SQLite3Jni.java -SQLTester.java := src/org/sqlite/jni/tester/SQLTester.java +SQLTester.java := src/org/sqlite/jni/SQLTester.java SQLite3Jni.class := $(SQLite3Jni.java:.java=.class) SQLTester.class := $(SQLTester.java:.java=.class) @@ -61,8 +61,12 @@ SQLTester.class := $(SQLTester.java:.java=.class) # which the fts5 APIs have been stripped unless that feature is # intended to be stripped for good. enable.fts5 ?= 1 -# If enable.tester is 0, the org/sqlite/jni/tester/* bits are elided. -enable.tester ?= $(if $(wildcard $(dir.src.jni.tester)/SQLTester.java),1,0) + +ifeq (,$(wildcard $(dir.tests)/*)) + enable.tester := 0 +else + enable.tester := 1 +endif # bin.version-info = binary to output various sqlite3 version info # building the distribution zip file. @@ -112,6 +116,9 @@ JAVA_FILES.unittest := $(patsubst %,$(dir.src.jni)/%,\ Tester1.java \ ) ifeq (1,$(enable.fts5)) + JAVA_FILES.unittest += $(patsubst %,$(dir.src.jni)/%,\ + TesterFts5.java \ + ) JAVA_FILES.main += $(patsubst %,$(dir.src.fts5)/%,\ fts5_api.java \ fts5_extension_function.java \ @@ -121,11 +128,10 @@ ifeq (1,$(enable.fts5)) Fts5ExtensionApi.java \ Fts5PhraseIter.java \ Fts5Tokenizer.java \ - TesterFts5.java \ XTokenizeCallback.java \ ) endif -JAVA_FILES.tester := $(dir.src.jni.tester)/SQLTester.java +JAVA_FILES.tester := $(SQLTester.java) JAVA_FILES.package.info := \ $(dir.src.jni)/package-info.java \ $(dir.src.jni)/annotation/package-info.java @@ -233,14 +239,12 @@ endef # Invoke ADD_JNI_H once for each Java file which includes JNI # declarations: $(eval $(call ADD_JNI_H,$(dir.src.jni),SQLite3Jni,)) +$(eval $(call ADD_JNI_H,$(dir.src.jni),SQLTester,_tester)) ifeq (1,$(enable.fts5)) $(eval $(call ADD_JNI_H,$(dir.src.fts5),Fts5ExtensionApi,_fts5)) $(eval $(call ADD_JNI_H,$(dir.src.fts5),fts5_api,_fts5)) $(eval $(call ADD_JNI_H,$(dir.src.fts5),fts5_tokenizer,_fts5)) endif -ifeq (1,$(enable.tester)) - $(eval $(call ADD_JNI_H,$(dir.src.jni.tester),SQLTester,_tester)) -endif $(sqlite3-jni.h.in): $(dir.bld.c) #package.dll.cfiles := @@ -252,17 +256,18 @@ package.dll.cflags = \ -I$(JDK_HOME)/include \ $(patsubst %,-I%,$(patsubst %.h,,$(wildcard $(JDK_HOME)/include/*))) \ -Wall -# Using (-Wall -Wextra) triggers an untennable number of -# gcc warnings from sqlite3.c for mundane things like -# unused parameters. -# # The gross $(patsubst...) above is to include the platform-specific # subdir which lives under $(JDK_HOME)/include and is a required # include path for client-level code. +# +# Using (-Wall -Wextra) triggers an untennable number of +# gcc warnings from sqlite3.c for mundane things like +# unused parameters. ######################################################################## ifeq (1,$(enable.tester)) package.dll.cflags += -DSQLITE_JNI_ENABLE_SQLTester endif + $(sqlite3-jni.h): $(sqlite3-jni.h.in) $(MAKEFILE) @cat $(sqlite3-jni.h.in) > $@.tmp @if cmp $@ $@.tmp >/dev/null; then \ @@ -308,21 +313,21 @@ ifeq (1,$(enable.tester)) tester-local: $(CLASS_FILES.tester) $(package.dll) $(bin.java) -ea -Djava.library.path=$(dir.bld.c) \ $(java.flags) -cp $(classpath) \ - org.sqlite.jni.tester.SQLTester $(tester.flags) $(tester.scripts) + org.sqlite.jni.SQLTester $(tester.flags) $(tester.scripts) tester: tester-local else tester: - @echo "SQLTester support is disabled. Build with enable.tester=1 to enable it." + @echo "SQLTester support is disabled." endif -tester.extdir.default := src/tests/ext +tester.extdir.default := $(dir.tests)/ext tester.extdir ?= $(tester.extdir.default) tester.extern-scripts := $(wildcard $(tester.extdir)/*.test) ifneq (,$(tester.extern-scripts)) tester-ext: $(bin.java) -ea -Djava.library.path=$(dir.bld.c) \ $(java.flags) -cp $(classpath) \ - org.sqlite.jni.tester.SQLTester $(tester.flags) $(tester.extern-scripts) + org.sqlite.jni.SQLTester $(tester.flags) $(tester.extern-scripts) else tester-ext: @echo "******************************************************"; \ @@ -381,8 +386,7 @@ run-jar: $(package.jar) $(package.dll) # javadoc... dir.doc := $(dir.jni)/javadoc doc.index := $(dir.doc)/index.html -javadoc.exclude := -exclude org.sqlite.jni.tester \ - -exclude org.sqlite.jni.fts5 +javadoc.exclude := -exclude org.sqlite.jni.fts5 # ^^^^ 2023-09-13: elide the fts5 parts from the public docs for # the time being, as it's not clear where the Java bindings for # those bits are going. diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 37fa2cc05b..4161d503fe 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -2906,17 +2906,13 @@ S3JniApi(sqlite3_complete(),int,1complete)( S3JniApi(sqlite3_compileoption_used(),jboolean,1compileoption_1used)( JniArgsEnvClass, jstring name ){ - if( name ){ - const char *zUtf8 = s3jni_jstring_to_mutf8(name) - /* We know these to be ASCII, so MUTF-8 is fine (and - hypothetically faster to convert). */; - const jboolean rc = - 0==sqlite3_compileoption_used(zUtf8) ? JNI_FALSE : JNI_TRUE; - s3jni_mutf8_release(name, zUtf8); - return rc; - }else{ - return JNI_FALSE; - } + const char *zUtf8 = s3jni_jstring_to_mutf8(name) + /* We know these to be ASCII, so MUTF-8 is fine (and + hypothetically faster to convert). */; + const jboolean rc = + 0==sqlite3_compileoption_used(zUtf8) ? JNI_FALSE : JNI_TRUE; + s3jni_mutf8_release(name, zUtf8); + return rc; } S3JniApi(sqlite3_config() /*for a small subset of options.*/, @@ -5573,7 +5569,7 @@ static int SQLTester_strnotglob(const char *zGlob, const char *z){ } JNIEXPORT jint JNICALL -Java_org_sqlite_jni_tester_SQLTester_strglob( +Java_org_sqlite_jni_SQLTester_strglob( JniArgsEnvClass, jbyteArray baG, jbyteArray baT ){ int rc = 0; @@ -5600,7 +5596,7 @@ static int SQLTester_auto_extension(sqlite3 *pDb, const char **pzErr, } JNIEXPORT void JNICALL -Java_org_sqlite_jni_tester_SQLTester_installCustomExtensions(JniArgsEnvClass){ +Java_org_sqlite_jni_SQLTester_installCustomExtensions(JniArgsEnvClass){ sqlite3_auto_extension( (void(*)(void))SQLTester_auto_extension ); } diff --git a/ext/jni/src/c/sqlite3-jni.h b/ext/jni/src/c/sqlite3-jni.h index 3b89ae7f73..c411541134 100644 --- a/ext/jni/src/c/sqlite3-jni.h +++ b/ext/jni/src/c/sqlite3-jni.h @@ -2099,6 +2099,35 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1value_1type JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1jni_1internal_1details (JNIEnv *, jclass); +#ifdef __cplusplus +} +#endif +#endif +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_sqlite_jni_tester_SQLTester */ + +#ifndef _Included_org_sqlite_jni_tester_SQLTester +#define _Included_org_sqlite_jni_tester_SQLTester +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_sqlite_jni_tester_SQLTester + * Method: strglob + * Signature: ([B[B)I + */ +JNIEXPORT jint JNICALL Java_org_sqlite_jni_tester_SQLTester_strglob + (JNIEnv *, jclass, jbyteArray, jbyteArray); + +/* + * Class: org_sqlite_jni_tester_SQLTester + * Method: installCustomExtensions + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_sqlite_jni_tester_SQLTester_installCustomExtensions + (JNIEnv *, jclass); + #ifdef __cplusplus } #endif @@ -2328,32 +2357,3 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_fts5_fts5_1tokenizer_xTokenize } #endif #endif -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_sqlite_jni_tester_SQLTester */ - -#ifndef _Included_org_sqlite_jni_tester_SQLTester -#define _Included_org_sqlite_jni_tester_SQLTester -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_sqlite_jni_tester_SQLTester - * Method: strglob - * Signature: ([B[B)I - */ -JNIEXPORT jint JNICALL Java_org_sqlite_jni_tester_SQLTester_strglob - (JNIEnv *, jclass, jbyteArray, jbyteArray); - -/* - * Class: org_sqlite_jni_tester_SQLTester - * Method: installCustomExtensions - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_sqlite_jni_tester_SQLTester_installCustomExtensions - (JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java b/ext/jni/src/org/sqlite/jni/SQLTester.java similarity index 99% rename from ext/jni/src/org/sqlite/jni/tester/SQLTester.java rename to ext/jni/src/org/sqlite/jni/SQLTester.java index 4a97d4974e..b3e184523a 100644 --- a/ext/jni/src/org/sqlite/jni/tester/SQLTester.java +++ b/ext/jni/src/org/sqlite/jni/SQLTester.java @@ -12,16 +12,13 @@ ** This file contains the main application entry pointer for the ** SQLTester framework. */ -package org.sqlite.jni.tester; +package org.sqlite.jni; import java.util.List; import java.util.ArrayList; import java.util.Arrays; import java.nio.charset.StandardCharsets; import java.util.regex.*; -import org.sqlite.jni.*; import static org.sqlite.jni.SQLite3Jni.*; -import org.sqlite.jni.sqlite3; - /** Modes for how to escape (or not) column values and names from @@ -150,12 +147,15 @@ class Outer { } /** - This class provides an application which aims to implement the +

This class provides an application which aims to implement the rudimentary SQL-driven test tool described in the accompanying {@code test-script-interpreter.md}. -

This is a work in progress. - +

This class is an internal testing tool, not part of the public + interface but is (A) in the same package as the library because + access permissions require it to be so and (B) the JDK8 javadoc + offers no way to filter individual classes out of the doc + generation process (it can only exclude packages, but see (A)).

An instance of this application provides a core set of services which TestScript instances use for processing testing logic. diff --git a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java index a67d9f57b8..38aa7aad99 100644 --- a/ext/jni/src/org/sqlite/jni/SQLite3Jni.java +++ b/ext/jni/src/org/sqlite/jni/SQLite3Jni.java @@ -123,7 +123,7 @@ public final class SQLite3Jni { which client-level code should use to make any informed decisions. */ - public static native boolean sqlite3_java_uncache_thread(); + static native boolean sqlite3_java_uncache_thread(); ////////////////////////////////////////////////////////////////////// // Maintenance reminder: please keep the sqlite3_.... functions @@ -147,7 +147,7 @@ public final class SQLite3Jni { "not a key" value. */ @Canonical - public static native long sqlite3_aggregate_context(sqlite3_context cx, boolean initialize); + static native long sqlite3_aggregate_context(sqlite3_context cx, boolean initialize); /** Functions almost as documented for the C API, with these @@ -166,10 +166,10 @@ public final class SQLite3Jni {

See the AutoExtension class docs for more information. */ @Canonical - public static native int sqlite3_auto_extension(@NotNull AutoExtensionCallback callback); + static native int sqlite3_auto_extension(@NotNull AutoExtensionCallback callback); @Canonical - private static native int sqlite3_backup_finish(@NotNull long ptrToBackup); + static native int sqlite3_backup_finish(@NotNull long ptrToBackup); @Canonical public static int sqlite3_backup_finish(@NotNull sqlite3_backup b){ @@ -177,7 +177,7 @@ public final class SQLite3Jni { } @Canonical - private static native sqlite3_backup sqlite3_backup_init( + static native sqlite3_backup sqlite3_backup_init( @NotNull long ptrToDbDest, @NotNull String destTableName, @NotNull long ptrToDbSrc, @NotNull String srcTableName ); @@ -192,7 +192,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_backup_pagecount(@NotNull long ptrToBackup); + static native int sqlite3_backup_pagecount(@NotNull long ptrToBackup); @Canonical public static int sqlite3_backup_pagecount(@NotNull sqlite3_backup b){ @@ -200,7 +200,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_backup_remaining(@NotNull long ptrToBackup); + static native int sqlite3_backup_remaining(@NotNull long ptrToBackup); @Canonical public static int sqlite3_backup_remaining(@NotNull sqlite3_backup b){ @@ -208,7 +208,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_backup_step(@NotNull long ptrToBackup, int nPage); + static native int sqlite3_backup_step(@NotNull long ptrToBackup, int nPage); @Canonical public static int sqlite3_backup_step(@NotNull sqlite3_backup b, int nPage){ @@ -216,7 +216,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_blob( + static native int sqlite3_bind_blob( @NotNull long ptrToStmt, int ndx, @Nullable byte[] data, int n ); @@ -239,7 +239,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_double( + static native int sqlite3_bind_double( @NotNull long ptrToStmt, int ndx, double v ); @@ -251,7 +251,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_int( + static native int sqlite3_bind_int( @NotNull long ptrToStmt, int ndx, int v ); @@ -263,7 +263,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_int64( + static native int sqlite3_bind_int64( @NotNull long ptrToStmt, int ndx, long v ); @@ -272,7 +272,7 @@ public final class SQLite3Jni { return sqlite3_bind_int64( stmt.getNativePointer(), ndx, v ); } - private static native int sqlite3_bind_java_object( + static native int sqlite3_bind_java_object( @NotNull long ptrToStmt, int ndx, @Nullable Object o ); @@ -289,7 +289,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_null(@NotNull long ptrToStmt, int ndx); + static native int sqlite3_bind_null(@NotNull long ptrToStmt, int ndx); @Canonical public static int sqlite3_bind_null(@NotNull sqlite3_stmt stmt, int ndx){ @@ -297,7 +297,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_parameter_count(@NotNull long ptrToStmt); + static native int sqlite3_bind_parameter_count(@NotNull long ptrToStmt); @Canonical public static int sqlite3_bind_parameter_count(@NotNull sqlite3_stmt stmt){ @@ -315,7 +315,7 @@ public final class SQLite3Jni { public-facing one. */ @Canonical - private static native int sqlite3_bind_parameter_index( + static native int sqlite3_bind_parameter_index( @NotNull long ptrToStmt, @NotNull byte[] paramName ); @@ -328,7 +328,7 @@ public final class SQLite3Jni { } @Canonical - private static native String sqlite3_bind_parameter_name( + static native String sqlite3_bind_parameter_name( @NotNull long ptrToStmt, int index ); @@ -338,7 +338,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_text( + static native int sqlite3_bind_text( @NotNull long ptrToStmt, int ndx, @Nullable byte[] utf8, int maxBytes ); @@ -383,7 +383,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_text16( + static native int sqlite3_bind_text16( @NotNull long ptrToStmt, int ndx, @Nullable byte[] data, int maxBytes ); @@ -426,7 +426,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_zeroblob(@NotNull long ptrToStmt, int ndx, int n); + static native int sqlite3_bind_zeroblob(@NotNull long ptrToStmt, int ndx, int n); @Canonical public static int sqlite3_bind_zeroblob(@NotNull sqlite3_stmt stmt, int ndx, int n){ @@ -434,7 +434,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_bind_zeroblob64( + static native int sqlite3_bind_zeroblob64( @NotNull long ptrToStmt, int ndx, long n ); @@ -444,7 +444,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_blob_bytes(@NotNull long ptrToBlob); + static native int sqlite3_blob_bytes(@NotNull long ptrToBlob); @Canonical public static int sqlite3_blob_bytes(@NotNull sqlite3_blob blob){ @@ -460,7 +460,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_blob_open( + static native int sqlite3_blob_open( @NotNull long ptrToDb, @NotNull String dbName, @NotNull String tableName, @NotNull String columnName, long iRow, int flags, @NotNull OutputPointer.sqlite3_blob out @@ -490,7 +490,7 @@ public final class SQLite3Jni { }; @Canonical - private static native int sqlite3_blob_read( + static native int sqlite3_blob_read( @NotNull long ptrToBlob, @NotNull byte[] target, int iOffset ); @@ -502,7 +502,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_blob_reopen( + static native int sqlite3_blob_reopen( @NotNull long ptrToBlob, long newRowId ); @@ -512,7 +512,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_blob_write( + static native int sqlite3_blob_write( @NotNull long ptrToBlob, @NotNull byte[] bytes, int iOffset ); @@ -524,7 +524,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_busy_handler( + static native int sqlite3_busy_handler( @NotNull long ptrToDb, @Nullable BusyHandlerCallback handler ); @@ -541,7 +541,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_busy_timeout(@NotNull long ptrToDb, int ms); + static native int sqlite3_busy_timeout(@NotNull long ptrToDb, int ms); @Canonical public static int sqlite3_busy_timeout(@NotNull sqlite3 db, int ms){ @@ -549,12 +549,12 @@ public final class SQLite3Jni { } @Canonical - public static native boolean sqlite3_cancel_auto_extension( + static native boolean sqlite3_cancel_auto_extension( @NotNull AutoExtensionCallback ax ); @Canonical - private static native int sqlite3_changes(@NotNull long ptrToDb); + static native int sqlite3_changes(@NotNull long ptrToDb); @Canonical public static int sqlite3_changes(@NotNull sqlite3 db){ @@ -562,7 +562,7 @@ public final class SQLite3Jni { } @Canonical - private static native long sqlite3_changes64(@NotNull long ptrToDb); + static native long sqlite3_changes64(@NotNull long ptrToDb); @Canonical public static long sqlite3_changes64(@NotNull sqlite3 db){ @@ -570,7 +570,7 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_clear_bindings(@NotNull long ptrToStmt); + static native int sqlite3_clear_bindings(@NotNull long ptrToStmt); @Canonical public static int sqlite3_clear_bindings(@NotNull sqlite3_stmt stmt){ @@ -578,7 +578,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_close(@Nullable long ptrToDb); + static native int sqlite3_close(@Nullable long ptrToDb); @Canonical public static int sqlite3_close(@Nullable sqlite3 db){ @@ -599,12 +599,12 @@ public final class SQLite3Jni { } @Canonical - public static native byte[] sqlite3_column_blob( + static native byte[] sqlite3_column_blob( @NotNull sqlite3_stmt stmt, int ndx ); @Canonical - private static native int sqlite3_column_bytes(@NotNull long ptrToStmt, int ndx); + static native int sqlite3_column_bytes(@NotNull long ptrToStmt, int ndx); @Canonical public static int sqlite3_column_bytes(@NotNull sqlite3_stmt stmt, int ndx){ @@ -612,7 +612,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_column_bytes16(@NotNull long ptrToStmt, int ndx); + static native int sqlite3_column_bytes16(@NotNull long ptrToStmt, int ndx); @Canonical public static int sqlite3_column_bytes16(@NotNull sqlite3_stmt stmt, int ndx){ @@ -620,7 +620,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_column_count(@NotNull long ptrToStmt); + static native int sqlite3_column_count(@NotNull long ptrToStmt); @Canonical public static int sqlite3_column_count(@NotNull sqlite3_stmt stmt){ @@ -628,7 +628,7 @@ public final class SQLite3Jni { } @Canonical - private static native String sqlite3_column_decltype(@NotNull long ptrToStmt, int ndx); + static native String sqlite3_column_decltype(@NotNull long ptrToStmt, int ndx); @Canonical public static String sqlite3_column_decltype(@NotNull sqlite3_stmt stmt, int ndx){ @@ -636,22 +636,22 @@ public final class SQLite3Jni { } @Canonical - public static native double sqlite3_column_double( + static native double sqlite3_column_double( @NotNull sqlite3_stmt stmt, int ndx ); @Canonical - public static native int sqlite3_column_int( + static native int sqlite3_column_int( @NotNull sqlite3_stmt stmt, int ndx ); @Canonical - public static native long sqlite3_column_int64( + static native long sqlite3_column_int64( @NotNull sqlite3_stmt stmt, int ndx ); @Canonical - private static native String sqlite3_column_name(@NotNull long ptrToStmt, int ndx); + static native String sqlite3_column_name(@NotNull long ptrToStmt, int ndx); @Canonical public static String sqlite3_column_name(@NotNull sqlite3_stmt stmt, int ndx){ @@ -659,7 +659,7 @@ public final class SQLite3Jni { } @Canonical - private static native String sqlite3_column_database_name(@NotNull long ptrToStmt, int ndx); + static native String sqlite3_column_database_name(@NotNull long ptrToStmt, int ndx); @Canonical public static String sqlite3_column_database_name(@NotNull sqlite3_stmt stmt, int ndx){ @@ -667,7 +667,7 @@ public final class SQLite3Jni { } @Canonical - private static native String sqlite3_column_origin_name(@NotNull long ptrToStmt, int ndx); + static native String sqlite3_column_origin_name(@NotNull long ptrToStmt, int ndx); @Canonical public static String sqlite3_column_origin_name(@NotNull sqlite3_stmt stmt, int ndx){ @@ -675,7 +675,7 @@ public final class SQLite3Jni { } @Canonical - private static native String sqlite3_column_table_name(@NotNull long ptrToStmt, int ndx); + static native String sqlite3_column_table_name(@NotNull long ptrToStmt, int ndx); @Canonical public static String sqlite3_column_table_name(@NotNull sqlite3_stmt stmt, int ndx){ @@ -691,12 +691,12 @@ public final class SQLite3Jni { @see #sqlite3_column_text16(sqlite3_stmt,int) */ @Canonical - public static native byte[] sqlite3_column_text( + static native byte[] sqlite3_column_text( @NotNull sqlite3_stmt stmt, int ndx ); @Canonical - public static native String sqlite3_column_text16( + static native String sqlite3_column_text16( @NotNull sqlite3_stmt stmt, int ndx ); @@ -738,7 +738,7 @@ public final class SQLite3Jni { // } @Canonical - private static native int sqlite3_column_type(@NotNull long ptrToStmt, int ndx); + static native int sqlite3_column_type(@NotNull long ptrToStmt, int ndx); @Canonical public static int sqlite3_column_type(@NotNull sqlite3_stmt stmt, int ndx){ @@ -746,7 +746,7 @@ public final class SQLite3Jni { } @Canonical - public static native sqlite3_value sqlite3_column_value( + static native sqlite3_value sqlite3_column_value( @NotNull sqlite3_stmt stmt, int ndx ); @@ -779,21 +779,17 @@ public final class SQLite3Jni { } @Canonical - public static native String sqlite3_compileoption_get(int n); + static native String sqlite3_compileoption_get(int n); - /** - Unlike the C API, returns false if its argument is NULL (as - opposed to invoking UB). - */ @Canonical - public static native boolean sqlite3_compileoption_used(String optName); + static native boolean sqlite3_compileoption_used(String optName); /** This implementation is private because it's too easy to pass it - non-NUL-terminated arrays. + non-NUL-terminated byte arrays from client code. */ @Canonical - private static native int sqlite3_complete( + static native int sqlite3_complete( @NotNull byte[] nulTerminatedUtf8Sql ); @@ -802,8 +798,8 @@ public final class SQLite3Jni { null (as opposed to invoking UB). */ @Canonical() - public static int sqlite3_complete(String sql){ - return null==sql ? SQLITE_MISUSE : sqlite3_complete( nulTerminateUtf8(sql) ); + static int sqlite3_complete(@NotNull String sql){ + return sqlite3_complete( nulTerminateUtf8(sql) ); } @@ -825,7 +821,7 @@ public final class SQLite3Jni { @Canonical(comment="Option subset: "+ "SQLITE_CONFIG_SINGLETHREAD, SQLITE_CONFIG_MULTITHREAD, "+ "SQLITE_CONFIG_SERIALIZED") - public static native int sqlite3_config(int op); + static native int sqlite3_config(int op); /** If the native library was built with SQLITE_ENABLE_SQLLOG defined @@ -842,21 +838,21 @@ public final class SQLite3Jni { library APIs are being called. */ @Canonical(comment="Option subset: SQLITE_CONFIG_SQLLOG") - public static native int sqlite3_config( @Nullable ConfigSqllogCallback logger ); + static native int sqlite3_config( @Nullable ConfigSqllogCallback logger ); /** The sqlite3_config() overload for handling the SQLITE_CONFIG_LOG option. */ @Canonical(comment="Option subset: SQLITE_CONFIG_LOG") - public static native int sqlite3_config( @Nullable ConfigLogCallback logger ); + static native int sqlite3_config( @Nullable ConfigLogCallback logger ); /** Unlike this C API, this returns null if its argument is null (as opposed to invoking UB). */ @Canonical - public static native sqlite3 sqlite3_context_db_handle( + static native sqlite3 sqlite3_context_db_handle( @NotNull sqlite3_context cx ); @@ -865,7 +861,7 @@ public final class SQLite3Jni { arguments are null (as opposed to invoking UB). */ @Canonical - public static native int sqlite3_create_collation( + static native int sqlite3_create_collation( @NotNull sqlite3 db, @NotNull String name, int eTextRep, @NotNull CollationCallback col ); @@ -882,13 +878,13 @@ public final class SQLite3Jni { functionName arguments are null (as opposed to invoking UB). */ @Canonical - public static native int sqlite3_create_function( + static native int sqlite3_create_function( @NotNull sqlite3 db, @NotNull String functionName, int nArg, int eTextRep, @NotNull SQLFunction func ); @Canonical - private static native int sqlite3_data_count(@NotNull long ptrToStmt); + static native int sqlite3_data_count(@NotNull long ptrToStmt); @Canonical public static int sqlite3_data_count(@NotNull sqlite3_stmt stmt){ @@ -904,7 +900,7 @@ public final class SQLite3Jni { are null (as opposed to invoking UB). */ @Canonical - public static native int sqlite3_db_config( + static native int sqlite3_db_config( @NotNull sqlite3 db, int op, int onOff, @Nullable OutputPointer.Int32 out ); @@ -916,35 +912,35 @@ public final class SQLite3Jni { extended in future versions. */ @Canonical(comment="Supports only a subset of options.") - public static native int sqlite3_db_config( + static native int sqlite3_db_config( @NotNull sqlite3 db, int op, @NotNull String val ); @Canonical - public static native String sqlite3_db_filename( + static native String sqlite3_db_filename( @NotNull sqlite3 db, @NotNull String dbName ); @Canonical - public static native sqlite3 sqlite3_db_handle( @NotNull sqlite3_stmt stmt ); + static native sqlite3 sqlite3_db_handle(@NotNull sqlite3_stmt stmt); @Canonical - public static native int sqlite3_db_release_memory(sqlite3 db); + static native int sqlite3_db_release_memory(sqlite3 db); @Canonical - public static native int sqlite3_db_status( + static native int sqlite3_db_status( @NotNull sqlite3 db, int op, @NotNull OutputPointer.Int32 pCurrent, @NotNull OutputPointer.Int32 pHighwater, boolean reset ); @Canonical - public static native int sqlite3_errcode(@NotNull sqlite3 db); + static native int sqlite3_errcode(@NotNull sqlite3 db); @Canonical - public static native String sqlite3_errmsg16(@NotNull sqlite3 db); + static native String sqlite3_errmsg16(@NotNull sqlite3 db); @Canonical - private static native int sqlite3_error_offset(@NotNull long ptrToDb); + static native int sqlite3_error_offset(@NotNull long ptrToDb); /** Note that the returned byte offset values assume UTF-8-encoded @@ -956,13 +952,13 @@ public final class SQLite3Jni { } @Canonical - public static native String sqlite3_errstr(int resultCode); + static native String sqlite3_errstr(int resultCode); @Canonical - public static native String sqlite3_expanded_sql(@NotNull sqlite3_stmt stmt); + static native String sqlite3_expanded_sql(@NotNull sqlite3_stmt stmt); @Canonical - private static native int sqlite3_extended_errcode(@NotNull long ptrToDb); + static native int sqlite3_extended_errcode(@NotNull long ptrToDb); @Canonical public static int sqlite3_extended_errcode(@NotNull sqlite3 db){ @@ -970,12 +966,12 @@ public final class SQLite3Jni { } @Canonical - public static native boolean sqlite3_extended_result_codes( + static native boolean sqlite3_extended_result_codes( @NotNull sqlite3 db, boolean onoff ); @Canonical - private static native boolean sqlite3_get_autocommit(@NotNull long ptrToDb); + static native boolean sqlite3_get_autocommit(@NotNull long ptrToDb); @Canonical public static boolean sqlite3_get_autocommit(@NotNull sqlite3 db){ @@ -983,7 +979,7 @@ public final class SQLite3Jni { } @Canonical - public static native Object sqlite3_get_auxdata( + static native Object sqlite3_get_auxdata( @NotNull sqlite3_context cx, int n ); @@ -996,35 +992,35 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_initialize(); + static native int sqlite3_initialize(); @Canonical - public static native void sqlite3_interrupt(@NotNull sqlite3 db); + static native void sqlite3_interrupt(@NotNull sqlite3 db); @Canonical - public static native boolean sqlite3_is_interrupted(@NotNull sqlite3 db); + static native boolean sqlite3_is_interrupted(@NotNull sqlite3 db); @Canonical - public static native boolean sqlite3_keyword_check(@NotNull String word); + static native boolean sqlite3_keyword_check(@NotNull String word); @Canonical - public static native int sqlite3_keyword_count(); + static native int sqlite3_keyword_count(); @Canonical - public static native String sqlite3_keyword_name(int index); + static native String sqlite3_keyword_name(int index); @Canonical - public static native long sqlite3_last_insert_rowid(@NotNull sqlite3 db); + static native long sqlite3_last_insert_rowid(@NotNull sqlite3 db); @Canonical - public static native String sqlite3_libversion(); + static native String sqlite3_libversion(); @Canonical - public static native int sqlite3_libversion_number(); + static native int sqlite3_libversion_number(); @Canonical - public static native int sqlite3_limit(@NotNull sqlite3 db, int id, int newVal); + static native int sqlite3_limit(@NotNull sqlite3 db, int id, int newVal); /** Works like its C counterpart and makes the native pointer of the @@ -1040,7 +1036,7 @@ public final class SQLite3Jni { db handle. */ @Canonical - public static native int sqlite3_open( + static native int sqlite3_open( @Nullable String filename, @NotNull OutputPointer.sqlite3 ppDb ); @@ -1059,7 +1055,7 @@ public final class SQLite3Jni { }; @Canonical - public static native int sqlite3_open_v2( + static native int sqlite3_open_v2( @Nullable String filename, @NotNull OutputPointer.sqlite3 ppDb, int flags, @Nullable String zVfs ); @@ -1104,7 +1100,7 @@ public final class SQLite3Jni { real utility. */ @Canonical - private static native int sqlite3_prepare( + static native int sqlite3_prepare( @NotNull long ptrToDb, @NotNull byte[] sqlUtf8, int maxBytes, @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset @@ -1164,7 +1160,7 @@ public final class SQLite3Jni { @see #sqlite3_prepare */ @Canonical - private static native int sqlite3_prepare_v2( + static native int sqlite3_prepare_v2( @NotNull long ptrToDb, @NotNull byte[] sqlUtf8, int maxBytes, @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset @@ -1218,7 +1214,7 @@ public final class SQLite3Jni { @see #sqlite3_prepare */ @Canonical - private static native int sqlite3_prepare_v3( + static native int sqlite3_prepare_v3( @NotNull long ptrToDb, @NotNull byte[] sqlUtf8, int maxBytes, int prepFlags, @NotNull OutputPointer.sqlite3_stmt outStmt, @Nullable OutputPointer.Int32 pTailOffset @@ -1374,7 +1370,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_preupdate_blobwrite(@NotNull long ptrToDb); + static native int sqlite3_preupdate_blobwrite(@NotNull long ptrToDb); /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this @@ -1387,7 +1383,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_preupdate_count(@NotNull long ptrToDb); + static native int sqlite3_preupdate_count(@NotNull long ptrToDb); /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this @@ -1400,7 +1396,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_preupdate_depth(@NotNull long ptrToDb); + static native int sqlite3_preupdate_depth(@NotNull long ptrToDb); /** If the C API was built with SQLITE_ENABLE_PREUPDATE_HOOK defined, this @@ -1413,7 +1409,7 @@ public final class SQLite3Jni { } @Canonical - private static native PreupdateHookCallback sqlite3_preupdate_hook( + static native PreupdateHookCallback sqlite3_preupdate_hook( @NotNull long ptrToDb, @Nullable PreupdateHookCallback hook ); @@ -1430,7 +1426,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_preupdate_new(@NotNull long ptrToDb, int col, + static native int sqlite3_preupdate_new(@NotNull long ptrToDb, int col, @NotNull OutputPointer.sqlite3_value out); /** @@ -1455,7 +1451,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_preupdate_old(@NotNull long ptrToDb, int col, + static native int sqlite3_preupdate_old(@NotNull long ptrToDb, int col, @NotNull OutputPointer.sqlite3_value out); /** @@ -1480,18 +1476,18 @@ public final class SQLite3Jni { } @Canonical - public static native void sqlite3_progress_handler( + static native void sqlite3_progress_handler( @NotNull sqlite3 db, int n, @Nullable ProgressHandlerCallback h ); @Canonical - public static native void sqlite3_randomness(byte[] target); + static native void sqlite3_randomness(byte[] target); @Canonical - public static native int sqlite3_release_memory(int n); + static native int sqlite3_release_memory(int n); @Canonical - public static native int sqlite3_reset(@NotNull sqlite3_stmt stmt); + static native int sqlite3_reset(@NotNull sqlite3_stmt stmt); /** Works like the C API except that it has no side effects if auto @@ -1499,10 +1495,10 @@ public final class SQLite3Jni { extensions cannot be manipulated while it is being traversed.) */ @Canonical - public static native void sqlite3_reset_auto_extension(); + static native void sqlite3_reset_auto_extension(); @Canonical - public static native void sqlite3_result_double( + static native void sqlite3_result_double( @NotNull sqlite3_context cx, double v ); @@ -1514,7 +1510,7 @@ public final class SQLite3Jni { complaint about the invalid argument. */ @Canonical - private static native void sqlite3_result_error( + static native void sqlite3_result_error( @NotNull sqlite3_context cx, @NotNull byte[] msg, int eTextRep ); @@ -1559,32 +1555,32 @@ public final class SQLite3Jni { } @Canonical - public static native void sqlite3_result_error_toobig( + static native void sqlite3_result_error_toobig( @NotNull sqlite3_context cx ); @Canonical - public static native void sqlite3_result_error_nomem( + static native void sqlite3_result_error_nomem( @NotNull sqlite3_context cx ); @Canonical - public static native void sqlite3_result_error_code( + static native void sqlite3_result_error_code( @NotNull sqlite3_context cx, int c ); @Canonical - public static native void sqlite3_result_null( + static native void sqlite3_result_null( @NotNull sqlite3_context cx ); @Canonical - public static native void sqlite3_result_int( + static native void sqlite3_result_int( @NotNull sqlite3_context cx, int v ); @Canonical - public static native void sqlite3_result_int64( + static native void sqlite3_result_int64( @NotNull sqlite3_context cx, long v ); @@ -1604,7 +1600,7 @@ public final class SQLite3Jni { @see #sqlite3_value_java_object @see #sqlite3_bind_java_object */ - public static native void sqlite3_result_java_object( + static native void sqlite3_result_java_object( @NotNull sqlite3_context cx, @NotNull Object o ); @@ -1669,17 +1665,17 @@ public final class SQLite3Jni { } @Canonical - public static native void sqlite3_result_value( + static native void sqlite3_result_value( @NotNull sqlite3_context cx, @NotNull sqlite3_value v ); @Canonical - public static native void sqlite3_result_zeroblob( + static native void sqlite3_result_zeroblob( @NotNull sqlite3_context cx, int n ); @Canonical - public static native int sqlite3_result_zeroblob64( + static native int sqlite3_result_zeroblob64( @NotNull sqlite3_context cx, long n ); @@ -1688,7 +1684,7 @@ public final class SQLite3Jni { unnecessary in Java. */ @Canonical - private static native void sqlite3_result_blob( + static native void sqlite3_result_blob( @NotNull sqlite3_context cx, @Nullable byte[] blob, int maxLen ); @@ -1718,7 +1714,7 @@ public final class SQLite3Jni { arguably unnecessary in Java.

*/ @Canonical - private static native void sqlite3_result_blob64( + static native void sqlite3_result_blob64( @NotNull sqlite3_context cx, @Nullable byte[] blob, long maxLen ); @@ -1734,7 +1730,7 @@ public final class SQLite3Jni { arguably unnecessary in Java. */ @Canonical - private static native void sqlite3_result_text( + static native void sqlite3_result_text( @NotNull sqlite3_context cx, @Nullable byte[] utf8, int maxLen ); @@ -1780,7 +1776,7 @@ public final class SQLite3Jni { arguably unnecessary in Java. */ @Canonical - private static native void sqlite3_result_text64( + static native void sqlite3_result_text64( @NotNull sqlite3_context cx, @Nullable byte[] text, long maxLength, int encoding ); @@ -1820,17 +1816,17 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_set_authorizer( + static native int sqlite3_set_authorizer( @NotNull sqlite3 db, @Nullable AuthorizerCallback auth ); @Canonical - public static native void sqlite3_set_auxdata( + static native void sqlite3_set_auxdata( @NotNull sqlite3_context cx, int n, @Nullable Object data ); @Canonical - public static native void sqlite3_set_last_insert_rowid( + static native void sqlite3_set_last_insert_rowid( @NotNull sqlite3 db, long rowid ); @@ -1848,31 +1844,31 @@ public final class SQLite3Jni { public static synchronized native int sqlite3_shutdown(); @Canonical - public static native int sqlite3_sleep(int ms); + static native int sqlite3_sleep(int ms); @Canonical - public static native String sqlite3_sourceid(); + static native String sqlite3_sourceid(); @Canonical - public static native String sqlite3_sql(@NotNull sqlite3_stmt stmt); + static native String sqlite3_sql(@NotNull sqlite3_stmt stmt); @Canonical - public static native int sqlite3_status( + static native int sqlite3_status( int op, @NotNull OutputPointer.Int32 pCurrent, @NotNull OutputPointer.Int32 pHighwater, boolean reset ); @Canonical - public static native int sqlite3_status64( + static native int sqlite3_status64( int op, @NotNull OutputPointer.Int64 pCurrent, @NotNull OutputPointer.Int64 pHighwater, boolean reset ); @Canonical - public static native int sqlite3_step(@NotNull sqlite3_stmt stmt); + static native int sqlite3_step(@NotNull sqlite3_stmt stmt); @Canonical - private static native int sqlite3_stmt_explain(@NotNull long ptrToStmt, int op); + static native int sqlite3_stmt_explain(@NotNull long ptrToStmt, int op); @Canonical public static int sqlite3_stmt_explain(@NotNull sqlite3_stmt stmt, int op){ @@ -1880,7 +1876,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_stmt_isexplain(@NotNull long ptrToStmt); + static native int sqlite3_stmt_isexplain(@NotNull long ptrToStmt); @Canonical public static int sqlite3_stmt_isexplain(@NotNull sqlite3_stmt stmt){ @@ -1888,7 +1884,7 @@ public final class SQLite3Jni { } @Canonical - private static native boolean sqlite3_stmt_readonly(@NotNull long ptrToStmt); + static native boolean sqlite3_stmt_readonly(@NotNull long ptrToStmt); @Canonical public static boolean sqlite3_stmt_readonly(@NotNull sqlite3_stmt stmt){ @@ -1896,7 +1892,7 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_stmt_status( + static native int sqlite3_stmt_status( @NotNull sqlite3_stmt stmt, int op, boolean reset ); @@ -1912,7 +1908,7 @@ public final class SQLite3Jni { signature is the public-facing one. */ @Canonical - private static native int sqlite3_strglob( + static native int sqlite3_strglob( @NotNull byte[] glob, @NotNull byte[] nullTerminatedUtf8 ); @@ -1928,7 +1924,7 @@ public final class SQLite3Jni { The LIKE counterpart of the private sqlite3_strglob() method. */ @Canonical - private static native int sqlite3_strlike( + static native int sqlite3_strlike( @NotNull byte[] glob, @NotNull byte[] nullTerminatedUtf8, int escChar ); @@ -1943,7 +1939,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_system_errno(@NotNull long ptrToDb); + static native int sqlite3_system_errno(@NotNull long ptrToDb); @Canonical public static int sqlite3_system_errno(@NotNull sqlite3 db){ @@ -1951,7 +1947,7 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_table_column_metadata( + static native int sqlite3_table_column_metadata( @NotNull sqlite3 db, @NotNull String zDbName, @NotNull String zTableName, @NotNull String zColumnName, @Nullable OutputPointer.String pzDataType, @@ -1990,10 +1986,10 @@ public final class SQLite3Jni { } @Canonical - public static native int sqlite3_threadsafe(); + static native int sqlite3_threadsafe(); @Canonical - private static native int sqlite3_total_changes(@NotNull long ptrToDb); + static native int sqlite3_total_changes(@NotNull long ptrToDb); @Canonical public static int sqlite3_total_changes(@NotNull sqlite3 db){ @@ -2001,7 +1997,7 @@ public final class SQLite3Jni { } @Canonical - private static native long sqlite3_total_changes64(@NotNull long ptrToDb); + static native long sqlite3_total_changes64(@NotNull long ptrToDb); @Canonical public static long sqlite3_total_changes64(@NotNull sqlite3 db){ @@ -2018,17 +2014,17 @@ public final class SQLite3Jni { mapping state fails. */ @Canonical - public static native int sqlite3_trace_v2( + static native int sqlite3_trace_v2( @NotNull sqlite3 db, int traceMask, @Nullable TraceV2Callback tracer ); @Canonical - public static native int sqlite3_txn_state( + static native int sqlite3_txn_state( @NotNull sqlite3 db, @Nullable String zSchema ); @Canonical - private static native UpdateHookCallback sqlite3_update_hook( + static native UpdateHookCallback sqlite3_update_hook( @NotNull long ptrToDb, @Nullable UpdateHookCallback hook ); @@ -2050,7 +2046,7 @@ public final class SQLite3Jni { */ @Canonical - private static native byte[] sqlite3_value_blob(@NotNull long ptrToValue); + static native byte[] sqlite3_value_blob(@NotNull long ptrToValue); @Canonical public static byte[] sqlite3_value_blob(@NotNull sqlite3_value v){ @@ -2058,7 +2054,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_bytes(@NotNull long ptrToValue); + static native int sqlite3_value_bytes(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_bytes(@NotNull sqlite3_value v){ @@ -2066,7 +2062,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_bytes16(@NotNull long ptrToValue); + static native int sqlite3_value_bytes16(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_bytes16(@NotNull sqlite3_value v){ @@ -2074,7 +2070,7 @@ public final class SQLite3Jni { } @Canonical - private static native double sqlite3_value_double(@NotNull long ptrToValue); + static native double sqlite3_value_double(@NotNull long ptrToValue); @Canonical public static double sqlite3_value_double(@NotNull sqlite3_value v){ @@ -2082,7 +2078,7 @@ public final class SQLite3Jni { } @Canonical - private static native sqlite3_value sqlite3_value_dup(@NotNull long ptrToValue); + static native sqlite3_value sqlite3_value_dup(@NotNull long ptrToValue); @Canonical public static sqlite3_value sqlite3_value_dup(@NotNull sqlite3_value v){ @@ -2090,7 +2086,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_encoding(@NotNull long ptrToValue); + static native int sqlite3_value_encoding(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_encoding(@NotNull sqlite3_value v){ @@ -2098,7 +2094,7 @@ public final class SQLite3Jni { } @Canonical - private static native void sqlite3_value_free(@Nullable long ptrToValue); + static native void sqlite3_value_free(@Nullable long ptrToValue); @Canonical public static void sqlite3_value_free(@Nullable sqlite3_value v){ @@ -2106,7 +2102,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_frombind(@NotNull long ptrToValue); + static native int sqlite3_value_frombind(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_frombind(@NotNull sqlite3_value v){ @@ -2114,7 +2110,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_int(@NotNull long ptrToValue); + static native int sqlite3_value_int(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_int(@NotNull sqlite3_value v){ @@ -2122,14 +2118,14 @@ public final class SQLite3Jni { } @Canonical - private static native long sqlite3_value_int64(@NotNull long ptrToValue); + static native long sqlite3_value_int64(@NotNull long ptrToValue); @Canonical public static long sqlite3_value_int64(@NotNull sqlite3_value v){ return sqlite3_value_int64(v.getNativePointer()); } - private static native Object sqlite3_value_java_object(@NotNull long ptrToValue); + static native Object sqlite3_value_java_object(@NotNull long ptrToValue); /** If the given value was set using {@link @@ -2156,7 +2152,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_nochange(@NotNull long ptrToValue); + static native int sqlite3_value_nochange(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_nochange(@NotNull sqlite3_value v){ @@ -2164,7 +2160,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_numeric_type(@NotNull long ptrToValue); + static native int sqlite3_value_numeric_type(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_numeric_type(@NotNull sqlite3_value v){ @@ -2172,7 +2168,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_subtype(@NotNull long ptrToValue); + static native int sqlite3_value_subtype(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_subtype(@NotNull sqlite3_value v){ @@ -2180,7 +2176,7 @@ public final class SQLite3Jni { } @Canonical - private static native byte[] sqlite3_value_text(@NotNull long ptrToValue); + static native byte[] sqlite3_value_text(@NotNull long ptrToValue); /** Functions identially to the C API, and this note is just to @@ -2194,7 +2190,7 @@ public final class SQLite3Jni { } @Canonical - private static native String sqlite3_value_text16(@NotNull long ptrToValue); + static native String sqlite3_value_text16(@NotNull long ptrToValue); @Canonical public static String sqlite3_value_text16(@NotNull sqlite3_value v){ @@ -2202,7 +2198,7 @@ public final class SQLite3Jni { } @Canonical - private static native int sqlite3_value_type(@NotNull long ptrToValue); + static native int sqlite3_value_type(@NotNull long ptrToValue); @Canonical public static int sqlite3_value_type(@NotNull sqlite3_value v){ @@ -2215,7 +2211,7 @@ public final class SQLite3Jni { It has no stable interface. It may go way or change behavior at any time. */ - public static native void sqlite3_jni_internal_details(); + static native void sqlite3_jni_internal_details(); ////////////////////////////////////////////////////////////////////// // SQLITE_... constants follow... diff --git a/ext/jni/src/org/sqlite/jni/Tester1.java b/ext/jni/src/org/sqlite/jni/Tester1.java index d4e8213736..9d40eb9ed6 100644 --- a/ext/jni/src/org/sqlite/jni/Tester1.java +++ b/ext/jni/src/org/sqlite/jni/Tester1.java @@ -1283,7 +1283,7 @@ public class Tester1 implements Runnable { } Exception err = null; try { - Class t = Class.forName("org.sqlite.jni.fts5.TesterFts5"); + Class t = Class.forName("org.sqlite.jni.TesterFts5"); java.lang.reflect.Constructor ctor = t.getConstructor(); ctor.setAccessible(true); final long timeStart = System.currentTimeMillis(); diff --git a/ext/jni/src/org/sqlite/jni/fts5/TesterFts5.java b/ext/jni/src/org/sqlite/jni/TesterFts5.java similarity index 99% rename from ext/jni/src/org/sqlite/jni/fts5/TesterFts5.java rename to ext/jni/src/org/sqlite/jni/TesterFts5.java index d65b7b7a5f..8577ee46e1 100644 --- a/ext/jni/src/org/sqlite/jni/fts5/TesterFts5.java +++ b/ext/jni/src/org/sqlite/jni/TesterFts5.java @@ -11,10 +11,11 @@ ************************************************************************* ** This file contains a set of tests for the sqlite3 JNI bindings. */ -package org.sqlite.jni.fts5; +package org.sqlite.jni; import static org.sqlite.jni.SQLite3Jni.*; import static org.sqlite.jni.Tester1.*; import org.sqlite.jni.*; +import org.sqlite.jni.fts5.*; import java.util.*; diff --git a/ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md b/ext/jni/src/org/sqlite/jni/test-script-interpreter.md similarity index 100% rename from ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md rename to ext/jni/src/org/sqlite/jni/test-script-interpreter.md diff --git a/manifest b/manifest index 929496c32e..42d18e5b1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\swork\stowards\sthe\snew\spointer-passing\smechanism\sin\sJNI,\sand\scode-adjacent\scleanups. -D 2023-09-30T09:41:58.693 +C Make\sall\snative\sJNI\ssqlite3_...()\sbindings\spackage-private\sas\sa\sfoot-shooting\sprotective\smeasure\s(higher-level\spre-native-call\sargument\svalidation\sis\slargely\spending).\sMove\sSQLTester.java\sand\sTesterFts5.java\sinto\sthe\sorg.sqlite.jni\spackage\sso\sthat\sthey\scan\saccess\sthe\sbeing-tested\smethods. +D 2023-09-30T10:31:56.592 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -235,11 +235,11 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/jni/GNUmakefile 42e00052401b6dd41c0cdd53b31450606ea37486283abdb038dff9be74bff71e +F ext/jni/GNUmakefile 029d131ba19c74aec87cab49d36162fc2102e7e3fd58f9b8d2555c92a4752c95 F ext/jni/README.md 9fceaeb17cecdc5d699dfc83c0cbc3a03fdb3b86bf676381894166c73375ee75 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c caab9e9fdb0b8d8682c730d9bbc166778971e86f443c3f6b57e70aca86236f0c -F ext/jni/src/c/sqlite3-jni.h e3ec460570ef74f1f3d7725f93a8cf89840e1fee983741a7939c5dc992971df5 +F ext/jni/src/c/sqlite3-jni.c d1fa417c9ee7db061f86e928834e1086172ef7199d2324b823136879b4c1a187 +F ext/jni/src/c/sqlite3-jni.h 9d6564f044664a82a3c2c8ab8d7f32b38082dc2a80bdb3370f21bb8d0ec901b9 F ext/jni/src/org/sqlite/jni/AbstractCollationCallback.java 95e88ba04f4aac51ffec65693e878e234088b2f21b387f4e4285c8b72b33e436 F ext/jni/src/org/sqlite/jni/AggregateFunction.java 7312486bc65fecdb91753c0a4515799194e031f45edbe16a6373cea18f404dc4 F ext/jni/src/org/sqlite/jni/AuthorizerCallback.java e6135be32f12bf140bffa39be7fd1a45ad83b2661ed49c08dbde04c8485feb38 @@ -259,10 +259,12 @@ F ext/jni/src/org/sqlite/jni/ProgressHandlerCallback.java 7b9ff2218129ece98ba60c F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86 F ext/jni/src/org/sqlite/jni/RollbackHookCallback.java d12352c0e22840de484ffa9b11ed5058bb0daca2e9f218055d3c54c947a273c4 F ext/jni/src/org/sqlite/jni/SQLFunction.java 544a875d33fd160467d82e2397ac33157b29971d715a821a4fad3c899113ee8c -F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 2cce647774f7f8511c3b61cd280c19d871b49c401155e3f17c346db5d05ac824 +F ext/jni/src/org/sqlite/jni/SQLTester.java e7ba02a72be4205c479d08cbc48cd8f3ac5b924eb6b36a3f5a676a67dcdb8af3 w ext/jni/src/org/sqlite/jni/tester/SQLTester.java +F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 65ff9e2426c35763139042ffb59ca565802ca668fe0c5c69334bbdf32a130d59 F ext/jni/src/org/sqlite/jni/ScalarFunction.java 6d387bb499fbe3bc13c53315335233dbf6a0c711e8fa7c521683219b041c614c F ext/jni/src/org/sqlite/jni/TableColumnMetadata.java 54511b4297fa28dcb3f49b24035e34ced10e3fd44fd0e458e784f4d6b0096dab -F ext/jni/src/org/sqlite/jni/Tester1.java 720e1efddd769d5785e95100ff48aa203f2288eea865326a1a81fd5af43ec3a5 +F ext/jni/src/org/sqlite/jni/Tester1.java ef0a6ee3b4e08ebd99010ca8196214bac902de0ea66f753a5cf581888f9a4211 +F ext/jni/src/org/sqlite/jni/TesterFts5.java 0995c5ca1da36b3b703c1c04132b2ee8edd16483be5c422ae378220a4817adbf w ext/jni/src/org/sqlite/jni/fts5/TesterFts5.java F ext/jni/src/org/sqlite/jni/TraceV2Callback.java beb0b064c1a5f8bfe585a324ed39a4e33edbe379a3fc60f1401661620d3ca7c0 F ext/jni/src/org/sqlite/jni/UpdateHookCallback.java 8376f4a931f2d5612b295c003c9515ba933ee76d8f95610e89c339727376e36c F ext/jni/src/org/sqlite/jni/WindowFunction.java 488980f4dbb6bdd7067d6cb9c43e4075475e51c54d9b74a5834422654b126246 @@ -276,7 +278,6 @@ F ext/jni/src/org/sqlite/jni/fts5/Fts5Context.java 7058da97059b8e156c17561a47ecd F ext/jni/src/org/sqlite/jni/fts5/Fts5ExtensionApi.java e2680721bd83129d0d650ba845b44d7634a9489a90a56c5ce3c54508bf470743 F ext/jni/src/org/sqlite/jni/fts5/Fts5PhraseIter.java 2a7f3d76a1206e6a43d4c4ed9609b294d5431cc7d8fb875d8419f76efa6e56dc F ext/jni/src/org/sqlite/jni/fts5/Fts5Tokenizer.java cc9a53846a168a215238af224c31cef0e8379780e36e8a5e743b00c08145cf19 -F ext/jni/src/org/sqlite/jni/fts5/TesterFts5.java 81ec50bb4c5a285177ea8bebe906792886fc733676d0eade76b18fac56057623 F ext/jni/src/org/sqlite/jni/fts5/XTokenizeCallback.java 1efd1220ea328a32f2d2a1b16c735864159e929480f71daad4de9d5944839167 F ext/jni/src/org/sqlite/jni/fts5/fts5_api.java e2ad9bc06a9d307e0a6221c11645783898906455a92b1f7d5ec9b9ff1af1b8ea F ext/jni/src/org/sqlite/jni/fts5/fts5_extension_function.java 1fe0f5692c1d67475d12b067f0469949073446f18c56eba5ee5da6ddd06db9b9 @@ -288,8 +289,7 @@ F ext/jni/src/org/sqlite/jni/sqlite3_blob.java fc631ad52feea6e3d1d62b0d0e769ac10 F ext/jni/src/org/sqlite/jni/sqlite3_context.java 66ca95ce904044263a4aff684abe262d56f73e6b06bca6cf650761d79d7779ad F ext/jni/src/org/sqlite/jni/sqlite3_stmt.java cf7f076d8b0f2a23faebbd64e12e8b3dd1977378ca828245d186f1b98458127d F ext/jni/src/org/sqlite/jni/sqlite3_value.java 3d1d4903e267bc0bc81d57d21f5e85978eff389a1a6ed46726dbe75f85e6914a -F ext/jni/src/org/sqlite/jni/tester/SQLTester.java 9892797db57c6e01f0c1601b5866474b6c046f0fd6c5b64f411e5815c941040e -F ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e +F ext/jni/src/org/sqlite/jni/test-script-interpreter.md f9f25126127045d051e918fe59004a1485311c50a13edbf18c79a6ff9160030e w ext/jni/src/org/sqlite/jni/tester/test-script-interpreter.md F ext/jni/src/tests/000-000-sanity.test c3427a0e0ac84d7cbe4c95fdc1cd4b61f9ddcf43443408f3000139478c4dc745 F ext/jni/src/tests/000-001-ignored.test e17e874c6ab3c437f1293d88093cf06286083b65bf162317f91bbfd92f961b70 F ext/jni/src/tests/900-001-fts.test bf0ce17a8d082773450e91f2388f5bbb2dfa316d0b676c313c637a91198090f0 @@ -2122,8 +2122,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0a873de76c0cbcd8e2eda3f0508e427f1dcb32b01798687c0545acfe10102179 -R 85f58d35114ff163d0c32151ce0233f3 +P 6c63987e893357dc8b10decaa96c30fb37b75481640a303e77a0d8224354491e +R 14bbbf737f96564a41d23e210ece88e9 U stephan -Z 80cc94af82e9bdc221a901efb80be260 +Z 2d0b47023fa8f7cf28e0da2e32c6e917 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2411bbf400..e344029e30 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c63987e893357dc8b10decaa96c30fb37b75481640a303e77a0d8224354491e \ No newline at end of file +ec82f7251acab7df40755ef5f456f36fe49b59e63a20be59bd610fc4280ba8cd \ No newline at end of file