mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
JNI build improvements. Rename a Java class. Get the jar target working again.
FossilOrigin-Name: d086b7844cace5c997261c97565aeef62aaeeef727ccc7e83f17c54d6217b779
This commit is contained in:
@ -266,6 +266,7 @@ static void * s3jni_realloc_or_die(JNIEnv * const env, void * p, size_t n){
|
||||
#else
|
||||
#define s3jni_oom_check(EXPR)
|
||||
#endif
|
||||
//#define S3JniDb_oom(pDb,EXPR) ((EXPR) ? sqlite3OomFault(pDb) : 0)
|
||||
|
||||
/* Helpers for Java value reference management. */
|
||||
static jobject s3jni_ref_global(JNIEnv * const env, jobject const v){
|
||||
@ -317,8 +318,8 @@ static const struct {
|
||||
const S3JniNphRef OutputPointer_sqlite3;
|
||||
const S3JniNphRef OutputPointer_sqlite3_stmt;
|
||||
const S3JniNphRef OutputPointer_sqlite3_value;
|
||||
#ifdef SQLITE_ENABLE_FTS5
|
||||
const S3JniNphRef OutputPointer_String;
|
||||
#ifdef SQLITE_ENABLE_FTS5
|
||||
const S3JniNphRef OutputPointer_ByteArray;
|
||||
const S3JniNphRef Fts5Context;
|
||||
const S3JniNphRef Fts5ExtensionApi;
|
||||
@ -346,8 +347,8 @@ static const struct {
|
||||
"Lorg/sqlite/jni/sqlite3_stmt;"),
|
||||
RefO(9, "OutputPointer$sqlite3_value",
|
||||
"Lorg/sqlite/jni/sqlite3_value;"),
|
||||
#ifdef SQLITE_ENABLE_FTS5
|
||||
RefO(10, "OutputPointer$String", "Ljava/lang/String;"),
|
||||
#ifdef SQLITE_ENABLE_FTS5
|
||||
RefO(11, "OutputPointer$ByteArray", "[B"),
|
||||
RefN(12, "Fts5Context"),
|
||||
RefN(13, "Fts5ExtensionApi"),
|
||||
@ -413,6 +414,10 @@ static const S3JniHook S3JniHook_empty = {0,0,0,0,0};
|
||||
** Per-(sqlite3*) state for various JNI bindings. This state is
|
||||
** allocated as needed, cleaned up in sqlite3_close(_v2)(), and
|
||||
** recycled when possible.
|
||||
**
|
||||
** Trivia: vars and parameters of this type are often named "ps"
|
||||
** because this class used to have a name for which that abbreviation
|
||||
** made sense.
|
||||
*/
|
||||
typedef struct S3JniDb S3JniDb;
|
||||
struct S3JniDb {
|
||||
@ -453,6 +458,10 @@ static const char * const S3JniDb_clientdata_key = "S3JniDb";
|
||||
|
||||
/*
|
||||
** Cache for per-JNIEnv (i.e. per-thread) data.
|
||||
**
|
||||
** Trivia: vars and parameters of this type are often named "jc"
|
||||
** because this class used to have a name for which that abbreviation
|
||||
** made sense.
|
||||
*/
|
||||
typedef struct S3JniEnv S3JniEnv;
|
||||
struct S3JniEnv {
|
||||
@ -1460,11 +1469,8 @@ static S3JniDb * S3JniDb_alloc(JNIEnv * const env, jobject jDb){
|
||||
** from it, or no matching entry can be found.
|
||||
*/
|
||||
static S3JniDb * S3JniDb__from_java(JNIEnv * const env, jobject jDb){
|
||||
S3JniDb * s = 0;
|
||||
sqlite3 * pDb = 0;
|
||||
if( jDb ) pDb = PtrGet_sqlite3(jDb);
|
||||
s = S3JniDb_from_clientdata(pDb);
|
||||
return s;
|
||||
sqlite3 * const pDb = jDb ? PtrGet_sqlite3(jDb) : 0;
|
||||
return pDb ? S3JniDb_from_clientdata(pDb) : 0;
|
||||
}
|
||||
#define S3JniDb_from_java(jObject) S3JniDb__from_java(env,(jObject))
|
||||
|
||||
@ -4259,7 +4265,7 @@ S3JniApi(sqlite3_trace_v2(),jint,1trace_1v2)(
|
||||
rc = sqlite3_trace_v2(ps->pDb, (unsigned)traceMask, s3jni_trace_impl, ps);
|
||||
if( 0==rc ){
|
||||
S3JniHook_unref(&ps->hooks.trace);
|
||||
ps->hooks.trace = hook;
|
||||
ps->hooks.trace = hook /* transfer ownership of reference */;
|
||||
}else{
|
||||
S3JniHook_unref(&hook);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import org.sqlite.jni.annotation.*;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_set_authorizer}.
|
||||
*/
|
||||
public interface AuthorizerCallback extends SQLite3CallbackProxy {
|
||||
public interface AuthorizerCallback extends CallbackProxy {
|
||||
/**
|
||||
Must function as described for the C-level
|
||||
sqlite3_set_authorizer() callback.
|
||||
|
@ -17,7 +17,7 @@ package org.sqlite.jni;
|
||||
Callback for use with the {@link SQLite3Jni#sqlite3_auto_extension}
|
||||
family of APIs.
|
||||
*/
|
||||
public interface AutoExtensionCallback extends SQLite3CallbackProxy {
|
||||
public interface AutoExtensionCallback extends CallbackProxy {
|
||||
/**
|
||||
Must function as described for a C-level
|
||||
sqlite3_auto_extension() callback.
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_busy_handler}.
|
||||
*/
|
||||
public interface BusyHandlerCallback extends SQLite3CallbackProxy {
|
||||
public interface BusyHandlerCallback extends CallbackProxy {
|
||||
/**
|
||||
Must function as documented for the C-level
|
||||
sqlite3_busy_handler() callback argument, minus the (void*)
|
||||
|
@ -41,4 +41,4 @@ package org.sqlite.jni;
|
||||
<p>2) They all have a {@code call()} method but its signature is
|
||||
callback-specific.
|
||||
*/
|
||||
public interface SQLite3CallbackProxy {}
|
||||
public interface CallbackProxy {}
|
@ -20,7 +20,7 @@ import org.sqlite.jni.annotation.NotNull;
|
||||
@see AbstractCollationCallback
|
||||
*/
|
||||
public interface CollationCallback
|
||||
extends SQLite3CallbackProxy, XDestroyCallback {
|
||||
extends CallbackProxy, XDestroyCallback {
|
||||
/**
|
||||
Must compare the given byte arrays and return the result using
|
||||
{@code memcmp()} semantics.
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_collation_needed}.
|
||||
*/
|
||||
public interface CollationNeededCallback extends SQLite3CallbackProxy {
|
||||
public interface CollationNeededCallback extends CallbackProxy {
|
||||
/**
|
||||
Has the same semantics as the C-level sqlite3_create_collation()
|
||||
callback.
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_commit_hook}.
|
||||
*/
|
||||
public interface CommitHookCallback extends SQLite3CallbackProxy {
|
||||
public interface CommitHookCallback extends CallbackProxy {
|
||||
/**
|
||||
Works as documented for the C-level sqlite3_commit_hook()
|
||||
callback. Must not throw.
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_preupdate_hook}.
|
||||
*/
|
||||
public interface PreupdateHookCallback extends SQLite3CallbackProxy {
|
||||
public interface PreupdateHookCallback extends CallbackProxy {
|
||||
/**
|
||||
Must function as described for the C-level sqlite3_preupdate_hook()
|
||||
callback.
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_progress_handler}.
|
||||
*/
|
||||
public interface ProgressHandlerCallback extends SQLite3CallbackProxy {
|
||||
public interface ProgressHandlerCallback extends CallbackProxy {
|
||||
/**
|
||||
Works as documented for the C-level sqlite3_progress_handler() callback.
|
||||
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_rollback_hook}.
|
||||
*/
|
||||
public interface RollbackHookCallback extends SQLite3CallbackProxy {
|
||||
public interface RollbackHookCallback extends CallbackProxy {
|
||||
/**
|
||||
Works as documented for the C-level sqlite3_rollback_hook()
|
||||
callback.
|
||||
|
@ -74,9 +74,15 @@ public class Tester1 implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void outln(Object val){
|
||||
public synchronized static void outPrefix(){
|
||||
if( !quietMode ){
|
||||
System.out.print(Thread.currentThread().getName()+": ");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void outln(Object val){
|
||||
if( !quietMode ){
|
||||
outPrefix();
|
||||
System.out.println(val);
|
||||
}
|
||||
}
|
||||
@ -90,7 +96,7 @@ public class Tester1 implements Runnable {
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized static void out(Object... vals){
|
||||
if( !quietMode ){
|
||||
System.out.print(Thread.currentThread().getName()+": ");
|
||||
outPrefix();
|
||||
for(Object v : vals) out(v);
|
||||
}
|
||||
}
|
||||
@ -429,7 +435,7 @@ public class Tester1 implements Runnable {
|
||||
sqlite3 db = createNewDb();
|
||||
execSql(db, "CREATE TABLE t(a)");
|
||||
sqlite3_stmt stmt = prepare(db, "INSERT INTO t(a) VALUES(?);");
|
||||
String[] list1 = { "hell🤩", "w😃rld", "!" };
|
||||
String[] list1 = { "hell🤩", "w😃rld", "!🤩" };
|
||||
int rc;
|
||||
int n = 0;
|
||||
for( String e : list1 ){
|
||||
@ -450,14 +456,16 @@ public class Tester1 implements Runnable {
|
||||
final String txt = sqlite3_column_text16(stmt, 0);
|
||||
sbuf.append( txt );
|
||||
affirm( txt.equals(sqlite3_column_text(stmt, 0)) );
|
||||
affirm( txt.length() < sqlite3_value_bytes(sv) );
|
||||
affirm( txt.equals(sqlite3_value_text(sv)) );
|
||||
affirm( txt.length() == sqlite3_value_bytes16(sv)/2 );
|
||||
affirm( txt.equals(sqlite3_value_text16(sv)) );
|
||||
sqlite3_value_free(sv);
|
||||
++n;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
affirm(3 == n);
|
||||
affirm("w😃rldhell🤩!".equals(sbuf.toString()));
|
||||
affirm("w😃rldhell🤩!🤩".equals(sbuf.toString()));
|
||||
sqlite3_close_v2(db);
|
||||
}
|
||||
|
||||
@ -1655,18 +1663,20 @@ public class Tester1 implements Runnable {
|
||||
sqlite3_libversion_number(),"\n",
|
||||
sqlite3_libversion(),"\n",SQLITE_SOURCE_ID,"\n",
|
||||
"SQLITE_THREADSAFE=",SQLITE_THREADSAFE);
|
||||
outln("Running ",nRepeat," loop(s) with ",nThread," thread(s) each.");
|
||||
final boolean showLoopCount = (nRepeat>1 && nThread>1);
|
||||
if( showLoopCount ){
|
||||
outln("Running ",nRepeat," loop(s) with ",nThread," thread(s) each.");
|
||||
}
|
||||
if( takeNaps ) outln("Napping between tests is enabled.");
|
||||
for( int n = 0; n < nRepeat; ++n ){
|
||||
++nLoop;
|
||||
out((1==nLoop ? "" : " ")+nLoop);
|
||||
if( showLoopCount ) out((1==nLoop ? "" : " ")+nLoop);
|
||||
if( nThread<=1 ){
|
||||
new Tester1(0).runTests(false);
|
||||
continue;
|
||||
}
|
||||
Tester1.mtMode = true;
|
||||
final ExecutorService ex = Executors.newFixedThreadPool( nThread );
|
||||
//final List<Future<?>> futures = new ArrayList<>();
|
||||
for( int i = 0; i < nThread; ++i ){
|
||||
ex.submit( new Tester1(i), i );
|
||||
}
|
||||
@ -1689,7 +1699,7 @@ public class Tester1 implements Runnable {
|
||||
if( null!=err ) throw err;
|
||||
}
|
||||
}
|
||||
outln();
|
||||
if( showLoopCount ) outln();
|
||||
quietMode = false;
|
||||
|
||||
final long timeEnd = System.currentTimeMillis();
|
||||
@ -1706,7 +1716,7 @@ public class Tester1 implements Runnable {
|
||||
final java.lang.reflect.Method[] declaredMethods =
|
||||
SQLite3Jni.class.getDeclaredMethods();
|
||||
for(java.lang.reflect.Method m : declaredMethods){
|
||||
int mod = m.getModifiers();
|
||||
final int mod = m.getModifiers();
|
||||
if( 0!=(mod & java.lang.reflect.Modifier.STATIC) ){
|
||||
final String name = m.getName();
|
||||
if(name.startsWith("sqlite3_")){
|
||||
|
@ -17,7 +17,7 @@ import org.sqlite.jni.annotation.Nullable;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_trace_v2}.
|
||||
*/
|
||||
public interface TraceV2Callback extends SQLite3CallbackProxy {
|
||||
public interface TraceV2Callback extends CallbackProxy {
|
||||
/**
|
||||
Called by sqlite3 for various tracing operations, as per
|
||||
sqlite3_trace_v2(). Note that this interface elides the 2nd
|
||||
|
@ -16,7 +16,7 @@ package org.sqlite.jni;
|
||||
/**
|
||||
Callback for use with {@link SQLite3Jni#sqlite3_update_hook}.
|
||||
*/
|
||||
public interface UpdateHookCallback extends SQLite3CallbackProxy {
|
||||
public interface UpdateHookCallback extends CallbackProxy {
|
||||
/**
|
||||
Must function as described for the C-level sqlite3_update_hook()
|
||||
callback.
|
||||
|
@ -12,9 +12,10 @@
|
||||
as cross-language semantics allow for. A closely-related goal is
|
||||
that <a href='https://sqlite.org/c3ref/intro.html'>the C
|
||||
documentation</a> should be usable as-is, insofar as possible,
|
||||
for most of the JNI binding. As a rule, undocumented symbols
|
||||
behave as documented for their C API counterpart, and only
|
||||
semantic differences are documented here.</li>
|
||||
for most of the JNI binding. As a rule, undocumented symbols in
|
||||
the Java interface behave as documented for their C API
|
||||
counterpart. Only semantic differences and Java-specific features
|
||||
are documented here.</li>
|
||||
|
||||
<li>Support Java as far back as version 8 (2014).</li>
|
||||
|
||||
|
Reference in New Issue
Block a user