summaryrefslogtreecommitdiff
path: root/bdb/libdb_java
diff options
context:
space:
mode:
authorunknown <ram@mysql.r18.ru>2002-10-30 15:57:05 +0400
committerunknown <ram@mysql.r18.ru>2002-10-30 15:57:05 +0400
commit155e78f014de1a2e259ae5119f4621fbb210a784 (patch)
tree6881a3cca88bea0bb9eeffd5aae34be437152786 /bdb/libdb_java
parentb8798d25ab71436bf690ee8ae48285a655c5487e (diff)
downloadmariadb-git-155e78f014de1a2e259ae5119f4621fbb210a784.tar.gz
BDB 4.1.24
BitKeeper/deleted/.del-ex_access.wpj~3df6ae8c99bf7c5f: Delete: bdb/build_vxworks/ex_access/ex_access.wpj BitKeeper/deleted/.del-ex_btrec.wpj~a7622f1c6f432dc6: Delete: bdb/build_vxworks/ex_btrec/ex_btrec.wpj BitKeeper/deleted/.del-ex_dbclient.wpj~7345440f3b204cdd: Delete: bdb/build_vxworks/ex_dbclient/ex_dbclient.wpj BitKeeper/deleted/.del-ex_env.wpj~fbe1ab10b04e8b74: Delete: bdb/build_vxworks/ex_env/ex_env.wpj BitKeeper/deleted/.del-ex_mpool.wpj~4479cfd5c45f327d: Delete: bdb/build_vxworks/ex_mpool/ex_mpool.wpj BitKeeper/deleted/.del-ex_tpcb.wpj~f78093006e14bf41: Delete: bdb/build_vxworks/ex_tpcb/ex_tpcb.wpj BitKeeper/deleted/.del-db_buildall.dsp~bd749ff6da11682: Delete: bdb/build_win32/db_buildall.dsp BitKeeper/deleted/.del-cxx_app.cpp~ad8df8e0791011ed: Delete: bdb/cxx/cxx_app.cpp BitKeeper/deleted/.del-cxx_log.cpp~a50ff3118fe06952: Delete: bdb/cxx/cxx_log.cpp BitKeeper/deleted/.del-cxx_table.cpp~ecd751e79b055556: Delete: bdb/cxx/cxx_table.cpp BitKeeper/deleted/.del-namemap.txt~796a3acd3885d8fd: Delete: bdb/cxx/namemap.txt BitKeeper/deleted/.del-Design.fileop~3ca4da68f1727373: Delete: bdb/db/Design.fileop BitKeeper/deleted/.del-db185_int.h~61bee3736e7959ef: Delete: bdb/db185/db185_int.h BitKeeper/deleted/.del-acconfig.h~411e8854d67ad8b5: Delete: bdb/dist/acconfig.h BitKeeper/deleted/.del-mutex.m4~a13383cde18a64e1: Delete: bdb/dist/aclocal/mutex.m4 BitKeeper/deleted/.del-options.m4~b9d0ca637213750a: Delete: bdb/dist/aclocal/options.m4 BitKeeper/deleted/.del-programs.m4~3ce7890b47732b30: Delete: bdb/dist/aclocal/programs.m4 BitKeeper/deleted/.del-tcl.m4~f944e2db93c3b6db: Delete: bdb/dist/aclocal/tcl.m4 BitKeeper/deleted/.del-types.m4~59cae158c9a32cff: Delete: bdb/dist/aclocal/types.m4 BitKeeper/deleted/.del-script~d38f6d3a4f159cb4: Delete: bdb/dist/build/script BitKeeper/deleted/.del-configure.in~ac795a92c8fe049c: Delete: bdb/dist/configure.in BitKeeper/deleted/.del-ltconfig~66bbd007d8024af: Delete: bdb/dist/ltconfig BitKeeper/deleted/.del-rec_ctemp~a28554362534f00a: Delete: bdb/dist/rec_ctemp BitKeeper/deleted/.del-s_tcl~2ffe4326459fcd9f: Delete: bdb/dist/s_tcl BitKeeper/deleted/.del-.IGNORE_ME~d8148b08fa7d5d15: Delete: bdb/dist/template/.IGNORE_ME BitKeeper/deleted/.del-btree.h~179f2aefec1753d: Delete: bdb/include/btree.h BitKeeper/deleted/.del-cxx_int.h~6b649c04766508f8: Delete: bdb/include/cxx_int.h BitKeeper/deleted/.del-db.src~6b433ae615b16a8d: Delete: bdb/include/db.src BitKeeper/deleted/.del-db_185.h~ad8b373d9391d35c: Delete: bdb/include/db_185.h BitKeeper/deleted/.del-db_am.h~a714912b6b75932f: Delete: bdb/include/db_am.h BitKeeper/deleted/.del-db_cxx.h~fcafadf45f5d19e9: Delete: bdb/include/db_cxx.h BitKeeper/deleted/.del-db_dispatch.h~6844f20f7eb46904: Delete: bdb/include/db_dispatch.h BitKeeper/deleted/.del-db_int.src~419a3f48b6a01da7: Delete: bdb/include/db_int.src BitKeeper/deleted/.del-db_join.h~76f9747a42c3399a: Delete: bdb/include/db_join.h BitKeeper/deleted/.del-db_page.h~e302ca3a4db3abdc: Delete: bdb/include/db_page.h BitKeeper/deleted/.del-db_server_int.h~e1d20b6ba3bca1ab: Delete: bdb/include/db_server_int.h BitKeeper/deleted/.del-db_shash.h~5fbf2d696fac90f3: Delete: bdb/include/db_shash.h BitKeeper/deleted/.del-db_swap.h~1e60887550864a59: Delete: bdb/include/db_swap.h BitKeeper/deleted/.del-db_upgrade.h~c644eee73701fc8d: Delete: bdb/include/db_upgrade.h BitKeeper/deleted/.del-db_verify.h~b8d6c297c61f342e: Delete: bdb/include/db_verify.h BitKeeper/deleted/.del-debug.h~dc2b4f2cf27ccebc: Delete: bdb/include/debug.h BitKeeper/deleted/.del-hash.h~2aaa548b28882dfb: Delete: bdb/include/hash.h BitKeeper/deleted/.del-lock.h~a761c1b7de57b77f: Delete: bdb/include/lock.h BitKeeper/deleted/.del-log.h~ff20184238e35e4d: Delete: bdb/include/log.h BitKeeper/deleted/.del-mp.h~7e317597622f3411: Delete: bdb/include/mp.h BitKeeper/deleted/.del-mutex.h~d3ae7a2977a68137: Delete: bdb/include/mutex.h BitKeeper/deleted/.del-os.h~91867cc8757cd0e3: Delete: bdb/include/os.h BitKeeper/deleted/.del-os_jump.h~e1b939fa5151d4be: Delete: bdb/include/os_jump.h BitKeeper/deleted/.del-qam.h~6fad0c1b5723d597: Delete: bdb/include/qam.h BitKeeper/deleted/.del-queue.h~4c72c0826c123d5: Delete: bdb/include/queue.h BitKeeper/deleted/.del-region.h~513fe04d977ca0fc: Delete: bdb/include/region.h BitKeeper/deleted/.del-shqueue.h~525fc3e6c2025c36: Delete: bdb/include/shqueue.h BitKeeper/deleted/.del-tcl_db.h~c536fd61a844f23f: Delete: bdb/include/tcl_db.h BitKeeper/deleted/.del-txn.h~c8d94b221ec147e4: Delete: bdb/include/txn.h BitKeeper/deleted/.del-xa.h~ecc466493aae9d9a: Delete: bdb/include/xa.h BitKeeper/deleted/.del-DbRecoveryInit.java~756b52601a0b9023: Delete: bdb/java/src/com/sleepycat/db/DbRecoveryInit.java BitKeeper/deleted/.del-DbTxnRecover.java~74607cba7ab89d6d: Delete: bdb/java/src/com/sleepycat/db/DbTxnRecover.java BitKeeper/deleted/.del-lock_conflict.c~fc5e0f14cf597a2b: Delete: bdb/lock/lock_conflict.c BitKeeper/deleted/.del-log.src~53ac9e7b5cb023f2: Delete: bdb/log/log.src BitKeeper/deleted/.del-log_findckp.c~24287f008916e81f: Delete: bdb/log/log_findckp.c BitKeeper/deleted/.del-log_rec.c~d51711f2cac09297: Delete: bdb/log/log_rec.c BitKeeper/deleted/.del-log_register.c~b40bb4efac75ca15: Delete: bdb/log/log_register.c BitKeeper/deleted/.del-Design~b3d0f179f2767b: Delete: bdb/mp/Design BitKeeper/deleted/.del-os_finit.c~95dbefc6fe79b26c: Delete: bdb/os/os_finit.c BitKeeper/deleted/.del-os_abs.c~df95d1e7db81924: Delete: bdb/os_vxworks/os_abs.c BitKeeper/deleted/.del-os_finit.c~803b484bdb9d0122: Delete: bdb/os_vxworks/os_finit.c BitKeeper/deleted/.del-os_map.c~3a6d7926398b76d3: Delete: bdb/os_vxworks/os_map.c BitKeeper/deleted/.del-os_finit.c~19a227c6d3c78ad: Delete: bdb/os_win32/os_finit.c BitKeeper/deleted/.del-log-corruption.patch~1cf2ecc7c6408d5d: Delete: bdb/patches/log-corruption.patch BitKeeper/deleted/.del-Btree.pm~af6d0c5eaed4a98e: Delete: bdb/perl.BerkeleyDB/BerkeleyDB/Btree.pm BitKeeper/deleted/.del-BerkeleyDB.pm~7244036d4482643: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pm BitKeeper/deleted/.del-BerkeleyDB.pod~e7b18fd6132448e3: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pod BitKeeper/deleted/.del-Hash.pm~10292a26c06a5c95: Delete: bdb/perl.BerkeleyDB/BerkeleyDB/Hash.pm BitKeeper/deleted/.del-BerkeleyDB.pod.P~79f76a1495eda203: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pod.P BitKeeper/deleted/.del-BerkeleyDB.xs~80c99afbd98e392c: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.xs BitKeeper/deleted/.del-Changes~729c1891efa60de9: Delete: bdb/perl.BerkeleyDB/Changes BitKeeper/deleted/.del-MANIFEST~63a1e34aecf157a0: Delete: bdb/perl.BerkeleyDB/MANIFEST BitKeeper/deleted/.del-Makefile.PL~c68797707d8df87a: Delete: bdb/perl.BerkeleyDB/Makefile.PL BitKeeper/deleted/.del-README~5f2f579b1a241407: Delete: bdb/perl.BerkeleyDB/README BitKeeper/deleted/.del-Todo~dca3c66c193adda9: Delete: bdb/perl.BerkeleyDB/Todo BitKeeper/deleted/.del-config.in~ae81681e450e0999: Delete: bdb/perl.BerkeleyDB/config.in BitKeeper/deleted/.del-dbinfo~28ad67d83be4f68e: Delete: bdb/perl.BerkeleyDB/dbinfo BitKeeper/deleted/.del-mkconsts~543ab60669c7a04e: Delete: bdb/perl.BerkeleyDB/mkconsts BitKeeper/deleted/.del-mkpod~182c0ca54e439afb: Delete: bdb/perl.BerkeleyDB/mkpod BitKeeper/deleted/.del-5.004~e008cb5a48805543: Delete: bdb/perl.BerkeleyDB/patches/5.004 BitKeeper/deleted/.del-irix_6_5.pl~61662bb08afcdec8: Delete: bdb/perl.BerkeleyDB/hints/irix_6_5.pl BitKeeper/deleted/.del-solaris.pl~6771e7182394e152: Delete: bdb/perl.BerkeleyDB/hints/solaris.pl BitKeeper/deleted/.del-typemap~783b8f5295b05f3d: Delete: bdb/perl.BerkeleyDB/typemap BitKeeper/deleted/.del-5.004_01~6081ce2fff7b0bc: Delete: bdb/perl.BerkeleyDB/patches/5.004_01 BitKeeper/deleted/.del-5.004_02~87214eac35ad9e6: Delete: bdb/perl.BerkeleyDB/patches/5.004_02 BitKeeper/deleted/.del-5.004_03~9a672becec7cb40f: Delete: bdb/perl.BerkeleyDB/patches/5.004_03 BitKeeper/deleted/.del-5.004_04~e326cb51af09d154: Delete: bdb/perl.BerkeleyDB/patches/5.004_04 BitKeeper/deleted/.del-5.004_05~7ab457a1e41a92fe: Delete: bdb/perl.BerkeleyDB/patches/5.004_05 BitKeeper/deleted/.del-5.005~f9e2d59b5964cd4b: Delete: bdb/perl.BerkeleyDB/patches/5.005 BitKeeper/deleted/.del-5.005_01~3eb9fb7b5842ea8e: Delete: bdb/perl.BerkeleyDB/patches/5.005_01 BitKeeper/deleted/.del-5.005_02~67477ce0bef717cb: Delete: bdb/perl.BerkeleyDB/patches/5.005_02 BitKeeper/deleted/.del-5.005_03~c4c29a1fb21e290a: Delete: bdb/perl.BerkeleyDB/patches/5.005_03 BitKeeper/deleted/.del-5.6.0~e1fb9897d124ee22: Delete: bdb/perl.BerkeleyDB/patches/5.6.0 BitKeeper/deleted/.del-btree.t~e4a1a3c675ddc406: Delete: bdb/perl.BerkeleyDB/t/btree.t BitKeeper/deleted/.del-db-3.0.t~d2c60991d84558f2: Delete: bdb/perl.BerkeleyDB/t/db-3.0.t BitKeeper/deleted/.del-db-3.1.t~6ee88cd13f55e018: Delete: bdb/perl.BerkeleyDB/t/db-3.1.t BitKeeper/deleted/.del-db-3.2.t~f73b6461f98fd1cf: Delete: bdb/perl.BerkeleyDB/t/db-3.2.t BitKeeper/deleted/.del-destroy.t~cc6a2ae1980a2ecd: Delete: bdb/perl.BerkeleyDB/t/destroy.t BitKeeper/deleted/.del-env.t~a8604a4499c4bd07: Delete: bdb/perl.BerkeleyDB/t/env.t BitKeeper/deleted/.del-examples.t~2571b77c3cc75574: Delete: bdb/perl.BerkeleyDB/t/examples.t BitKeeper/deleted/.del-examples.t.T~8228bdd75ac78b88: Delete: bdb/perl.BerkeleyDB/t/examples.t.T BitKeeper/deleted/.del-examples3.t.T~66a186897a87026d: Delete: bdb/perl.BerkeleyDB/t/examples3.t.T BitKeeper/deleted/.del-examples3.t~fe3822ba2f2d7f83: Delete: bdb/perl.BerkeleyDB/t/examples3.t BitKeeper/deleted/.del-filter.t~f87b045c1b708637: Delete: bdb/perl.BerkeleyDB/t/filter.t BitKeeper/deleted/.del-hash.t~616bfb4d644de3a3: Delete: bdb/perl.BerkeleyDB/t/hash.t BitKeeper/deleted/.del-join.t~29fc39f74a83ca22: Delete: bdb/perl.BerkeleyDB/t/join.t BitKeeper/deleted/.del-mldbm.t~31f5015341eea040: Delete: bdb/perl.BerkeleyDB/t/mldbm.t BitKeeper/deleted/.del-queue.t~8f338034ce44a641: Delete: bdb/perl.BerkeleyDB/t/queue.t BitKeeper/deleted/.del-recno.t~d4ddbd3743add63e: Delete: bdb/perl.BerkeleyDB/t/recno.t BitKeeper/deleted/.del-strict.t~6885cdd2ea71ca2d: Delete: bdb/perl.BerkeleyDB/t/strict.t BitKeeper/deleted/.del-subdb.t~aab62a5d5864c603: Delete: bdb/perl.BerkeleyDB/t/subdb.t BitKeeper/deleted/.del-txn.t~65033b8558ae1216: Delete: bdb/perl.BerkeleyDB/t/txn.t BitKeeper/deleted/.del-unknown.t~f3710458682665e1: Delete: bdb/perl.BerkeleyDB/t/unknown.t BitKeeper/deleted/.del-Changes~436f74a5c414c65b: Delete: bdb/perl.DB_File/Changes BitKeeper/deleted/.del-DB_File.pm~ae0951c6c7665a82: Delete: bdb/perl.DB_File/DB_File.pm BitKeeper/deleted/.del-DB_File.xs~89e49a0b5556f1d8: Delete: bdb/perl.DB_File/DB_File.xs BitKeeper/deleted/.del-DB_File_BS~290fad5dbbb87069: Delete: bdb/perl.DB_File/DB_File_BS BitKeeper/deleted/.del-MANIFEST~90ee581572bdd4ac: Delete: bdb/perl.DB_File/MANIFEST BitKeeper/deleted/.del-Makefile.PL~ac0567bb5a377e38: Delete: bdb/perl.DB_File/Makefile.PL BitKeeper/deleted/.del-README~77e924a5a9bae6b3: Delete: bdb/perl.DB_File/README BitKeeper/deleted/.del-config.in~ab4c2792b86a810b: Delete: bdb/perl.DB_File/config.in BitKeeper/deleted/.del-dbinfo~461c43b30fab2cb: Delete: bdb/perl.DB_File/dbinfo BitKeeper/deleted/.del-dynixptx.pl~50dcddfae25d17e9: Delete: bdb/perl.DB_File/hints/dynixptx.pl BitKeeper/deleted/.del-typemap~55cffb3288a9e587: Delete: bdb/perl.DB_File/typemap BitKeeper/deleted/.del-version.c~a4df0e646f8b3975: Delete: bdb/perl.DB_File/version.c BitKeeper/deleted/.del-5.004_01~d6830d0082702af7: Delete: bdb/perl.DB_File/patches/5.004_01 BitKeeper/deleted/.del-5.004_02~78b082dc80c91031: Delete: bdb/perl.DB_File/patches/5.004_02 BitKeeper/deleted/.del-5.004~4411ec2e3c9e008b: Delete: bdb/perl.DB_File/patches/5.004 BitKeeper/deleted/.del-sco.pl~1e795fe14fe4dcfe: Delete: bdb/perl.DB_File/hints/sco.pl BitKeeper/deleted/.del-5.004_03~33f274648b160d95: Delete: bdb/perl.DB_File/patches/5.004_03 BitKeeper/deleted/.del-5.004_04~8f3d1b3cf18bb20a: Delete: bdb/perl.DB_File/patches/5.004_04 BitKeeper/deleted/.del-5.004_05~9c0f02e7331e142: Delete: bdb/perl.DB_File/patches/5.004_05 BitKeeper/deleted/.del-5.005~c2108cb2e3c8d951: Delete: bdb/perl.DB_File/patches/5.005 BitKeeper/deleted/.del-5.005_01~3b45e9673afc4cfa: Delete: bdb/perl.DB_File/patches/5.005_01 BitKeeper/deleted/.del-5.005_02~9fe5766bb02a4522: Delete: bdb/perl.DB_File/patches/5.005_02 BitKeeper/deleted/.del-5.005_03~ffa1c38c19ae72ea: Delete: bdb/perl.DB_File/patches/5.005_03 BitKeeper/deleted/.del-5.6.0~373be3a5ce47be85: Delete: bdb/perl.DB_File/patches/5.6.0 BitKeeper/deleted/.del-db-btree.t~3231595a1c241eb3: Delete: bdb/perl.DB_File/t/db-btree.t BitKeeper/deleted/.del-db-hash.t~7c4ad0c795c7fad2: Delete: bdb/perl.DB_File/t/db-hash.t BitKeeper/deleted/.del-db-recno.t~6c2d3d80b9ba4a50: Delete: bdb/perl.DB_File/t/db-recno.t BitKeeper/deleted/.del-db_server.sed~cdb00ebcd48a64e2: Delete: bdb/rpc_server/db_server.sed BitKeeper/deleted/.del-db_server_proc.c~d46c8f409c3747f4: Delete: bdb/rpc_server/db_server_proc.c BitKeeper/deleted/.del-db_server_svc.sed~3f5e59f334fa4607: Delete: bdb/rpc_server/db_server_svc.sed BitKeeper/deleted/.del-db_server_util.c~a809f3a4629acda: Delete: bdb/rpc_server/db_server_util.c BitKeeper/deleted/.del-log.tcl~ff1b41f1355b97d7: Delete: bdb/test/log.tcl BitKeeper/deleted/.del-mpool.tcl~b0df4dc1b04db26c: Delete: bdb/test/mpool.tcl BitKeeper/deleted/.del-mutex.tcl~52fd5c73a150565: Delete: bdb/test/mutex.tcl BitKeeper/deleted/.del-txn.tcl~c4ff071550b5446e: Delete: bdb/test/txn.tcl BitKeeper/deleted/.del-README~e800a12a5392010a: Delete: bdb/test/upgrade/README BitKeeper/deleted/.del-pack-2.6.6.pl~89d5076d758d3e98: Delete: bdb/test/upgrade/generate-2.X/pack-2.6.6.pl BitKeeper/deleted/.del-test-2.6.patch~4a52dc83d447547b: Delete: bdb/test/upgrade/generate-2.X/test-2.6.patch
Diffstat (limited to 'bdb/libdb_java')
-rw-r--r--bdb/libdb_java/checkapi.prl4
-rw-r--r--bdb/libdb_java/com_sleepycat_db_Db.h267
-rw-r--r--bdb/libdb_java/com_sleepycat_db_DbEnv.h238
-rw-r--r--bdb/libdb_java/com_sleepycat_db_DbLock.h10
-rw-r--r--bdb/libdb_java/com_sleepycat_db_DbLogc.h37
-rw-r--r--bdb/libdb_java/com_sleepycat_db_DbLsn.h2
-rw-r--r--bdb/libdb_java/com_sleepycat_db_DbTxn.h22
-rw-r--r--bdb/libdb_java/com_sleepycat_db_DbUtil.h22
-rw-r--r--bdb/libdb_java/com_sleepycat_db_Dbc.h10
-rw-r--r--bdb/libdb_java/com_sleepycat_db_Dbt.h134
-rw-r--r--bdb/libdb_java/com_sleepycat_db_xa_DbXAResource.h95
-rw-r--r--bdb/libdb_java/java_Db.c734
-rw-r--r--bdb/libdb_java/java_DbEnv.c1302
-rw-r--r--bdb/libdb_java/java_DbLock.c33
-rw-r--r--bdb/libdb_java/java_DbLogc.c110
-rw-r--r--bdb/libdb_java/java_DbLsn.c12
-rw-r--r--bdb/libdb_java/java_DbTxn.c71
-rw-r--r--bdb/libdb_java/java_DbUtil.c27
-rw-r--r--bdb/libdb_java/java_DbXAResource.c288
-rw-r--r--bdb/libdb_java/java_Dbc.c158
-rw-r--r--bdb/libdb_java/java_Dbt.c141
-rw-r--r--bdb/libdb_java/java_info.c816
-rw-r--r--bdb/libdb_java/java_info.h103
-rw-r--r--bdb/libdb_java/java_locked.c375
-rw-r--r--bdb/libdb_java/java_locked.h116
-rw-r--r--bdb/libdb_java/java_stat_auto.c207
-rw-r--r--bdb/libdb_java/java_stat_auto.h9
-rw-r--r--bdb/libdb_java/java_util.c584
-rw-r--r--bdb/libdb_java/java_util.h304
29 files changed, 3951 insertions, 2280 deletions
diff --git a/bdb/libdb_java/checkapi.prl b/bdb/libdb_java/checkapi.prl
index 25882c056cc..a27b8ffd107 100644
--- a/bdb/libdb_java/checkapi.prl
+++ b/bdb/libdb_java/checkapi.prl
@@ -30,7 +30,7 @@ nextline:
$def = "";
}
if ($in_def == 1) {
- $def .= $_;
+ $def .= " $_";
}
if (/\)/) {
$line = "";
@@ -42,6 +42,8 @@ nextline:
# remove comments
s@/\*[^*]*\*/@@g;
s@[ ][ ]*@ @g;
+ s@^[ ]@@g;
+ s@[ ]$@@g;
s@JNIEnv *\* *@JNIEnv @g;
s@([,*()]) @\1@g;
s@ ([,*()])@\1@g;
diff --git a/bdb/libdb_java/com_sleepycat_db_Db.h b/bdb/libdb_java/com_sleepycat_db_Db.h
index d9e1f1cbbc7..0787ae87aed 100644
--- a/bdb/libdb_java/com_sleepycat_db_Db.h
+++ b/bdb/libdb_java/com_sleepycat_db_Db.h
@@ -3,10 +3,211 @@
/* Header for class com_sleepycat_db_Db */
#ifndef _Included_com_sleepycat_db_Db
-#define _Included_com_sleepycat_db_Db
+#define _Included_com_sleepycat_db_Db
#ifdef __cplusplus
extern "C" {
#endif
+#undef com_sleepycat_db_Db_DB_BTREE
+#define com_sleepycat_db_Db_DB_BTREE 1L
+#undef com_sleepycat_db_Db_DB_DONOTINDEX
+#define com_sleepycat_db_Db_DB_DONOTINDEX -30999L
+#undef com_sleepycat_db_Db_DB_HASH
+#define com_sleepycat_db_Db_DB_HASH 2L
+#undef com_sleepycat_db_Db_DB_KEYEMPTY
+#define com_sleepycat_db_Db_DB_KEYEMPTY -30998L
+#undef com_sleepycat_db_Db_DB_KEYEXIST
+#define com_sleepycat_db_Db_DB_KEYEXIST -30997L
+#undef com_sleepycat_db_Db_DB_LOCK_DEADLOCK
+#define com_sleepycat_db_Db_DB_LOCK_DEADLOCK -30996L
+#undef com_sleepycat_db_Db_DB_LOCK_NOTGRANTED
+#define com_sleepycat_db_Db_DB_LOCK_NOTGRANTED -30995L
+#undef com_sleepycat_db_Db_DB_NOSERVER
+#define com_sleepycat_db_Db_DB_NOSERVER -30994L
+#undef com_sleepycat_db_Db_DB_NOSERVER_HOME
+#define com_sleepycat_db_Db_DB_NOSERVER_HOME -30993L
+#undef com_sleepycat_db_Db_DB_NOSERVER_ID
+#define com_sleepycat_db_Db_DB_NOSERVER_ID -30992L
+#undef com_sleepycat_db_Db_DB_NOTFOUND
+#define com_sleepycat_db_Db_DB_NOTFOUND -30991L
+#undef com_sleepycat_db_Db_DB_OLD_VERSION
+#define com_sleepycat_db_Db_DB_OLD_VERSION -30990L
+#undef com_sleepycat_db_Db_DB_PAGE_NOTFOUND
+#define com_sleepycat_db_Db_DB_PAGE_NOTFOUND -30989L
+#undef com_sleepycat_db_Db_DB_QUEUE
+#define com_sleepycat_db_Db_DB_QUEUE 4L
+#undef com_sleepycat_db_Db_DB_RECNO
+#define com_sleepycat_db_Db_DB_RECNO 3L
+#undef com_sleepycat_db_Db_DB_REP_DUPMASTER
+#define com_sleepycat_db_Db_DB_REP_DUPMASTER -30988L
+#undef com_sleepycat_db_Db_DB_REP_HOLDELECTION
+#define com_sleepycat_db_Db_DB_REP_HOLDELECTION -30987L
+#undef com_sleepycat_db_Db_DB_REP_NEWMASTER
+#define com_sleepycat_db_Db_DB_REP_NEWMASTER -30986L
+#undef com_sleepycat_db_Db_DB_REP_NEWSITE
+#define com_sleepycat_db_Db_DB_REP_NEWSITE -30985L
+#undef com_sleepycat_db_Db_DB_REP_OUTDATED
+#define com_sleepycat_db_Db_DB_REP_OUTDATED -30984L
+#undef com_sleepycat_db_Db_DB_RUNRECOVERY
+#define com_sleepycat_db_Db_DB_RUNRECOVERY -30982L
+#undef com_sleepycat_db_Db_DB_SECONDARY_BAD
+#define com_sleepycat_db_Db_DB_SECONDARY_BAD -30981L
+#undef com_sleepycat_db_Db_DB_TXN_ABORT
+#define com_sleepycat_db_Db_DB_TXN_ABORT 0L
+#undef com_sleepycat_db_Db_DB_TXN_APPLY
+#define com_sleepycat_db_Db_DB_TXN_APPLY 1L
+#undef com_sleepycat_db_Db_DB_TXN_BACKWARD_ROLL
+#define com_sleepycat_db_Db_DB_TXN_BACKWARD_ROLL 3L
+#undef com_sleepycat_db_Db_DB_TXN_FORWARD_ROLL
+#define com_sleepycat_db_Db_DB_TXN_FORWARD_ROLL 4L
+#undef com_sleepycat_db_Db_DB_TXN_PRINT
+#define com_sleepycat_db_Db_DB_TXN_PRINT 8L
+#undef com_sleepycat_db_Db_DB_UNKNOWN
+#define com_sleepycat_db_Db_DB_UNKNOWN 5L
+#undef com_sleepycat_db_Db_DB_VERIFY_BAD
+#define com_sleepycat_db_Db_DB_VERIFY_BAD -30980L
+/* Inaccessible static: DB_AFTER */
+/* Inaccessible static: DB_AGGRESSIVE */
+/* Inaccessible static: DB_APPEND */
+/* Inaccessible static: DB_ARCH_ABS */
+/* Inaccessible static: DB_ARCH_DATA */
+/* Inaccessible static: DB_ARCH_LOG */
+/* Inaccessible static: DB_AUTO_COMMIT */
+/* Inaccessible static: DB_BEFORE */
+/* Inaccessible static: DB_CACHED_COUNTS */
+/* Inaccessible static: DB_CDB_ALLDB */
+/* Inaccessible static: DB_CHKSUM_SHA1 */
+/* Inaccessible static: DB_CLIENT */
+/* Inaccessible static: DB_CONSUME */
+/* Inaccessible static: DB_CONSUME_WAIT */
+/* Inaccessible static: DB_CREATE */
+/* Inaccessible static: DB_CURRENT */
+/* Inaccessible static: DB_CXX_NO_EXCEPTIONS */
+/* Inaccessible static: DB_DBT_MALLOC */
+/* Inaccessible static: DB_DBT_PARTIAL */
+/* Inaccessible static: DB_DBT_REALLOC */
+/* Inaccessible static: DB_DBT_USERMEM */
+/* Inaccessible static: DB_DIRECT */
+/* Inaccessible static: DB_DIRECT_DB */
+/* Inaccessible static: DB_DIRECT_LOG */
+/* Inaccessible static: DB_DIRTY_READ */
+/* Inaccessible static: DB_DUP */
+/* Inaccessible static: DB_DUPSORT */
+/* Inaccessible static: DB_EID_BROADCAST */
+/* Inaccessible static: DB_EID_INVALID */
+/* Inaccessible static: DB_ENCRYPT */
+/* Inaccessible static: DB_ENCRYPT_AES */
+/* Inaccessible static: DB_EXCL */
+/* Inaccessible static: DB_FAST_STAT */
+/* Inaccessible static: DB_FIRST */
+/* Inaccessible static: DB_FLUSH */
+/* Inaccessible static: DB_FORCE */
+/* Inaccessible static: DB_GET_BOTH */
+/* Inaccessible static: DB_GET_BOTH_RANGE */
+/* Inaccessible static: DB_GET_RECNO */
+/* Inaccessible static: DB_INIT_CDB */
+/* Inaccessible static: DB_INIT_LOCK */
+/* Inaccessible static: DB_INIT_LOG */
+/* Inaccessible static: DB_INIT_MPOOL */
+/* Inaccessible static: DB_INIT_TXN */
+/* Inaccessible static: DB_JOINENV */
+/* Inaccessible static: DB_JOIN_ITEM */
+/* Inaccessible static: DB_JOIN_NOSORT */
+/* Inaccessible static: DB_KEYFIRST */
+/* Inaccessible static: DB_KEYLAST */
+/* Inaccessible static: DB_LAST */
+/* Inaccessible static: DB_LOCKDOWN */
+/* Inaccessible static: DB_LOCK_DEFAULT */
+/* Inaccessible static: DB_LOCK_EXPIRE */
+/* Inaccessible static: DB_LOCK_GET */
+/* Inaccessible static: DB_LOCK_GET_TIMEOUT */
+/* Inaccessible static: DB_LOCK_IREAD */
+/* Inaccessible static: DB_LOCK_IWR */
+/* Inaccessible static: DB_LOCK_IWRITE */
+/* Inaccessible static: DB_LOCK_MAXLOCKS */
+/* Inaccessible static: DB_LOCK_MINLOCKS */
+/* Inaccessible static: DB_LOCK_MINWRITE */
+/* Inaccessible static: DB_LOCK_NOWAIT */
+/* Inaccessible static: DB_LOCK_OLDEST */
+/* Inaccessible static: DB_LOCK_PUT */
+/* Inaccessible static: DB_LOCK_PUT_ALL */
+/* Inaccessible static: DB_LOCK_PUT_OBJ */
+/* Inaccessible static: DB_LOCK_RANDOM */
+/* Inaccessible static: DB_LOCK_READ */
+/* Inaccessible static: DB_LOCK_TIMEOUT */
+/* Inaccessible static: DB_LOCK_WRITE */
+/* Inaccessible static: DB_LOCK_YOUNGEST */
+/* Inaccessible static: DB_MULTIPLE */
+/* Inaccessible static: DB_MULTIPLE_KEY */
+/* Inaccessible static: DB_NEXT */
+/* Inaccessible static: DB_NEXT_DUP */
+/* Inaccessible static: DB_NEXT_NODUP */
+/* Inaccessible static: DB_NODUPDATA */
+/* Inaccessible static: DB_NOLOCKING */
+/* Inaccessible static: DB_NOMMAP */
+/* Inaccessible static: DB_NOORDERCHK */
+/* Inaccessible static: DB_NOOVERWRITE */
+/* Inaccessible static: DB_NOPANIC */
+/* Inaccessible static: DB_NOSYNC */
+/* Inaccessible static: DB_ODDFILESIZE */
+/* Inaccessible static: DB_ORDERCHKONLY */
+/* Inaccessible static: DB_OVERWRITE */
+/* Inaccessible static: DB_PANIC_ENVIRONMENT */
+/* Inaccessible static: DB_POSITION */
+/* Inaccessible static: DB_PREV */
+/* Inaccessible static: DB_PREV_NODUP */
+/* Inaccessible static: DB_PRINTABLE */
+/* Inaccessible static: DB_PRIORITY_DEFAULT */
+/* Inaccessible static: DB_PRIORITY_HIGH */
+/* Inaccessible static: DB_PRIORITY_LOW */
+/* Inaccessible static: DB_PRIORITY_VERY_HIGH */
+/* Inaccessible static: DB_PRIORITY_VERY_LOW */
+/* Inaccessible static: DB_PRIVATE */
+/* Inaccessible static: DB_RDONLY */
+/* Inaccessible static: DB_RECNUM */
+/* Inaccessible static: DB_RECORDCOUNT */
+/* Inaccessible static: DB_RECOVER */
+/* Inaccessible static: DB_RECOVER_FATAL */
+/* Inaccessible static: DB_REGION_INIT */
+/* Inaccessible static: DB_RENUMBER */
+/* Inaccessible static: DB_REP_CLIENT */
+/* Inaccessible static: DB_REP_LOGSONLY */
+/* Inaccessible static: DB_REP_MASTER */
+/* Inaccessible static: DB_REP_PERMANENT */
+/* Inaccessible static: DB_REP_UNAVAIL */
+/* Inaccessible static: DB_REVSPLITOFF */
+/* Inaccessible static: DB_RMW */
+/* Inaccessible static: DB_SALVAGE */
+/* Inaccessible static: DB_SET */
+/* Inaccessible static: DB_SET_LOCK_TIMEOUT */
+/* Inaccessible static: DB_SET_RANGE */
+/* Inaccessible static: DB_SET_RECNO */
+/* Inaccessible static: DB_SET_TXN_TIMEOUT */
+/* Inaccessible static: DB_SNAPSHOT */
+/* Inaccessible static: DB_STAT_CLEAR */
+/* Inaccessible static: DB_SYSTEM_MEM */
+/* Inaccessible static: DB_THREAD */
+/* Inaccessible static: DB_TRUNCATE */
+/* Inaccessible static: DB_TXN_NOSYNC */
+/* Inaccessible static: DB_TXN_NOWAIT */
+/* Inaccessible static: DB_TXN_SYNC */
+/* Inaccessible static: DB_TXN_WRITE_NOSYNC */
+/* Inaccessible static: DB_UPGRADE */
+/* Inaccessible static: DB_USE_ENVIRON */
+/* Inaccessible static: DB_USE_ENVIRON_ROOT */
+/* Inaccessible static: DB_VERB_CHKPOINT */
+/* Inaccessible static: DB_VERB_DEADLOCK */
+/* Inaccessible static: DB_VERB_RECOVERY */
+/* Inaccessible static: DB_VERB_REPLICATION */
+/* Inaccessible static: DB_VERB_WAITSFOR */
+/* Inaccessible static: DB_VERIFY */
+/* Inaccessible static: DB_VERSION_MAJOR */
+/* Inaccessible static: DB_VERSION_MINOR */
+/* Inaccessible static: DB_VERSION_PATCH */
+/* Inaccessible static: DB_WRITECURSOR */
+/* Inaccessible static: DB_XA_CREATE */
+/* Inaccessible static: DB_XIDDATASIZE */
+/* Inaccessible static: DB_YIELDCPU */
+/* Inaccessible static: already_loaded_ */
/*
* Class: com_sleepycat_db_Db
* Method: _init
@@ -25,6 +226,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1notify_1internal
/*
* Class: com_sleepycat_db_Db
+ * Method: _associate
+ * Signature: (Lcom/sleepycat/db/DbTxn;Lcom/sleepycat/db/Db;Lcom/sleepycat/db/DbSecondaryKeyCreate;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1associate
+ (JNIEnv *, jobject, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_Db
* Method: _close
* Signature: (I)I
*/
@@ -122,10 +331,18 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_key_1range
/*
* Class: com_sleepycat_db_Db
* Method: _open
- * Signature: (Ljava/lang/String;Ljava/lang/String;III)V
+ * Signature: (Lcom/sleepycat/db/DbTxn;Ljava/lang/String;Ljava/lang/String;III)V
*/
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1open
- (JNIEnv *, jobject, jstring, jstring, jint, jint, jint);
+ (JNIEnv *, jobject, jobject, jstring, jstring, jint, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_Db
+ * Method: pget
+ * Signature: (Lcom/sleepycat/db/DbTxn;Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/Dbt;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_pget
+ (JNIEnv *, jobject, jobject, jobject, jobject, jobject, jint);
/*
* Class: com_sleepycat_db_Db
@@ -137,18 +354,18 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_put
/*
* Class: com_sleepycat_db_Db
- * Method: rename
+ * Method: _rename
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_rename
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1rename
(JNIEnv *, jobject, jstring, jstring, jstring, jint);
/*
* Class: com_sleepycat_db_Db
- * Method: remove
+ * Method: _remove
* Signature: (Ljava/lang/String;Ljava/lang/String;I)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_remove
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1remove
(JNIEnv *, jobject, jstring, jstring, jint);
/*
@@ -201,6 +418,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_set_1cachesize
/*
* Class: com_sleepycat_db_Db
+ * Method: set_cache_priority
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_set_1cache_1priority
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_Db
* Method: dup_compare_changed
* Signature: (Lcom/sleepycat/db/DbDupCompare;)V
*/
@@ -209,6 +434,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_dup_1compare_1changed
/*
* Class: com_sleepycat_db_Db
+ * Method: set_encrypt
+ * Signature: (Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_set_1encrypt
+ (JNIEnv *, jobject, jstring, jint);
+
+/*
+ * Class: com_sleepycat_db_Db
* Method: feedback_changed
* Signature: (Lcom/sleepycat/db/DbFeedback;)V
*/
@@ -225,6 +458,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_set_1flags
/*
* Class: com_sleepycat_db_Db
+ * Method: get_flags_raw
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_get_1flags_1raw
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_sleepycat_db_Db
* Method: set_h_ffactor
* Signature: (I)V
*/
@@ -314,13 +555,21 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Db_stat
/*
* Class: com_sleepycat_db_Db
* Method: sync
- * Signature: (I)I
+ * Signature: (I)V
*/
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_sync
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_sync
(JNIEnv *, jobject, jint);
/*
* Class: com_sleepycat_db_Db
+ * Method: truncate
+ * Signature: (Lcom/sleepycat/db/DbTxn;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_truncate
+ (JNIEnv *, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_Db
* Method: upgrade
* Signature: (Ljava/lang/String;I)V
*/
diff --git a/bdb/libdb_java/com_sleepycat_db_DbEnv.h b/bdb/libdb_java/com_sleepycat_db_DbEnv.h
index 4168ea9abe2..f239dfc7593 100644
--- a/bdb/libdb_java/com_sleepycat_db_DbEnv.h
+++ b/bdb/libdb_java/com_sleepycat_db_DbEnv.h
@@ -3,7 +3,7 @@
/* Header for class com_sleepycat_db_DbEnv */
#ifndef _Included_com_sleepycat_db_DbEnv
-#define _Included_com_sleepycat_db_DbEnv
+#define _Included_com_sleepycat_db_DbEnv
#ifdef __cplusplus
extern "C" {
#endif
@@ -17,6 +17,22 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1close
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: dbremove
+ * Signature: (Lcom/sleepycat/db/DbTxn;Ljava/lang/String;Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_dbremove
+ (JNIEnv *, jobject, jobject, jstring, jstring, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
+ * Method: dbrename
+ * Signature: (Lcom/sleepycat/db/DbTxn;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_dbrename
+ (JNIEnv *, jobject, jobject, jstring, jstring, jstring, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: err
* Signature: (ILjava/lang/String;)V
*/
@@ -57,6 +73,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1init_1using_1db
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: _init_using_xa
+ * Signature: (Lcom/sleepycat/db/DbErrcall;II)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1init_1using_1xa
+ (JNIEnv *, jobject, jobject, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: _notify_db_close
* Signature: ()V
*/
@@ -89,6 +113,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1cachesize
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: set_encrypt
+ * Signature: (Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1encrypt
+ (JNIEnv *, jobject, jstring, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: _set_errcall
* Signature: (Lcom/sleepycat/db/DbErrcall;)V
*/
@@ -106,7 +138,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1set_1errpfx
/*
* Class: com_sleepycat_db_DbEnv
* Method: feedback_changed
- * Signature: (Lcom/sleepycat/db/DbFeedback;)V
+ * Signature: (Lcom/sleepycat/db/DbEnvFeedback;)V
*/
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_feedback_1changed
(JNIEnv *, jobject, jobject);
@@ -114,10 +146,10 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_feedback_1changed
/*
* Class: com_sleepycat_db_DbEnv
* Method: set_verbose
- * Signature: (II)V
+ * Signature: (IZ)V
*/
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1verbose
- (JNIEnv *, jobject, jint, jint);
+ (JNIEnv *, jobject, jint, jboolean);
/*
* Class: com_sleepycat_db_DbEnv
@@ -153,6 +185,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1lg_1max
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: set_lg_regionmax
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1lg_1regionmax
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: set_lk_conflicts
* Signature: ([[B)V
*/
@@ -209,59 +249,35 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1mp_1mmapsize
/*
* Class: com_sleepycat_db_DbEnv
- * Method: set_mutexlocks
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1mutexlocks
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_DbEnv
- * Method: set_pageyield
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1pageyield
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: com_sleepycat_db_DbEnv
- * Method: set_panicstate
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1panicstate
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: com_sleepycat_db_DbEnv
- * Method: recovery_init_changed
- * Signature: (Lcom/sleepycat/db/DbRecoveryInit;)V
+ * Method: set_flags
+ * Signature: (IZ)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_recovery_1init_1changed
- (JNIEnv *, jobject, jobject);
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1flags
+ (JNIEnv *, jobject, jint, jboolean);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: set_region_init
- * Signature: (I)V
+ * Method: set_rep_limit
+ * Signature: (II)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1region_1init
- (JNIEnv *, jclass, jint);
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1rep_1limit
+ (JNIEnv *, jobject, jint, jint);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: set_flags
- * Signature: (II)V
+ * Method: rep_transport_changed
+ * Signature: (ILcom/sleepycat/db/DbRepTransport;)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1flags
- (JNIEnv *, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_rep_1transport_1changed
+ (JNIEnv *, jobject, jint, jobject);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: set_server
- * Signature: (Ljava/lang/String;JJI)V
+ * Method: set_rpc_server
+ * Signature: (Lcom/sleepycat/db/DbClient;Ljava/lang/String;JJI)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1server
- (JNIEnv *, jobject, jstring, jlong, jlong, jint);
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1rpc_1server
+ (JNIEnv *, jobject, jobject, jstring, jlong, jlong, jint);
/*
* Class: com_sleepycat_db_DbEnv
@@ -277,7 +293,15 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1shm_1key
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1tas_1spins
- (JNIEnv *, jclass, jint);
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
+ * Method: set_timeout
+ * Signature: (JI)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1timeout
+ (JNIEnv *, jobject, jlong, jint);
/*
* Class: com_sleepycat_db_DbEnv
@@ -289,10 +313,10 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1tmp_1dir
/*
* Class: com_sleepycat_db_DbEnv
- * Method: tx_recover_changed
- * Signature: (Lcom/sleepycat/db/DbTxnRecover;)V
+ * Method: app_dispatch_changed
+ * Signature: (Lcom/sleepycat/db/DbAppDispatch;)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_tx_1recover_1changed
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_app_1dispatch_1changed
(JNIEnv *, jobject, jobject);
/*
@@ -369,6 +393,14 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1get
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: lock_put
+ * Signature: (Lcom/sleepycat/db/DbLock;)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1put
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: lock_id
* Signature: ()I
*/
@@ -377,11 +409,27 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_lock_1id
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: lock_id_free
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1id_1free
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: lock_stat
- * Signature: ()Lcom/sleepycat/db/DbLockStat;
+ * Signature: (I)Lcom/sleepycat/db/DbLockStat;
*/
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1stat
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
+ * Method: lock_vec
+ * Signature: (II[Lcom/sleepycat/db/DbLockRequest;II)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1vec
+ (JNIEnv *, jobject, jint, jint, jobjectArray, jint, jint);
/*
* Class: com_sleepycat_db_DbEnv
@@ -401,6 +449,14 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_log_1compare
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: log_cursor
+ * Signature: (I)Lcom/sleepycat/db/DbLogc;
+ */
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1cursor
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: log_file
* Signature: (Lcom/sleepycat/db/DbLsn;)Ljava/lang/String;
*/
@@ -417,14 +473,6 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1flush
/*
* Class: com_sleepycat_db_DbEnv
- * Method: log_get
- * Signature: (Lcom/sleepycat/db/DbLsn;Lcom/sleepycat/db/Dbt;I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1get
- (JNIEnv *, jobject, jobject, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_DbEnv
* Method: log_put
* Signature: (Lcom/sleepycat/db/DbLsn;Lcom/sleepycat/db/Dbt;I)V
*/
@@ -434,49 +482,65 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1put
/*
* Class: com_sleepycat_db_DbEnv
* Method: log_stat
- * Signature: ()Lcom/sleepycat/db/DbLogStat;
+ * Signature: (I)Lcom/sleepycat/db/DbLogStat;
*/
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1stat
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jint);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: log_register
- * Signature: (Lcom/sleepycat/db/Db;Ljava/lang/String;)V
+ * Method: memp_stat
+ * Signature: (I)Lcom/sleepycat/db/DbMpoolStat;
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1register
- (JNIEnv *, jobject, jobject, jstring);
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_memp_1stat
+ (JNIEnv *, jobject, jint);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: log_unregister
- * Signature: (Lcom/sleepycat/db/Db;)V
+ * Method: memp_fstat
+ * Signature: (I)[Lcom/sleepycat/db/DbMpoolFStat;
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1unregister
- (JNIEnv *, jobject, jobject);
+JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_memp_1fstat
+ (JNIEnv *, jobject, jint);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: memp_stat
- * Signature: ()Lcom/sleepycat/db/DbMpoolStat;
+ * Method: memp_trickle
+ * Signature: (I)I
*/
-JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_memp_1stat
- (JNIEnv *, jobject);
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_memp_1trickle
+ (JNIEnv *, jobject, jint);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: memp_fstat
- * Signature: ()[Lcom/sleepycat/db/DbMpoolFStat;
+ * Method: rep_elect
+ * Signature: (III)I
*/
-JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_memp_1fstat
- (JNIEnv *, jobject);
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_rep_1elect
+ (JNIEnv *, jobject, jint, jint, jint);
/*
* Class: com_sleepycat_db_DbEnv
- * Method: memp_trickle
- * Signature: (I)I
+ * Method: rep_process_message
+ * Signature: (Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/DbEnv$RepProcessMessage;)I
*/
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_memp_1trickle
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_rep_1process_1message
+ (JNIEnv *, jobject, jobject, jobject, jobject);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
+ * Method: rep_start
+ * Signature: (Lcom/sleepycat/db/Dbt;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_rep_1start
+ (JNIEnv *, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
+ * Method: rep_stat
+ * Signature: (I)Lcom/sleepycat/db/DbRepStat;
+ */
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_rep_1stat
(JNIEnv *, jobject, jint);
/*
@@ -490,18 +554,26 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1begin
/*
* Class: com_sleepycat_db_DbEnv
* Method: txn_checkpoint
- * Signature: (III)I
+ * Signature: (III)V
*/
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_txn_1checkpoint
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_txn_1checkpoint
(JNIEnv *, jobject, jint, jint, jint);
/*
* Class: com_sleepycat_db_DbEnv
+ * Method: txn_recover
+ * Signature: (II)[Lcom/sleepycat/db/DbPreplist;
+ */
+JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_txn_1recover
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_DbEnv
* Method: txn_stat
- * Signature: ()Lcom/sleepycat/db/DbTxnStat;
+ * Signature: (I)Lcom/sleepycat/db/DbTxnStat;
*/
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1stat
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jint);
#ifdef __cplusplus
}
diff --git a/bdb/libdb_java/com_sleepycat_db_DbLock.h b/bdb/libdb_java/com_sleepycat_db_DbLock.h
index 8a1c135bb3b..9f3d77d44bc 100644
--- a/bdb/libdb_java/com_sleepycat_db_DbLock.h
+++ b/bdb/libdb_java/com_sleepycat_db_DbLock.h
@@ -3,7 +3,7 @@
/* Header for class com_sleepycat_db_DbLock */
#ifndef _Included_com_sleepycat_db_DbLock
-#define _Included_com_sleepycat_db_DbLock
+#define _Included_com_sleepycat_db_DbLock
#ifdef __cplusplus
extern "C" {
#endif
@@ -15,14 +15,6 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLock_finalize
(JNIEnv *, jobject);
-/*
- * Class: com_sleepycat_db_DbLock
- * Method: put
- * Signature: (Lcom/sleepycat/db/DbEnv;)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLock_put
- (JNIEnv *, jobject, jobject);
-
#ifdef __cplusplus
}
#endif
diff --git a/bdb/libdb_java/com_sleepycat_db_DbLogc.h b/bdb/libdb_java/com_sleepycat_db_DbLogc.h
new file mode 100644
index 00000000000..8d029c761ba
--- /dev/null
+++ b/bdb/libdb_java/com_sleepycat_db_DbLogc.h
@@ -0,0 +1,37 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_sleepycat_db_DbLogc */
+
+#ifndef _Included_com_sleepycat_db_DbLogc
+#define _Included_com_sleepycat_db_DbLogc
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_sleepycat_db_DbLogc
+ * Method: close
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_close
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbLogc
+ * Method: get
+ * Signature: (Lcom/sleepycat/db/DbLsn;Lcom/sleepycat/db/Dbt;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get
+ (JNIEnv *, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbLogc
+ * Method: finalize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_finalize
+ (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/bdb/libdb_java/com_sleepycat_db_DbLsn.h b/bdb/libdb_java/com_sleepycat_db_DbLsn.h
index 093eaf372b5..080fa0a8758 100644
--- a/bdb/libdb_java/com_sleepycat_db_DbLsn.h
+++ b/bdb/libdb_java/com_sleepycat_db_DbLsn.h
@@ -3,7 +3,7 @@
/* Header for class com_sleepycat_db_DbLsn */
#ifndef _Included_com_sleepycat_db_DbLsn
-#define _Included_com_sleepycat_db_DbLsn
+#define _Included_com_sleepycat_db_DbLsn
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/bdb/libdb_java/com_sleepycat_db_DbTxn.h b/bdb/libdb_java/com_sleepycat_db_DbTxn.h
index 4dcf47405c0..59641c041a4 100644
--- a/bdb/libdb_java/com_sleepycat_db_DbTxn.h
+++ b/bdb/libdb_java/com_sleepycat_db_DbTxn.h
@@ -3,7 +3,7 @@
/* Header for class com_sleepycat_db_DbTxn */
#ifndef _Included_com_sleepycat_db_DbTxn
-#define _Included_com_sleepycat_db_DbTxn
+#define _Included_com_sleepycat_db_DbTxn
#ifdef __cplusplus
extern "C" {
#endif
@@ -25,6 +25,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_commit
/*
* Class: com_sleepycat_db_DbTxn
+ * Method: discard
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_discard
+ (JNIEnv *, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_DbTxn
* Method: id
* Signature: ()I
*/
@@ -34,18 +42,18 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbTxn_id
/*
* Class: com_sleepycat_db_DbTxn
* Method: prepare
- * Signature: ()V
+ * Signature: ([B)V
*/
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_prepare
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jbyteArray);
/*
* Class: com_sleepycat_db_DbTxn
- * Method: finalize
- * Signature: ()V
+ * Method: set_timeout
+ * Signature: (JI)V
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_finalize
- (JNIEnv *, jobject);
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_set_1timeout
+ (JNIEnv *, jobject, jlong, jint);
#ifdef __cplusplus
}
diff --git a/bdb/libdb_java/com_sleepycat_db_DbUtil.h b/bdb/libdb_java/com_sleepycat_db_DbUtil.h
new file mode 100644
index 00000000000..7f8495590c0
--- /dev/null
+++ b/bdb/libdb_java/com_sleepycat_db_DbUtil.h
@@ -0,0 +1,22 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_sleepycat_db_DbUtil */
+
+#ifndef _Included_com_sleepycat_db_DbUtil
+#define _Included_com_sleepycat_db_DbUtil
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inaccessible static: big_endian */
+/*
+ * Class: com_sleepycat_db_DbUtil
+ * Method: is_big_endian
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_sleepycat_db_DbUtil_is_1big_1endian
+ (JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/bdb/libdb_java/com_sleepycat_db_Dbc.h b/bdb/libdb_java/com_sleepycat_db_Dbc.h
index e62679c6f66..447ab234844 100644
--- a/bdb/libdb_java/com_sleepycat_db_Dbc.h
+++ b/bdb/libdb_java/com_sleepycat_db_Dbc.h
@@ -3,7 +3,7 @@
/* Header for class com_sleepycat_db_Dbc */
#ifndef _Included_com_sleepycat_db_Dbc
-#define _Included_com_sleepycat_db_Dbc
+#define _Included_com_sleepycat_db_Dbc
#ifdef __cplusplus
extern "C" {
#endif
@@ -49,6 +49,14 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_get
/*
* Class: com_sleepycat_db_Dbc
+ * Method: pget
+ * Signature: (Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/Dbt;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_pget
+ (JNIEnv *, jobject, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_Dbc
* Method: put
* Signature: (Lcom/sleepycat/db/Dbt;Lcom/sleepycat/db/Dbt;I)I
*/
diff --git a/bdb/libdb_java/com_sleepycat_db_Dbt.h b/bdb/libdb_java/com_sleepycat_db_Dbt.h
index cdb58c682c9..c09bd8e6131 100644
--- a/bdb/libdb_java/com_sleepycat_db_Dbt.h
+++ b/bdb/libdb_java/com_sleepycat_db_Dbt.h
@@ -3,7 +3,7 @@
/* Header for class com_sleepycat_db_Dbt */
#ifndef _Included_com_sleepycat_db_Dbt
-#define _Included_com_sleepycat_db_Dbt
+#define _Included_com_sleepycat_db_Dbt
#ifdef __cplusplus
extern "C" {
#endif
@@ -17,138 +17,18 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_finalize
/*
* Class: com_sleepycat_db_Dbt
- * Method: get_data
- * Signature: ()[B
- */
-JNIEXPORT jbyteArray JNICALL Java_com_sleepycat_db_Dbt_get_1data
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: internal_set_data
- * Signature: ([B)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_internal_1set_1data
- (JNIEnv *, jobject, jbyteArray);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_offset
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1offset
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_offset
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1offset
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_size
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1size
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_size
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1size
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_ulen
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1ulen
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_ulen
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1ulen
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_dlen
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1dlen
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_dlen
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1dlen
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_doff
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1doff
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_doff
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1doff
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_flags
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1flags
- (JNIEnv *, jobject);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_flags
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1flags
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: set_recno_key_data
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1recno_1key_1data
- (JNIEnv *, jobject, jint);
-
-/*
- * Class: com_sleepycat_db_Dbt
- * Method: get_recno_key_data
- * Signature: ()I
+ * Method: init
+ * Signature: ()V
*/
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1recno_1key_1data
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_init
(JNIEnv *, jobject);
/*
* Class: com_sleepycat_db_Dbt
- * Method: init
- * Signature: ()V
+ * Method: create_data
+ * Signature: ()[B
*/
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_init
+JNIEXPORT jbyteArray JNICALL Java_com_sleepycat_db_Dbt_create_1data
(JNIEnv *, jobject);
#ifdef __cplusplus
diff --git a/bdb/libdb_java/com_sleepycat_db_xa_DbXAResource.h b/bdb/libdb_java/com_sleepycat_db_xa_DbXAResource.h
new file mode 100644
index 00000000000..00e9e2e6893
--- /dev/null
+++ b/bdb/libdb_java/com_sleepycat_db_xa_DbXAResource.h
@@ -0,0 +1,95 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_sleepycat_db_xa_DbXAResource */
+
+#ifndef _Included_com_sleepycat_db_xa_DbXAResource
+#define _Included_com_sleepycat_db_xa_DbXAResource
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inaccessible static: unique_rmid */
+/* Inaccessible static: class_00024com_00024sleepycat_00024db_00024xa_00024DbXAResource */
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _init
+ * Signature: (Ljava/lang/String;II)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1init
+ (JNIEnv *, jobject, jstring, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _close
+ * Signature: (Ljava/lang/String;II)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1close
+ (JNIEnv *, jobject, jstring, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _commit
+ * Signature: (Ljavax/transaction/xa/Xid;IZ)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1commit
+ (JNIEnv *, jobject, jobject, jint, jboolean);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _end
+ * Signature: (Ljavax/transaction/xa/Xid;II)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1end
+ (JNIEnv *, jobject, jobject, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _forget
+ * Signature: (Ljavax/transaction/xa/Xid;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1forget
+ (JNIEnv *, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _prepare
+ * Signature: (Ljavax/transaction/xa/Xid;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_xa_DbXAResource__1prepare
+ (JNIEnv *, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _recover
+ * Signature: (II)[Ljavax/transaction/xa/Xid;
+ */
+JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_xa_DbXAResource__1recover
+ (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _rollback
+ * Signature: (Ljavax/transaction/xa/Xid;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1rollback
+ (JNIEnv *, jobject, jobject, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: _start
+ * Signature: (Ljavax/transaction/xa/Xid;II)V
+ */
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1start
+ (JNIEnv *, jobject, jobject, jint, jint);
+
+/*
+ * Class: com_sleepycat_db_xa_DbXAResource
+ * Method: xa_attach
+ * Signature: (Ljavax/transaction/xa/Xid;Ljava/lang/Integer;)Lcom/sleepycat/db/xa/DbXAResource$DbAttach;
+ */
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_xa_DbXAResource_xa_1attach
+ (JNIEnv *, jclass, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/bdb/libdb_java/java_Db.c b/bdb/libdb_java/java_Db.c
index 5b01e5068d6..465c40f7d5a 100644
--- a/bdb/libdb_java/java_Db.c
+++ b/bdb/libdb_java/java_Db.c
@@ -1,24 +1,25 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_Db.c,v 11.34 2000/11/30 00:58:38 ubell Exp $";
+static const char revid[] = "$Id: java_Db.c,v 11.80 2002/08/29 14:22:23 margo Exp $";
#endif /* not lint */
#include <jni.h>
#include <stdlib.h>
#include <string.h>
-#include "db.h"
#include "db_int.h"
-#include "db_page.h"
-#include "db_ext.h"
+#include "dbinc/db_page.h"
+#include "dbinc/btree.h"
+#include "dbinc_auto/db_ext.h"
#include "java_util.h"
+#include "java_stat_auto.h"
#include "com_sleepycat_db_Db.h"
/* This struct is used in Db.verify and its callback */
@@ -30,25 +31,29 @@ struct verify_callback_struct {
jmethodID writemid;
};
-JAVADB_WO_ACCESS_METHOD(Db, jint, flags, DB, flags)
-JAVADB_WO_ACCESS_METHOD(Db, jint, h_1ffactor, DB, h_ffactor)
-JAVADB_WO_ACCESS_METHOD(Db, jint, h_1nelem, DB, h_nelem)
-JAVADB_WO_ACCESS_METHOD(Db, jint, lorder, DB, lorder)
-JAVADB_WO_ACCESS_METHOD(Db, jint, re_1delim, DB, re_delim)
-JAVADB_WO_ACCESS_METHOD(Db, jint, re_1len, DB, re_len)
-JAVADB_WO_ACCESS_METHOD(Db, jint, re_1pad, DB, re_pad)
-JAVADB_WO_ACCESS_METHOD(Db, jint, q_1extentsize, DB, q_extentsize)
-JAVADB_WO_ACCESS_METHOD(Db, jint, bt_1maxkey, DB, bt_maxkey)
-JAVADB_WO_ACCESS_METHOD(Db, jint, bt_1minkey, DB, bt_minkey)
-
-/* This only gets called once ever, at the beginning of execution
+JAVADB_GET_FLD(Db, jint, flags_1raw, DB, flags)
+
+JAVADB_SET_METH(Db, jint, flags, DB, flags)
+JAVADB_SET_METH(Db, jint, h_1ffactor, DB, h_ffactor)
+JAVADB_SET_METH(Db, jint, h_1nelem, DB, h_nelem)
+JAVADB_SET_METH(Db, jint, lorder, DB, lorder)
+JAVADB_SET_METH(Db, jint, re_1delim, DB, re_delim)
+JAVADB_SET_METH(Db, jint, re_1len, DB, re_len)
+JAVADB_SET_METH(Db, jint, re_1pad, DB, re_pad)
+JAVADB_SET_METH(Db, jint, q_1extentsize, DB, q_extentsize)
+JAVADB_SET_METH(Db, jint, bt_1maxkey, DB, bt_maxkey)
+JAVADB_SET_METH(Db, jint, bt_1minkey, DB, bt_minkey)
+
+/*
+ * This only gets called once ever, at the beginning of execution
* and can be used to initialize unchanging methodIds, fieldIds, etc.
*/
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_one_1time_1init
(JNIEnv *jnienv, /*Db.class*/ jclass jthisclass)
{
- COMPQUIET(jnienv, NULL);
COMPQUIET(jthisclass, NULL);
+
+ one_time_init(jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1init
@@ -66,12 +71,31 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1init
err = db_create(&db, dbenv, flags);
if (verify_return(jnienv, err, 0)) {
set_private_dbobj(jnienv, name_DB, jthis, db);
- dbinfo = dbji_construct(jnienv, flags);
+ dbinfo = dbji_construct(jnienv, jthis, flags);
set_private_info(jnienv, name_DB, jthis, dbinfo);
- db->cj_internal = dbinfo;
+ db->api_internal = dbinfo;
}
}
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1associate
+ (JNIEnv *jnienv, /*Db*/ jobject jthis, /* DbTxn */ jobject jtxn,
+ /*Db*/ jobject jsecondary, /*DbSecondaryKeyCreate*/ jobject jcallback,
+ jint flags)
+{
+ DB *db, *secondary;
+ DB_JAVAINFO *second_info;
+ DB_TXN *txn;
+
+ db = get_DB(jnienv, jthis);
+ txn = get_DB_TXN(jnienv, jtxn);
+ secondary = get_DB(jnienv, jsecondary);
+
+ second_info = (DB_JAVAINFO*)secondary->api_internal;
+ dbji_set_assoc_object(second_info, jnienv, db, txn, secondary,
+ jcallback, flags);
+
+}
+
JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db__1close
(JNIEnv *jnienv, /*Db*/ jobject jthis, jint flags)
{
@@ -84,24 +108,22 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db__1close
if (!verify_non_null(jnienv, db))
return (0);
- JAVADB_API_BEGIN(db, jthis);
-
- /* Null out the private data to indicate the DB is invalid.
+ /*
+ * Null out the private data to indicate the DB is invalid.
* We do this in advance to help guard against multithreading
* issues.
*/
set_private_dbobj(jnienv, name_DB, jthis, 0);
err = db->close(db, flags);
- if (err != DB_INCOMPLETE)
- verify_return(jnienv, err, 0);
+ verify_return(jnienv, err, 0);
dbji_dealloc(dbinfo, jnienv);
- /* don't call JAVADB_API_END - db cannot be used */
return (err);
}
-/* We are being notified that the parent DbEnv has closed.
+/*
+ * We are being notified that the parent DbEnv has closed.
* Zero out the pointer to the DB, since it is no longer
* valid, to prevent mistakes. The user will get a null
* pointer exception if they try to use this Db again.
@@ -122,10 +144,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_append_1recno_1changed
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- dbinfo = (DB_JAVAINFO*)db->cj_internal;
+ dbinfo = (DB_JAVAINFO*)db->api_internal;
dbji_set_append_recno_object(dbinfo, jnienv, db, jcallback);
- JAVADB_API_END(db);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_bt_1compare_1changed
@@ -138,10 +158,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_bt_1compare_1changed
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- dbinfo = (DB_JAVAINFO*)db->cj_internal;
+ dbinfo = (DB_JAVAINFO*)db->api_internal;
dbji_set_bt_compare_object(dbinfo, jnienv, db, jbtcompare);
- JAVADB_API_END(db);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_bt_1prefix_1changed
@@ -154,10 +172,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_bt_1prefix_1changed
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- dbinfo = (DB_JAVAINFO*)db->cj_internal;
+ dbinfo = (DB_JAVAINFO*)db->api_internal;
dbji_set_bt_prefix_object(dbinfo, jnienv, db, jbtprefix);
- JAVADB_API_END(db);
}
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Db_cursor
@@ -182,26 +198,23 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_del
int err;
DB_TXN *dbtxnid;
DB *db;
- JDBT dbkey;
+ LOCKED_DBT lkey;
err = 0;
db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
return (0);
- JAVADB_API_BEGIN(db, jthis);
dbtxnid = get_DB_TXN(jnienv, txnid);
- if (jdbt_lock(&dbkey, jnienv, key, inOp) != 0)
+ if (locked_dbt_get(&lkey, jnienv, db->dbenv, key, inOp) != 0)
goto out;
- err = db->del(db, dbtxnid, &dbkey.dbt->dbt, dbflags);
- if (err != DB_NOTFOUND) {
+ err = db->del(db, dbtxnid, &lkey.javainfo->dbt, dbflags);
+ if (!DB_RETOK_DBDEL(err))
verify_return(jnienv, err, 0);
- }
out:
- jdbt_unlock(&dbkey, jnienv);
- JAVADB_API_END(db);
+ locked_dbt_put(&lkey, jnienv, db->dbenv);
return (err);
}
@@ -215,49 +228,43 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_dup_1compare_1changed
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- dbinfo = (DB_JAVAINFO*)db->cj_internal;
+ dbinfo = (DB_JAVAINFO*)db->api_internal;
dbji_set_dup_compare_object(dbinfo, jnienv, db, jdupcompare);
- JAVADB_API_END(db);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_err
(JNIEnv *jnienv, /*Db*/ jobject jthis, jint ecode, jstring msg)
{
DB *db;
- JSTR msg_string;
+ LOCKED_STRING ls_msg;
- if (jstr_lock(&msg_string, jnienv, msg) != 0)
+ if (locked_string_get(&ls_msg, jnienv, msg) != 0)
goto out;
db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
goto out;
- JAVADB_API_BEGIN(db, jthis);
- db->err(db, ecode, msg_string.string);
- JAVADB_API_END(db);
+ db->err(db, ecode, "%s", ls_msg.string);
out:
- jstr_unlock(&msg_string, jnienv);
+ locked_string_put(&ls_msg, jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_errx
(JNIEnv *jnienv, /*Db*/ jobject jthis, jstring msg)
{
- JSTR msg_string;
+ LOCKED_STRING ls_msg;
DB *db = get_DB(jnienv, jthis);
- if (jstr_lock(&msg_string, jnienv, msg) != 0)
+ if (locked_string_get(&ls_msg, jnienv, msg) != 0)
goto out;
if (!verify_non_null(jnienv, db))
goto out;
- JAVADB_API_BEGIN(db, jthis);
- db->errx(db, msg_string.string);
- JAVADB_API_END(db);
+ db->errx(db, "%s", ls_msg.string);
out:
- jstr_unlock(&msg_string, jnienv);
+ locked_string_put(&ls_msg, jnienv);
}
JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_fd
@@ -270,14 +277,31 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_fd
if (!verify_non_null(jnienv, db))
return (0);
- JAVADB_API_BEGIN(db, jthis);
err = db->fd(db, &return_value);
verify_return(jnienv, err, 0);
- JAVADB_API_END(db);
return (return_value);
}
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_set_1encrypt
+ (JNIEnv *jnienv, /*Db*/ jobject jthis, jstring jpasswd, jint flags)
+{
+ int err;
+ DB *db;
+ LOCKED_STRING ls_passwd;
+
+ db = get_DB(jnienv, jthis);
+ if (!verify_non_null(jnienv, db))
+ return;
+ if (locked_string_get(&ls_passwd, jnienv, jpasswd) != 0)
+ goto out;
+
+ err = db->set_encrypt(db, ls_passwd.string, flags);
+ verify_return(jnienv, err, 0);
+
+out: locked_string_put(&ls_passwd, jnienv);
+}
+
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_feedback_1changed
(JNIEnv *jnienv, /*Db*/ jobject jthis, /*DbFeedback*/ jobject jfeedback)
{
@@ -288,10 +312,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_feedback_1changed
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- dbinfo = (DB_JAVAINFO*)db->cj_internal;
+ dbinfo = (DB_JAVAINFO*)db->api_internal;
dbji_set_feedback_object(dbinfo, jnienv, db, jfeedback);
- JAVADB_API_END(db);
}
JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_get
@@ -300,16 +322,16 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_get
{
int err, op_flags, retry;
DB *db;
+ DB_ENV *dbenv;
OpKind keyop, dataop;
DB_TXN *dbtxnid;
- JDBT dbkey, dbdata;
+ LOCKED_DBT lkey, ldata;
err = 0;
db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
goto out3;
-
- JAVADB_API_BEGIN(db, jthis);
+ dbenv = db->dbenv;
/* Depending on flags, the key may be input/output. */
keyop = inOp;
@@ -325,30 +347,34 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_get
dbtxnid = get_DB_TXN(jnienv, txnid);
- if (jdbt_lock(&dbkey, jnienv, key, keyop) != 0)
+ if (locked_dbt_get(&lkey, jnienv, dbenv, key, keyop) != 0)
goto out2;
- if (jdbt_lock(&dbdata, jnienv, data, dataop) != 0)
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, dataop) != 0)
goto out1;
for (retry = 0; retry < 3; retry++) {
- err = db->get(db, dbtxnid, &dbkey.dbt->dbt, &dbdata.dbt->dbt, flags);
+ err = db->get(db,
+ dbtxnid, &lkey.javainfo->dbt, &ldata.javainfo->dbt, flags);
- /* If we failed due to lack of memory in our DBT arrays,
+ /*
+ * If we failed due to lack of memory in our DBT arrays,
* retry.
*/
if (err != ENOMEM)
break;
- if (!jdbt_realloc(&dbdata, jnienv))
+ if (!locked_dbt_realloc(&lkey, jnienv, dbenv) &&
+ !locked_dbt_realloc(&ldata, jnienv, dbenv))
break;
}
- if (err != DB_NOTFOUND) {
- verify_return(jnienv, err, 0);
- }
out1:
- jdbt_unlock(&dbdata, jnienv);
+ locked_dbt_put(&ldata, jnienv, dbenv);
out2:
- jdbt_unlock(&dbkey, jnienv);
+ locked_dbt_put(&lkey, jnienv, dbenv);
out3:
- JAVADB_API_END(db);
+ if (!DB_RETOK_DBGET(err)) {
+ if (verify_dbt(jnienv, err, &lkey) &&
+ verify_dbt(jnienv, err, &ldata))
+ verify_return(jnienv, err, 0);
+ }
return (err);
}
@@ -362,10 +388,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_hash_1changed
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- dbinfo = (DB_JAVAINFO*)db->cj_internal;
+ dbinfo = (DB_JAVAINFO*)db->api_internal;
dbji_set_h_hash_object(dbinfo, jnienv, db, jhash);
- JAVADB_API_END(db);
}
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Db_join
@@ -373,15 +397,25 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Db_join
jint flags)
{
int err;
- DB *db = get_DB(jnienv, jthis);
- int count = (*jnienv)->GetArrayLength(jnienv, curslist);
- DBC **newlist = (DBC **)malloc(sizeof(DBC *) * (count+1));
+ DB *db;
+ int count;
+ DBC **newlist;
DBC *dbc;
int i;
+ int size;
+
+ db = get_DB(jnienv, jthis);
+ count = (*jnienv)->GetArrayLength(jnienv, curslist);
+ size = sizeof(DBC *) * (count+1);
+ if ((err = __os_malloc(db->dbenv, size, &newlist)) != 0) {
+ if (!verify_return(jnienv, err, 0))
+ return (NULL);
+ }
/* Convert the java array of Dbc's to a C array of DBC's. */
- for (i=0; i<count; i++) {
- jobject jobj = (*jnienv)->GetObjectArrayElement(jnienv, curslist, i);
+ for (i = 0; i < count; i++) {
+ jobject jobj =
+ (*jnienv)->GetObjectArrayElement(jnienv, curslist, i);
if (jobj == 0) {
/*
* An embedded null in the array is treated
@@ -398,39 +432,39 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Db_join
if (!verify_non_null(jnienv, db))
return (NULL);
- JAVADB_API_BEGIN(db, jthis);
err = db->join(db, newlist, &dbc, flags);
- free(newlist);
verify_return(jnienv, err, 0);
+ __os_free(db->dbenv, newlist);
- JAVADB_API_END(db);
return (get_Dbc(jnienv, dbc));
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_key_1range
- (JNIEnv *jnienv, /*Db*/ jobject jthis, /*DbTxn*/ jobject jtxn,
+ (JNIEnv *jnienv, /*Db*/ jobject jthis, /*DbTxn*/ jobject txnid,
/*Dbt*/ jobject jkey, jobject /*DbKeyRange*/ range, jint flags)
{
int err;
- DB *db = get_DB(jnienv, jthis);
- DB_TXN *txn = get_DB_TXN(jnienv, jtxn);
- JDBT dbkey;
+ DB *db;
+ DB_TXN *dbtxnid;
+ LOCKED_DBT lkey;
DB_KEY_RANGE result;
jfieldID fid;
jclass krclass;
+ db = get_DB(jnienv, jthis);
+ dbtxnid = get_DB_TXN(jnienv, txnid);
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
if (!verify_non_null(jnienv, range))
return;
- if (jdbt_lock(&dbkey, jnienv, jkey, inOp) != 0)
+ if (locked_dbt_get(&lkey, jnienv, db->dbenv, jkey, inOp) != 0)
goto out;
- err = db->key_range(db, txn, &dbkey.dbt->dbt, &result, flags);
+ err = db->key_range(db, dbtxnid, &lkey.javainfo->dbt, &result, flags);
if (verify_return(jnienv, err, 0)) {
/* fill in the values of the DbKeyRange structure */
- krclass = get_class(jnienv, "DbKeyRange");
+ if ((krclass = get_class(jnienv, "DbKeyRange")) == NULL)
+ return; /* An exception has been posted. */
fid = (*jnienv)->GetFieldID(jnienv, krclass, "less", "D");
(*jnienv)->SetDoubleField(jnienv, range, fid, result.less);
fid = (*jnienv)->GetFieldID(jnienv, krclass, "equal", "D");
@@ -439,8 +473,77 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_key_1range
(*jnienv)->SetDoubleField(jnienv, range, fid, result.greater);
}
out:
- jdbt_unlock(&dbkey, jnienv);
- JAVADB_API_END(db);
+ locked_dbt_put(&lkey, jnienv, db->dbenv);
+}
+
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_pget
+ (JNIEnv *jnienv, /*Db*/ jobject jthis, /*DbTxn*/ jobject txnid,
+ /*Dbt*/ jobject key, /*Dbt*/ jobject rkey, /*Dbt*/ jobject data, jint flags)
+{
+ int err, op_flags, retry;
+ DB *db;
+ DB_ENV *dbenv;
+ OpKind keyop, rkeyop, dataop;
+ DB_TXN *dbtxnid;
+ LOCKED_DBT lkey, lrkey, ldata;
+
+ err = 0;
+ db = get_DB(jnienv, jthis);
+ if (!verify_non_null(jnienv, db))
+ goto out4;
+ dbenv = db->dbenv;
+
+ /* Depending on flags, the key may be input/output. */
+ keyop = inOp;
+ rkeyop = outOp;
+ dataop = outOp;
+ op_flags = flags & DB_OPFLAGS_MASK;
+ if (op_flags == DB_SET_RECNO) {
+ keyop = inOutOp;
+ }
+ else if (op_flags == DB_GET_BOTH) {
+ keyop = inOutOp;
+ rkeyop = inOutOp;
+ dataop = inOutOp;
+ }
+
+ dbtxnid = get_DB_TXN(jnienv, txnid);
+
+ if (locked_dbt_get(&lkey, jnienv, dbenv, key, keyop) != 0)
+ goto out3;
+ if (locked_dbt_get(&lrkey, jnienv, dbenv, rkey, rkeyop) != 0)
+ goto out2;
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, dataop) != 0)
+ goto out1;
+ for (retry = 0; retry < 3; retry++) {
+ err = db->pget(db, dbtxnid, &lkey.javainfo->dbt,
+ &lrkey.javainfo->dbt, &ldata.javainfo->dbt, flags);
+
+ /*
+ * If we failed due to lack of memory in our DBT arrays,
+ * retry.
+ */
+ if (err != ENOMEM)
+ break;
+ if (!locked_dbt_realloc(&lkey, jnienv, dbenv) &&
+ !locked_dbt_realloc(&lrkey, jnienv, dbenv) &&
+ !locked_dbt_realloc(&ldata, jnienv, dbenv))
+ break;
+ }
+ out1:
+ locked_dbt_put(&ldata, jnienv, dbenv);
+ out2:
+ locked_dbt_put(&lrkey, jnienv, dbenv);
+ out3:
+ locked_dbt_put(&lkey, jnienv, dbenv);
+ out4:
+ if (!DB_RETOK_DBGET(err)) {
+ if (verify_dbt(jnienv, err, &lkey) &&
+ verify_dbt(jnienv, err, &lrkey) &&
+ verify_dbt(jnienv, err, &ldata))
+ verify_return(jnienv, err, 0);
+ }
+ return (err);
}
JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_put
@@ -449,137 +552,124 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_put
{
int err;
DB *db;
+ DB_ENV *dbenv;
DB_TXN *dbtxnid;
- JDBT dbkey, dbdata;
+ LOCKED_DBT lkey, ldata;
+ OpKind keyop;
err = 0;
db = get_DB(jnienv, jthis);
dbtxnid = get_DB_TXN(jnienv, txnid);
if (!verify_non_null(jnienv, db))
- return (0); /* error will be thrown, retval doesn't matter */
- JAVADB_API_BEGIN(db, jthis);
+ return (0); /* error will be thrown, retval doesn't matter */
+ dbenv = db->dbenv;
- if (jdbt_lock(&dbkey, jnienv, key, inOp) != 0)
+ /*
+ * For DB_APPEND, the key may be output-only; for all other flags,
+ * it's input-only.
+ */
+ if ((flags & DB_OPFLAGS_MASK) == DB_APPEND)
+ keyop = outOp;
+ else
+ keyop = inOp;
+
+ if (locked_dbt_get(&lkey, jnienv, dbenv, key, keyop) != 0)
goto out2;
- if (jdbt_lock(&dbdata, jnienv, data, inOp) != 0)
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, inOp) != 0)
goto out1;
if (!verify_non_null(jnienv, db))
goto out1;
- err = db->put(db, dbtxnid, &dbkey.dbt->dbt, &dbdata.dbt->dbt, flags);
- if (err != DB_KEYEXIST) {
+
+ err = db->put(db,
+ dbtxnid, &lkey.javainfo->dbt, &ldata.javainfo->dbt, flags);
+ if (!DB_RETOK_DBPUT(err))
verify_return(jnienv, err, 0);
- }
+
out1:
- jdbt_unlock(&dbdata, jnienv);
+ locked_dbt_put(&ldata, jnienv, dbenv);
out2:
- jdbt_unlock(&dbkey, jnienv);
- JAVADB_API_END(db);
+ locked_dbt_put(&lkey, jnienv, dbenv);
return (err);
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_rename
- (JNIEnv *jnienv, /*Db*/ jobject jthis, jstring file,
- jstring database, jstring newname, jint flags)
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1remove
+ (JNIEnv *jnienv, /*Db*/ jobject jthis,
+ jstring file, jstring database, jint flags)
{
int err;
DB *db;
DB_JAVAINFO *dbinfo;
- JSTR j_file;
- JSTR j_database;
- JSTR j_newname;
+ LOCKED_STRING ls_file;
+ LOCKED_STRING ls_database;
db = get_DB(jnienv, jthis);
dbinfo = get_DB_JAVAINFO(jnienv, jthis);
+
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- if (jstr_lock(&j_file, jnienv, file) != 0)
- goto out3;
- if (jstr_lock(&j_database, jnienv, database) != 0)
+ if (locked_string_get(&ls_file, jnienv, file) != 0)
goto out2;
- if (jstr_lock(&j_newname, jnienv, newname) != 0)
+ if (locked_string_get(&ls_database, jnienv, database) != 0)
goto out1;
+ err = db->remove(db, ls_file.string, ls_database.string, flags);
- err = db->rename(db, j_file.string, j_database.string,
- j_newname.string, flags);
-
- verify_return(jnienv, err, EXCEPTION_FILE_NOT_FOUND);
- dbji_dealloc(dbinfo, jnienv);
set_private_dbobj(jnienv, name_DB, jthis, 0);
+ verify_return(jnienv, err, EXCEPTION_FILE_NOT_FOUND);
out1:
- jstr_unlock(&j_newname, jnienv);
+ locked_string_put(&ls_database, jnienv);
out2:
- jstr_unlock(&j_database, jnienv);
- out3:
- jstr_unlock(&j_file, jnienv);
- /* don't call JAVADB_API_END - db cannot be used */
+ locked_string_put(&ls_file, jnienv);
+
+ dbji_dealloc(dbinfo, jnienv);
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_remove
- (JNIEnv *jnienv, /*Db*/ jobject jthis, jstring file,
- jstring database, jint flags)
+JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1rename
+ (JNIEnv *jnienv, /*Db*/ jobject jthis,
+ jstring file, jstring database, jstring newname, jint flags)
{
int err;
- DB *db = get_DB(jnienv, jthis);
- DB_JAVAINFO *dbinfo = get_DB_JAVAINFO(jnienv, jthis);
- JSTR j_file;
- JSTR j_database;
+ DB *db;
+ DB_JAVAINFO *dbinfo;
+ LOCKED_STRING ls_file;
+ LOCKED_STRING ls_database;
+ LOCKED_STRING ls_newname;
+ db = get_DB(jnienv, jthis);
dbinfo = get_DB_JAVAINFO(jnienv, jthis);
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
- if (jstr_lock(&j_file, jnienv, file) != 0)
+ if (locked_string_get(&ls_file, jnienv, file) != 0)
+ goto out3;
+ if (locked_string_get(&ls_database, jnienv, database) != 0)
goto out2;
- if (jstr_lock(&j_database, jnienv, database) != 0)
+ if (locked_string_get(&ls_newname, jnienv, newname) != 0)
goto out1;
- err = db->remove(db, j_file.string, j_database.string, flags);
- set_private_dbobj(jnienv, name_DB, jthis, 0);
+ err = db->rename(db, ls_file.string, ls_database.string,
+ ls_newname.string, flags);
+
verify_return(jnienv, err, EXCEPTION_FILE_NOT_FOUND);
- dbji_dealloc(dbinfo, jnienv);
+ set_private_dbobj(jnienv, name_DB, jthis, 0);
out1:
- jstr_unlock(&j_database, jnienv);
+ locked_string_put(&ls_newname, jnienv);
out2:
- jstr_unlock(&j_file, jnienv);
- /* don't call JAVADB_API_END - db cannot be used */
-}
-
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_Db_set_1pagesize
- (JNIEnv *jnienv, /*Db*/ jobject jthis, jlong value)
-{
- int err;
- DB *db;
+ locked_string_put(&ls_database, jnienv);
+ out3:
+ locked_string_put(&ls_file, jnienv);
- db = get_DB(jnienv, jthis);
- if (verify_non_null(jnienv, db)) {
- JAVADB_API_BEGIN(db, jthis);
- err = db->set_pagesize(db, (u_int32_t)value);
- verify_return(jnienv, err, 0);
- JAVADB_API_END(db);
- }
+ dbji_dealloc(dbinfo, jnienv);
}
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_Db_set_1cachesize
- (JNIEnv *jnienv, /*Db*/ jobject jthis, jint gbytes, jint bytes,
- jint ncaches)
-{
- int err;
- DB *db;
-
- db = get_DB(jnienv, jthis);
- if (verify_non_null(jnienv, db)) {
- JAVADB_API_BEGIN(db, jthis);
- err = db->set_cachesize(db, gbytes, bytes, ncaches);
- verify_return(jnienv, err, 0);
- JAVADB_API_END(db);
- }
-}
+JAVADB_METHOD(Db_set_1pagesize, (JAVADB_ARGS, jlong pagesize), DB,
+ set_pagesize, (c_this, (u_int32_t)pagesize))
+JAVADB_METHOD(Db_set_1cachesize,
+ (JAVADB_ARGS, jint gbytes, jint bytes, jint ncaches), DB,
+ set_cachesize, (c_this, gbytes, bytes, ncaches))
+JAVADB_METHOD(Db_set_1cache_1priority, (JAVADB_ARGS, jint priority), DB,
+ set_cache_priority, (c_this, (DB_CACHE_PRIORITY)priority))
JNIEXPORT void JNICALL
Java_com_sleepycat_db_Db_set_1re_1source
@@ -590,257 +680,185 @@ JNIEXPORT void JNICALL
db = get_DB(jnienv, jthis);
if (verify_non_null(jnienv, db)) {
- JAVADB_API_BEGIN(db, jthis);
/* XXX does the string from get_c_string ever get freed? */
if (re_source != NULL)
- err = db->set_re_source(db, get_c_string(jnienv, re_source));
+ err = db->set_re_source(db,
+ get_c_string(jnienv, re_source));
else
err = db->set_re_source(db, 0);
verify_return(jnienv, err, 0);
- JAVADB_API_END(db);
}
}
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Db_stat
(JNIEnv *jnienv, jobject jthis, jint flags)
{
- int err;
- DB *db = get_DB(jnienv, jthis);
- jobject retval = NULL;
- jclass dbclass;
- void *statp = 0;
+ DB *db;
DB_BTREE_STAT *bstp;
DB_HASH_STAT *hstp;
DB_QUEUE_STAT *qstp;
+ DBTYPE dbtype;
+ jobject retval;
+ jclass dbclass;
+ size_t bytesize;
+ void *statp;
+ bytesize = 0;
+ retval = NULL;
+ statp = NULL;
+
+ db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
return (NULL);
- JAVADB_API_BEGIN(db, jthis);
-
- err = db->stat(db, &statp, NULL, flags);
- if (verify_return(jnienv, err, 0)) {
- DBTYPE dbtype = db->get_type(db);
+ if (verify_return(jnienv, db->stat(db, &statp, flags), 0) &&
+ verify_return(jnienv, db->get_type(db, &dbtype), 0)) {
switch (dbtype) {
-
/* Btree and recno share the same stat structure */
case DB_BTREE:
case DB_RECNO:
bstp = (DB_BTREE_STAT *)statp;
+ bytesize = sizeof(DB_BTREE_STAT);
retval = create_default_object(jnienv,
name_DB_BTREE_STAT);
- dbclass = get_class(jnienv, name_DB_BTREE_STAT);
-
- /* Set the individual fields */
- set_int_field(jnienv, dbclass, retval,
- "bt_magic", bstp->bt_magic);
- set_int_field(jnienv, dbclass, retval,
- "bt_version", bstp->bt_version);
- set_int_field(jnienv, dbclass, retval,
- "bt_metaflags", bstp->bt_metaflags);
- set_int_field(jnienv, dbclass, retval,
- "bt_nkeys", bstp->bt_nkeys);
- set_int_field(jnienv, dbclass, retval,
- "bt_ndata", bstp->bt_ndata);
- set_int_field(jnienv, dbclass, retval,
- "bt_pagesize", bstp->bt_pagesize);
- set_int_field(jnienv, dbclass, retval,
- "bt_maxkey", bstp->bt_maxkey);
- set_int_field(jnienv, dbclass, retval,
- "bt_minkey", bstp->bt_minkey);
- set_int_field(jnienv, dbclass, retval,
- "bt_re_len", bstp->bt_re_len);
- set_int_field(jnienv, dbclass, retval,
- "bt_re_pad", bstp->bt_re_pad);
- set_int_field(jnienv, dbclass, retval,
- "bt_levels", bstp->bt_levels);
- set_int_field(jnienv, dbclass, retval,
- "bt_int_pg", bstp->bt_int_pg);
- set_int_field(jnienv, dbclass, retval,
- "bt_leaf_pg", bstp->bt_leaf_pg);
- set_int_field(jnienv, dbclass, retval,
- "bt_dup_pg", bstp->bt_dup_pg);
- set_int_field(jnienv, dbclass, retval,
- "bt_over_pg", bstp->bt_over_pg);
- set_int_field(jnienv, dbclass, retval,
- "bt_free", bstp->bt_free);
- set_int_field(jnienv, dbclass, retval,
- "bt_int_pgfree", bstp->bt_int_pgfree);
- set_int_field(jnienv, dbclass, retval,
- "bt_leaf_pgfree", bstp->bt_leaf_pgfree);
- set_int_field(jnienv, dbclass, retval,
- "bt_dup_pgfree", bstp->bt_dup_pgfree);
- set_int_field(jnienv, dbclass, retval,
- "bt_over_pgfree", bstp->bt_over_pgfree);
+ if ((dbclass =
+ get_class(jnienv, name_DB_BTREE_STAT)) == NULL)
+ break; /* An exception has been posted. */
+ __jv_fill_bt_stat(jnienv, dbclass, retval, bstp);
break;
/* Hash stat structure */
case DB_HASH:
hstp = (DB_HASH_STAT *)statp;
+ bytesize = sizeof(DB_HASH_STAT);
retval = create_default_object(jnienv,
name_DB_HASH_STAT);
- dbclass = get_class(jnienv, name_DB_HASH_STAT);
-
- /* Set the individual fields */
- set_int_field(jnienv, dbclass, retval,
- "hash_magic", hstp->hash_magic);
- set_int_field(jnienv, dbclass, retval,
- "hash_version", hstp->hash_version);
- set_int_field(jnienv, dbclass, retval,
- "hash_metaflags", hstp->hash_metaflags);
- set_int_field(jnienv, dbclass, retval,
- "hash_nkeys", hstp->hash_nkeys);
- set_int_field(jnienv, dbclass, retval,
- "hash_ndata", hstp->hash_ndata);
- set_int_field(jnienv, dbclass, retval,
- "hash_pagesize", hstp->hash_pagesize);
- set_int_field(jnienv, dbclass, retval,
- "hash_nelem", hstp->hash_nelem);
- set_int_field(jnienv, dbclass, retval,
- "hash_ffactor", hstp->hash_ffactor);
- set_int_field(jnienv, dbclass, retval,
- "hash_buckets", hstp->hash_buckets);
- set_int_field(jnienv, dbclass, retval,
- "hash_free", hstp->hash_free);
- set_int_field(jnienv, dbclass, retval,
- "hash_bfree", hstp->hash_bfree);
- set_int_field(jnienv, dbclass, retval,
- "hash_bigpages", hstp->hash_bigpages);
- set_int_field(jnienv, dbclass, retval,
- "hash_big_bfree", hstp->hash_big_bfree);
- set_int_field(jnienv, dbclass, retval,
- "hash_overflows", hstp->hash_overflows);
- set_int_field(jnienv, dbclass, retval,
- "hash_ovfl_free", hstp->hash_ovfl_free);
- set_int_field(jnienv, dbclass, retval,
- "hash_dup", hstp->hash_dup);
- set_int_field(jnienv, dbclass, retval,
- "hash_dup_free", hstp->hash_dup_free);
+ if ((dbclass =
+ get_class(jnienv, name_DB_HASH_STAT)) == NULL)
+ break; /* An exception has been posted. */
+ __jv_fill_h_stat(jnienv, dbclass, retval, hstp);
break;
case DB_QUEUE:
qstp = (DB_QUEUE_STAT *)statp;
+ bytesize = sizeof(DB_QUEUE_STAT);
retval = create_default_object(jnienv,
name_DB_QUEUE_STAT);
- dbclass = get_class(jnienv, name_DB_QUEUE_STAT);
-
- /* Set the individual fields */
- set_int_field(jnienv, dbclass, retval,
- "qs_magic", qstp->qs_magic);
- set_int_field(jnienv, dbclass, retval,
- "qs_version", qstp->qs_version);
- set_int_field(jnienv, dbclass, retval,
- "qs_metaflags", qstp->qs_metaflags);
- set_int_field(jnienv, dbclass, retval,
- "qs_nkeys", qstp->qs_nkeys);
- set_int_field(jnienv, dbclass, retval,
- "qs_ndata", qstp->qs_ndata);
- set_int_field(jnienv, dbclass, retval,
- "qs_pagesize", qstp->qs_pagesize);
- set_int_field(jnienv, dbclass, retval,
- "qs_pages", qstp->qs_pages);
- set_int_field(jnienv, dbclass, retval,
- "qs_re_len", qstp->qs_re_len);
- set_int_field(jnienv, dbclass, retval,
- "qs_re_pad", qstp->qs_re_pad);
- set_int_field(jnienv, dbclass, retval,
- "qs_pgfree", qstp->qs_pgfree);
- set_int_field(jnienv, dbclass, retval,
- "qs_first_recno", qstp->qs_first_recno);
- set_int_field(jnienv, dbclass, retval,
- "qs_cur_recno", qstp->qs_cur_recno);
+ if ((dbclass =
+ get_class(jnienv, name_DB_QUEUE_STAT)) == NULL)
+ break; /* An exception has been posted. */
+
+ __jv_fill_qam_stat(jnienv, dbclass, retval, qstp);
break;
/* That's all the database types we're aware of! */
default:
report_exception(jnienv,
"Db.stat not implemented for types"
- "other than HASH, BTREE and RECNO",
+ " other than BTREE, HASH, QUEUE,"
+ " and RECNO",
EINVAL, 0);
break;
}
- free(statp);
+ if (bytesize != 0)
+ __os_ufree(db->dbenv, statp);
}
- JAVADB_API_END(db);
return (retval);
}
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_sync
- (JNIEnv *jnienv, /*Db*/ jobject jthis, jint flags)
-{
- int err;
- DB *db = get_DB(jnienv, jthis);
-
- if (!verify_non_null(jnienv, db))
- return (0);
- JAVADB_API_BEGIN(db, jthis);
- err = db->sync(db, flags);
- if (err != DB_INCOMPLETE)
- verify_return(jnienv, err, 0);
- JAVADB_API_END(db);
- return (err);
-}
+JAVADB_METHOD(Db_sync, (JAVADB_ARGS, jint flags), DB,
+ sync, (c_this, flags))
JNIEXPORT jboolean JNICALL Java_com_sleepycat_db_Db_get_1byteswapped
(JNIEnv *jnienv, /*Db*/ jobject jthis)
{
DB *db;
- jboolean retval;
+ int err, isbyteswapped;
+
+ /* This value should never be seen, because of the exception. */
+ isbyteswapped = 0;
db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
return (0);
- JAVADB_API_BEGIN(db, jthis);
- retval = db->get_byteswapped(db) ? 1 : 0;
- JAVADB_API_END(db);
- return (retval);
+ err = db->get_byteswapped(db, &isbyteswapped);
+ (void)verify_return(jnienv, err, 0);
+
+ return ((jboolean)isbyteswapped);
}
JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_get_1type
(JNIEnv *jnienv, /*Db*/ jobject jthis)
{
DB *db;
+ int err;
+ DBTYPE dbtype;
+
+ /* This value should never be seen, because of the exception. */
+ dbtype = DB_UNKNOWN;
db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
return (0);
- return ((jint)db->type);
+ err = db->get_type(db, &dbtype);
+ (void)verify_return(jnienv, err, 0);
+
+ return ((jint)dbtype);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1open
- (JNIEnv *jnienv, /*Db*/ jobject jthis, jstring file, jstring database,
- jint type, jint flags, jint mode)
+ (JNIEnv *jnienv, /*Db*/ jobject jthis, /*DbTxn*/ jobject txnid,
+ jstring file, jstring database, jint type, jint flags, jint mode)
{
int err;
DB *db;
- JSTR dbfile;
- JSTR dbdatabase;
+ DB_TXN *dbtxnid;
+ LOCKED_STRING ls_file;
+ LOCKED_STRING ls_database;
- /* Java is assumed to be threaded. */
+ /* Java is assumed to be threaded */
flags |= DB_THREAD;
db = get_DB(jnienv, jthis);
- if (jstr_lock(&dbfile, jnienv, file) != 0)
+
+ dbtxnid = get_DB_TXN(jnienv, txnid);
+ if (locked_string_get(&ls_file, jnienv, file) != 0)
goto out2;
- if (jstr_lock(&dbdatabase, jnienv, database) != 0)
+ if (locked_string_get(&ls_database, jnienv, database) != 0)
goto out1;
if (verify_non_null(jnienv, db)) {
- JAVADB_API_BEGIN(db, jthis);
- err = db->open(db, dbfile.string, dbdatabase.string,
+ err = db->open(db, dbtxnid, ls_file.string, ls_database.string,
(DBTYPE)type, flags, mode);
verify_return(jnienv, err, EXCEPTION_FILE_NOT_FOUND);
- JAVADB_API_END(db);
}
out1:
- jstr_unlock(&dbdatabase, jnienv);
+ locked_string_put(&ls_database, jnienv);
out2:
- jstr_unlock(&dbfile, jnienv);
+ locked_string_put(&ls_file, jnienv);
+}
+
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Db_truncate
+ (JNIEnv *jnienv, /*Db*/ jobject jthis, /*DbTxn*/ jobject jtxnid, jint flags)
+{
+ int err;
+ DB *db;
+ u_int32_t count;
+ DB_TXN *dbtxnid;
+
+ db = get_DB(jnienv, jthis);
+ dbtxnid = get_DB_TXN(jnienv, jtxnid);
+ count = 0;
+ if (verify_non_null(jnienv, db)) {
+ err = db->truncate(db, dbtxnid, &count, flags);
+ verify_return(jnienv, err, 0);
+ }
+ return (jint)count;
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_upgrade
@@ -849,18 +867,16 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_upgrade
{
int err;
DB *db = get_DB(jnienv, jthis);
- JSTR j_name;
+ LOCKED_STRING ls_name;
if (verify_non_null(jnienv, db)) {
- JAVADB_API_BEGIN(db, jthis);
- if (jstr_lock(&j_name, jnienv, name) != 0)
+ if (locked_string_get(&ls_name, jnienv, name) != 0)
goto out;
- err = db->upgrade(db, j_name.string, flags);
+ err = db->upgrade(db, ls_name.string, flags);
verify_return(jnienv, err, 0);
- JAVADB_API_END(db);
}
out:
- jstr_unlock(&j_name, jnienv);
+ locked_string_put(&ls_name, jnienv);
}
static int java_verify_callback(void *handle, const void *str_arg)
@@ -868,7 +884,6 @@ static int java_verify_callback(void *handle, const void *str_arg)
char *str;
struct verify_callback_struct *vc;
int len;
- jthrowable except;
JNIEnv *jnienv;
str = (char *)str_arg;
@@ -879,11 +894,15 @@ static int java_verify_callback(void *handle, const void *str_arg)
vc->nbytes = len;
vc->bytes = (*jnienv)->NewByteArray(jnienv, len);
}
- (*jnienv)->SetByteArrayRegion(jnienv, vc->bytes, 0, len, (jbyte*)str);
- (*jnienv)->CallVoidMethod(jnienv, vc->streamobj,
- vc->writemid, vc->bytes, 0, len-1);
- if ((except = (*jnienv)->ExceptionOccurred(jnienv)) != NULL)
+ if (vc->bytes != NULL) {
+ (*jnienv)->SetByteArrayRegion(jnienv, vc->bytes, 0, len,
+ (jbyte*)str);
+ (*jnienv)->CallVoidMethod(jnienv, vc->streamobj,
+ vc->writemid, vc->bytes, 0, len-1);
+ }
+
+ if ((*jnienv)->ExceptionOccurred(jnienv) != NULL)
return (EIO);
return (0);
@@ -895,26 +914,25 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_verify
{
int err;
DB *db;
- JSTR j_name;
- JSTR j_subdb;
+ LOCKED_STRING ls_name;
+ LOCKED_STRING ls_subdb;
struct verify_callback_struct vcs;
jclass streamclass;
db = get_DB(jnienv, jthis);
if (!verify_non_null(jnienv, db))
return;
- JAVADB_API_BEGIN(db, jthis);
-
- if (jstr_lock(&j_name, jnienv, name) != 0)
+ if (locked_string_get(&ls_name, jnienv, name) != 0)
goto out2;
- if (jstr_lock(&j_subdb, jnienv, subdb) != 0)
+ if (locked_string_get(&ls_subdb, jnienv, subdb) != 0)
goto out1;
/* set up everything we need for the callbacks */
vcs.env = jnienv;
vcs.streamobj = stream;
vcs.nbytes = 100;
- vcs.bytes = (*jnienv)->NewByteArray(jnienv, vcs.nbytes);
+ if ((vcs.bytes = (*jnienv)->NewByteArray(jnienv, vcs.nbytes)) == NULL)
+ goto out1;
/* get the method ID for OutputStream.write(byte[], int, int); */
streamclass = (*jnienv)->FindClass(jnienv, "java/io/OutputStream");
@@ -922,15 +940,14 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db_verify
"write", "([BII)V");
/* invoke verify - this will invoke the callback repeatedly. */
- err = __db_verify_internal(db, j_name.string, j_subdb.string,
+ err = __db_verify_internal(db, ls_name.string, ls_subdb.string,
&vcs, java_verify_callback, flags);
verify_return(jnienv, err, 0);
out1:
- jstr_unlock(&j_subdb, jnienv);
+ locked_string_put(&ls_subdb, jnienv);
out2:
- jstr_unlock(&j_name, jnienv);
- JAVADB_API_END(db);
+ locked_string_put(&ls_name, jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1finalize
@@ -944,7 +961,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Db__1finalize
db = get_DB(jnienv, jthis);
DB_ASSERT(dbinfo != NULL);
- /* Note: We can never be sure if the underlying DB is attached to
+ /*
+ * Note: We can never be sure if the underlying DB is attached to
* a DB_ENV that was already closed. Sure, that's a user error,
* but it shouldn't crash the VM. Therefore, we cannot just
* automatically close if the handle indicates we are not yet
diff --git a/bdb/libdb_java/java_DbEnv.c b/bdb/libdb_java/java_DbEnv.c
index ff9207dd2c8..651c38a0e3d 100644
--- a/bdb/libdb_java/java_DbEnv.c
+++ b/bdb/libdb_java/java_DbEnv.c
@@ -1,40 +1,40 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_DbEnv.c,v 11.37 2001/01/11 18:19:52 bostic Exp $";
+static const char revid[] = "$Id: java_DbEnv.c,v 11.105 2002/08/29 14:22:23 margo Exp $";
#endif /* not lint */
#include <jni.h>
#include <stdlib.h>
#include <string.h>
-#include "db.h"
#include "db_int.h"
#include "java_util.h"
+#include "java_stat_auto.h"
#include "com_sleepycat_db_DbEnv.h"
/* We keep these lined up, and alphabetical by field name,
* for comparison with C++'s list.
*/
-JAVADB_WO_ACCESS_STRING(DbEnv, data_1dir, DB_ENV, data_dir)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lg_1bsize, DB_ENV, lg_bsize)
-JAVADB_WO_ACCESS_STRING(DbEnv, lg_1dir, DB_ENV, lg_dir)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lg_1max, DB_ENV, lg_max)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lk_1detect, DB_ENV, lk_detect)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lk_1max, DB_ENV, lk_max)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lk_1max_1locks, DB_ENV, lk_max_locks)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lk_1max_1lockers, DB_ENV, lk_max_lockers)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, lk_1max_1objects, DB_ENV, lk_max_objects)
+JAVADB_SET_METH_STR(DbEnv, data_1dir, DB_ENV, data_dir)
+JAVADB_SET_METH(DbEnv, jint, lg_1bsize, DB_ENV, lg_bsize)
+JAVADB_SET_METH_STR(DbEnv, lg_1dir, DB_ENV, lg_dir)
+JAVADB_SET_METH(DbEnv, jint, lg_1max, DB_ENV, lg_max)
+JAVADB_SET_METH(DbEnv, jint, lg_1regionmax, DB_ENV, lg_regionmax)
+JAVADB_SET_METH(DbEnv, jint, lk_1detect, DB_ENV, lk_detect)
+JAVADB_SET_METH(DbEnv, jint, lk_1max, DB_ENV, lk_max)
+JAVADB_SET_METH(DbEnv, jint, lk_1max_1locks, DB_ENV, lk_max_locks)
+JAVADB_SET_METH(DbEnv, jint, lk_1max_1lockers, DB_ENV, lk_max_lockers)
+JAVADB_SET_METH(DbEnv, jint, lk_1max_1objects, DB_ENV, lk_max_objects)
/* mp_mmapsize is declared below, it needs an extra cast */
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, mutexlocks, DB_ENV, mutexlocks)
-JAVADB_WO_ACCESS_STRING(DbEnv, tmp_1dir, DB_ENV, tmp_dir)
-JAVADB_WO_ACCESS_METHOD(DbEnv, jint, tx_1max, DB_ENV, tx_max)
+JAVADB_SET_METH_STR(DbEnv, tmp_1dir, DB_ENV, tmp_dir)
+JAVADB_SET_METH(DbEnv, jint, tx_1max, DB_ENV, tx_max)
static void DbEnv_errcall_callback(const char *prefix, char *message)
{
@@ -42,7 +42,8 @@ static void DbEnv_errcall_callback(const char *prefix, char *message)
DB_ENV_JAVAINFO *envinfo = (DB_ENV_JAVAINFO *)prefix;
jstring pre;
- /* Note: these error cases are "impossible", and would
+ /*
+ * Note: these error cases are "impossible", and would
* normally warrant an exception. However, without
* a jnienv, we cannot throw an exception...
* We don't want to trap or exit, since the point of
@@ -50,7 +51,8 @@ static void DbEnv_errcall_callback(const char *prefix, char *message)
* error situations.
*/
if (envinfo == NULL) {
- /* Something is *really* wrong here, the
+ /*
+ * Something is *really* wrong here, the
* prefix is set in every environment created.
*/
fprintf(stderr, "Error callback failed!\n");
@@ -70,7 +72,7 @@ static void DbEnv_errcall_callback(const char *prefix, char *message)
}
pre = dbjie_get_errpfx(envinfo, jnienv);
- report_errcall(jnienv, dbjie_get_errcall(envinfo), pre, message);
+ report_errcall(jnienv, dbjie_get_errcall(envinfo), pre, message);
}
static void DbEnv_initialize(JNIEnv *jnienv, DB_ENV *dbenv,
@@ -82,15 +84,16 @@ static void DbEnv_initialize(JNIEnv *jnienv, DB_ENV *dbenv,
envinfo = get_DB_ENV_JAVAINFO(jnienv, jenv);
DB_ASSERT(envinfo == NULL);
- envinfo = dbjie_construct(jnienv, jerrcall, is_dbopen);
+ envinfo = dbjie_construct(jnienv, jenv, jerrcall, is_dbopen);
set_private_info(jnienv, name_DB_ENV, jenv, envinfo);
dbenv->set_errpfx(dbenv, (const char*)envinfo);
dbenv->set_errcall(dbenv, DbEnv_errcall_callback);
- dbenv->cj_internal = envinfo;
+ dbenv->api2_internal = envinfo;
set_private_dbobj(jnienv, name_DB_ENV, jenv, dbenv);
}
-/* This is called when this DbEnv was made on behalf of a Db
+/*
+ * This is called when this DbEnv was made on behalf of a Db
* created directly (without a parent DbEnv), and the Db is
* being closed. We'll zero out the pointer to the DB_ENV,
* since it is no longer valid, to prevent mistakes.
@@ -107,7 +110,8 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1notify_1db_1close
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_feedback_1changed
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbFeedback*/ jobject jfeedback)
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis,
+ /*DbEnvFeedback*/ jobject jfeedback)
{
DB_ENV *dbenv;
DB_ENV_JAVAINFO *dbenvinfo;
@@ -118,9 +122,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_feedback_1changed
!verify_non_null(jnienv, dbenvinfo))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
dbjie_set_feedback_object(dbenvinfo, jnienv, dbenv, jfeedback);
- JAVADB_ENV_API_END(dbenv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1init
@@ -144,7 +146,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1init_1using_1db
db = get_DB(jnienv, jdb);
dbenv = db->dbenv;
- DbEnv_initialize(jnienv, dbenv, jthis, jerrcall, 1);
+ DbEnv_initialize(jnienv, dbenv, jthis, jerrcall, 0);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_open
@@ -153,7 +155,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_open
{
int err;
DB_ENV *dbenv;
- JSTR j_home;
+ LOCKED_STRING ls_home;
DB_ENV_JAVAINFO *dbenvinfo;
dbenv = get_DB_ENV(jnienv, jthis);
@@ -161,18 +163,16 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_open
if (!verify_non_null(jnienv, dbenv) ||
!verify_non_null(jnienv, dbenvinfo))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- if (jstr_lock(&j_home, jnienv, db_home) != 0)
+ if (locked_string_get(&ls_home, jnienv, db_home) != 0)
goto out;
/* Java is assumed to be threaded. */
flags |= DB_THREAD;
- err = dbenv->open(dbenv, j_home.string, flags, mode);
+ err = dbenv->open(dbenv, ls_home.string, flags, mode);
verify_return(jnienv, err, EXCEPTION_FILE_NOT_FOUND);
out:
- jstr_unlock(&j_home, jnienv);
- JAVADB_ENV_API_END(dbenv);
+ locked_string_put(&ls_home, jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_remove
@@ -180,27 +180,25 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_remove
{
DB_ENV *dbenv;
DB_ENV_JAVAINFO *dbenvinfo;
- JSTR j_home;
+ LOCKED_STRING ls_home;
int err = 0;
dbenv = get_DB_ENV(jnienv, jthis);
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
if (!verify_non_null(jnienv, dbenv))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- if (jstr_lock(&j_home, jnienv, db_home) != 0)
+ if (locked_string_get(&ls_home, jnienv, db_home) != 0)
goto out;
- err = dbenv->remove(dbenv, j_home.string, flags);
+ err = dbenv->remove(dbenv, ls_home.string, flags);
set_private_dbobj(jnienv, name_DB_ENV, jthis, 0);
- if (dbenvinfo != NULL)
- dbjie_dealloc(dbenvinfo, jnienv);
-
verify_return(jnienv, err, 0);
out:
- jstr_unlock(&j_home, jnienv);
- /* don't call JAVADB_ENV_API_END - env cannot be used */
+ locked_string_put(&ls_home, jnienv);
+
+ if (dbenvinfo != NULL)
+ dbjie_dealloc(dbenvinfo, jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1close
@@ -215,8 +213,6 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1close
if (!verify_non_null(jnienv, dbenv))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
err = dbenv->close(dbenv, flags);
set_private_dbobj(jnienv, name_DB_ENV, jthis, 0);
@@ -225,50 +221,101 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1close
/* Throw an exception if the close failed. */
verify_return(jnienv, err, 0);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_dbremove
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbTxn*/ jobject jtxn,
+ jstring name, jstring subdb, jint flags)
+{
+ LOCKED_STRING ls_name, ls_subdb;
+ DB_ENV *dbenv;
+ DB_TXN *txn;
+ int err;
+
+ dbenv = get_DB_ENV(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbenv))
+ return;
+ txn = get_DB_TXN(jnienv, jtxn);
+ if (locked_string_get(&ls_name, jnienv, name) != 0)
+ return;
+ if (locked_string_get(&ls_subdb, jnienv, subdb) != 0)
+ goto err1;
+
+ err = dbenv->dbremove(dbenv, txn, ls_name.string, ls_subdb.string,
+ flags);
+
+ /* Throw an exception if the dbremove failed. */
+ verify_return(jnienv, err, 0);
+
+ locked_string_put(&ls_subdb, jnienv);
+err1: locked_string_put(&ls_name, jnienv);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_dbrename
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbTxn*/ jobject jtxn,
+ jstring name, jstring subdb, jstring newname, jint flags)
+{
+ LOCKED_STRING ls_name, ls_subdb, ls_newname;
+ DB_ENV *dbenv;
+ DB_TXN *txn;
+ int err;
+
+ dbenv = get_DB_ENV(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbenv))
+ return;
+ txn = get_DB_TXN(jnienv, jtxn);
+ if (locked_string_get(&ls_name, jnienv, name) != 0)
+ return;
+ if (locked_string_get(&ls_subdb, jnienv, subdb) != 0)
+ goto err2;
+ if (locked_string_get(&ls_newname, jnienv, newname) != 0)
+ goto err1;
+
+ err = dbenv->dbrename(dbenv, txn, ls_name.string, ls_subdb.string,
+ ls_newname.string, flags);
+
+ /* Throw an exception if the dbrename failed. */
+ verify_return(jnienv, err, 0);
- /* don't call JAVADB_ENV_API_END - env cannot be used */
+ locked_string_put(&ls_newname, jnienv);
+err1: locked_string_put(&ls_subdb, jnienv);
+err2: locked_string_put(&ls_name, jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_err
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint ecode, jstring msg)
{
- JSTR msg_string;
+ LOCKED_STRING ls_msg;
DB_ENV *dbenv;
dbenv = get_DB_ENV(jnienv, jthis);
if (!verify_non_null(jnienv, dbenv))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- if (jstr_lock(&msg_string, jnienv, msg) != 0)
+ if (locked_string_get(&ls_msg, jnienv, msg) != 0)
goto out;
- dbenv->err(dbenv, ecode, msg_string.string);
+ dbenv->err(dbenv, ecode, "%s", ls_msg.string);
out:
- jstr_unlock(&msg_string, jnienv);
- JAVADB_ENV_API_END(dbenv);
+ locked_string_put(&ls_msg, jnienv);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_errx
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring msg)
{
- JSTR msg_string;
+ LOCKED_STRING ls_msg;
DB_ENV *dbenv;
dbenv = get_DB_ENV(jnienv, jthis);
if (!verify_non_null(jnienv, dbenv))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- if (jstr_lock(&msg_string, jnienv, msg) != 0)
+ if (locked_string_get(&ls_msg, jnienv, msg) != 0)
goto out;
- dbenv->errx(dbenv, msg_string.string);
+ dbenv->errx(dbenv, "%s", ls_msg.string);
out:
- jstr_unlock(&msg_string, jnienv);
- JAVADB_ENV_API_END(dbenv);
+ locked_string_put(&ls_msg, jnienv);
}
/*static*/
@@ -282,190 +329,255 @@ JNIEXPORT jstring JNICALL Java_com_sleepycat_db_DbEnv_strerror
return (get_java_string(jnienv, message));
}
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1cachesize
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint gbytes, jint bytes,
- jint ncaches)
+JAVADB_METHOD(DbEnv_set_1cachesize,
+ (JAVADB_ARGS, jint gbytes, jint bytes, jint ncaches), DB_ENV,
+ set_cachesize, (c_this, gbytes, bytes, ncaches))
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1encrypt
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring jpasswd, jint flags)
{
- DB_ENV *dbenv;
int err;
+ DB_ENV *dbenv;
+ LOCKED_STRING ls_passwd;
dbenv = get_DB_ENV(jnienv, jthis);
- if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = dbenv->set_cachesize(dbenv, gbytes, bytes, ncaches);
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
- }
+ if (!verify_non_null(jnienv, dbenv))
+ return;
+ if (locked_string_get(&ls_passwd, jnienv, jpasswd) != 0)
+ goto out;
+
+ err = dbenv->set_encrypt(dbenv, ls_passwd.string, flags);
+ verify_return(jnienv, err, 0);
+
+out: locked_string_put(&ls_passwd, jnienv);
}
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1flags
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags, jint onoff)
+JAVADB_METHOD(DbEnv_set_1flags,
+ (JAVADB_ARGS, jint flags, jboolean onoff), DB_ENV,
+ set_flags, (c_this, flags, onoff ? 1 : 0))
+
+JAVADB_METHOD(DbEnv_set_1mp_1mmapsize, (JAVADB_ARGS, jlong value), DB_ENV,
+ set_mp_mmapsize, (c_this, (size_t)value))
+
+JAVADB_METHOD(DbEnv_set_1tas_1spins, (JAVADB_ARGS, jint spins), DB_ENV,
+ set_tas_spins, (c_this, (u_int32_t)spins))
+
+JAVADB_METHOD(DbEnv_set_1timeout,
+ (JAVADB_ARGS, jlong timeout, jint flags), DB_ENV,
+ set_timeout, (c_this, (u_int32_t)timeout, flags))
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1lk_1conflicts
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jobjectArray array)
{
DB_ENV *dbenv;
+ DB_ENV_JAVAINFO *dbenvinfo;
int err;
+ jsize i, len;
+ u_char *newarr;
+ int bytesize;
dbenv = get_DB_ENV(jnienv, jthis);
- if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = dbenv->set_flags(dbenv, flags, onoff);
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
+ dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbenv) ||
+ !verify_non_null(jnienv, dbenvinfo))
+ return;
+
+ len = (*jnienv)->GetArrayLength(jnienv, array);
+ bytesize = sizeof(u_char) * len * len;
+
+ if ((err = __os_malloc(dbenv, bytesize, &newarr)) != 0) {
+ if (!verify_return(jnienv, err, 0))
+ return;
}
+
+ for (i=0; i<len; i++) {
+ jobject subArray =
+ (*jnienv)->GetObjectArrayElement(jnienv, array, i);
+ (*jnienv)->GetByteArrayRegion(jnienv, (jbyteArray)subArray,
+ 0, len,
+ (jbyte *)&newarr[i*len]);
+ }
+ dbjie_set_conflict(dbenvinfo, newarr, bytesize);
+ err = dbenv->set_lk_conflicts(dbenv, newarr, len);
+ verify_return(jnienv, err, 0);
}
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1mp_1mmapsize
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jlong value)
+JNIEXPORT jint JNICALL
+ Java_com_sleepycat_db_DbEnv_rep_1elect
+ (JNIEnv *jnienv, /* DbEnv */ jobject jthis, jint nsites, jint pri,
+ jint timeout)
{
DB_ENV *dbenv;
- int err;
+ int err, id;
- dbenv = get_DB_ENV(jnienv, jthis);
- if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = dbenv->set_mp_mmapsize(dbenv, (size_t)value);
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
- }
-}
+ if (!verify_non_null(jnienv, jthis))
+ return (DB_EID_INVALID);
-/*static*/
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1pageyield
- (JNIEnv *jnienv, jclass jthis_class, jint value)
-{
- int err;
+ dbenv = get_DB_ENV(jnienv, jthis);
- COMPQUIET(jthis_class, NULL);
- err = db_env_set_pageyield(value);
+ err = dbenv->rep_elect(dbenv, (int)nsites,
+ (int)pri, (u_int32_t)timeout, &id);
verify_return(jnienv, err, 0);
+
+ return ((jint)id);
}
-/*static*/
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1panicstate
- (JNIEnv *jnienv, jclass jthis_class, jint value)
+JNIEXPORT jint JNICALL
+ Java_com_sleepycat_db_DbEnv_rep_1process_1message
+ (JNIEnv *jnienv, /* DbEnv */ jobject jthis, /* Dbt */ jobject control,
+ /* Dbt */ jobject rec, /* RepProcessMessage */ jobject result)
{
- int err;
+ DB_ENV *dbenv;
+ LOCKED_DBT cdbt, rdbt;
+ int err, envid;
- COMPQUIET(jthis_class, NULL);
- err = db_env_set_panicstate(value);
- verify_return(jnienv, err, 0);
+ if (!verify_non_null(jnienv, jthis) || !verify_non_null(jnienv, result))
+ return (-1);
+
+ dbenv = get_DB_ENV(jnienv, jthis);
+ err = 0;
+
+ /* The DBTs are always inputs. */
+ if (locked_dbt_get(&cdbt, jnienv, dbenv, control, inOp) != 0)
+ goto out2;
+ if (locked_dbt_get(&rdbt, jnienv, dbenv, rec, inOp) != 0)
+ goto out1;
+
+ envid = (*jnienv)->GetIntField(jnienv,
+ result, fid_RepProcessMessage_envid);
+
+ err = dbenv->rep_process_message(dbenv, &cdbt.javainfo->dbt,
+ &rdbt.javainfo->dbt, &envid);
+
+ if (err == DB_REP_NEWMASTER)
+ (*jnienv)->SetIntField(jnienv,
+ result, fid_RepProcessMessage_envid, envid);
+ else if (!DB_RETOK_REPPMSG(err))
+ verify_return(jnienv, err, 0);
+
+out1: locked_dbt_put(&rdbt, jnienv, dbenv);
+out2: locked_dbt_put(&cdbt, jnienv, dbenv);
+
+ return (err);
}
-/*static*/
JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1region_1init
- (JNIEnv *jnienv, jclass jthis_class, jint value)
+ Java_com_sleepycat_db_DbEnv_rep_1start
+ (JNIEnv *jnienv, /* DbEnv */ jobject jthis, /* Dbt */ jobject cookie,
+ jint flags)
{
+ DB_ENV *dbenv;
+ DBT *dbtp;
+ LOCKED_DBT ldbt;
int err;
- COMPQUIET(jthis_class, NULL);
- err = db_env_set_region_init(value);
+ if (!verify_non_null(jnienv, jthis))
+ return;
+
+ dbenv = get_DB_ENV(jnienv, jthis);
+
+ /* The Dbt cookie may be null; if so, pass in a NULL DBT. */
+ if (cookie != NULL) {
+ if (locked_dbt_get(&ldbt, jnienv, dbenv, cookie, inOp) != 0)
+ goto out;
+ dbtp = &ldbt.javainfo->dbt;
+ } else
+ dbtp = NULL;
+
+ err = dbenv->rep_start(dbenv, dbtp, flags);
verify_return(jnienv, err, 0);
+
+out: if (cookie != NULL)
+ locked_dbt_put(&ldbt, jnienv, dbenv);
}
-/*static*/
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1tas_1spins
- (JNIEnv *jnienv, jclass jthis_class, jint value)
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_rep_1stat
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err;
+ DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
+ DB_REP_STAT *statp = NULL;
+ jobject retval = NULL;
+ jclass dbclass;
- COMPQUIET(jthis_class, NULL);
- err = db_env_set_tas_spins(value);
- verify_return(jnienv, err, 0);
+ if (!verify_non_null(jnienv, dbenv))
+ return (NULL);
+
+ err = dbenv->rep_stat(dbenv, &statp, (u_int32_t)flags);
+ if (verify_return(jnienv, err, 0)) {
+ if ((dbclass = get_class(jnienv, name_DB_REP_STAT)) == NULL ||
+ (retval =
+ create_default_object(jnienv, name_DB_REP_STAT)) == NULL)
+ goto err; /* An exception has been posted. */
+
+ __jv_fill_rep_stat(jnienv, dbclass, retval, statp);
+
+err: __os_ufree(dbenv, statp);
+ }
+ return (retval);
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_recovery_1init_1changed
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbRecoveryInit*/ jobject jrecoveryinit)
+JNIEXPORT void JNICALL
+Java_com_sleepycat_db_DbEnv_set_1rep_1limit
+ (JNIEnv *jnienv, /* DbEnv */ jobject jthis, jint gbytes, jint bytes)
{
DB_ENV *dbenv;
- DB_ENV_JAVAINFO *dbenvinfo;
+ int err;
dbenv = get_DB_ENV(jnienv, jthis);
- dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
- if (!verify_non_null(jnienv, dbenv) ||
- !verify_non_null(jnienv, dbenv))
- return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- dbjie_set_recovery_init_object(dbenvinfo, jnienv, dbenv, jrecoveryinit);
- JAVADB_ENV_API_END(dbenv);
+ if (verify_non_null(jnienv, dbenv)) {
+ err = dbenv->set_rep_limit(dbenv,
+ (u_int32_t)gbytes, (u_int32_t)bytes);
+ verify_return(jnienv, err, 0);
+ }
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1lk_1conflicts
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jobjectArray array)
+JNIEXPORT void JNICALL
+ Java_com_sleepycat_db_DbEnv_rep_1transport_1changed
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint envid,
+ /* DbRepTransport */ jobject jreptransport)
{
DB_ENV *dbenv;
DB_ENV_JAVAINFO *dbenvinfo;
- int err;
- jsize i, len;
- unsigned char *newarr;
dbenv = get_DB_ENV(jnienv, jthis);
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
if (!verify_non_null(jnienv, dbenv) ||
- !verify_non_null(jnienv, dbenvinfo))
+ !verify_non_null(jnienv, dbenvinfo) ||
+ !verify_non_null(jnienv, jreptransport))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- len = (*jnienv)->GetArrayLength(jnienv, array);
-
- newarr = (unsigned char *)malloc(sizeof(unsigned char) * len * len);
-
- for (i=0; i<len; i++) {
- jobject subArray =
- (*jnienv)->GetObjectArrayElement(jnienv, array, i);
- (*jnienv)->GetByteArrayRegion(jnienv, (jbyteArray)subArray,
- 0, len,
- (jbyte *)&newarr[i*len]);
- }
- dbjie_set_conflict(dbenvinfo, newarr);
- err = dbenv->set_lk_conflicts(dbenv, newarr, len);
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
+ dbjie_set_rep_transport_object(dbenvinfo,
+ jnienv, dbenv, envid, jreptransport);
}
JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1server
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring jhost, jlong tsec,
- jlong ssec, jint flags)
+ Java_com_sleepycat_db_DbEnv_set_1rpc_1server
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbClient*/ jobject jclient,
+ jstring jhost, jlong tsec, jlong ssec, jint flags)
{
int err;
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
const char *host = (*jnienv)->GetStringUTFChars(jnienv, jhost, NULL);
+ if (jclient != NULL) {
+ report_exception(jnienv, "DbEnv.set_rpc_server client arg "
+ "must be null; reserved for future use",
+ EINVAL, 0);
+ return;
+ }
if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = dbenv->set_server(dbenv, (char *)host,
+ err = dbenv->set_rpc_server(dbenv, NULL, host,
(long)tsec, (long)ssec, flags);
/* Throw an exception if the call failed. */
verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
}
}
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1shm_1key
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jlong shm_key)
-{
- int err;
- DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
-
- if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = dbenv->set_shm_key(dbenv, (long)shm_key);
-
- /* Throw an exception if the call failed. */
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
- }
-}
+JAVADB_METHOD(DbEnv_set_1shm_1key, (JAVADB_ARGS, jlong shm_key), DB_ENV,
+ set_shm_key, (c_this, (long)shm_key))
JNIEXPORT void JNICALL
Java_com_sleepycat_db_DbEnv__1set_1tx_1timestamp
@@ -476,31 +588,16 @@ JNIEXPORT void JNICALL
time_t time = seconds;
if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
err = dbenv->set_tx_timestamp(dbenv, &time);
/* Throw an exception if the call failed. */
verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
}
}
-JNIEXPORT void JNICALL
- Java_com_sleepycat_db_DbEnv_set_1verbose
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint which, jint onoff)
-{
- int err;
- DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
-
- if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = dbenv->set_verbose(dbenv, which, onoff);
-
- /* Throw an exception if the call failed. */
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
- }
-}
+JAVADB_METHOD(DbEnv_set_1verbose,
+ (JAVADB_ARGS, jint which, jboolean onoff), DB_ENV,
+ set_verbose, (c_this, which, onoff ? 1 : 0))
/*static*/
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_get_1version_1major
@@ -550,15 +647,16 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_lock_1id
if (!verify_non_null(jnienv, dbenv))
return (-1);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = lock_id(dbenv, &id);
+ err = dbenv->lock_id(dbenv, &id);
verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
return (id);
}
+JAVADB_METHOD(DbEnv_lock_1id_1free, (JAVADB_ARGS, jint id), DB_ENV,
+ lock_id_free, (c_this, id))
+
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1stat
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err;
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
@@ -568,44 +666,18 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1stat
if (!verify_non_null(jnienv, dbenv))
return (NULL);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- /* We cannot use the default allocator (on Win* platforms anyway)
- * because it often causes problems when we free storage
- * in a DLL that was allocated in another DLL. Using
- * our own allocator (ours just calls malloc!) ensures
- * that there is no mismatch.
- */
- err = lock_stat(dbenv, &statp, NULL);
+ err = dbenv->lock_stat(dbenv, &statp, (u_int32_t)flags);
if (verify_return(jnienv, err, 0)) {
- retval = create_default_object(jnienv, name_DB_LOCK_STAT);
- dbclass = get_class(jnienv, name_DB_LOCK_STAT);
+ if ((dbclass = get_class(jnienv, name_DB_LOCK_STAT)) == NULL ||
+ (retval =
+ create_default_object(jnienv, name_DB_LOCK_STAT)) == NULL)
+ goto err; /* An exception has been posted. */
- /* Set the individual fields */
- set_int_field(jnienv, dbclass, retval,
- "st_maxlocks", statp->st_maxlocks);
- set_int_field(jnienv, dbclass, retval,
- "st_nmodes", statp->st_nmodes);
- set_int_field(jnienv, dbclass, retval,
- "st_nlockers", statp->st_nlockers);
- set_int_field(jnienv, dbclass, retval,
- "st_nconflicts", statp->st_nconflicts);
- set_int_field(jnienv, dbclass, retval,
- "st_nrequests", statp->st_nrequests);
- set_int_field(jnienv, dbclass, retval,
- "st_nreleases", statp->st_nreleases);
- set_int_field(jnienv, dbclass, retval,
- "st_ndeadlocks", statp->st_ndeadlocks);
- set_int_field(jnienv, dbclass, retval,
- "st_region_wait", statp->st_region_wait);
- set_int_field(jnienv, dbclass, retval,
- "st_region_nowait", statp->st_region_nowait);
- set_int_field(jnienv, dbclass, retval,
- "st_regsize", statp->st_regsize);
-
- free(statp);
+ __jv_fill_lock_stat(jnienv, dbclass, retval, statp);
+
+err: __os_ufree(dbenv, statp);
}
- JAVADB_ENV_API_END(dbenv);
return (retval);
}
@@ -618,10 +690,8 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_lock_1detect
if (!verify_non_null(jnienv, dbenv))
return (0);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = lock_detect(dbenv, atype, flags, &aborted);
+ err = dbenv->lock_detect(dbenv, atype, flags, &aborted);
verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
return (aborted);
}
@@ -632,33 +702,260 @@ JNIEXPORT /*DbLock*/ jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1get
int err;
DB_ENV *dbenv;
DB_LOCK *dblock;
- JDBT dbobj;
+ LOCKED_DBT lobj;
/*DbLock*/ jobject retval;
dbenv = get_DB_ENV(jnienv, jthis);
if (!verify_non_null(jnienv, dbenv))
return (NULL);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- dblock = (DB_LOCK*)malloc(sizeof(DB_LOCK));
+ if ((err = __os_malloc(dbenv, sizeof(DB_LOCK), &dblock)) != 0)
+ if (!verify_return(jnienv, err, 0))
+ return (NULL);
+
memset(dblock, 0, sizeof(DB_LOCK));
err = 0;
retval = NULL;
- if (jdbt_lock(&dbobj, jnienv, obj, inOp) != 0)
+ if (locked_dbt_get(&lobj, jnienv, dbenv, obj, inOp) != 0)
goto out;
- err = lock_get(dbenv, locker, flags, &dbobj.dbt->dbt,
+ err = dbenv->lock_get(dbenv, locker, flags, &lobj.javainfo->dbt,
(db_lockmode_t)lock_mode, dblock);
- if (verify_return(jnienv, err, 0)) {
+
+ if (err == DB_LOCK_NOTGRANTED)
+ report_notgranted_exception(jnienv,
+ "DbEnv.lock_get not granted",
+ DB_LOCK_GET, lock_mode, obj,
+ NULL, -1);
+ else if (verify_return(jnienv, err, 0)) {
retval = create_default_object(jnienv, name_DB_LOCK);
set_private_dbobj(jnienv, name_DB_LOCK, retval, dblock);
}
+
out:
- jdbt_unlock(&dbobj, jnienv);
- JAVADB_ENV_API_END(dbenv);
+ locked_dbt_put(&lobj, jnienv, dbenv);
return (retval);
}
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1vec
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*u_int32_t*/ jint locker,
+ jint flags, /*const Dbt*/ jobjectArray list, jint offset, jint count)
+{
+ DB_ENV *dbenv;
+ DB_LOCKREQ *lockreq;
+ DB_LOCKREQ *prereq; /* preprocessed requests */
+ DB_LOCKREQ *failedreq;
+ DB_LOCK *lockp;
+ LOCKED_DBT *locked_dbts;
+ int err;
+ int alloc_err;
+ int i;
+ size_t bytesize;
+ size_t ldbtsize;
+ jobject jlockreq;
+ db_lockop_t op;
+ jobject jobj;
+ jobject jlock;
+ int completed;
+
+ dbenv = get_DB_ENV(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbenv))
+ goto out0;
+
+ if ((*jnienv)->GetArrayLength(jnienv, list) < offset + count) {
+ report_exception(jnienv,
+ "DbEnv.lock_vec array not large enough",
+ 0, 0);
+ goto out0;
+ }
+
+ bytesize = sizeof(DB_LOCKREQ) * count;
+ if ((err = __os_malloc(dbenv, bytesize, &lockreq)) != 0) {
+ verify_return(jnienv, err, 0);
+ goto out0;
+ }
+ memset(lockreq, 0, bytesize);
+
+ ldbtsize = sizeof(LOCKED_DBT) * count;
+ if ((err = __os_malloc(dbenv, ldbtsize, &locked_dbts)) != 0) {
+ verify_return(jnienv, err, 0);
+ goto out1;
+ }
+ memset(lockreq, 0, ldbtsize);
+ prereq = &lockreq[0];
+
+ /* fill in the lockreq array */
+ for (i = 0, prereq = &lockreq[0]; i < count; i++, prereq++) {
+ jlockreq = (*jnienv)->GetObjectArrayElement(jnienv, list,
+ offset + i);
+ if (jlockreq == NULL) {
+ report_exception(jnienv,
+ "DbEnv.lock_vec list entry is null",
+ 0, 0);
+ goto out2;
+ }
+ op = (*jnienv)->GetIntField(jnienv, jlockreq,
+ fid_DbLockRequest_op);
+ prereq->op = op;
+
+ switch (op) {
+ case DB_LOCK_GET_TIMEOUT:
+ /* Needed: mode, timeout, obj. Returned: lock. */
+ prereq->op = (*jnienv)->GetIntField(jnienv, jlockreq,
+ fid_DbLockRequest_timeout);
+ /* FALLTHROUGH */
+ case DB_LOCK_GET:
+ /* Needed: mode, obj. Returned: lock. */
+ prereq->mode = (*jnienv)->GetIntField(jnienv, jlockreq,
+ fid_DbLockRequest_mode);
+ jobj = (*jnienv)->GetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_obj);
+ if ((err = locked_dbt_get(&locked_dbts[i], jnienv,
+ dbenv, jobj, inOp)) != 0)
+ goto out2;
+ prereq->obj = &locked_dbts[i].javainfo->dbt;
+ break;
+ case DB_LOCK_PUT:
+ /* Needed: lock. Ignored: mode, obj. */
+ jlock = (*jnienv)->GetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_lock);
+ if (!verify_non_null(jnienv, jlock))
+ goto out2;
+ lockp = get_DB_LOCK(jnienv, jlock);
+ if (!verify_non_null(jnienv, lockp))
+ goto out2;
+
+ prereq->lock = *lockp;
+ break;
+ case DB_LOCK_PUT_ALL:
+ case DB_LOCK_TIMEOUT:
+ /* Needed: (none). Ignored: lock, mode, obj. */
+ break;
+ case DB_LOCK_PUT_OBJ:
+ /* Needed: obj. Ignored: lock, mode. */
+ jobj = (*jnienv)->GetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_obj);
+ if ((err = locked_dbt_get(&locked_dbts[i], jnienv,
+ dbenv, jobj, inOp)) != 0)
+ goto out2;
+ prereq->obj = &locked_dbts[i].javainfo->dbt;
+ break;
+ default:
+ report_exception(jnienv,
+ "DbEnv.lock_vec bad op value",
+ 0, 0);
+ goto out2;
+ }
+ }
+
+ err = dbenv->lock_vec(dbenv, locker, flags, lockreq, count, &failedreq);
+ if (err == 0)
+ completed = count;
+ else
+ completed = failedreq - lockreq;
+
+ /* do post processing for any and all requests that completed */
+ for (i = 0; i < completed; i++) {
+ op = lockreq[i].op;
+ if (op == DB_LOCK_PUT) {
+ /*
+ * After a successful put, the DbLock can no longer
+ * be used, so we release the storage related to it.
+ */
+ jlockreq = (*jnienv)->GetObjectArrayElement(jnienv,
+ list, i + offset);
+ jlock = (*jnienv)->GetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_lock);
+ lockp = get_DB_LOCK(jnienv, jlock);
+ __os_free(NULL, lockp);
+ set_private_dbobj(jnienv, name_DB_LOCK, jlock, 0);
+ }
+ else if (op == DB_LOCK_GET) {
+ /*
+ * Store the lock that was obtained.
+ * We need to create storage for it since
+ * the lockreq array only exists during this
+ * method call.
+ */
+ alloc_err = __os_malloc(dbenv, sizeof(DB_LOCK), &lockp);
+ if (!verify_return(jnienv, alloc_err, 0))
+ goto out2;
+
+ *lockp = lockreq[i].lock;
+
+ jlockreq = (*jnienv)->GetObjectArrayElement(jnienv,
+ list, i + offset);
+ jlock = create_default_object(jnienv, name_DB_LOCK);
+ set_private_dbobj(jnienv, name_DB_LOCK, jlock, lockp);
+ (*jnienv)->SetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_lock,
+ jlock);
+ }
+ }
+
+ /* If one of the locks was not granted, build the exception now. */
+ if (err == DB_LOCK_NOTGRANTED && i < count) {
+ jlockreq = (*jnienv)->GetObjectArrayElement(jnienv,
+ list, i + offset);
+ jobj = (*jnienv)->GetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_obj);
+ jlock = (*jnienv)->GetObjectField(jnienv, jlockreq,
+ fid_DbLockRequest_lock);
+ report_notgranted_exception(jnienv,
+ "DbEnv.lock_vec incomplete",
+ lockreq[i].op,
+ lockreq[i].mode,
+ jobj,
+ jlock,
+ i);
+ }
+ else
+ verify_return(jnienv, err, 0);
+
+ out2:
+ /* Free the dbts that we have locked */
+ for (i = 0 ; i < (prereq - lockreq); i++) {
+ if ((op = lockreq[i].op) == DB_LOCK_GET ||
+ op == DB_LOCK_PUT_OBJ)
+ locked_dbt_put(&locked_dbts[i], jnienv, dbenv);
+ }
+ __os_free(dbenv, locked_dbts);
+
+ out1:
+ __os_free(dbenv, lockreq);
+
+ out0:
+ return;
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1put
+ (JNIEnv *jnienv, jobject jthis, /*DbLock*/ jobject jlock)
+{
+ int err;
+ DB_ENV *dbenv;
+ DB_LOCK *dblock;
+
+ dbenv = get_DB_ENV(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbenv))
+ return;
+
+ dblock = get_DB_LOCK(jnienv, jlock);
+ if (!verify_non_null(jnienv, dblock))
+ return;
+
+ err = dbenv->lock_put(dbenv, dblock);
+ if (verify_return(jnienv, err, 0)) {
+ /*
+ * After a successful put, the DbLock can no longer
+ * be used, so we release the storage related to it
+ * (allocated in DbEnv.lock_get()).
+ */
+ __os_free(NULL, dblock);
+
+ set_private_dbobj(jnienv, name_DB_LOCK, jlock, 0);
+ }
+}
+
JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_log_1archive
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
@@ -672,8 +969,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_log_1archive
strarray = NULL;
if (!verify_non_null(jnienv, dbenv))
return (0);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = log_archive(dbenv, &ret, flags, 0);
+ err = dbenv->log_archive(dbenv, &ret, flags);
if (!verify_return(jnienv, err, 0))
return (0);
@@ -682,16 +978,16 @@ JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_log_1archive
while (ret[len] != NULL)
len++;
stringClass = (*jnienv)->FindClass(jnienv, "java/lang/String");
- strarray = (*jnienv)->NewObjectArray(jnienv, len,
- stringClass, 0);
+ if ((strarray = (*jnienv)->NewObjectArray(jnienv,
+ len, stringClass, 0)) == NULL)
+ goto out;
for (i=0; i<len; i++) {
jstring str = (*jnienv)->NewStringUTF(jnienv, ret[i]);
(*jnienv)->SetObjectArrayElement(jnienv, strarray,
- i, str);
+ i, str);
}
}
- JAVADB_ENV_API_END(dbenv);
- return (strarray);
+out: return (strarray);
}
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_log_1compare
@@ -708,80 +1004,40 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_log_1compare
return (log_compare(dblsn0, dblsn1));
}
-JNIEXPORT jstring JNICALL Java_com_sleepycat_db_DbEnv_log_1file
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbLsn*/ jobject lsn)
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1cursor
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err;
+ DB_LOGC *dblogc;
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
- DB_LSN *dblsn = get_DB_LSN(jnienv, lsn);
- char filename[FILENAME_MAX+1] = "";
if (!verify_non_null(jnienv, dbenv))
return (NULL);
-
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- err = log_file(dbenv, dblsn, filename, FILENAME_MAX);
+ err = dbenv->log_cursor(dbenv, &dblogc, flags);
verify_return(jnienv, err, 0);
- filename[FILENAME_MAX] = '\0'; /* just to be sure */
- JAVADB_ENV_API_END(dbenv);
- return (get_java_string(jnienv, filename));
+ return (get_DbLogc(jnienv, dblogc));
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1flush
+JNIEXPORT jstring JNICALL Java_com_sleepycat_db_DbEnv_log_1file
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbLsn*/ jobject lsn)
{
int err;
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
DB_LSN *dblsn = get_DB_LSN(jnienv, lsn);
+ char filename[FILENAME_MAX+1] = "";
if (!verify_non_null(jnienv, dbenv))
- return;
-
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
+ return (NULL);
- err = log_flush(dbenv, dblsn);
+ err = dbenv->log_file(dbenv, dblsn, filename, FILENAME_MAX);
verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
+ filename[FILENAME_MAX] = '\0'; /* just to be sure */
+ return (get_java_string(jnienv, filename));
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1get
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbLsn*/ jobject lsn,
- /*DbDbt*/ jobject data, jint flags)
-{
- int err, retry;
- DB_ENV *dbenv;
- DB_LSN *dblsn;
- JDBT dbdata;
-
- dbenv = get_DB_ENV(jnienv, jthis);
- dblsn = get_DB_LSN(jnienv, lsn);
-
- if (!verify_non_null(jnienv, dbenv))
- return;
-
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- if (jdbt_lock(&dbdata, jnienv, data, outOp) != 0)
- goto out;
-
- for (retry = 0; retry < 3; retry++) {
- err = log_get(dbenv, dblsn, &dbdata.dbt->dbt, flags);
- /* If we failed due to lack of memory in our DBT arrays,
- * retry.
- */
- if (err != ENOMEM)
- break;
- if (!jdbt_realloc(&dbdata, jnienv))
- break;
- }
-
- verify_return(jnienv, err, 0);
-
- out:
- jdbt_unlock(&dbdata, jnienv);
- JAVADB_ENV_API_END(dbenv);
-}
+JAVADB_METHOD(DbEnv_log_1flush,
+ (JAVADB_ARGS, /*DbLsn*/ jobject lsn), DB_ENV,
+ log_flush, (c_this, get_DB_LSN(jnienv, lsn)))
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1put
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbLsn*/ jobject lsn,
@@ -790,72 +1046,28 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1put
int err;
DB_ENV *dbenv;
DB_LSN *dblsn;
- JDBT dbdata;
+ LOCKED_DBT ldata;
dbenv = get_DB_ENV(jnienv, jthis);
dblsn = get_DB_LSN(jnienv, lsn);
if (!verify_non_null(jnienv, dbenv))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- if (jdbt_lock(&dbdata, jnienv, data, inOp) != 0)
- goto out;
-
- err = log_put(dbenv, dblsn, &dbdata.dbt->dbt, flags);
- verify_return(jnienv, err, 0);
- out:
- jdbt_unlock(&dbdata, jnienv);
- JAVADB_ENV_API_END(dbenv);
-}
-
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1register
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*Db*/ jobject dbp,
- jstring name)
-{
- int err;
- DB_ENV *dbenv;
- DB *dbdb;
- JSTR dbname;
-
- dbenv = get_DB_ENV(jnienv, jthis);
- dbdb = get_DB(jnienv, dbp);
- if (!verify_non_null(jnienv, dbenv))
+ /* log_put's DB_LSN argument may not be NULL. */
+ if (!verify_non_null(jnienv, dblsn))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- if (jstr_lock(&dbname, jnienv, name) != 0)
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, inOp) != 0)
goto out;
- err = log_register(dbenv, dbdb, dbname.string);
+ err = dbenv->log_put(dbenv, dblsn, &ldata.javainfo->dbt, flags);
verify_return(jnienv, err, 0);
out:
- jstr_unlock(&dbname, jnienv);
- JAVADB_ENV_API_END(dbenv);
-}
-
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1unregister
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*Db*/ jobject dbp)
-{
- int err;
- DB_ENV *dbenv;
- DB *dbdb;
-
- dbenv = get_DB_ENV(jnienv, jthis);
- dbdb = get_DB(jnienv, dbp);
- if (!verify_non_null(jnienv, dbenv))
- return;
-
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- err = log_unregister(dbenv, dbdb);
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
+ locked_dbt_put(&ldata, jnienv, dbenv);
}
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1stat
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err;
DB_ENV *dbenv;
@@ -869,59 +1081,22 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1stat
if (!verify_non_null(jnienv, dbenv))
return (NULL);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- /* We cannot use the default allocator (on Win* platforms anyway)
- * because it often causes problems when we free storage
- * in a DLL that was allocated in another DLL. Using
- * our own allocator (ours just calls malloc!) ensures
- * that there is no mismatch.
- */
- err = log_stat(dbenv, &statp, NULL);
+ err = dbenv->log_stat(dbenv, &statp, (u_int32_t)flags);
if (verify_return(jnienv, err, 0)) {
- retval = create_default_object(jnienv, name_DB_LOG_STAT);
- dbclass = get_class(jnienv, name_DB_LOG_STAT);
+ if ((dbclass = get_class(jnienv, name_DB_LOG_STAT)) == NULL ||
+ (retval =
+ create_default_object(jnienv, name_DB_LOG_STAT)) == NULL)
+ goto err; /* An exception has been posted. */
- /* Set the individual fields */
- set_int_field(jnienv, dbclass, retval,
- "st_magic", statp->st_magic);
- set_int_field(jnienv, dbclass, retval,
- "st_version", statp->st_version);
- set_int_field(jnienv, dbclass, retval,
- "st_mode", statp->st_mode);
- set_int_field(jnienv, dbclass, retval,
- "st_lg_max", statp->st_lg_max);
- set_int_field(jnienv, dbclass, retval,
- "st_w_bytes", statp->st_w_bytes);
- set_int_field(jnienv, dbclass, retval,
- "st_w_mbytes", statp->st_w_mbytes);
- set_int_field(jnienv, dbclass, retval,
- "st_wc_bytes", statp->st_wc_bytes);
- set_int_field(jnienv, dbclass, retval,
- "st_wc_mbytes", statp->st_wc_mbytes);
- set_int_field(jnienv, dbclass, retval,
- "st_wcount", statp->st_wcount);
- set_int_field(jnienv, dbclass, retval,
- "st_scount", statp->st_scount);
- set_int_field(jnienv, dbclass, retval,
- "st_region_wait", statp->st_region_wait);
- set_int_field(jnienv, dbclass, retval,
- "st_region_nowait", statp->st_region_nowait);
- set_int_field(jnienv, dbclass, retval,
- "st_cur_file", statp->st_cur_file);
- set_int_field(jnienv, dbclass, retval,
- "st_cur_offset", statp->st_cur_offset);
- set_int_field(jnienv, dbclass, retval,
- "st_regsize", statp->st_regsize);
-
- free(statp);
+ __jv_fill_log_stat(jnienv, dbclass, retval, statp);
+
+err: __os_ufree(dbenv, statp);
}
- JAVADB_ENV_API_END(dbenv);
return (retval);
}
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_memp_1stat
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err;
jclass dbclass;
@@ -935,65 +1110,22 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_memp_1stat
if (!verify_non_null(jnienv, dbenv))
return (NULL);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- /* We cannot use the default allocator (on Win* platforms anyway)
- * because it often causes problems when we free storage
- * in a DLL that was allocated in another DLL. Using
- * our own allocator (ours just calls malloc!) ensures
- * that there is no mismatch.
- */
- err = memp_stat(dbenv, &statp, 0, NULL);
+ err = dbenv->memp_stat(dbenv, &statp, 0, (u_int32_t)flags);
if (verify_return(jnienv, err, 0)) {
- retval = create_default_object(jnienv, name_DB_MPOOL_STAT);
- dbclass = get_class(jnienv, name_DB_MPOOL_STAT);
-
- set_int_field(jnienv, dbclass, retval, "st_cachesize", 0);
- set_int_field(jnienv, dbclass, retval,
- "st_cache_hit", statp->st_cache_hit);
- set_int_field(jnienv, dbclass, retval,
- "st_cache_miss", statp->st_cache_miss);
- set_int_field(jnienv, dbclass, retval,
- "st_map", statp->st_map);
- set_int_field(jnienv, dbclass, retval,
- "st_page_create", statp->st_page_create);
- set_int_field(jnienv, dbclass, retval,
- "st_page_in", statp->st_page_in);
- set_int_field(jnienv, dbclass, retval,
- "st_page_out", statp->st_page_out);
- set_int_field(jnienv, dbclass, retval,
- "st_ro_evict", statp->st_ro_evict);
- set_int_field(jnienv, dbclass, retval,
- "st_rw_evict", statp->st_rw_evict);
- set_int_field(jnienv, dbclass, retval,
- "st_hash_buckets", statp->st_hash_buckets);
- set_int_field(jnienv, dbclass, retval,
- "st_hash_searches", statp->st_hash_searches);
- set_int_field(jnienv, dbclass, retval,
- "st_hash_longest", statp->st_hash_longest);
- set_int_field(jnienv, dbclass, retval,
- "st_hash_examined", statp->st_hash_examined);
- set_int_field(jnienv, dbclass, retval,
- "st_page_clean", statp->st_page_clean);
- set_int_field(jnienv, dbclass, retval,
- "st_page_dirty", statp->st_page_dirty);
- set_int_field(jnienv, dbclass, retval,
- "st_page_trickle", statp->st_page_trickle);
- set_int_field(jnienv, dbclass, retval,
- "st_region_wait", statp->st_region_wait);
- set_int_field(jnienv, dbclass, retval,
- "st_region_nowait", statp->st_region_nowait);
- set_int_field(jnienv, dbclass, retval,
- "st_regsize", statp->st_regsize);
-
- free(statp);
+ if ((dbclass = get_class(jnienv, name_DB_MPOOL_STAT)) == NULL ||
+ (retval =
+ create_default_object(jnienv, name_DB_MPOOL_STAT)) == NULL)
+ goto err; /* An exception has been posted. */
+
+ __jv_fill_mpool_stat(jnienv, dbclass, retval, statp);
+
+err: __os_ufree(dbenv, statp);
}
- JAVADB_ENV_API_END(dbenv);
return (retval);
}
JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_memp_1fstat
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err, i, len;
jclass fstat_class;
@@ -1009,57 +1141,49 @@ JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_memp_1fstat
if (!verify_non_null(jnienv, dbenv))
return (NULL);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- /* We cannot use the default allocator (on Win* platforms anyway)
- * because it often causes problems when we free storage
- * in a DLL that was allocated in another DLL. Using
- * our own allocator (ours just calls malloc!) ensures
- * that there is no mismatch.
- */
- err = memp_stat(dbenv, 0, &fstatp, NULL);
+ err = dbenv->memp_stat(dbenv, 0, &fstatp, (u_int32_t)flags);
if (verify_return(jnienv, err, 0)) {
len = 0;
- while (fstatp[len])
+ while (fstatp[len] != NULL)
len++;
- fstat_class = get_class(jnienv, name_DB_MPOOL_FSTAT);
- retval = (*jnienv)->NewObjectArray(jnienv, len,
- fstat_class, 0);
+ if ((fstat_class =
+ get_class(jnienv, name_DB_MPOOL_FSTAT)) == NULL ||
+ (retval = (*jnienv)->NewObjectArray(jnienv, len,
+ fstat_class, 0)) == NULL)
+ goto err;
for (i=0; i<len; i++) {
- jobject obj = create_default_object(jnienv,
- name_DB_MPOOL_FSTAT);
+ jobject obj;
+ if ((obj = create_default_object(jnienv,
+ name_DB_MPOOL_FSTAT)) == NULL)
+ goto err;
(*jnienv)->SetObjectArrayElement(jnienv, retval,
- i, obj);
+ i, obj);
/* Set the string field. */
- filename_id =
- (*jnienv)->GetFieldID(jnienv, fstat_class,
- "file_name",
- string_signature);
- jfilename =
- get_java_string(jnienv, fstatp[i]->file_name);
+ filename_id = (*jnienv)->GetFieldID(jnienv,
+ fstat_class, "file_name", string_signature);
+ jfilename = get_java_string(jnienv,
+ fstatp[i]->file_name);
(*jnienv)->SetObjectField(jnienv, obj,
- filename_id, jfilename);
-
+ filename_id, jfilename);
set_int_field(jnienv, fstat_class, obj,
- "st_pagesize", fstatp[i]->st_pagesize);
+ "st_pagesize", fstatp[i]->st_pagesize);
set_int_field(jnienv, fstat_class, obj,
- "st_cache_hit", fstatp[i]->st_cache_hit);
+ "st_cache_hit", fstatp[i]->st_cache_hit);
set_int_field(jnienv, fstat_class, obj,
- "st_cache_miss", fstatp[i]->st_cache_miss);
+ "st_cache_miss", fstatp[i]->st_cache_miss);
set_int_field(jnienv, fstat_class, obj,
- "st_map", fstatp[i]->st_map);
+ "st_map", fstatp[i]->st_map);
set_int_field(jnienv, fstat_class, obj,
- "st_page_create", fstatp[i]->st_page_create);
+ "st_page_create", fstatp[i]->st_page_create);
set_int_field(jnienv, fstat_class, obj,
- "st_page_in", fstatp[i]->st_page_in);
+ "st_page_in", fstatp[i]->st_page_in);
set_int_field(jnienv, fstat_class, obj,
- "st_page_out", fstatp[i]->st_page_out);
- free(fstatp[i]);
+ "st_page_out", fstatp[i]->st_page_out);
+ __os_ufree(dbenv, fstatp[i]);
}
- free(fstatp);
+err: __os_ufree(dbenv, fstatp);
}
- JAVADB_ENV_API_END(dbenv);
return (retval);
}
@@ -1071,10 +1195,8 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_memp_1trickle
int result = 0;
if (verify_non_null(jnienv, dbenv)) {
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = memp_trickle(dbenv, pct, &result);
+ err = dbenv->memp_trickle(dbenv, pct, &result);
verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
}
return (result);
}
@@ -1090,36 +1212,21 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1begin
if (!verify_non_null(jnienv, dbenv))
return (0);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
dbpid = get_DB_TXN(jnienv, pid);
result = 0;
- err = txn_begin(dbenv, dbpid, &result, flags);
+ err = dbenv->txn_begin(dbenv, dbpid, &result, flags);
if (!verify_return(jnienv, err, 0))
return (0);
- JAVADB_ENV_API_END(dbenv);
return (get_DbTxn(jnienv, result));
}
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_txn_1checkpoint
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint kbyte, jint min, jint flags)
-{
- int err;
- DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
-
- if (!verify_non_null(jnienv, dbenv))
- return (0);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- err = txn_checkpoint(dbenv, kbyte, min, flags);
- if (err != DB_INCOMPLETE)
- verify_return(jnienv, err, 0);
- JAVADB_ENV_API_END(dbenv);
- return (err);
-}
+JAVADB_METHOD(DbEnv_txn_1checkpoint,
+ (JAVADB_ARGS, jint kbyte, jint min, jint flags), DB_ENV,
+ txn_checkpoint, (c_this, kbyte, min, flags))
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_tx_1recover_1changed
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbFeedback*/ jobject jtxrecover)
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_app_1dispatch_1changed
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbFeedback*/ jobject jappdispatch)
{
DB_ENV *dbenv;
DB_ENV_JAVAINFO *dbenvinfo;
@@ -1130,13 +1237,96 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_tx_1recover_1changed
!verify_non_null(jnienv, dbenvinfo))
return;
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
- dbjie_set_tx_recover_object(dbenvinfo, jnienv, dbenv, jtxrecover);
- JAVADB_ENV_API_END(dbenv);
+ dbjie_set_app_dispatch_object(dbenvinfo, jnienv, dbenv, jappdispatch);
+}
+
+JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_txn_1recover
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint count, jint flags)
+{
+ int err;
+ DB_ENV *dbenv;
+ DB_PREPLIST *preps;
+ long retcount;
+ int i;
+ char signature[128];
+ size_t bytesize;
+ jobject retval;
+ jobject obj;
+ jobject txnobj;
+ jbyteArray bytearr;
+ jclass preplist_class;
+ jfieldID txn_fieldid;
+ jfieldID gid_fieldid;
+
+ retval = NULL;
+ dbenv = get_DB_ENV(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbenv))
+ return (NULL);
+
+ /*
+ * We need to allocate some local storage for the
+ * returned preplist, and that requires us to do
+ * our own argument validation.
+ */
+ if (count <= 0) {
+ verify_return(jnienv, EINVAL, 0);
+ goto out;
+ }
+
+ bytesize = sizeof(DB_PREPLIST) * count;
+ if ((err = __os_malloc(dbenv, bytesize, &preps)) != 0) {
+ verify_return(jnienv, err, 0);
+ goto out;
+ }
+
+ err = dbenv->txn_recover(dbenv, preps, count, &retcount, flags);
+
+ if (verify_return(jnienv, err, 0)) {
+ if ((preplist_class =
+ get_class(jnienv, name_DB_PREPLIST)) == NULL ||
+ (retval = (*jnienv)->NewObjectArray(jnienv, retcount,
+ preplist_class, 0)) == NULL)
+ goto err;
+
+ (void)snprintf(signature, sizeof(signature),
+ "L%s%s;", DB_PACKAGE_NAME, name_DB_TXN);
+ txn_fieldid = (*jnienv)->GetFieldID(jnienv, preplist_class,
+ "txn", signature);
+ gid_fieldid = (*jnienv)->GetFieldID(jnienv, preplist_class,
+ "gid", "[B");
+
+ for (i=0; i<retcount; i++) {
+ /*
+ * First, make a blank DbPreplist object
+ * and set the array entry.
+ */
+ if ((obj = create_default_object(jnienv,
+ name_DB_PREPLIST)) == NULL)
+ goto err;
+ (*jnienv)->SetObjectArrayElement(jnienv,
+ retval, i, obj);
+
+ /* Set the txn field. */
+ txnobj = get_DbTxn(jnienv, preps[i].txn);
+ (*jnienv)->SetObjectField(jnienv,
+ obj, txn_fieldid, txnobj);
+
+ /* Build the gid array and set the field. */
+ if ((bytearr = (*jnienv)->NewByteArray(jnienv,
+ sizeof(preps[i].gid))) == NULL)
+ goto err;
+ (*jnienv)->SetByteArrayRegion(jnienv, bytearr, 0,
+ sizeof(preps[i].gid), (jbyte *)&preps[i].gid[0]);
+ (*jnienv)->SetObjectField(jnienv, obj,
+ gid_fieldid, bytearr);
+ }
+ }
+err: __os_free(dbenv, preps);
+out: return (retval);
}
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1stat
- (JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
+ (JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
{
int err;
DB_ENV *dbenv;
@@ -1154,57 +1344,29 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1stat
if (!verify_non_null(jnienv, dbenv))
return (NULL);
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
-
- /* We cannot use the default allocator (on Win* platforms anyway)
- * because it often causes problems when we free storage
- * in a DLL that was allocated in another DLL. Using
- * our own allocator (ours just calls malloc!) ensures
- * that there is no mismatch.
- */
- err = txn_stat(dbenv, &statp, NULL);
+ err = dbenv->txn_stat(dbenv, &statp, (u_int32_t)flags);
if (verify_return(jnienv, err, 0)) {
- retval = create_default_object(jnienv, name_DB_TXN_STAT);
- dbclass = get_class(jnienv, name_DB_TXN_STAT);
+ if ((dbclass = get_class(jnienv, name_DB_TXN_STAT)) == NULL ||
+ (retval =
+ create_default_object(jnienv, name_DB_TXN_STAT)) == NULL)
+ goto err;
/* Set the individual fields */
+ __jv_fill_txn_stat(jnienv, dbclass, retval, statp);
+
+ if ((active_class =
+ get_class(jnienv, name_DB_TXN_STAT_ACTIVE)) == NULL ||
+ (actives = (*jnienv)->NewObjectArray(jnienv,
+ statp->st_nactive, active_class, 0)) == NULL)
+ goto err;
- set_lsn_field(jnienv, dbclass, retval,
- "st_last_ckp", statp->st_last_ckp);
- set_lsn_field(jnienv, dbclass, retval,
- "st_pending_ckp", statp->st_pending_ckp);
- set_long_field(jnienv, dbclass, retval,
- "st_time_ckp", statp->st_time_ckp);
- set_int_field(jnienv, dbclass, retval,
- "st_last_txnid", statp->st_last_txnid);
- set_int_field(jnienv, dbclass, retval,
- "st_maxtxns", statp->st_maxtxns);
- set_int_field(jnienv, dbclass, retval,
- "st_naborts", statp->st_naborts);
- set_int_field(jnienv, dbclass, retval,
- "st_nbegins", statp->st_nbegins);
- set_int_field(jnienv, dbclass, retval,
- "st_ncommits", statp->st_ncommits);
- set_int_field(jnienv, dbclass, retval,
- "st_nactive", statp->st_nactive);
- set_int_field(jnienv, dbclass, retval,
- "st_maxnactive", statp->st_maxnactive);
-
- active_class = get_class(jnienv, name_DB_TXN_STAT_ACTIVE);
- actives =
- (*jnienv)->NewObjectArray(jnienv, statp->st_nactive,
- active_class, 0);
-
- /* Set the st_txnarray field. This is a little more involved
+ /*
+ * Set the st_txnarray field. This is a little more involved
* than other fields, since the type is an array, so none
* of our utility functions help.
*/
- strncpy(active_signature, "[L", sizeof(active_signature));
- strncat(active_signature, DB_PACKAGE_NAME,
- sizeof(active_signature));
- strncat(active_signature, name_DB_TXN_STAT_ACTIVE,
- sizeof(active_signature));
- strncat(active_signature, ";", sizeof(active_signature));
+ (void)snprintf(active_signature, sizeof(active_signature),
+ "[L%s%s;", DB_PACKAGE_NAME, name_DB_TXN_STAT_ACTIVE);
arrid = (*jnienv)->GetFieldID(jnienv, dbclass, "st_txnarray",
active_signature);
@@ -1212,26 +1374,21 @@ JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1stat
/* Now fill the in the elements of st_txnarray. */
for (i=0; i<statp->st_nactive; i++) {
- obj = create_default_object(jnienv, name_DB_TXN_STAT_ACTIVE);
- (*jnienv)->SetObjectArrayElement(jnienv, actives, i, obj);
+ obj = create_default_object(jnienv,
+ name_DB_TXN_STAT_ACTIVE);
+ (*jnienv)->SetObjectArrayElement(jnienv,
+ actives, i, obj);
set_int_field(jnienv, active_class, obj,
"txnid", statp->st_txnarray[i].txnid);
- set_int_field(jnienv, active_class, obj,
- "parentid", statp->st_txnarray[i].parentid);
+ set_int_field(jnienv, active_class, obj, "parentid",
+ statp->st_txnarray[i].parentid);
set_lsn_field(jnienv, active_class, obj,
"lsn", statp->st_txnarray[i].lsn);
}
- set_int_field(jnienv, dbclass, retval,
- "st_region_wait", statp->st_region_wait);
- set_int_field(jnienv, dbclass, retval,
- "st_region_nowait", statp->st_region_nowait);
- set_int_field(jnienv, dbclass, retval,
- "st_regsize", statp->st_regsize);
-
- free(statp);
+
+err: __os_ufree(dbenv, statp);
}
- JAVADB_ENV_API_END(dbenv);
return (retval);
}
@@ -1247,10 +1404,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1set_1errcall
if (verify_non_null(jnienv, dbenv) &&
verify_non_null(jnienv, dbenvinfo)) {
-
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
dbjie_set_errcall(dbenvinfo, jnienv, errcall);
- JAVADB_ENV_API_END(dbenv);
}
}
@@ -1265,10 +1419,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1set_1errpfx
if (verify_non_null(jnienv, dbenv) &&
verify_non_null(jnienv, dbenvinfo)) {
-
- JAVADB_ENV_API_BEGIN(dbenv, jthis);
dbjie_set_errpfx(dbenvinfo, jnienv, str);
- JAVADB_ENV_API_END(dbenv);
}
}
@@ -1283,8 +1434,7 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1finalize
envinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
DB_ASSERT(envinfo != NULL);
- /* Note: We detect unclosed DbEnvs and report it.
- */
+ /* Note: We detect and report unclosed DbEnvs. */
if (dbenv != NULL && envinfo != NULL && !dbjie_is_dbopen(envinfo)) {
/* If this error occurs, this object was never closed. */
diff --git a/bdb/libdb_java/java_DbLock.c b/bdb/libdb_java/java_DbLock.c
index 287ca6622e5..00a9836bfa0 100644
--- a/bdb/libdb_java/java_DbLock.c
+++ b/bdb/libdb_java/java_DbLock.c
@@ -1,55 +1,30 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_DbLock.c,v 11.4 2000/11/30 00:58:39 ubell Exp $";
+static const char revid[] = "$Id: java_DbLock.c,v 11.12 2002/02/28 21:27:38 ubell Exp $";
#endif /* not lint */
#include <jni.h>
#include <stdlib.h>
#include <string.h>
-#include "db.h"
+#include "db_int.h"
#include "java_util.h"
#include "com_sleepycat_db_DbLock.h"
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLock_put
- (JNIEnv *jnienv, jobject jthis, /*DbEnv*/ jobject env)
-{
- int err;
- DB_LOCK *dblock = get_DB_LOCK(jnienv, jthis);
- DB_ENV *dbenv = get_DB_ENV(jnienv, env);
-
- if (!verify_non_null(jnienv, dbenv))
- return;
-
- if (!verify_non_null(jnienv, dblock))
- return;
-
- err = lock_put(dbenv, dblock);
- if (verify_return(jnienv, err, 0)) {
- /* After a successful put, the DbLock can no longer
- * be used, so we release the storage related to it
- * (allocated in DbEnv.lock_get() or lock_tget()).
- */
- free(dblock);
-
- set_private_dbobj(jnienv, name_DB_LOCK, jthis, 0);
- }
-}
-
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLock_finalize
(JNIEnv *jnienv, jobject jthis)
{
DB_LOCK *dblock = get_DB_LOCK(jnienv, jthis);
if (dblock) {
/* Free any data related to DB_LOCK here */
- free(dblock);
+ __os_free(NULL, dblock);
}
set_private_dbobj(jnienv, name_DB_LOCK, jthis, 0); /* paranoia */
}
diff --git a/bdb/libdb_java/java_DbLogc.c b/bdb/libdb_java/java_DbLogc.c
new file mode 100644
index 00000000000..69294d9baac
--- /dev/null
+++ b/bdb/libdb_java/java_DbLogc.c
@@ -0,0 +1,110 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 1997-2002
+ * Sleepycat Software. All rights reserved.
+ */
+#include "db_config.h"
+
+#ifndef lint
+static const char revid[] = "$Id: java_DbLogc.c,v 11.6 2002/07/02 12:03:03 mjc Exp $";
+#endif /* not lint */
+
+#include <jni.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef DIAGNOSTIC
+#include <stdio.h>
+#endif
+
+#include "db_int.h"
+#include "java_util.h"
+#include "com_sleepycat_db_DbLogc.h"
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_close
+ (JNIEnv *jnienv, jobject jthis, jint flags)
+{
+ int err;
+ DB_LOGC *dblogc = get_DB_LOGC(jnienv, jthis);
+
+ if (!verify_non_null(jnienv, dblogc))
+ return;
+ err = dblogc->close(dblogc, flags);
+ if (verify_return(jnienv, err, 0)) {
+ set_private_dbobj(jnienv, name_DB_LOGC, jthis, 0);
+ }
+}
+
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get
+ (JNIEnv *jnienv, jobject jthis,
+ /*DbLsn*/ jobject lsn, /*Dbt*/ jobject data, jint flags)
+{
+ int err, retry;
+ DB_LOGC *dblogc;
+ DB_LSN *dblsn;
+ LOCKED_DBT ldata;
+ OpKind dataop;
+
+ /*
+ * Depending on flags, the user may be supplying the key,
+ * or else we may have to retrieve it.
+ */
+ err = 0;
+ dataop = outOp;
+
+ dblogc = get_DB_LOGC(jnienv, jthis);
+ dblsn = get_DB_LSN(jnienv, lsn);
+ if (locked_dbt_get(&ldata, jnienv, dblogc->dbenv, data, dataop) != 0)
+ goto out1;
+
+ if (!verify_non_null(jnienv, dblogc))
+ goto out1;
+
+ for (retry = 0; retry < 3; retry++) {
+ err = dblogc->get(dblogc, dblsn, &ldata.javainfo->dbt, flags);
+
+ /*
+ * If we failed due to lack of memory in our DBT arrays,
+ * retry.
+ */
+ if (err != ENOMEM)
+ break;
+ if (!locked_dbt_realloc(&ldata, jnienv, dblogc->dbenv))
+ break;
+ }
+ out1:
+ locked_dbt_put(&ldata, jnienv, dblogc->dbenv);
+ if (!DB_RETOK_LGGET(err)) {
+ if (verify_dbt(jnienv, err, &ldata))
+ verify_return(jnienv, err, 0);
+ }
+ return (err);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_finalize
+ (JNIEnv *jnienv, jobject jthis)
+{
+ /*
+ * Free any data related to DB_LOGC here.
+ * If we ever have java-only data embedded in the DB_LOGC
+ * and need to do this, we'll have to track DbLogc's
+ * according to which DbEnv owns them, just as
+ * we track Db's according to which DbEnv owns them.
+ * That's necessary to avoid double freeing that
+ * comes about when closes interact with GC.
+ */
+
+#ifdef DIAGNOSTIC
+ DB_LOGC *dblogc;
+
+ dblogc = get_DB_LOGC(jnienv, jthis);
+ if (dblogc != NULL)
+ fprintf(stderr, "Java API: DbLogc has not been closed\n");
+#else
+
+ COMPQUIET(jnienv, NULL);
+ COMPQUIET(jthis, NULL);
+
+#endif
+}
diff --git a/bdb/libdb_java/java_DbLsn.c b/bdb/libdb_java/java_DbLsn.c
index 8f26f2ecb58..d53082826f4 100644
--- a/bdb/libdb_java/java_DbLsn.c
+++ b/bdb/libdb_java/java_DbLsn.c
@@ -1,13 +1,13 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_DbLsn.c,v 11.5 2000/11/30 00:58:39 ubell Exp $";
+static const char revid[] = "$Id: java_DbLsn.c,v 11.12 2002/05/07 16:12:41 dda Exp $";
#endif /* not lint */
#include <jni.h>
@@ -15,7 +15,6 @@ static const char revid[] = "$Id: java_DbLsn.c,v 11.5 2000/11/30 00:58:39 ubell
#include <string.h>
#include <stdio.h> /* needed for FILENAME_MAX */
-#include "db.h"
#include "db_int.h"
#include "java_util.h"
#include "com_sleepycat_db_DbLsn.h"
@@ -23,8 +22,9 @@ static const char revid[] = "$Id: java_DbLsn.c,v 11.5 2000/11/30 00:58:39 ubell
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLsn_init_1lsn
(JNIEnv *jnienv, /*DbLsn*/ jobject jthis)
{
- /* Note: the DB_LSN object stored in the private_dbobj_
- * is allocated in get_DbLsn().
+ /*
+ * Note: the DB_LSN object stored in the private_dbobj_
+ * is allocated in get_DbLsn() or get_DB_LSN().
*/
COMPQUIET(jnienv, NULL);
@@ -38,6 +38,6 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLsn_finalize
dblsn = get_DB_LSN(jnienv, jthis);
if (dblsn) {
- free(dblsn);
+ (void)__os_free(NULL, dblsn);
}
}
diff --git a/bdb/libdb_java/java_DbTxn.c b/bdb/libdb_java/java_DbTxn.c
index 67c2599a6fc..51195501b77 100644
--- a/bdb/libdb_java/java_DbTxn.c
+++ b/bdb/libdb_java/java_DbTxn.c
@@ -1,13 +1,13 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_DbTxn.c,v 11.3 2000/09/18 18:32:25 dda Exp $";
+static const char revid[] = "$Id: java_DbTxn.c,v 11.16 2002/08/06 05:19:05 bostic Exp $";
#endif /* not lint */
#include <jni.h>
@@ -15,33 +15,16 @@ static const char revid[] = "$Id: java_DbTxn.c,v 11.3 2000/09/18 18:32:25 dda Ex
#include <stdlib.h>
#include <string.h>
-#include "db.h"
+#include "db_int.h"
#include "java_util.h"
#include "com_sleepycat_db_DbTxn.h"
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_abort
- (JNIEnv *jnienv, jobject jthis)
-{
- int err;
- DB_TXN *dbtxn = get_DB_TXN(jnienv, jthis);
- if (!verify_non_null(jnienv, dbtxn))
- return;
-
- err = txn_abort(dbtxn);
- verify_return(jnienv, err, 0);
-}
-
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_commit
- (JNIEnv *jnienv, jobject jthis, jint flags)
-{
- int err;
- DB_TXN *dbtxn = get_DB_TXN(jnienv, jthis);
- if (!verify_non_null(jnienv, dbtxn))
- return;
-
- err = txn_commit(dbtxn, flags);
- verify_return(jnienv, err, 0);
-}
+JAVADB_METHOD(DbTxn_abort, (JAVADB_ARGS), DB_TXN,
+ abort, (c_this))
+JAVADB_METHOD(DbTxn_commit, (JAVADB_ARGS, jint flags), DB_TXN,
+ commit, (c_this, flags))
+JAVADB_METHOD(DbTxn_discard, (JAVADB_ARGS, jint flags), DB_TXN,
+ discard, (c_this, flags))
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbTxn_id
(JNIEnv *jnienv, jobject jthis)
@@ -51,32 +34,34 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbTxn_id
if (!verify_non_null(jnienv, dbtxn))
return (-1);
- /* No error to check for from txn_id */
- retval = txn_id(dbtxn);
+ /* No error to check for from DB_TXN->id */
+ retval = dbtxn->id(dbtxn);
return (retval);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_prepare
- (JNIEnv *jnienv, jobject jthis)
+ (JNIEnv *jnienv, jobject jthis, jbyteArray gid)
{
int err;
- DB_TXN *dbtxn = get_DB_TXN(jnienv, jthis);
+ DB_TXN *dbtxn;
+ jbyte *c_array;
+
+ dbtxn = get_DB_TXN(jnienv, jthis);
if (!verify_non_null(jnienv, dbtxn))
return;
- err = txn_prepare(dbtxn);
+ if (gid == NULL ||
+ (*jnienv)->GetArrayLength(jnienv, gid) < DB_XIDDATASIZE) {
+ report_exception(jnienv, "DbTxn.prepare gid array "
+ "must be >= 128 bytes", EINVAL, 0);
+ return;
+ }
+ c_array = (*jnienv)->GetByteArrayElements(jnienv, gid, NULL);
+ err = dbtxn->prepare(dbtxn, (u_int8_t *)c_array);
+ (*jnienv)->ReleaseByteArrayElements(jnienv, gid, c_array, 0);
verify_return(jnienv, err, 0);
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_DbTxn_finalize
- (JNIEnv *jnienv, jobject jthis)
-{
- DB_TXN *dbtxn = get_DB_TXN(jnienv, jthis);
- if (dbtxn) {
- /* Free any data related to DB_TXN here
- * Note: we don't make a policy of doing
- * a commit or abort here. The txnmgr
- * should be closed, and DB will clean up.
- */
- }
-}
+JAVADB_METHOD(DbTxn_set_1timeout,
+ (JAVADB_ARGS, jlong timeout, jint flags), DB_TXN,
+ set_timeout, (c_this, (u_int32_t)timeout, flags))
diff --git a/bdb/libdb_java/java_DbUtil.c b/bdb/libdb_java/java_DbUtil.c
new file mode 100644
index 00000000000..edcbc6d9f15
--- /dev/null
+++ b/bdb/libdb_java/java_DbUtil.c
@@ -0,0 +1,27 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2001-2002
+ * Sleepycat Software. All rights reserved.
+ */
+#include "db_config.h"
+
+#ifndef lint
+static const char revid[] = "$Id: java_DbUtil.c,v 1.5 2002/01/11 15:52:44 bostic Exp $";
+#endif /* not lint */
+
+#include <jni.h>
+
+#include "db_int.h"
+#include "java_util.h"
+#include "com_sleepycat_db_DbUtil.h"
+
+JNIEXPORT jboolean JNICALL
+Java_com_sleepycat_db_DbUtil_is_1big_1endian (JNIEnv *jnienv,
+ jclass jthis_class)
+{
+ COMPQUIET(jnienv, NULL);
+ COMPQUIET(jthis_class, NULL);
+
+ return (__db_isbigendian() ? JNI_TRUE : JNI_FALSE);
+}
diff --git a/bdb/libdb_java/java_DbXAResource.c b/bdb/libdb_java/java_DbXAResource.c
new file mode 100644
index 00000000000..609529bfe83
--- /dev/null
+++ b/bdb/libdb_java/java_DbXAResource.c
@@ -0,0 +1,288 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 1997-2001
+ * Sleepycat Software. All rights reserved.
+ */
+#include "db_config.h"
+
+#ifndef lint
+static const char revid[] = "$Id: java_DbXAResource.c,v 11.6 2002/08/06 05:19:06 bostic Exp $";
+#endif /* not lint */
+
+#include <jni.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef DIAGNOSTIC
+#include <stdio.h>
+#endif
+
+#include "db_int.h"
+#include "java_util.h"
+#include "dbinc/xa.h"
+#include "dbinc_auto/xa_ext.h"
+#include "com_sleepycat_db_xa_DbXAResource.h"
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1init
+ (JNIEnv *jnienv, jobject jthis, jstring home, jint rmid, jint flags)
+{
+ int err;
+ LOCKED_STRING ls_home;
+ jclass cl;
+ jmethodID mid;
+
+ COMPQUIET(jthis, NULL);
+ if (locked_string_get(&ls_home, jnienv, home) != 0)
+ goto out;
+ if ((err = __db_xa_open((char *)ls_home.string,
+ rmid, flags)) != XA_OK) {
+ verify_return(jnienv, err, EXCEPTION_XA);
+ }
+
+ /*
+ * Now create the DbEnv object, it will get attached
+ * to the DB_ENV just made in __db_xa_open.
+ */
+ if ((cl = get_class(jnienv, name_DB_ENV)) == NULL)
+ goto out;
+
+ mid = (*jnienv)->GetStaticMethodID(jnienv, cl,
+ "_create_DbEnv_for_XA", "(II)V");
+ (*jnienv)->CallStaticVoidMethod(jnienv, cl, mid, 0, rmid);
+
+ out:
+ locked_string_put(&ls_home, jnienv);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1close
+ (JNIEnv *jnienv, jobject jthis, jstring home, jint rmid, jint flags)
+{
+ int err;
+ LOCKED_STRING ls_home;
+
+ COMPQUIET(jthis, NULL);
+ if (locked_string_get(&ls_home, jnienv, home) != 0)
+ goto out;
+ if ((err = __db_xa_close((char *)ls_home.string,
+ rmid, flags)) != XA_OK)
+ verify_return(jnienv, err, EXCEPTION_XA);
+ out:
+ locked_string_put(&ls_home, jnienv);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1commit
+ (JNIEnv *jnienv, jobject jthis, jobject jxid, jint rmid,
+ jboolean onePhase)
+{
+ XID xid;
+ long flags;
+ int err;
+
+ COMPQUIET(jthis, NULL);
+ if (!get_XID(jnienv, jxid, &xid))
+ return;
+ flags = 0;
+ if (onePhase == JNI_TRUE)
+ flags |= TMONEPHASE;
+ if ((err = __db_xa_commit(&xid, rmid, flags)) != XA_OK)
+ verify_return(jnienv, err, EXCEPTION_XA);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1end
+ (JNIEnv *jnienv, jobject jthis, jobject jxid, jint rmid, jint flags)
+{
+ XID xid;
+ int err;
+
+ COMPQUIET(jthis, NULL);
+ if (!get_XID(jnienv, jxid, &xid))
+ return;
+ if ((err = __db_xa_end(&xid, rmid, flags)) != XA_OK)
+ verify_return(jnienv, err, EXCEPTION_XA);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1forget
+ (JNIEnv *jnienv, jobject jthis, jobject jxid, jint rmid)
+{
+ XID xid;
+ int err;
+
+ COMPQUIET(jthis, NULL);
+ if (!get_XID(jnienv, jxid, &xid))
+ return;
+ if ((err = __db_xa_forget(&xid, rmid, 0)) != XA_OK)
+ verify_return(jnienv, err, EXCEPTION_XA);
+}
+
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_xa_DbXAResource__1prepare
+ (JNIEnv *jnienv, jobject jthis, jobject jxid, jint rmid)
+{
+ XID xid;
+ int err;
+
+ COMPQUIET(jthis, NULL);
+ if (!get_XID(jnienv, jxid, &xid))
+ return (0);
+ err = __db_xa_prepare(&xid, rmid, 0);
+ if (err != XA_OK && err != XA_RDONLY)
+ verify_return(jnienv, err, EXCEPTION_XA);
+
+ return (err);
+}
+
+JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_xa_DbXAResource__1recover
+ (JNIEnv *jnienv, jobject jthis, jint rmid, jint flags)
+{
+ XID *xids;
+ int err;
+ int total;
+ int cnt;
+ int i;
+ int curflags;
+ size_t nbytes;
+ jclass xid_class;
+ jmethodID mid;
+ jobject obj;
+ jobjectArray retval;
+
+ COMPQUIET(jthis, NULL);
+ total = 0;
+ cnt = 0;
+ xids = NULL;
+ flags &= ~(DB_FIRST | DB_LAST | DB_NEXT);
+
+ /* Repeatedly call __db_xa_recover to fill up an array of XIDs */
+ curflags = flags | DB_FIRST;
+ do {
+ total += cnt;
+ nbytes = sizeof(XID) * (total + 10);
+ if ((err = __os_realloc(NULL, nbytes, &xids)) != 0) {
+ if (xids != NULL)
+ __os_free(NULL, xids);
+ verify_return(jnienv, XAER_NOTA, EXCEPTION_XA);
+ return (NULL);
+ }
+ cnt = __db_xa_recover(&xids[total], 10, rmid, curflags);
+ curflags = flags | DB_NEXT;
+ } while (cnt > 0);
+
+ if (xids != NULL)
+ __os_free(NULL, xids);
+
+ if (cnt < 0) {
+ verify_return(jnienv, cnt, EXCEPTION_XA);
+ return (NULL);
+ }
+
+ /* Create the java DbXid array and fill it up */
+ if ((xid_class = get_class(jnienv, name_DB_XID)) == NULL)
+ return (NULL);
+ mid = (*jnienv)->GetMethodID(jnienv, xid_class, "<init>",
+ "(I[B[B)V");
+ if ((retval = (*jnienv)->NewObjectArray(jnienv, total, xid_class, 0))
+ == NULL)
+ goto out;
+
+ for (i = 0; i < total; i++) {
+ jobject gtrid;
+ jobject bqual;
+ jsize gtrid_len;
+ jsize bqual_len;
+
+ gtrid_len = (jsize)xids[i].gtrid_length;
+ bqual_len = (jsize)xids[i].bqual_length;
+ gtrid = (*jnienv)->NewByteArray(jnienv, gtrid_len);
+ bqual = (*jnienv)->NewByteArray(jnienv, bqual_len);
+ if (gtrid == NULL || bqual == NULL)
+ goto out;
+ (*jnienv)->SetByteArrayRegion(jnienv, gtrid, 0, gtrid_len,
+ (jbyte *)&xids[i].data[0]);
+ (*jnienv)->SetByteArrayRegion(jnienv, bqual, 0, bqual_len,
+ (jbyte *)&xids[i].data[gtrid_len]);
+ if ((obj = (*jnienv)->NewObject(jnienv, xid_class, mid,
+ (jint)xids[i].formatID, gtrid, bqual)) == NULL)
+ goto out;
+ (*jnienv)->SetObjectArrayElement(jnienv, retval, i, obj);
+ }
+out: return (retval);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1rollback
+ (JNIEnv *jnienv, jobject jthis, jobject jxid, jint rmid)
+{
+ XID xid;
+ int err;
+
+ COMPQUIET(jthis, NULL);
+ if (!get_XID(jnienv, jxid, &xid))
+ return;
+ if ((err = __db_xa_rollback(&xid, rmid, 0)) != XA_OK)
+ verify_return(jnienv, err, EXCEPTION_XA);
+}
+
+JNIEXPORT void JNICALL Java_com_sleepycat_db_xa_DbXAResource__1start
+ (JNIEnv *jnienv, jobject jthis, jobject jxid, jint rmid, jint flags)
+{
+ XID xid;
+ int err;
+
+ COMPQUIET(jthis, NULL);
+ if (!get_XID(jnienv, jxid, &xid))
+ return;
+
+ if ((err = __db_xa_start(&xid, rmid, flags)) != XA_OK)
+ verify_return(jnienv, err, EXCEPTION_XA);
+}
+
+JNIEXPORT jobject JNICALL Java_com_sleepycat_db_xa_DbXAResource_xa_1attach
+ (JNIEnv *jnienv, jclass jthisclass, jobject jxid, jobject jrmid)
+{
+ XID xid;
+ XID *xidp;
+ int ret;
+ DB_ENV *env;
+ DB_TXN *txn;
+ int rmid;
+ int *rmidp;
+ jobject jtxn;
+ jobject jenv;
+ jclass cl;
+ jmethodID mid;
+
+ COMPQUIET(jthisclass, NULL);
+ if (jxid == NULL) {
+ xidp = NULL;
+ }
+ else {
+ xidp = &xid;
+ if (!get_XID(jnienv, jxid, &xid))
+ return (NULL);
+ }
+ if (jrmid == NULL) {
+ rmidp = NULL;
+ }
+ else {
+ rmidp = &rmid;
+ rmid = (int)(*jnienv)->CallIntMethod(jnienv, jrmid,
+ mid_Integer_intValue);
+ }
+
+ if ((ret = db_env_xa_attach(rmidp, xidp, &env, &txn)) != 0) {
+ /*
+ * DB_NOTFOUND is a normal return, it means we
+ * have no current transaction,
+ */
+ if (ret != DB_NOTFOUND)
+ verify_return(jnienv, ret, 0);
+ return (NULL);
+ }
+
+ jenv = ((DB_ENV_JAVAINFO *)env->api2_internal)->jenvref;
+ jtxn = get_DbTxn(jnienv, txn);
+ if ((cl = get_class(jnienv, name_DB_XAATTACH)) == NULL)
+ return (NULL);
+ mid = (*jnienv)->GetMethodID(jnienv, cl, "<init>",
+ "(Lcom/sleepycat/db/DbEnv;Lcom/sleepycat/db/DbTxn;)V");
+ return (*jnienv)->NewObject(jnienv, cl, mid, jenv, jtxn);
+}
diff --git a/bdb/libdb_java/java_Dbc.c b/bdb/libdb_java/java_Dbc.c
index f1d0acdec85..63ab368fc03 100644
--- a/bdb/libdb_java/java_Dbc.c
+++ b/bdb/libdb_java/java_Dbc.c
@@ -1,13 +1,13 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_Dbc.c,v 11.10 2000/10/25 19:54:55 dda Exp $";
+static const char revid[] = "$Id: java_Dbc.c,v 11.23 2002/08/06 05:19:06 bostic Exp $";
#endif /* not lint */
#include <jni.h>
@@ -18,7 +18,6 @@ static const char revid[] = "$Id: java_Dbc.c,v 11.10 2000/10/25 19:54:55 dda Exp
#include <stdio.h>
#endif
-#include "db.h"
#include "db_int.h"
#include "java_util.h"
#include "com_sleepycat_db_Dbc.h"
@@ -51,20 +50,8 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_count
return (count);
}
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_del
- (JNIEnv *jnienv, jobject jthis, jint flags)
-{
- int err;
- DBC *dbc = get_DBC(jnienv, jthis);
-
- if (!verify_non_null(jnienv, dbc))
- return (0);
- err = dbc->c_del(dbc, flags);
- if (err != DB_KEYEMPTY) {
- verify_return(jnienv, err, 0);
- }
- return (err);
-}
+JAVADB_METHOD_INT(Dbc_del, (JAVADB_ARGS, jint flags), DBC,
+ c_del, (c_this, flags), DB_RETOK_DBCDEL)
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_Dbc_dup
(JNIEnv *jnienv, jobject jthis, jint flags)
@@ -88,10 +75,12 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_get
{
int err, retry, op_flags;
DBC *dbc;
- JDBT dbkey, dbdata;
+ DB_ENV *dbenv;
+ LOCKED_DBT lkey, ldata;
OpKind keyop, dataop;
- /* Depending on flags, the user may be supplying the key,
+ /*
+ * Depending on flags, the user may be supplying the key,
* or else we may have to retrieve it.
*/
err = 0;
@@ -106,38 +95,124 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_get
op_flags == DB_SET_RECNO) {
keyop = inOutOp;
}
- else if (op_flags == DB_GET_BOTH) {
+ else if (op_flags == DB_GET_BOTH || op_flags == DB_GET_BOTH_RANGE) {
keyop = inOutOp;
dataop = inOutOp;
}
dbc = get_DBC(jnienv, jthis);
- if (jdbt_lock(&dbkey, jnienv, key, keyop) != 0)
+ if (!verify_non_null(jnienv, dbc))
+ return (0);
+ dbenv = dbc->dbp->dbenv;
+
+ if (locked_dbt_get(&lkey, jnienv, dbenv, key, keyop) != 0)
goto out2;
- if (jdbt_lock(&dbdata, jnienv, data, dataop) != 0)
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, dataop) != 0)
goto out1;
if (!verify_non_null(jnienv, dbc))
goto out1;
for (retry = 0; retry < 3; retry++) {
- err = dbc->c_get(dbc, &dbkey.dbt->dbt, &dbdata.dbt->dbt, flags);
+ err = dbc->c_get(dbc,
+ &lkey.javainfo->dbt, &ldata.javainfo->dbt, flags);
- /* If we failed due to lack of memory in our DBT arrays,
+ /*
+ * If we failed due to lack of memory in our DBT arrays,
* retry.
*/
if (err != ENOMEM)
break;
- if (!jdbt_realloc(&dbkey, jnienv) && !jdbt_realloc(&dbdata, jnienv))
+ if (!locked_dbt_realloc(&lkey, jnienv,
+ dbenv) && !locked_dbt_realloc(&ldata, jnienv, dbenv))
break;
}
- if (err != DB_NOTFOUND) {
- verify_return(jnienv, err, 0);
+ out1:
+ locked_dbt_put(&ldata, jnienv, dbenv);
+ out2:
+ locked_dbt_put(&lkey, jnienv, dbenv);
+ if (!DB_RETOK_DBCGET(err)) {
+ if (verify_dbt(jnienv, err, &lkey) &&
+ verify_dbt(jnienv, err, &ldata))
+ verify_return(jnienv, err, 0);
+ }
+ return (err);
+}
+
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_pget
+ (JNIEnv *jnienv, jobject jthis,
+ /*Dbt*/ jobject key, /*Dbt*/ jobject pkey, /*Dbt*/ jobject data, jint flags)
+{
+ int err, retry, op_flags;
+ DBC *dbc;
+ DB_ENV *dbenv;
+ LOCKED_DBT lkey, lpkey, ldata;
+ OpKind keyop, pkeyop, dataop;
+
+ /*
+ * Depending on flags, the user may be supplying the key,
+ * or else we may have to retrieve it.
+ */
+ err = 0;
+ keyop = outOp;
+ pkeyop = outOp;
+ dataop = outOp;
+
+ op_flags = flags & DB_OPFLAGS_MASK;
+ if (op_flags == DB_SET) {
+ keyop = inOp;
+ }
+ else if (op_flags == DB_SET_RANGE ||
+ op_flags == DB_SET_RECNO) {
+ keyop = inOutOp;
+ }
+ else if (op_flags == DB_GET_BOTH || op_flags == DB_GET_BOTH_RANGE) {
+ pkeyop = inOutOp;
+ keyop = inOutOp;
+ dataop = inOutOp;
+ }
+
+ dbc = get_DBC(jnienv, jthis);
+ if (!verify_non_null(jnienv, dbc))
+ return (0);
+ dbenv = dbc->dbp->dbenv;
+ if (locked_dbt_get(&lkey, jnienv, dbenv, key, keyop) != 0)
+ goto out3;
+ if (locked_dbt_get(&lpkey, jnienv, dbenv, pkey, pkeyop) != 0)
+ goto out2;
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, dataop) != 0)
+ goto out1;
+
+ if (!verify_non_null(jnienv, dbc))
+ goto out1;
+
+ for (retry = 0; retry < 3; retry++) {
+ err = dbc->c_pget(dbc, &lkey.javainfo->dbt,
+ &lpkey.javainfo->dbt, &ldata.javainfo->dbt, flags);
+
+ /*
+ * If we failed due to lack of memory in our DBT arrays,
+ * retry.
+ */
+ if (err != ENOMEM)
+ break;
+ if (!locked_dbt_realloc(&lkey, jnienv, dbenv) &&
+ !locked_dbt_realloc(&lpkey, jnienv, dbenv) &&
+ !locked_dbt_realloc(&ldata, jnienv, dbenv))
+ break;
}
out1:
- jdbt_unlock(&dbdata, jnienv);
+ locked_dbt_put(&ldata, jnienv, dbenv);
out2:
- jdbt_unlock(&dbkey, jnienv);
+ locked_dbt_put(&lpkey, jnienv, dbenv);
+ out3:
+ locked_dbt_put(&lkey, jnienv, dbenv);
+ if (!DB_RETOK_DBCGET(err)) {
+ if (verify_dbt(jnienv, err, &lkey) &&
+ verify_dbt(jnienv, err, &lpkey) &&
+ verify_dbt(jnienv, err, &ldata))
+ verify_return(jnienv, err, 0);
+ }
return (err);
}
@@ -147,32 +222,39 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbc_put
{
int err;
DBC *dbc;
- JDBT dbkey, dbdata;
+ DB_ENV *dbenv;
+ LOCKED_DBT lkey, ldata;
+ OpKind keyop;
err = 0;
dbc = get_DBC(jnienv, jthis);
- if (jdbt_lock(&dbkey, jnienv, key, inOp) != 0)
+ if (!verify_non_null(jnienv, dbc))
+ return (0);
+ dbenv = dbc->dbp->dbenv;
+ keyop = (dbc->dbp->type == DB_RECNO &&
+ (flags == DB_BEFORE || flags == DB_AFTER)) ? outOp : inOp;
+ if (locked_dbt_get(&lkey, jnienv, dbenv, key, keyop) != 0)
goto out2;
- if (jdbt_lock(&dbdata, jnienv, data, inOp) != 0)
+ if (locked_dbt_get(&ldata, jnienv, dbenv, data, inOp) != 0)
goto out1;
if (!verify_non_null(jnienv, dbc))
goto out1;
- err = dbc->c_put(dbc, &dbkey.dbt->dbt, &dbdata.dbt->dbt, flags);
- if (err != DB_KEYEXIST) {
+ err = dbc->c_put(dbc, &lkey.javainfo->dbt, &ldata.javainfo->dbt, flags);
+ if (!DB_RETOK_DBCPUT(err))
verify_return(jnienv, err, 0);
- }
out1:
- jdbt_unlock(&dbdata, jnienv);
+ locked_dbt_put(&ldata, jnienv, dbenv);
out2:
- jdbt_unlock(&dbkey, jnienv);
+ locked_dbt_put(&lkey, jnienv, dbenv);
return (err);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbc_finalize
(JNIEnv *jnienv, jobject jthis)
{
- /* Free any data related to DBC here.
+ /*
+ * Free any data related to DBC here.
* If we ever have java-only data embedded in the DBC
* and need to do this, we'll have to track Dbc's
* according to which Db owns them, just as
diff --git a/bdb/libdb_java/java_Dbt.c b/bdb/libdb_java/java_Dbt.c
index 0e094da6a2d..d21109f3408 100644
--- a/bdb/libdb_java/java_Dbt.c
+++ b/bdb/libdb_java/java_Dbt.c
@@ -1,13 +1,13 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_Dbt.c,v 11.10 2000/10/25 19:54:55 dda Exp $";
+static const char revid[] = "$Id: java_Dbt.c,v 11.18 2002/06/20 11:11:55 mjc Exp $";
#endif /* not lint */
#include <jni.h>
@@ -15,16 +15,10 @@ static const char revid[] = "$Id: java_Dbt.c,v 11.10 2000/10/25 19:54:55 dda Exp
#include <stdlib.h>
#include <string.h>
-#include "db.h"
+#include "db_int.h"
#include "java_util.h"
#include "com_sleepycat_db_Dbt.h"
-JAVADB_RW_ACCESS(Dbt, jint, size, DBT, size)
-JAVADB_RW_ACCESS(Dbt, jint, ulen, DBT, ulen)
-JAVADB_RW_ACCESS(Dbt, jint, dlen, DBT, dlen)
-JAVADB_RW_ACCESS(Dbt, jint, doff, DBT, doff)
-JAVADB_RW_ACCESS(Dbt, jint, flags, DBT, flags)
-
JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_init
(JNIEnv *jnienv, jobject jthis)
{
@@ -34,129 +28,22 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_init
set_private_dbobj(jnienv, name_DBT, jthis, dbtji);
}
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_internal_1set_1data
- (JNIEnv *jnienv, jobject jthis, jbyteArray array)
-{
- DBT_JAVAINFO *db_this;
-
- db_this = get_DBT_JAVAINFO(jnienv, jthis);
- if (verify_non_null(jnienv, db_this)) {
-
- /* If we previously allocated an array for java,
- * must release reference.
- */
- dbjit_release(db_this, jnienv);
-
- /* Make the array a global ref,
- * it won't be GC'd till we release it.
- */
- if (array)
- array = (jbyteArray)NEW_GLOBAL_REF(jnienv, array);
- db_this->array_ = array;
- }
-}
-
-JNIEXPORT jbyteArray JNICALL Java_com_sleepycat_db_Dbt_get_1data
+JNIEXPORT jbyteArray JNICALL Java_com_sleepycat_db_Dbt_create_1data
(JNIEnv *jnienv, jobject jthis)
{
DBT_JAVAINFO *db_this;
- jbyteArray arr;
+ jbyteArray arr = NULL;
int len;
db_this = get_DBT_JAVAINFO(jnienv, jthis);
if (verify_non_null(jnienv, db_this)) {
- /* XXX this will copy the data on each call to get_data,
- * even if it is unchanged.
- */
- if (db_this->create_array_ != 0) {
- /* XXX we should reuse the existing array if we can */
- len = db_this->dbt.size;
- if (db_this->array_ != NULL)
- DELETE_GLOBAL_REF(jnienv, db_this->array_);
- arr = (*jnienv)->NewByteArray(jnienv, len);
- db_this->array_ =
- (jbyteArray)NEW_GLOBAL_REF(jnienv, arr);
- (*jnienv)->SetByteArrayRegion(jnienv, arr, 0, len,
- db_this->dbt.data);
- }
- return (db_this->array_);
- }
- return (0);
-}
-
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1offset
- (JNIEnv *jnienv, jobject jthis, jint offset)
-{
- DBT_JAVAINFO *db_this;
-
- db_this = get_DBT_JAVAINFO(jnienv, jthis);
- if (verify_non_null(jnienv, db_this)) {
- db_this->offset_ = offset;
- }
-}
-
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1offset
- (JNIEnv *jnienv, jobject jthis)
-{
- DBT_JAVAINFO *db_this;
-
- db_this = get_DBT_JAVAINFO(jnienv, jthis);
- if (verify_non_null(jnienv, db_this)) {
- return db_this->offset_;
- }
- return (0);
-}
-
-JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_set_1recno_1key_1data(JNIEnv *jnienv, jobject jthis, jint value)
-{
- JDBT jdbt;
-
- if (jdbt_lock(&jdbt, jnienv, jthis, inOp) != 0)
- goto out;
-
- if (!jdbt.dbt->dbt.data ||
- jdbt.java_array_len_ < sizeof(db_recno_t)) {
- char buf[200];
- sprintf(buf, "set_recno_key_data error: %p %p %d %d",
- &jdbt.dbt->dbt, jdbt.dbt->dbt.data,
- jdbt.dbt->dbt.ulen, sizeof(db_recno_t));
- report_exception(jnienv, buf, 0, 0);
- }
- else {
- *(db_recno_t*)(jdbt.dbt->dbt.data) = value;
+ len = db_this->dbt.size;
+ if ((arr = (*jnienv)->NewByteArray(jnienv, len)) == NULL)
+ goto out;
+ (*jnienv)->SetByteArrayRegion(jnienv, arr, 0, len,
+ db_this->dbt.data);
}
- out:
- jdbt_unlock(&jdbt, jnienv);
-}
-
-JNIEXPORT jint JNICALL Java_com_sleepycat_db_Dbt_get_1recno_1key_1data(JNIEnv *jnienv, jobject jthis)
-{
- jint ret;
- JDBT jdbt;
-
- ret = 0;
-
- /* Although this is kind of like "retrieve", we don't support
- * DB_DBT_MALLOC for this operation, so we tell jdbt_lock
- * that is not a retrieve.
- */
- if (jdbt_lock(&jdbt, jnienv, jthis, inOp) != 0)
- goto out;
-
- if (!jdbt.dbt->dbt.data ||
- jdbt.java_array_len_ < sizeof(db_recno_t)) {
- char buf[200];
- sprintf(buf, "get_recno_key_data error: %p %p %d %d",
- &jdbt.dbt->dbt, jdbt.dbt->dbt.data,
- jdbt.dbt->dbt.ulen, sizeof(db_recno_t));
- report_exception(jnienv, buf, 0, 0);
- }
- else {
- ret = *(db_recno_t*)(jdbt.dbt->dbt.data);
- }
- out:
- jdbt_unlock(&jdbt, jnienv);
- return (ret);
+out: return (arr);
}
JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_finalize
@@ -167,10 +54,6 @@ JNIEXPORT void JNICALL Java_com_sleepycat_db_Dbt_finalize
dbtji = get_DBT_JAVAINFO(jnienv, jthis);
if (dbtji) {
/* Free any data related to DBT here */
- dbjit_release(dbtji, jnienv);
-
- /* Extra paranoia */
- memset(dbtji, 0, sizeof(DBT_JAVAINFO));
- free(dbtji);
+ dbjit_destroy(dbtji);
}
}
diff --git a/bdb/libdb_java/java_info.c b/bdb/libdb_java/java_info.c
index ccd469fa256..22fcbd23d46 100644
--- a/bdb/libdb_java/java_info.c
+++ b/bdb/libdb_java/java_info.c
@@ -1,13 +1,13 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_info.c,v 11.18 2000/10/28 13:09:39 dda Exp $";
+static const char revid[] = "$Id: java_info.c,v 11.46 2002/08/29 14:22:23 margo Exp $";
#endif /* not lint */
#include <jni.h>
@@ -15,63 +15,74 @@ static const char revid[] = "$Id: java_info.c,v 11.18 2000/10/28 13:09:39 dda Ex
#include <stdlib.h>
#include <string.h>
-#include "db.h"
#include "db_int.h"
#include "java_util.h"
/****************************************************************
*
* Callback functions
- *
*/
+static int Db_assoc_callback(DB *db,
+ const DBT *key,
+ const DBT *data,
+ DBT *retval)
+{
+ DB_JAVAINFO *dbinfo;
+
+ DB_ASSERT(db != NULL);
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ return (dbji_call_assoc(dbinfo, db, dbinfo->jdbref,
+ key, data, retval));
+}
+
static void Db_feedback_callback(DB *db, int opcode, int percent)
{
DB_JAVAINFO *dbinfo;
DB_ASSERT(db != NULL);
- dbinfo = (DB_JAVAINFO *)db->cj_internal;
- dbji_call_feedback(dbinfo, db, dbinfo->jdbref_, opcode, percent);
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ dbji_call_feedback(dbinfo, db, dbinfo->jdbref, opcode, percent);
}
static int Db_append_recno_callback(DB *db, DBT *dbt, db_recno_t recno)
{
DB_JAVAINFO *dbinfo;
- dbinfo = (DB_JAVAINFO *)db->cj_internal;
- return (dbji_call_append_recno(dbinfo, db, dbinfo->jdbref_, dbt, recno));
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ return (dbji_call_append_recno(dbinfo, db, dbinfo->jdbref, dbt, recno));
}
static int Db_bt_compare_callback(DB *db, const DBT *dbt1, const DBT *dbt2)
{
DB_JAVAINFO *dbinfo;
- dbinfo = (DB_JAVAINFO *)db->cj_internal;
- return (dbji_call_bt_compare(dbinfo, db, dbinfo->jdbref_, dbt1, dbt2));
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ return (dbji_call_bt_compare(dbinfo, db, dbinfo->jdbref, dbt1, dbt2));
}
static size_t Db_bt_prefix_callback(DB *db, const DBT *dbt1, const DBT *dbt2)
{
DB_JAVAINFO *dbinfo;
- dbinfo = (DB_JAVAINFO *)db->cj_internal;
- return (dbji_call_bt_prefix(dbinfo, db, dbinfo->jdbref_, dbt1, dbt2));
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ return (dbji_call_bt_prefix(dbinfo, db, dbinfo->jdbref, dbt1, dbt2));
}
static int Db_dup_compare_callback(DB *db, const DBT *dbt1, const DBT *dbt2)
{
DB_JAVAINFO *dbinfo;
- dbinfo = (DB_JAVAINFO *)db->cj_internal;
- return (dbji_call_dup_compare(dbinfo, db, dbinfo->jdbref_, dbt1, dbt2));
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ return (dbji_call_dup_compare(dbinfo, db, dbinfo->jdbref, dbt1, dbt2));
}
static u_int32_t Db_h_hash_callback(DB *db, const void *data, u_int32_t len)
{
DB_JAVAINFO *dbinfo;
- dbinfo = (DB_JAVAINFO *)db->cj_internal;
- return (dbji_call_h_hash(dbinfo, db, dbinfo->jdbref_, data, len));
+ dbinfo = (DB_JAVAINFO *)db->api_internal;
+ return (dbji_call_h_hash(dbinfo, db, dbinfo->jdbref, data, len));
}
static void DbEnv_feedback_callback(DB_ENV *dbenv, int opcode, int percent)
@@ -79,91 +90,87 @@ static void DbEnv_feedback_callback(DB_ENV *dbenv, int opcode, int percent)
DB_ENV_JAVAINFO *dbinfo;
DB_ASSERT(dbenv != NULL);
- dbinfo = (DB_ENV_JAVAINFO *)dbenv->cj_internal;
- dbjie_call_feedback(dbinfo, dbenv, dbinfo->jenvref_, opcode, percent);
+ dbinfo = (DB_ENV_JAVAINFO *)dbenv->api2_internal;
+ dbjie_call_feedback(dbinfo, dbenv, dbinfo->jenvref, opcode, percent);
}
-static int DbEnv_recovery_init_callback(DB_ENV *dbenv)
+static int DbEnv_rep_transport_callback(DB_ENV *dbenv,
+ const DBT *control, const DBT *rec,
+ int envid, u_int32_t flags)
{
DB_ENV_JAVAINFO *dbinfo;
- dbinfo = (DB_ENV_JAVAINFO *)dbenv->cj_internal;
- return (dbjie_call_recovery_init(dbinfo, dbenv, dbinfo->jenvref_));
+ dbinfo = (DB_ENV_JAVAINFO *)dbenv->api2_internal;
+ return (dbjie_call_rep_transport(dbinfo, dbenv,
+ dbinfo->jenvref, control, rec, envid, (int)flags));
}
-static int DbEnv_tx_recover_callback(DB_ENV *dbenv, DBT *dbt,
+static int DbEnv_app_dispatch_callback(DB_ENV *dbenv, DBT *dbt,
DB_LSN *lsn, db_recops recops)
{
DB_ENV_JAVAINFO *dbinfo;
DB_ASSERT(dbenv != NULL);
- dbinfo = (DB_ENV_JAVAINFO *)dbenv->cj_internal;
- return dbjie_call_tx_recover(dbinfo, dbenv, dbinfo->jenvref_, dbt,
- lsn, recops);
+ dbinfo = (DB_ENV_JAVAINFO *)dbenv->api2_internal;
+ return (dbjie_call_app_dispatch(dbinfo, dbenv, dbinfo->jenvref, dbt,
+ lsn, recops));
}
/****************************************************************
*
* Implementation of class DBT_javainfo
- *
*/
DBT_JAVAINFO *
dbjit_construct()
{
DBT_JAVAINFO *dbjit;
+ int err;
+
+ /*XXX should return err*/
+ if ((err = __os_malloc(NULL, sizeof(DBT_JAVAINFO), &dbjit)) != 0)
+ return (NULL);
- dbjit = (DBT_JAVAINFO *)malloc(sizeof(DBT_JAVAINFO));
memset(dbjit, 0, sizeof(DBT_JAVAINFO));
return (dbjit);
}
void dbjit_destroy(DBT_JAVAINFO *dbjit)
{
- /* Sanity check:
- * We cannot delete the global ref because we don't have a JNIEnv.
- */
- if (dbjit->array_ != NULL) {
- fprintf(stderr, "object is not freed\n");
- }
-
+ DB_ASSERT(!F_ISSET(dbjit, DBT_JAVAINFO_LOCKED));
/* Extra paranoia */
- memset(dbjit, 0, sizeof(DB_JAVAINFO));
- free(dbjit);
-}
-
-void dbjit_release(DBT_JAVAINFO *dbjit, JNIEnv *jnienv)
-{
- if (dbjit->array_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjit->array_);
- dbjit->array_ = NULL;
- }
+ memset(dbjit, 0, sizeof(DBT_JAVAINFO));
+ (void)__os_free(NULL, dbjit);
}
/****************************************************************
*
* Implementation of class DB_ENV_JAVAINFO
- *
*/
/* create/initialize an object */
DB_ENV_JAVAINFO *
dbjie_construct(JNIEnv *jnienv,
+ jobject jenv,
jobject default_errcall,
int is_dbopen)
{
DB_ENV_JAVAINFO *dbjie;
+ int err;
- dbjie = (DB_ENV_JAVAINFO *)malloc(sizeof(DB_ENV_JAVAINFO));
+ /*XXX should return err*/
+ if ((err = __os_malloc(NULL, sizeof(DB_ENV_JAVAINFO), &dbjie)) != 0)
+ return (NULL);
memset(dbjie, 0, sizeof(DB_ENV_JAVAINFO));
- dbjie->is_dbopen_ = is_dbopen;
+ dbjie->is_dbopen = is_dbopen;
- if ((*jnienv)->GetJavaVM(jnienv, &dbjie->javavm_) != 0) {
- free(dbjie);
+ if ((*jnienv)->GetJavaVM(jnienv, &dbjie->javavm) != 0) {
+ __os_free(NULL, dbjie);
report_exception(jnienv, "cannot get Java VM", 0, 0);
return (NULL);
}
- /* The default error call just prints to the 'System.err'
+ /*
+ * The default error call just prints to the 'System.err'
* stream. If the user does set_errcall to null, we'll
* want to have a reference to set it back to.
*
@@ -172,42 +179,44 @@ dbjie_construct(JNIEnv *jnienv,
* error prefix, error stream, and user's error callback
* that much easier.
*/
- dbjie->default_errcall_ = NEW_GLOBAL_REF(jnienv, default_errcall);
- dbjie->errcall_ = NEW_GLOBAL_REF(jnienv, default_errcall);
+ dbjie->default_errcall = NEW_GLOBAL_REF(jnienv, default_errcall);
+ dbjie->errcall = NEW_GLOBAL_REF(jnienv, default_errcall);
+ dbjie->jenvref = NEW_GLOBAL_REF(jnienv, jenv);
return (dbjie);
}
/* release all objects held by this this one */
void dbjie_dealloc(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv)
{
- if (dbjie->recovery_init_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->recovery_init_);
- dbjie->recovery_init_ = NULL;
+ if (dbjie->feedback != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->feedback);
+ dbjie->feedback = NULL;
}
- if (dbjie->feedback_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->feedback_);
- dbjie->feedback_ = NULL;
+ if (dbjie->app_dispatch != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->app_dispatch);
+ dbjie->app_dispatch = NULL;
}
- if (dbjie->tx_recover_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->tx_recover_);
- dbjie->tx_recover_ = NULL;
+ if (dbjie->errcall != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->errcall);
+ dbjie->errcall = NULL;
}
- if (dbjie->errcall_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->errcall_);
- dbjie->errcall_ = NULL;
+ if (dbjie->default_errcall != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->default_errcall);
+ dbjie->default_errcall = NULL;
}
- if (dbjie->default_errcall_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->default_errcall_);
- dbjie->default_errcall_ = NULL;
+ if (dbjie->jenvref != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->jenvref);
+ dbjie->jenvref = NULL;
}
- if (dbjie->conflict_ != NULL) {
- free(dbjie->conflict_);
- dbjie->conflict_ = NULL;
+ if (dbjie->conflict != NULL) {
+ __os_free(NULL, dbjie->conflict);
+ dbjie->conflict = NULL;
+ dbjie->conflict_size = 0;
}
- if (dbjie->errpfx_ != NULL) {
- free(dbjie->errpfx_);
- dbjie->errpfx_ = NULL;
+ if (dbjie->errpfx != NULL) {
+ __os_free(NULL, dbjie->errpfx);
+ dbjie->errpfx = NULL;
}
}
@@ -218,17 +227,19 @@ void dbjie_destroy(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv)
/* Extra paranoia */
memset(dbjie, 0, sizeof(DB_ENV_JAVAINFO));
- free(dbjie);
+ (void)__os_free(NULL, dbjie);
}
-/* Attach to the current thread that is running and
+/*
+ * Attach to the current thread that is running and
* return that. We use the java virtual machine
* that we saved in the constructor.
*/
JNIEnv *
dbjie_get_jnienv(DB_ENV_JAVAINFO *dbjie)
{
- /* Note:
+ /*
+ * Note:
* Different versions of the JNI disagree on the signature
* for AttachCurrentThread. The most recent documentation
* seems to say that (JNIEnv **) is correct, but newer
@@ -240,10 +251,12 @@ dbjie_get_jnienv(DB_ENV_JAVAINFO *dbjie)
JNIEnv *attachret = 0;
#endif
- /* This should always succeed, as we are called via
+ /*
+ * This should always succeed, as we are called via
* some Java activity. I think therefore I am (a thread).
*/
- if ((*dbjie->javavm_)->AttachCurrentThread(dbjie->javavm_, &attachret, 0) != 0)
+ if ((*dbjie->javavm)->AttachCurrentThread(dbjie->javavm, &attachret, 0)
+ != 0)
return (0);
return ((JNIEnv *)attachret);
@@ -252,40 +265,42 @@ dbjie_get_jnienv(DB_ENV_JAVAINFO *dbjie)
jstring
dbjie_get_errpfx(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv)
{
- return (get_java_string(jnienv, dbjie->errpfx_));
+ return (get_java_string(jnienv, dbjie->errpfx));
}
void
dbjie_set_errcall(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv, jobject new_errcall)
{
- /* If the new_errcall is null, we'll set the error call
+ /*
+ * If the new_errcall is null, we'll set the error call
* to the default one.
*/
if (new_errcall == NULL)
- new_errcall = dbjie->default_errcall_;
+ new_errcall = dbjie->default_errcall;
- DELETE_GLOBAL_REF(jnienv, dbjie->errcall_);
- dbjie->errcall_ = NEW_GLOBAL_REF(jnienv, new_errcall);
+ DELETE_GLOBAL_REF(jnienv, dbjie->errcall);
+ dbjie->errcall = NEW_GLOBAL_REF(jnienv, new_errcall);
}
void
dbjie_set_errpfx(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv, jstring errpfx)
{
- if (dbjie->errpfx_ != NULL)
- free(dbjie->errpfx_);
+ if (dbjie->errpfx != NULL)
+ __os_free(NULL, dbjie->errpfx);
if (errpfx)
- dbjie->errpfx_ = get_c_string(jnienv, errpfx);
+ dbjie->errpfx = get_c_string(jnienv, errpfx);
else
- dbjie->errpfx_ = NULL;
+ dbjie->errpfx = NULL;
}
void
-dbjie_set_conflict(DB_ENV_JAVAINFO *dbjie, unsigned char *newarr)
+dbjie_set_conflict(DB_ENV_JAVAINFO *dbjie, u_char *newarr, size_t size)
{
- if (dbjie->conflict_)
- free(dbjie->conflict_);
- dbjie->conflict_ = newarr;
+ if (dbjie->conflict != NULL)
+ (void)__os_free(NULL, dbjie->conflict);
+ dbjie->conflict = newarr;
+ dbjie->conflict_size = size;
}
void dbjie_set_feedback_object(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv,
@@ -293,8 +308,8 @@ void dbjie_set_feedback_object(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv,
{
int err;
- if (dbjie->feedback_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->feedback_);
+ if (dbjie->feedback != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->feedback);
}
if (jfeedback == NULL) {
if ((err = dbenv->set_feedback(dbenv, NULL)) != 0)
@@ -308,7 +323,7 @@ void dbjie_set_feedback_object(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv,
err, 0);
}
- dbjie->feedback_ = NEW_GLOBAL_REF(jnienv, jfeedback);
+ dbjie->feedback = NEW_GLOBAL_REF(jnienv, jfeedback);
}
void dbjie_call_feedback(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv, jobject jenv,
@@ -325,97 +340,107 @@ void dbjie_call_feedback(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv, jobject jenv,
return;
}
- feedback_class = get_class(jnienv, name_DbEnvFeedback);
+ if ((feedback_class =
+ get_class(jnienv, name_DbEnvFeedback)) == NULL) {
+ fprintf(stderr, "Cannot find callback class %s\n",
+ name_DbEnvFeedback);
+ return; /* An exception has been posted. */
+ }
id = (*jnienv)->GetMethodID(jnienv, feedback_class,
"feedback",
"(Lcom/sleepycat/db/DbEnv;II)V");
if (!id) {
- fprintf(stderr, "Cannot find callback class\n");
+ fprintf(stderr, "Cannot find callback method feedback\n");
return;
}
- (*jnienv)->CallVoidMethod(jnienv, dbjie->feedback_, id,
+ (*jnienv)->CallVoidMethod(jnienv, dbjie->feedback, id,
jenv, (jint)opcode, (jint)percent);
}
-void dbjie_set_recovery_init_object(DB_ENV_JAVAINFO *dbjie,
- JNIEnv *jnienv, DB_ENV *dbenv,
- jobject jrecovery_init)
+void dbjie_set_rep_transport_object(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv,
+ DB_ENV *dbenv, int id, jobject jtransport)
{
int err;
- if (dbjie->recovery_init_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->recovery_init_);
- }
- if (jrecovery_init == NULL) {
- if ((err = dbenv->set_recovery_init(dbenv, NULL)) != 0)
- report_exception(jnienv, "set_recovery_init failed",
- err, 0);
- }
- else {
- if ((err = dbenv->set_recovery_init(dbenv,
- DbEnv_recovery_init_callback)) != 0)
- report_exception(jnienv, "set_recovery_init failed",
- err, 0);
- }
+ if (dbjie->rep_transport != NULL)
+ DELETE_GLOBAL_REF(jnienv, dbjie->rep_transport);
+
+ err = dbenv->set_rep_transport(dbenv, id,
+ DbEnv_rep_transport_callback);
+ verify_return(jnienv, err, 0);
- dbjie->recovery_init_ = NEW_GLOBAL_REF(jnienv, jrecovery_init);
+ dbjie->rep_transport = NEW_GLOBAL_REF(jnienv, jtransport);
}
-int dbjie_call_recovery_init(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv,
- jobject jenv)
+int dbjie_call_rep_transport(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv,
+ jobject jenv, const DBT *control,
+ const DBT *rec, int flags, int envid)
{
JNIEnv *jnienv;
- jclass recovery_init_class;
- jmethodID id;
+ jclass rep_transport_class;
+ jmethodID jid;
+ jobject jcdbt, jrdbt;
COMPQUIET(dbenv, NULL);
jnienv = dbjie_get_jnienv(dbjie);
if (jnienv == NULL) {
fprintf(stderr, "Cannot attach to current thread!\n");
- return (EINVAL);
+ return (0);
}
- recovery_init_class = get_class(jnienv, name_DbRecoveryInit);
- id = (*jnienv)->GetMethodID(jnienv, recovery_init_class,
- "recovery_init",
- "(Lcom/sleepycat/db/DbEnv;)V");
- if (!id) {
- fprintf(stderr, "Cannot find callback class\n");
- return (EINVAL);
+ if ((rep_transport_class =
+ get_class(jnienv, name_DbRepTransport)) == NULL) {
+ fprintf(stderr, "Cannot find callback class %s\n",
+ name_DbRepTransport);
+ return (0); /* An exception has been posted. */
}
- return (*jnienv)->CallIntMethod(jnienv, dbjie->recovery_init_,
- id, jenv);
+ jid = (*jnienv)->GetMethodID(jnienv, rep_transport_class,
+ "send",
+ "(Lcom/sleepycat/db/DbEnv;"
+ "Lcom/sleepycat/db/Dbt;"
+ "Lcom/sleepycat/db/Dbt;II)I");
+
+ if (!jid) {
+ fprintf(stderr, "Cannot find callback method send\n");
+ return (0);
+ }
+
+ jcdbt = get_const_Dbt(jnienv, control, NULL);
+ jrdbt = get_const_Dbt(jnienv, rec, NULL);
+
+ return (*jnienv)->CallIntMethod(jnienv, dbjie->rep_transport, jid, jenv,
+ jcdbt, jrdbt, flags, envid);
}
-void dbjie_set_tx_recover_object(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv,
- DB_ENV *dbenv, jobject jtx_recover)
+void dbjie_set_app_dispatch_object(DB_ENV_JAVAINFO *dbjie, JNIEnv *jnienv,
+ DB_ENV *dbenv, jobject japp_dispatch)
{
int err;
- if (dbjie->tx_recover_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbjie->tx_recover_);
+ if (dbjie->app_dispatch != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbjie->app_dispatch);
}
- if (jtx_recover == NULL) {
- if ((err = dbenv->set_tx_recover(dbenv, NULL)) != 0)
- report_exception(jnienv, "set_tx_recover failed",
+ if (japp_dispatch == NULL) {
+ if ((err = dbenv->set_app_dispatch(dbenv, NULL)) != 0)
+ report_exception(jnienv, "set_app_dispatch failed",
err, 0);
}
else {
- if ((err = dbenv->set_tx_recover(dbenv,
- DbEnv_tx_recover_callback)) != 0)
- report_exception(jnienv, "set_tx_recover failed",
+ if ((err = dbenv->set_app_dispatch(dbenv,
+ DbEnv_app_dispatch_callback)) != 0)
+ report_exception(jnienv, "set_app_dispatch failed",
err, 0);
}
- dbjie->tx_recover_ = NEW_GLOBAL_REF(jnienv, jtx_recover);
+ dbjie->app_dispatch = NEW_GLOBAL_REF(jnienv, japp_dispatch);
}
-int dbjie_call_tx_recover(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv, jobject jenv,
+int dbjie_call_app_dispatch(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv, jobject jenv,
DBT *dbt, DB_LSN *lsn, int recops)
{
JNIEnv *jnienv;
- jclass tx_recover_class;
+ jclass app_dispatch_class;
jmethodID id;
jobject jdbt;
jobject jlsn;
@@ -427,90 +452,104 @@ int dbjie_call_tx_recover(DB_ENV_JAVAINFO *dbjie, DB_ENV *dbenv, jobject jenv,
return (0);
}
- tx_recover_class = get_class(jnienv, name_DbTxnRecover);
- id = (*jnienv)->GetMethodID(jnienv, tx_recover_class,
- "tx_recover",
+ if ((app_dispatch_class =
+ get_class(jnienv, name_DbTxnRecover)) == NULL) {
+ fprintf(stderr, "Cannot find callback class %s\n",
+ name_DbTxnRecover);
+ return (0); /* An exception has been posted. */
+ }
+ id = (*jnienv)->GetMethodID(jnienv, app_dispatch_class,
+ "app_dispatch",
"(Lcom/sleepycat/db/DbEnv;"
"Lcom/sleepycat/db/Dbt;"
"Lcom/sleepycat/db/DbLsn;"
"I)I");
if (!id) {
- fprintf(stderr, "Cannot find callback class\n");
+ fprintf(stderr, "Cannot find callback method app_dispatch\n");
return (0);
}
- if (dbt == NULL)
- jdbt = NULL;
- else
- jdbt = get_Dbt(jnienv, dbt);
+ jdbt = get_Dbt(jnienv, dbt, NULL);
if (lsn == NULL)
jlsn = NULL;
else
jlsn = get_DbLsn(jnienv, *lsn);
- return (*jnienv)->CallIntMethod(jnienv, dbjie->tx_recover_, id, jenv,
+ return (*jnienv)->CallIntMethod(jnienv, dbjie->app_dispatch, id, jenv,
jdbt, jlsn, recops);
}
jobject dbjie_get_errcall(DB_ENV_JAVAINFO *dbjie)
{
- return (dbjie->errcall_);
+ return (dbjie->errcall);
}
-int dbjie_is_dbopen(DB_ENV_JAVAINFO *dbjie)
+jint dbjie_is_dbopen(DB_ENV_JAVAINFO *dbjie)
{
- return (dbjie->is_dbopen_);
+ return (dbjie->is_dbopen);
}
/****************************************************************
*
* Implementation of class DB_JAVAINFO
- *
*/
-DB_JAVAINFO *dbji_construct(JNIEnv *jnienv, jint flags)
+DB_JAVAINFO *dbji_construct(JNIEnv *jnienv, jobject jdb, jint flags)
{
DB_JAVAINFO *dbji;
+ int err;
+
+ /*XXX should return err*/
+ if ((err = __os_malloc(NULL, sizeof(DB_JAVAINFO), &dbji)) != 0)
+ return (NULL);
- dbji = (DB_JAVAINFO *)malloc(sizeof(DB_JAVAINFO));
memset(dbji, 0, sizeof(DB_JAVAINFO));
- if ((*jnienv)->GetJavaVM(jnienv, &dbji->javavm_) != 0) {
+ if ((*jnienv)->GetJavaVM(jnienv, &dbji->javavm) != 0) {
report_exception(jnienv, "cannot get Java VM", 0, 0);
- free(dbji);
+ (void)__os_free(NULL, dbji);
return (NULL);
}
- dbji->construct_flags_ = flags;
+ dbji->jdbref = NEW_GLOBAL_REF(jnienv, jdb);
+ dbji->construct_flags = flags;
return (dbji);
}
void
dbji_dealloc(DB_JAVAINFO *dbji, JNIEnv *jnienv)
{
- if (dbji->append_recno_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->append_recno_);
- dbji->append_recno_ = NULL;
+ if (dbji->append_recno != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->append_recno);
+ dbji->append_recno = NULL;
+ }
+ if (dbji->assoc != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->assoc);
+ dbji->assoc = NULL;
+ }
+ if (dbji->bt_compare != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->bt_compare);
+ dbji->bt_compare = NULL;
}
- if (dbji->bt_compare_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->bt_compare_);
- dbji->bt_compare_ = NULL;
+ if (dbji->bt_prefix != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->bt_prefix);
+ dbji->bt_prefix = NULL;
}
- if (dbji->bt_prefix_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->bt_prefix_);
- dbji->bt_prefix_ = NULL;
+ if (dbji->dup_compare != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->dup_compare);
+ dbji->dup_compare = NULL;
}
- if (dbji->dup_compare_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->dup_compare_);
- dbji->dup_compare_ = NULL;
+ if (dbji->feedback != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->feedback);
+ dbji->feedback = NULL;
}
- if (dbji->feedback_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->feedback_);
- dbji->feedback_ = NULL;
+ if (dbji->h_hash != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->h_hash);
+ dbji->h_hash = NULL;
}
- if (dbji->h_hash_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->h_hash_);
- dbji->h_hash_ = NULL;
+ if (dbji->jdbref != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->jdbref);
+ dbji->jdbref = NULL;
}
}
@@ -518,12 +557,13 @@ void
dbji_destroy(DB_JAVAINFO *dbji, JNIEnv *jnienv)
{
dbji_dealloc(dbji, jnienv);
- free(dbji);
+ __os_free(NULL, dbji);
}
JNIEnv *dbji_get_jnienv(DB_JAVAINFO *dbji)
{
- /* Note:
+ /*
+ * Note:
* Different versions of the JNI disagree on the signature
* for AttachCurrentThread. The most recent documentation
* seems to say that (JNIEnv **) is correct, but newer
@@ -535,10 +575,12 @@ JNIEnv *dbji_get_jnienv(DB_JAVAINFO *dbji)
JNIEnv *attachret = 0;
#endif
- /* This should always succeed, as we are called via
+ /*
+ * This should always succeed, as we are called via
* some Java activity. I think therefore I am (a thread).
*/
- if ((*dbji->javavm_)->AttachCurrentThread(dbji->javavm_, &attachret, 0) != 0)
+ if ((*dbji->javavm)->AttachCurrentThread(dbji->javavm, &attachret, 0)
+ != 0)
return (0);
return ((JNIEnv *)attachret);
@@ -546,7 +588,7 @@ JNIEnv *dbji_get_jnienv(DB_JAVAINFO *dbji)
jint dbji_get_flags(DB_JAVAINFO *dbji)
{
- return (dbji->construct_flags_);
+ return (dbji->construct_flags);
}
void dbji_set_feedback_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
@@ -554,14 +596,17 @@ void dbji_set_feedback_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
{
jclass feedback_class;
- if (dbji->feedback_method_id_ == NULL) {
- feedback_class = get_class(jnienv, name_DbFeedback);
- dbji->feedback_method_id_ =
+ if (dbji->feedback_method_id == NULL) {
+ if ((feedback_class =
+ get_class(jnienv, name_DbFeedback)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->feedback_method_id =
(*jnienv)->GetMethodID(jnienv, feedback_class,
"feedback",
"(Lcom/sleepycat/db/Db;II)V");
- if (dbji->feedback_method_id_ != NULL) {
- /* XXX
+ if (dbji->feedback_method_id == NULL) {
+ /*
+ * XXX
* We should really have a better way
* to translate this to a Java exception class.
* In theory, it shouldn't happen.
@@ -572,8 +617,8 @@ void dbji_set_feedback_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
}
}
- if (dbji->feedback_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->feedback_);
+ if (dbji->feedback != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->feedback);
}
if (jfeedback == NULL) {
db->set_feedback(db, NULL);
@@ -582,7 +627,7 @@ void dbji_set_feedback_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
db->set_feedback(db, Db_feedback_callback);
}
- dbji->feedback_ = NEW_GLOBAL_REF(jnienv, jfeedback);
+ dbji->feedback = NEW_GLOBAL_REF(jnienv, jfeedback);
}
@@ -598,9 +643,9 @@ void dbji_call_feedback(DB_JAVAINFO *dbji, DB *db, jobject jdb,
return;
}
- DB_ASSERT(dbji->feedback_method_id_ != NULL);
- (*jnienv)->CallVoidMethod(jnienv, dbji->feedback_,
- dbji->feedback_method_id_,
+ DB_ASSERT(dbji->feedback_method_id != NULL);
+ (*jnienv)->CallVoidMethod(jnienv, dbji->feedback,
+ dbji->feedback_method_id,
jdb, (jint)opcode, (jint)percent);
}
@@ -609,15 +654,18 @@ void dbji_set_append_recno_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
{
jclass append_recno_class;
- if (dbji->append_recno_method_id_ == NULL) {
- append_recno_class = get_class(jnienv, name_DbAppendRecno);
- dbji->append_recno_method_id_ =
+ if (dbji->append_recno_method_id == NULL) {
+ if ((append_recno_class =
+ get_class(jnienv, name_DbAppendRecno)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->append_recno_method_id =
(*jnienv)->GetMethodID(jnienv, append_recno_class,
"db_append_recno",
"(Lcom/sleepycat/db/Db;"
"Lcom/sleepycat/db/Dbt;I)V");
- if (dbji->append_recno_method_id_ == NULL) {
- /* XXX
+ if (dbji->append_recno_method_id == NULL) {
+ /*
+ * XXX
* We should really have a better way
* to translate this to a Java exception class.
* In theory, it shouldn't happen.
@@ -628,8 +676,8 @@ void dbji_set_append_recno_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
}
}
- if (dbji->append_recno_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->append_recno_);
+ if (dbji->append_recno != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->append_recno);
}
if (jcallback == NULL) {
db->set_append_recno(db, NULL);
@@ -638,51 +686,36 @@ void dbji_set_append_recno_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
db->set_append_recno(db, Db_append_recno_callback);
}
- dbji->append_recno_ = NEW_GLOBAL_REF(jnienv, jcallback);
+ dbji->append_recno = NEW_GLOBAL_REF(jnienv, jcallback);
}
extern int dbji_call_append_recno(DB_JAVAINFO *dbji, DB *db, jobject jdb,
DBT *dbt, jint recno)
{
JNIEnv *jnienv;
- jobject jdbt;
+ jobject jresult;
DBT_JAVAINFO *dbtji;
- jbyteArray arr;
- unsigned int arraylen;
- unsigned char *data;
+ LOCKED_DBT lresult;
+ DB_ENV *dbenv;
+ u_char *bytearray;
+ int err;
- COMPQUIET(db, NULL);
jnienv = dbji_get_jnienv(dbji);
+ dbenv = db->dbenv;
if (jnienv == NULL) {
fprintf(stderr, "Cannot attach to current thread!\n");
return (0);
}
- /* XXX
- * We should have a pool of Dbt objects used for this purpose
- * instead of creating new ones each time. Because of
- * multithreading, we may need an arbitrary number (more than two).
- * We might also have a byte arrays that grow as needed,
- * so we don't need to allocate those either.
- *
- * Note, we do not set the 'create_array_' flag as on other
- * callbacks as we are creating the array here.
- */
- jdbt = create_default_object(jnienv, name_DBT);
- dbtji = get_DBT_JAVAINFO(jnienv, jdbt);
- memcpy(&dbtji->dbt, dbt, sizeof(DBT));
- dbtji->dbt.data = NULL;
- arr = (*jnienv)->NewByteArray(jnienv, dbt->size);
- (*jnienv)->SetByteArrayRegion(jnienv, arr, 0, dbt->size,
- (jbyte *)dbt->data);
- dbtji->array_ = (jbyteArray)NEW_GLOBAL_REF(jnienv, arr);
-
- DB_ASSERT(dbji->append_recno_method_id_ != NULL);
- (*jnienv)->CallVoidMethod(jnienv, dbji->append_recno_,
- dbji->append_recno_method_id_,
- jdb, jdbt, recno);
-
- /* The underlying C API requires that an errno be returned
+ jresult = get_Dbt(jnienv, dbt, &dbtji);
+
+ DB_ASSERT(dbji->append_recno_method_id != NULL);
+ (*jnienv)->CallVoidMethod(jnienv, dbji->append_recno,
+ dbji->append_recno_method_id,
+ jdb, jresult, recno);
+
+ /*
+ * The underlying C API requires that an errno be returned
* on error. Java users know nothing of errnos, so we
* allow them to throw exceptions instead. We leave the
* exception in place and return DB_JAVA_CALLBACK to the C API
@@ -701,26 +734,146 @@ extern int dbji_call_append_recno(DB_JAVAINFO *dbji, DB *db, jobject jdb,
if ((*jnienv)->ExceptionOccurred(jnienv) != NULL)
return (DB_JAVA_CALLBACK);
- if (dbtji->array_ == NULL) {
- report_exception(jnienv, "Dbt.data is null", 0, 0);
- return (EFAULT);
+ /*
+ * Now get the DBT back from java, because the user probably
+ * changed it. We'll have to copy back the array too and let
+ * our caller free it.
+ *
+ * We expect that the user *has* changed the DBT (why else would
+ * they set up an append_recno callback?) so we don't
+ * worry about optimizing the unchanged case.
+ */
+ if ((err = locked_dbt_get(&lresult, jnienv, dbenv, jresult, inOp)) != 0)
+ return (err);
+
+ memcpy(dbt, &lresult.javainfo->dbt, sizeof(DBT));
+ if ((err = __os_malloc(dbenv, dbt->size, &bytearray)) != 0)
+ goto out;
+
+ memcpy(bytearray, dbt->data, dbt->size);
+ dbt->data = bytearray;
+ dbt->flags |= DB_DBT_APPMALLOC;
+
+ out:
+ locked_dbt_put(&lresult, jnienv, dbenv);
+ return (err);
+}
+
+void dbji_set_assoc_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
+ DB *db, DB_TXN *txn, DB *second,
+ jobject jcallback, int flags)
+{
+ jclass assoc_class;
+ int err;
+
+ if (dbji->assoc_method_id == NULL) {
+ if ((assoc_class =
+ get_class(jnienv, name_DbSecondaryKeyCreate)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->assoc_method_id =
+ (*jnienv)->GetMethodID(jnienv, assoc_class,
+ "secondary_key_create",
+ "(Lcom/sleepycat/db/Db;"
+ "Lcom/sleepycat/db/Dbt;"
+ "Lcom/sleepycat/db/Dbt;"
+ "Lcom/sleepycat/db/Dbt;)I");
+ if (dbji->assoc_method_id == NULL) {
+ /*
+ * XXX
+ * We should really have a better way
+ * to translate this to a Java exception class.
+ * In theory, it shouldn't happen.
+ */
+ report_exception(jnienv, "Cannot find callback method",
+ EFAULT, 0);
+ return;
+ }
}
- arraylen = (*jnienv)->GetArrayLength(jnienv, dbtji->array_);
- if (dbtji->offset_ < 0 ) {
- report_exception(jnienv, "Dbt.offset illegal", 0, 0);
- return (EFAULT);
+ if (dbji->assoc != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->assoc);
+ dbji->assoc = NULL;
}
- if (dbt->ulen + dbtji->offset_ > arraylen) {
- report_exception(jnienv,
- "Dbt.ulen + Dbt.offset greater than array length", 0, 0);
- return (EFAULT);
+
+ if (jcallback == NULL)
+ err = db->associate(db, txn, second, NULL, flags);
+ else
+ err = db->associate(db, txn, second, Db_assoc_callback, flags);
+
+ if (verify_return(jnienv, err, 0))
+ dbji->assoc = NEW_GLOBAL_REF(jnienv, jcallback);
+}
+
+extern int dbji_call_assoc(DB_JAVAINFO *dbji, DB *db, jobject jdb,
+ const DBT *key, const DBT *value, DBT *result)
+{
+ JNIEnv *jnienv;
+ jobject jresult;
+ LOCKED_DBT lresult;
+ DB_ENV *dbenv;
+ int err;
+ int sz;
+ u_char *bytearray;
+ jint retval;
+
+ jnienv = dbji_get_jnienv(dbji);
+ if (jnienv == NULL) {
+ fprintf(stderr, "Cannot attach to current thread!\n");
+ return (0);
}
- data = (*jnienv)->GetByteArrayElements(jnienv, dbtji->array_,
- (jboolean *)0);
- dbt->data = data + dbtji->offset_;
- return (0);
+ DB_ASSERT(dbji->assoc_method_id != NULL);
+
+ dbenv = db->dbenv;
+ jresult = create_default_object(jnienv, name_DBT);
+
+ retval = (*jnienv)->CallIntMethod(jnienv, dbji->assoc,
+ dbji->assoc_method_id, jdb,
+ get_const_Dbt(jnienv, key, NULL),
+ get_const_Dbt(jnienv, value, NULL),
+ jresult);
+ if (retval != 0)
+ return (retval);
+
+ if ((*jnienv)->ExceptionOccurred(jnienv) != NULL)
+ return (DB_JAVA_CALLBACK);
+
+ if ((err = locked_dbt_get(&lresult, jnienv, dbenv, jresult, inOp)) != 0)
+ return (err);
+
+ sz = lresult.javainfo->dbt.size;
+ if (sz > 0) {
+ bytearray = (u_char *)lresult.javainfo->dbt.data;
+
+ /*
+ * If the byte array is in the range of one of the
+ * arrays passed to us we can use it directly.
+ * If not, we must create our own array and
+ * fill it in with the java array. Since
+ * the java array may disappear and we don't
+ * want to keep its memory locked indefinitely,
+ * we cannot just pin the array.
+ *
+ * XXX consider pinning the array, and having
+ * some way for the C layer to notify the java
+ * layer when it can be unpinned.
+ */
+ if ((bytearray < (u_char *)key->data ||
+ bytearray + sz > (u_char *)key->data + key->size) &&
+ (bytearray < (u_char *)value->data ||
+ bytearray + sz > (u_char *)value->data + value->size)) {
+
+ result->flags |= DB_DBT_APPMALLOC;
+ if ((err = __os_malloc(dbenv, sz, &bytearray)) != 0)
+ goto out;
+ memcpy(bytearray, lresult.javainfo->dbt.data, sz);
+ }
+ result->data = bytearray;
+ result->size = sz;
+ }
+ out:
+ locked_dbt_put(&lresult, jnienv, dbenv);
+ return (err);
}
void dbji_set_bt_compare_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
@@ -728,16 +881,19 @@ void dbji_set_bt_compare_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
{
jclass bt_compare_class;
- if (dbji->bt_compare_method_id_ == NULL) {
- bt_compare_class = get_class(jnienv, name_DbBtreeCompare);
- dbji->bt_compare_method_id_ =
+ if (dbji->bt_compare_method_id == NULL) {
+ if ((bt_compare_class =
+ get_class(jnienv, name_DbBtreeCompare)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->bt_compare_method_id =
(*jnienv)->GetMethodID(jnienv, bt_compare_class,
"bt_compare",
"(Lcom/sleepycat/db/Db;"
"Lcom/sleepycat/db/Dbt;"
"Lcom/sleepycat/db/Dbt;)I");
- if (dbji->bt_compare_method_id_ == NULL) {
- /* XXX
+ if (dbji->bt_compare_method_id == NULL) {
+ /*
+ * XXX
* We should really have a better way
* to translate this to a Java exception class.
* In theory, it shouldn't happen.
@@ -748,8 +904,8 @@ void dbji_set_bt_compare_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
}
}
- if (dbji->bt_compare_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->bt_compare_);
+ if (dbji->bt_compare != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->bt_compare);
}
if (jcompare == NULL) {
db->set_bt_compare(db, NULL);
@@ -758,7 +914,7 @@ void dbji_set_bt_compare_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
db->set_bt_compare(db, Db_bt_compare_callback);
}
- dbji->bt_compare_ = NEW_GLOBAL_REF(jnienv, jcompare);
+ dbji->bt_compare = NEW_GLOBAL_REF(jnienv, jcompare);
}
int dbji_call_bt_compare(DB_JAVAINFO *dbji, DB *db, jobject jdb,
@@ -766,7 +922,6 @@ int dbji_call_bt_compare(DB_JAVAINFO *dbji, DB *db, jobject jdb,
{
JNIEnv *jnienv;
jobject jdbt1, jdbt2;
- DBT_JAVAINFO *dbtji1, *dbtji2;
COMPQUIET(db, NULL);
jnienv = dbji_get_jnienv(dbji);
@@ -775,25 +930,12 @@ int dbji_call_bt_compare(DB_JAVAINFO *dbji, DB *db, jobject jdb,
return (0);
}
- /* XXX
- * We should have a pool of Dbt objects used for this purpose
- * instead of creating new ones each time. Because of
- * multithreading, we may need an arbitrary number (more than two).
- * We might also have a byte arrays that grow as needed,
- * so we don't need to allocate those either.
- */
- jdbt1 = create_default_object(jnienv, name_DBT);
- jdbt2 = create_default_object(jnienv, name_DBT);
- dbtji1 = get_DBT_JAVAINFO(jnienv, jdbt1);
- memcpy(&dbtji1->dbt, dbt1, sizeof(DBT));
- dbtji1->create_array_ = 1;
- dbtji2 = get_DBT_JAVAINFO(jnienv, jdbt2);
- memcpy(&dbtji2->dbt, dbt2, sizeof(DBT));
- dbtji2->create_array_ = 1;
-
- DB_ASSERT(dbji->bt_compare_method_id_ != NULL);
- return (*jnienv)->CallIntMethod(jnienv, dbji->bt_compare_,
- dbji->bt_compare_method_id_,
+ jdbt1 = get_const_Dbt(jnienv, dbt1, NULL);
+ jdbt2 = get_const_Dbt(jnienv, dbt2, NULL);
+
+ DB_ASSERT(dbji->bt_compare_method_id != NULL);
+ return (*jnienv)->CallIntMethod(jnienv, dbji->bt_compare,
+ dbji->bt_compare_method_id,
jdb, jdbt1, jdbt2);
}
@@ -802,16 +944,19 @@ void dbji_set_bt_prefix_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
{
jclass bt_prefix_class;
- if (dbji->bt_prefix_method_id_ == NULL) {
- bt_prefix_class = get_class(jnienv, name_DbBtreePrefix);
- dbji->bt_prefix_method_id_ =
+ if (dbji->bt_prefix_method_id == NULL) {
+ if ((bt_prefix_class =
+ get_class(jnienv, name_DbBtreePrefix)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->bt_prefix_method_id =
(*jnienv)->GetMethodID(jnienv, bt_prefix_class,
"bt_prefix",
"(Lcom/sleepycat/db/Db;"
"Lcom/sleepycat/db/Dbt;"
"Lcom/sleepycat/db/Dbt;)I");
- if (dbji->bt_prefix_method_id_ == NULL) {
- /* XXX
+ if (dbji->bt_prefix_method_id == NULL) {
+ /*
+ * XXX
* We should really have a better way
* to translate this to a Java exception class.
* In theory, it shouldn't happen.
@@ -822,8 +967,8 @@ void dbji_set_bt_prefix_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
}
}
- if (dbji->bt_prefix_ != NULL) {
- DELETE_GLOBAL_REF(jnienv, dbji->bt_prefix_);
+ if (dbji->bt_prefix != NULL) {
+ DELETE_GLOBAL_REF(jnienv, dbji->bt_prefix);
}
if (jprefix == NULL) {
db->set_bt_prefix(db, NULL);
@@ -832,7 +977,7 @@ void dbji_set_bt_prefix_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
db->set_bt_prefix(db, Db_bt_prefix_callback);
}
- dbji->bt_prefix_ = NEW_GLOBAL_REF(jnienv, jprefix);
+ dbji->bt_prefix = NEW_GLOBAL_REF(jnienv, jprefix);
}
size_t dbji_call_bt_prefix(DB_JAVAINFO *dbji, DB *db, jobject jdb,
@@ -840,7 +985,6 @@ size_t dbji_call_bt_prefix(DB_JAVAINFO *dbji, DB *db, jobject jdb,
{
JNIEnv *jnienv;
jobject jdbt1, jdbt2;
- DBT_JAVAINFO *dbtji1, *dbtji2;
COMPQUIET(db, NULL);
jnienv = dbji_get_jnienv(dbji);
@@ -849,25 +993,12 @@ size_t dbji_call_bt_prefix(DB_JAVAINFO *dbji, DB *db, jobject jdb,
return (0);
}
- /* XXX
- * We should have a pool of Dbt objects used for this purpose
- * instead of creating new ones each time. Because of
- * multithreading, we may need an arbitrary number (more than two).
- * We might also have a byte arrays that grow as needed,
- * so we don't need to allocate those either.
- */
- jdbt1 = create_default_object(jnienv, name_DBT);
- jdbt2 = create_default_object(jnienv, name_DBT);
- dbtji1 = get_DBT_JAVAINFO(jnienv, jdbt1);
- memcpy(&dbtji1->dbt, dbt1, sizeof(DBT));
- dbtji1->create_array_ = 1;
- dbtji2 = get_DBT_JAVAINFO(jnienv, jdbt2);
- memcpy(&dbtji2->dbt, dbt2, sizeof(DBT));
- dbtji2->create_array_ = 1;
-
- DB_ASSERT(dbji->bt_prefix_method_id_ != NULL);
- return (size_t)(*jnienv)->CallIntMethod(jnienv, dbji->bt_prefix_,
- dbji->bt_prefix_method_id_,
+ jdbt1 = get_const_Dbt(jnienv, dbt1, NULL);
+ jdbt2 = get_const_Dbt(jnienv, dbt2, NULL);
+
+ DB_ASSERT(dbji->bt_prefix_method_id != NULL);
+ return (size_t)(*jnienv)->CallIntMethod(jnienv, dbji->bt_prefix,
+ dbji->bt_prefix_method_id,
jdb, jdbt1, jdbt2);
}
@@ -876,16 +1007,19 @@ void dbji_set_dup_compare_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
{
jclass dup_compare_class;
- if (dbji->dup_compare_method_id_ == NULL) {
- dup_compare_class = get_class(jnienv, name_DbDupCompare);
- dbji->dup_compare_method_id_ =
+ if (dbji->dup_compare_method_id == NULL) {
+ if ((dup_compare_class =
+ get_class(jnienv, name_DbDupCompare)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->dup_compare_method_id =
(*jnienv)->GetMethodID(jnienv, dup_compare_class,
"dup_compare",
"(Lcom/sleepycat/db/Db;"
"Lcom/sleepycat/db/Dbt;"
"Lcom/sleepycat/db/Dbt;)I");
- if (dbji->dup_compare_method_id_ == NULL) {
- /* XXX
+ if (dbji->dup_compare_method_id == NULL) {
+ /*
+ * XXX
* We should really have a better way
* to translate this to a Java exception class.
* In theory, it shouldn't happen.
@@ -896,15 +1030,15 @@ void dbji_set_dup_compare_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
}
}
- if (dbji->dup_compare_ != NULL)
- DELETE_GLOBAL_REF(jnienv, dbji->dup_compare_);
+ if (dbji->dup_compare != NULL)
+ DELETE_GLOBAL_REF(jnienv, dbji->dup_compare);
if (jcompare == NULL)
db->set_dup_compare(db, NULL);
else
db->set_dup_compare(db, Db_dup_compare_callback);
- dbji->dup_compare_ = NEW_GLOBAL_REF(jnienv, jcompare);
+ dbji->dup_compare = NEW_GLOBAL_REF(jnienv, jcompare);
}
int dbji_call_dup_compare(DB_JAVAINFO *dbji, DB *db, jobject jdb,
@@ -912,7 +1046,6 @@ int dbji_call_dup_compare(DB_JAVAINFO *dbji, DB *db, jobject jdb,
{
JNIEnv *jnienv;
jobject jdbt1, jdbt2;
- DBT_JAVAINFO *dbtji1, *dbtji2;
COMPQUIET(db, NULL);
jnienv = dbji_get_jnienv(dbji);
@@ -921,25 +1054,12 @@ int dbji_call_dup_compare(DB_JAVAINFO *dbji, DB *db, jobject jdb,
return (0);
}
- /* XXX
- * We should have a pool of Dbt objects used for this purpose
- * instead of creating new ones each time. Because of
- * multithreading, we may need an arbitrary number (more than two).
- * We might also have a byte arrays that grow as needed,
- * so we don't need to allocate those either.
- */
- jdbt1 = create_default_object(jnienv, name_DBT);
- jdbt2 = create_default_object(jnienv, name_DBT);
- dbtji1 = get_DBT_JAVAINFO(jnienv, jdbt1);
- memcpy(&dbtji1->dbt, dbt1, sizeof(DBT));
- dbtji1->create_array_ = 1;
- dbtji2 = get_DBT_JAVAINFO(jnienv, jdbt2);
- memcpy(&dbtji2->dbt, dbt2, sizeof(DBT));
- dbtji2->create_array_ = 1;
-
- DB_ASSERT(dbji->dup_compare_method_id_ != NULL);
- return (*jnienv)->CallIntMethod(jnienv, dbji->dup_compare_,
- dbji->dup_compare_method_id_,
+ jdbt1 = get_const_Dbt(jnienv, dbt1, NULL);
+ jdbt2 = get_const_Dbt(jnienv, dbt2, NULL);
+
+ DB_ASSERT(dbji->dup_compare_method_id != NULL);
+ return (*jnienv)->CallIntMethod(jnienv, dbji->dup_compare,
+ dbji->dup_compare_method_id,
jdb, jdbt1, jdbt2);
}
@@ -948,15 +1068,18 @@ void dbji_set_h_hash_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
{
jclass h_hash_class;
- if (dbji->h_hash_method_id_ == NULL) {
- h_hash_class = get_class(jnienv, name_DbHash);
- dbji->h_hash_method_id_ =
+ if (dbji->h_hash_method_id == NULL) {
+ if ((h_hash_class =
+ get_class(jnienv, name_DbHash)) == NULL)
+ return; /* An exception has been posted. */
+ dbji->h_hash_method_id =
(*jnienv)->GetMethodID(jnienv, h_hash_class,
"hash",
"(Lcom/sleepycat/db/Db;"
"[BI)I");
- if (dbji->h_hash_method_id_ == NULL) {
- /* XXX
+ if (dbji->h_hash_method_id == NULL) {
+ /*
+ * XXX
* We should really have a better way
* to translate this to a Java exception class.
* In theory, it shouldn't happen.
@@ -967,22 +1090,22 @@ void dbji_set_h_hash_object(DB_JAVAINFO *dbji, JNIEnv *jnienv,
}
}
- if (dbji->h_hash_ != NULL)
- DELETE_GLOBAL_REF(jnienv, dbji->h_hash_);
+ if (dbji->h_hash != NULL)
+ DELETE_GLOBAL_REF(jnienv, dbji->h_hash);
if (jhash == NULL)
db->set_h_hash(db, NULL);
else
db->set_h_hash(db, Db_h_hash_callback);
- dbji->h_hash_ = NEW_GLOBAL_REF(jnienv, jhash);
+ dbji->h_hash = NEW_GLOBAL_REF(jnienv, jhash);
}
int dbji_call_h_hash(DB_JAVAINFO *dbji, DB *db, jobject jdb,
const void *data, int len)
{
JNIEnv *jnienv;
- jbyteArray jarray;
+ jbyteArray jdata;
COMPQUIET(db, NULL);
jnienv = dbji_get_jnienv(dbji);
@@ -991,11 +1114,12 @@ int dbji_call_h_hash(DB_JAVAINFO *dbji, DB *db, jobject jdb,
return (0);
}
- DB_ASSERT(dbji->h_hash_method_id_ != NULL);
+ DB_ASSERT(dbji->h_hash_method_id != NULL);
- jarray = (*jnienv)->NewByteArray(jnienv, len);
- (*jnienv)->SetByteArrayRegion(jnienv, jarray, 0, len, (void *)data);
- return (*jnienv)->CallIntMethod(jnienv, dbji->h_hash_,
- dbji->h_hash_method_id_,
- jdb, jarray, len);
+ if ((jdata = (*jnienv)->NewByteArray(jnienv, len)) == NULL)
+ return (0); /* An exception has been posted by the JVM */
+ (*jnienv)->SetByteArrayRegion(jnienv, jdata, 0, len, (void *)data);
+ return (*jnienv)->CallIntMethod(jnienv, dbji->h_hash,
+ dbji->h_hash_method_id,
+ jdb, jdata, len);
}
diff --git a/bdb/libdb_java/java_info.h b/bdb/libdb_java/java_info.h
index 69032be80e6..bda83db420e 100644
--- a/bdb/libdb_java/java_info.h
+++ b/bdb/libdb_java/java_info.h
@@ -1,10 +1,10 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*
- * $Id: java_info.h,v 11.17 2000/07/31 20:28:30 dda Exp $
+ * $Id: java_info.h,v 11.35 2002/08/29 14:22:23 margo Exp $
*/
#ifndef _JAVA_INFO_H_
@@ -36,16 +36,22 @@
typedef struct _dbt_javainfo
{
DBT dbt;
- DB *db_; /* associated DB */
- jobject dbtref_; /* the java Dbt object */
- jbyteArray array_;
- int offset_;
- int create_array_; /* flag to create the array as needed */
+ DB *db; /* associated DB */
+ jobject dbtref; /* the java Dbt object */
+ jbyteArray array; /* the java array object -
+ this is only valid during the API call */
+ int offset; /* offset into the Java array */
+
+#define DBT_JAVAINFO_LOCKED 0x01 /* a LOCKED_DBT has been created */
+ u_int32_t flags;
}
-DBT_JAVAINFO; /* used with all 'dbtji' functions */
+DBT_JAVAINFO; /* used with all 'dbtji' functions */
+/* create/initialize a DBT_JAVAINFO object */
extern DBT_JAVAINFO *dbjit_construct();
-extern void dbjit_release(DBT_JAVAINFO *dbjit, JNIEnv *jnienv);
+
+/* free this DBT_JAVAINFO, releasing anything allocated on its behalf */
+extern void dbjit_destroy(DBT_JAVAINFO *dbjit);
/****************************************************************
*
@@ -82,22 +88,25 @@ extern void dbjit_release(DBT_JAVAINFO *dbjit, JNIEnv *jnienv);
*/
typedef struct _db_env_javainfo
{
- JavaVM *javavm_;
- int is_dbopen_;
- char *errpfx_;
- jobject jdbref_; /* temporary reference */
- jobject jenvref_; /* temporary reference */
- jobject default_errcall_; /* global reference */
- jobject errcall_; /* global reference */
- jobject feedback_; /* global reference */
- jobject tx_recover_; /* global reference */
- jobject recovery_init_; /* global reference */
- unsigned char *conflict_;
+ JavaVM *javavm;
+ int is_dbopen;
+ char *errpfx;
+ jobject jenvref; /* global reference */
+ jobject default_errcall; /* global reference */
+ jobject errcall; /* global reference */
+ jobject feedback; /* global reference */
+ jobject rep_transport; /* global reference */
+ jobject app_dispatch; /* global reference */
+ jobject recovery_init; /* global reference */
+ u_char *conflict;
+ size_t conflict_size;
+ jint construct_flags;
}
-DB_ENV_JAVAINFO; /* used with all 'dbjie' functions */
+DB_ENV_JAVAINFO; /* used with all 'dbjie' functions */
/* create/initialize an object */
extern DB_ENV_JAVAINFO *dbjie_construct(JNIEnv *jnienv,
+ jobject jenv,
jobject default_errcall,
int is_dbopen);
@@ -115,7 +124,7 @@ extern void dbjie_set_errpfx(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
extern jstring dbjie_get_errpfx(DB_ENV_JAVAINFO *, JNIEnv *jnienv);
extern void dbjie_set_errcall(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
jobject new_errcall);
-extern void dbjie_set_conflict(DB_ENV_JAVAINFO *, unsigned char *v);
+extern void dbjie_set_conflict(DB_ENV_JAVAINFO *, u_char *v, size_t sz);
extern void dbjie_set_feedback_object(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
DB_ENV *dbenv, jobject value);
extern void dbjie_call_feedback(DB_ENV_JAVAINFO *, DB_ENV *dbenv, jobject jenv,
@@ -124,13 +133,18 @@ extern void dbjie_set_recovery_init_object(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
DB_ENV *dbenv, jobject value);
extern int dbjie_call_recovery_init(DB_ENV_JAVAINFO *, DB_ENV *dbenv,
jobject jenv);
-extern void dbjie_set_tx_recover_object(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
+extern void dbjie_set_rep_transport_object(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
+ DB_ENV *dbenv, int id, jobject obj);
+extern int dbjie_call_rep_transport(DB_ENV_JAVAINFO *, DB_ENV *dbenv,
+ jobject jenv, const DBT *control,
+ const DBT *rec, int envid, int flags);
+extern void dbjie_set_app_dispatch_object(DB_ENV_JAVAINFO *, JNIEnv *jnienv,
DB_ENV *dbenv, jobject value);
-extern int dbjie_call_tx_recover(DB_ENV_JAVAINFO *,
+extern int dbjie_call_app_dispatch(DB_ENV_JAVAINFO *,
DB_ENV *dbenv, jobject jenv,
DBT *dbt, DB_LSN *lsn, int recops);
extern jobject dbjie_get_errcall(DB_ENV_JAVAINFO *) ;
-extern int dbjie_is_dbopen(DB_ENV_JAVAINFO *);
+extern jint dbjie_is_dbopen(DB_ENV_JAVAINFO *);
/****************************************************************
*
@@ -147,25 +161,27 @@ extern int dbjie_is_dbopen(DB_ENV_JAVAINFO *);
*/
typedef struct _db_javainfo
{
- JavaVM *javavm_;
- jobject jdbref_; /* temporary reference during callback */
- jobject feedback_; /* global reference */
- jobject append_recno_; /* global reference */
- jobject bt_compare_; /* global reference */
- jobject bt_prefix_; /* global reference */
- jobject dup_compare_; /* global reference */
- jobject h_hash_; /* global reference */
- jmethodID feedback_method_id_;
- jmethodID append_recno_method_id_;
- jmethodID bt_compare_method_id_;
- jmethodID bt_prefix_method_id_;
- jmethodID dup_compare_method_id_;
- jmethodID h_hash_method_id_;
- jint construct_flags_;
+ JavaVM *javavm;
+ jobject jdbref; /* global reference */
+ jobject append_recno; /* global reference */
+ jobject assoc; /* global reference */
+ jobject bt_compare; /* global reference */
+ jobject bt_prefix; /* global reference */
+ jobject dup_compare; /* global reference */
+ jobject feedback; /* global reference */
+ jobject h_hash; /* global reference */
+ jmethodID append_recno_method_id;
+ jmethodID assoc_method_id;
+ jmethodID bt_compare_method_id;
+ jmethodID bt_prefix_method_id;
+ jmethodID dup_compare_method_id;
+ jmethodID feedback_method_id;
+ jmethodID h_hash_method_id;
+ jint construct_flags;
} DB_JAVAINFO;
/* create/initialize an object */
-extern DB_JAVAINFO *dbji_construct(JNIEnv *jnienv, jint flags);
+extern DB_JAVAINFO *dbji_construct(JNIEnv *jnienv, jobject jdb, jint flags);
/* release all objects held by this this one */
extern void dbji_dealloc(DB_JAVAINFO *, JNIEnv *jnienv);
@@ -184,6 +200,11 @@ extern void dbji_call_feedback(DB_JAVAINFO *, DB *db, jobject jdb,
extern void dbji_set_append_recno_object(DB_JAVAINFO *, JNIEnv *jnienv, DB *db, jobject value);
extern int dbji_call_append_recno(DB_JAVAINFO *, DB *db, jobject jdb,
DBT *dbt, jint recno);
+extern void dbji_set_assoc_object(DB_JAVAINFO *, JNIEnv *jnienv,
+ DB *db, DB_TXN *txn, DB *second,
+ jobject value, int flags);
+extern int dbji_call_assoc(DB_JAVAINFO *, DB *db, jobject jdb,
+ const DBT *key, const DBT* data, DBT *result);
extern void dbji_set_bt_compare_object(DB_JAVAINFO *, JNIEnv *jnienv, DB *db, jobject value);
extern int dbji_call_bt_compare(DB_JAVAINFO *, DB *db, jobject jdb,
const DBT *dbt1, const DBT *dbt2);
diff --git a/bdb/libdb_java/java_locked.c b/bdb/libdb_java/java_locked.c
index a5603df5d60..9534a387b40 100644
--- a/bdb/libdb_java/java_locked.c
+++ b/bdb/libdb_java/java_locked.c
@@ -1,13 +1,13 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_locked.c,v 11.11 2000/10/25 19:54:55 dda Exp $";
+static const char revid[] = "$Id: java_locked.c,v 11.32 2002/08/06 05:19:07 bostic Exp $";
#endif /* not lint */
#include <jni.h>
@@ -15,280 +15,307 @@ static const char revid[] = "$Id: java_locked.c,v 11.11 2000/10/25 19:54:55 dda
#include <stdlib.h>
#include <string.h>
-#include "db.h"
+#include "db_int.h"
#include "java_util.h"
/****************************************************************
*
- * Implementation of class LockedDBT
- *
+ * Implementation of functions to manipulate LOCKED_DBT.
*/
int
-jdbt_lock(JDBT *jdbt, JNIEnv *jnienv, jobject obj, OpKind kind)
+locked_dbt_get(LOCKED_DBT *ldbt, JNIEnv *jnienv, DB_ENV *dbenv,
+ jobject jdbt, OpKind kind)
{
DBT *dbt;
- jdbt->obj_ = obj;
- jdbt->do_realloc_ = 0;
- jdbt->kind_ = kind;
- jdbt->java_array_len_= 0;
- jdbt->java_data_ = 0;
- jdbt->before_data_ = 0;
- jdbt->has_error_ = 0;
- jdbt->dbt = (DBT_JAVAINFO *)get_private_dbobj(jnienv, name_DBT, obj);
-
- if (!verify_non_null(jnienv, jdbt->dbt)) {
- jdbt->has_error_ = 1;
+ COMPQUIET(dbenv, NULL);
+ ldbt->jdbt = jdbt;
+ ldbt->java_array_len = 0;
+ ldbt->flags = 0;
+ ldbt->kind = kind;
+ ldbt->java_data = 0;
+ ldbt->before_data = 0;
+ ldbt->javainfo =
+ (DBT_JAVAINFO *)get_private_dbobj(jnienv, name_DBT, jdbt);
+
+ if (!verify_non_null(jnienv, ldbt->javainfo)) {
+ report_exception(jnienv, "Dbt is gc'ed?", 0, 0);
+ F_SET(ldbt, LOCKED_ERROR);
return (EINVAL);
}
- dbt = &jdbt->dbt->dbt;
-
- if (kind == outOp &&
- (dbt->flags & (DB_DBT_USERMEM | DB_DBT_MALLOC | DB_DBT_REALLOC)) == 0) {
- report_exception(jnienv,
- "Dbt.flags must be set to Db.DB_DBT_USERMEM, "
- "Db.DB_DBT_MALLOC or Db.DB_DBT_REALLOC",
- 0, 0);
- jdbt->has_error_ = 1;
+ if (F_ISSET(ldbt->javainfo, DBT_JAVAINFO_LOCKED)) {
+ report_exception(jnienv, "Dbt is already in use", 0, 0);
+ F_SET(ldbt, LOCKED_ERROR);
return (EINVAL);
}
+ dbt = &ldbt->javainfo->dbt;
- /* If this is requested to be realloc, we cannot use the
- * underlying realloc, because the array we will pass in
- * is not allocated by us, but the Java VM, so it cannot
- * be successfully realloced. We simulate the reallocation,
- * by using USERMEM and reallocating the java array when a
- * ENOMEM error occurs. We change the flags during the operation,
- * and they are reset when the operation completes (in the
- * LockedDBT destructor.
+ if ((*jnienv)->GetBooleanField(jnienv,
+ jdbt, fid_Dbt_must_create_data) != 0)
+ F_SET(ldbt, LOCKED_CREATE_DATA);
+ else
+ ldbt->javainfo->array =
+ (*jnienv)->GetObjectField(jnienv, jdbt, fid_Dbt_data);
+
+ dbt->size = (*jnienv)->GetIntField(jnienv, jdbt, fid_Dbt_size);
+ dbt->ulen = (*jnienv)->GetIntField(jnienv, jdbt, fid_Dbt_ulen);
+ dbt->dlen = (*jnienv)->GetIntField(jnienv, jdbt, fid_Dbt_dlen);
+ dbt->doff = (*jnienv)->GetIntField(jnienv, jdbt, fid_Dbt_doff);
+ dbt->flags = (*jnienv)->GetIntField(jnienv, jdbt, fid_Dbt_flags);
+ ldbt->javainfo->offset = (*jnienv)->GetIntField(jnienv, jdbt,
+ fid_Dbt_offset);
+
+ /*
+ * If no flags are set, use default behavior of DB_DBT_MALLOC.
+ * We can safely set dbt->flags because flags will never be copied
+ * back to the Java Dbt.
+ */
+ if (kind != inOp &&
+ !F_ISSET(dbt, DB_DBT_USERMEM | DB_DBT_MALLOC | DB_DBT_REALLOC))
+ F_SET(dbt, DB_DBT_MALLOC);
+
+ /*
+ * If this is requested to be realloc with an existing array,
+ * we cannot use the underlying realloc, because the array we
+ * will pass in is allocated by the Java VM, not us, so it
+ * cannot be realloced. We simulate the reallocation by using
+ * USERMEM and reallocating the java array when a ENOMEM error
+ * occurs. We change the flags during the operation, and they
+ * are reset when the operation completes (in locked_dbt_put).
*/
- if ((dbt->flags & DB_DBT_REALLOC) != 0) {
- dbt->flags &= ~DB_DBT_REALLOC;
- dbt->flags |= DB_DBT_USERMEM;
- jdbt->do_realloc_ = 1;
+ if (F_ISSET(dbt, DB_DBT_REALLOC) && ldbt->javainfo->array != NULL) {
+ F_CLR(dbt, DB_DBT_REALLOC);
+ F_SET(dbt, DB_DBT_USERMEM);
+ F_SET(ldbt, LOCKED_REALLOC_NONNULL);
}
- if ((dbt->flags & DB_DBT_USERMEM) || kind != outOp) {
+ if ((F_ISSET(dbt, DB_DBT_USERMEM) || kind != outOp) &&
+ !F_ISSET(ldbt, LOCKED_CREATE_DATA)) {
- /* If writing with DB_DBT_USERMEM/REALLOC
+ /*
+ * If writing with DB_DBT_USERMEM
* or it's a set (or get/set) operation,
* then the data should point to a java array.
* Note that outOp means data is coming out of the database
* (it's a get). inOp means data is going into the database
* (either a put, or a key input).
*/
- if (!jdbt->dbt->array_) {
+ if (!ldbt->javainfo->array) {
report_exception(jnienv, "Dbt.data is null", 0, 0);
- jdbt->has_error_ = 1;
+ F_SET(ldbt, LOCKED_ERROR);
return (EINVAL);
}
/* Verify other parameters */
- jdbt->java_array_len_ = (*jnienv)->GetArrayLength(jnienv, jdbt->dbt->array_);
- if (jdbt->dbt->offset_ < 0 ) {
+ ldbt->java_array_len = (*jnienv)->GetArrayLength(jnienv,
+ ldbt->javainfo->array);
+ if (ldbt->javainfo->offset < 0 ) {
report_exception(jnienv, "Dbt.offset illegal", 0, 0);
- jdbt->has_error_ = 1;
+ F_SET(ldbt, LOCKED_ERROR);
return (EINVAL);
}
- if (dbt->ulen + jdbt->dbt->offset_ > jdbt->java_array_len_) {
+ if (dbt->size + ldbt->javainfo->offset > ldbt->java_array_len) {
report_exception(jnienv,
- "Dbt.ulen + Dbt.offset greater than array length", 0, 0);
- jdbt->has_error_ = 1;
+ "Dbt.size + Dbt.offset greater than array length",
+ 0, 0);
+ F_SET(ldbt, LOCKED_ERROR);
return (EINVAL);
}
- jdbt->java_data_ = (*jnienv)->GetByteArrayElements(jnienv, jdbt->dbt->array_,
- (jboolean *)0);
- dbt->data = jdbt->before_data_ = jdbt->java_data_ + jdbt->dbt->offset_;
+ ldbt->java_data = (*jnienv)->GetByteArrayElements(jnienv,
+ ldbt->javainfo->array,
+ (jboolean *)0);
+
+ dbt->data = ldbt->before_data = ldbt->java_data +
+ ldbt->javainfo->offset;
}
- else {
+ else if (!F_ISSET(ldbt, LOCKED_CREATE_DATA)) {
- /* If writing with DB_DBT_MALLOC, then the data is
- * allocated by DB.
+ /*
+ * If writing with DB_DBT_MALLOC or DB_DBT_REALLOC with
+ * a null array, then the data is allocated by DB.
*/
- dbt->data = jdbt->before_data_ = 0;
+ dbt->data = ldbt->before_data = 0;
}
+
+ /*
+ * RPC makes the assumption that if dbt->size is non-zero, there
+ * is data to copy from dbt->data. We may have set dbt->size
+ * to a non-zero integer above but decided not to point
+ * dbt->data at anything. (One example is if we're doing an outOp
+ * with an already-used Dbt whose values we expect to just
+ * overwrite.)
+ *
+ * Clean up the dbt fields so we don't run into trouble.
+ * (Note that doff, dlen, and flags all may contain meaningful
+ * values.)
+ */
+ if (dbt->data == NULL)
+ dbt->size = dbt->ulen = 0;
+
+ F_SET(ldbt->javainfo, DBT_JAVAINFO_LOCKED);
return (0);
}
-/* The LockedDBT destructor is called when the java handler returns
- * to the user, since that's when the LockedDBT objects go out of scope.
- * Since it is thus called after any call to the underlying database,
- * it copies any information from temporary structures back to user
- * accessible arrays, and of course must free memory and remove references.
+/*
+ * locked_dbt_put must be called for any LOCKED_DBT struct before a
+ * java handler returns to the user. It can be thought of as the
+ * LOCKED_DBT destructor. It copies any information from temporary
+ * structures back to user accessible arrays, and of course must free
+ * memory and remove references. The LOCKED_DBT itself is not freed,
+ * as it is expected to be a stack variable.
+ *
+ * Note that after this call, the LOCKED_DBT can still be used in
+ * limited ways, e.g. to look at values in the C DBT.
*/
void
-jdbt_unlock(JDBT *jdbt, JNIEnv *jnienv)
+locked_dbt_put(LOCKED_DBT *ldbt, JNIEnv *jnienv, DB_ENV *dbenv)
{
DBT *dbt;
- dbt = &jdbt->dbt->dbt;
+ dbt = &ldbt->javainfo->dbt;
- /* Fix up the flags if we changed them. */
- if (jdbt->do_realloc_) {
- dbt->flags &= ~DB_DBT_USERMEM;
- dbt->flags |= DB_DBT_REALLOC;
- }
+ /*
+ * If the error flag was set, we never succeeded
+ * in allocating storage.
+ */
+ if (F_ISSET(ldbt, LOCKED_ERROR))
+ return;
- if ((dbt->flags & (DB_DBT_USERMEM | DB_DBT_REALLOC)) ||
- jdbt->kind_ == inOp) {
+ if (((F_ISSET(dbt, DB_DBT_USERMEM) ||
+ F_ISSET(ldbt, LOCKED_REALLOC_NONNULL)) ||
+ ldbt->kind == inOp) && !F_ISSET(ldbt, LOCKED_CREATE_DATA)) {
- /* If writing with DB_DBT_USERMEM/REALLOC or it's a set
+ /*
+ * If writing with DB_DBT_USERMEM or it's a set
* (or get/set) operation, then the data may be already in
* the java array, in which case, we just need to release it.
* If DB didn't put it in the array (indicated by the
* dbt->data changing), we need to do that
*/
- if (jdbt->before_data_ != jdbt->java_data_) {
+ if (ldbt->before_data != ldbt->java_data) {
(*jnienv)->SetByteArrayRegion(jnienv,
- jdbt->dbt->array_,
- jdbt->dbt->offset_,
+ ldbt->javainfo->array,
+ ldbt->javainfo->offset,
dbt->ulen,
- jdbt->before_data_);
+ ldbt->before_data);
}
- (*jnienv)->ReleaseByteArrayElements(jnienv, jdbt->dbt->array_, jdbt->java_data_, 0);
+ (*jnienv)->ReleaseByteArrayElements(jnienv,
+ ldbt->javainfo->array,
+ ldbt->java_data, 0);
dbt->data = 0;
}
- if ((dbt->flags & DB_DBT_MALLOC) && jdbt->kind_ != inOp) {
-
- /* If writing with DB_DBT_MALLOC, then the data was allocated
- * by DB. If dbt->data is zero, it means an error occurred
- * (and should have been already reported).
+ else if (F_ISSET(dbt, DB_DBT_MALLOC | DB_DBT_REALLOC) &&
+ ldbt->kind != inOp && !F_ISSET(ldbt, LOCKED_CREATE_DATA)) {
+
+ /*
+ * If writing with DB_DBT_MALLOC, or DB_DBT_REALLOC
+ * with a zero buffer, then the data was allocated by
+ * DB. If dbt->data is zero, it means an error
+ * occurred (and should have been already reported).
*/
if (dbt->data) {
- /* Release any old references. */
- dbjit_release(jdbt->dbt, jnienv);
-
- /* In the case of SET_RANGE, the key is inOutOp
+ /*
+ * In the case of SET_RANGE, the key is inOutOp
* and when not found, its data will be left as
* its original value. Only copy and free it
* here if it has been allocated by DB
* (dbt->data has changed).
*/
- if (dbt->data != jdbt->before_data_) {
- jdbt->dbt->array_ = (jbyteArray)
- NEW_GLOBAL_REF(jnienv,
- (*jnienv)->NewByteArray(jnienv,
- dbt->size));
- jdbt->dbt->offset_ = 0;
+ if (dbt->data != ldbt->before_data) {
+ jbyteArray newarr;
+
+ if ((newarr = (*jnienv)->NewByteArray(jnienv,
+ dbt->size)) == NULL) {
+ /* The JVM has posted an exception. */
+ F_SET(ldbt, LOCKED_ERROR);
+ return;
+ }
+ (*jnienv)->SetObjectField(jnienv, ldbt->jdbt,
+ fid_Dbt_data,
+ newarr);
+ ldbt->javainfo->offset = 0;
(*jnienv)->SetByteArrayRegion(jnienv,
- jdbt->dbt->array_, 0, dbt->size,
+ newarr, 0, dbt->size,
(jbyte *)dbt->data);
- free(dbt->data);
+ (void)__os_ufree(dbenv, dbt->data);
dbt->data = 0;
}
}
}
+
+ /*
+ * The size field may have changed after a DB API call,
+ * so we set that back too.
+ */
+ (*jnienv)->SetIntField(jnienv, ldbt->jdbt, fid_Dbt_size, dbt->size);
+ ldbt->javainfo->array = NULL;
+ F_CLR(ldbt->javainfo, DBT_JAVAINFO_LOCKED);
}
-/* Realloc the java array to receive data if the DBT was marked
- * for realloc, and the last operation set the size field to an
- * amount greater than ulen.
+/*
+ * Realloc the java array to receive data if the DBT used
+ * DB_DBT_REALLOC flag with a non-null data array, and the last
+ * operation set the size field to an amount greater than ulen.
+ * Return 1 if these conditions are met, otherwise 0. This is used
+ * internally to simulate the operations needed for DB_DBT_REALLOC.
*/
-int jdbt_realloc(JDBT *jdbt, JNIEnv *jnienv)
+int locked_dbt_realloc(LOCKED_DBT *ldbt, JNIEnv *jnienv, DB_ENV *dbenv)
{
DBT *dbt;
- dbt = &jdbt->dbt->dbt;
+ COMPQUIET(dbenv, NULL);
+ dbt = &ldbt->javainfo->dbt;
- if (!jdbt->do_realloc_ || jdbt->has_error_ || dbt->size <= dbt->ulen)
+ if (!F_ISSET(ldbt, LOCKED_REALLOC_NONNULL) ||
+ F_ISSET(ldbt, LOCKED_ERROR) || dbt->size <= dbt->ulen)
return (0);
- (*jnienv)->ReleaseByteArrayElements(jnienv, jdbt->dbt->array_, jdbt->java_data_, 0);
- dbjit_release(jdbt->dbt, jnienv);
+ (*jnienv)->ReleaseByteArrayElements(jnienv, ldbt->javainfo->array,
+ ldbt->java_data, 0);
- /* We allocate a new array of the needed size.
+ /*
+ * We allocate a new array of the needed size.
* We'll set the offset to 0, as the old offset
* really doesn't make any sense.
*/
- jdbt->java_array_len_ = dbt->ulen = dbt->size;
- jdbt->dbt->offset_ = 0;
- jdbt->dbt->array_ = (jbyteArray)
- NEW_GLOBAL_REF(jnienv, (*jnienv)->NewByteArray(jnienv, dbt->size));
-
- jdbt->java_data_ = (*jnienv)->GetByteArrayElements(jnienv,
- jdbt->dbt->array_,
- (jboolean *)0);
- dbt->data = jdbt->before_data_ = jdbt->java_data_;
+ if ((ldbt->javainfo->array = (*jnienv)->NewByteArray(jnienv,
+ dbt->size)) == NULL) {
+ F_SET(ldbt, LOCKED_ERROR);
+ return (0);
+ }
+
+ ldbt->java_array_len = dbt->ulen = dbt->size;
+ ldbt->javainfo->offset = 0;
+ (*jnienv)->SetObjectField(jnienv, ldbt->jdbt, fid_Dbt_data,
+ ldbt->javainfo->array);
+ ldbt->java_data = (*jnienv)->GetByteArrayElements(jnienv,
+ ldbt->javainfo->array, (jboolean *)0);
+ memcpy(ldbt->java_data, ldbt->before_data, dbt->ulen);
+ dbt->data = ldbt->before_data = ldbt->java_data;
return (1);
}
/****************************************************************
*
- * Implementation of class JSTR
- *
+ * Implementation of functions to manipulate LOCKED_STRING.
*/
int
-jstr_lock(JSTR *js, JNIEnv *jnienv, jstring jstr)
+locked_string_get(LOCKED_STRING *ls, JNIEnv *jnienv, jstring jstr)
{
- js->jstr_ = jstr;
+ ls->jstr = jstr;
if (jstr == 0)
- js->string = 0;
+ ls->string = 0;
else
- js->string = (*jnienv)->GetStringUTFChars(jnienv, jstr,
+ ls->string = (*jnienv)->GetStringUTFChars(jnienv, jstr,
(jboolean *)0);
return (0);
}
-void jstr_unlock(JSTR *js, JNIEnv *jnienv)
+void locked_string_put(LOCKED_STRING *ls, JNIEnv *jnienv)
{
- if (js->jstr_)
- (*jnienv)->ReleaseStringUTFChars(jnienv, js->jstr_, js->string);
-}
-
-/****************************************************************
- *
- * Implementation of class JSTRARRAY
- *
- */
-int
-jstrarray_lock(JSTRARRAY *jsa, JNIEnv *jnienv, jobjectArray arr)
-{
- int i;
-
- jsa->arr_ = arr;
- jsa->array = 0;
-
- if (arr != 0) {
- int count = (*jnienv)->GetArrayLength(jnienv, arr);
- const char **new_array =
- (const char **)malloc((sizeof(const char *))*(count+1));
- for (i=0; i<count; i++) {
- jstring jstr = (jstring)(*jnienv)->GetObjectArrayElement(jnienv, arr, i);
- if (jstr == 0) {
- /*
- * An embedded null in the string array
- * is treated as an endpoint.
- */
- new_array[i] = 0;
- break;
- }
- else {
- new_array[i] =
- (*jnienv)->GetStringUTFChars(jnienv, jstr, (jboolean *)0);
- }
- }
- new_array[count] = 0;
- jsa->array = new_array;
- }
- return (0);
-}
-
-void jstrarray_unlock(JSTRARRAY *jsa, JNIEnv *jnienv)
-{
- int i;
- jstring jstr;
-
- if (jsa->arr_) {
- int count = (*jnienv)->GetArrayLength(jnienv, jsa->arr_);
- for (i=0; i<count; i++) {
- if (jsa->array[i] == 0)
- break;
- jstr = (jstring)(*jnienv)->GetObjectArrayElement(jnienv, jsa->arr_, i);
- (*jnienv)->ReleaseStringUTFChars(jnienv, jstr, jsa->array[i]);
- }
- free((void*)jsa->array);
- }
+ if (ls->jstr)
+ (*jnienv)->ReleaseStringUTFChars(jnienv, ls->jstr, ls->string);
}
diff --git a/bdb/libdb_java/java_locked.h b/bdb/libdb_java/java_locked.h
index 9b88cdd0619..a79d929abee 100644
--- a/bdb/libdb_java/java_locked.h
+++ b/bdb/libdb_java/java_locked.h
@@ -1,98 +1,82 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*
- * $Id: java_locked.h,v 11.9 2000/10/25 19:54:55 dda Exp $
+ * $Id: java_locked.h,v 11.18 2002/05/07 16:12:42 dda Exp $
*/
#ifndef _JAVA_LOCKED_H_
#define _JAVA_LOCKED_H_
/*
- * Used internally by LockedDBT constructor.
+ * Used as argument to locked_dbt_get().
*/
typedef enum _OpKind {
- inOp, /* setting data in database (passing data in) */
- outOp, /* getting data from database to user memory */
- inOutOp /* both getting/setting data */
+ inOp, /* setting data in database (passing data in) */
+ outOp, /* getting data from database to user memory */
+ inOutOp /* both getting/setting data */
} OpKind;
/*
+ * LOCKED_DBT
*
- * Declaration of JDBT
- *
- * A JDBT object exists during a
- * single native call to the DB API. Its constructor's job is
- * to temporarily convert any java array found in the DBT_JAVAINFO
- * to actual bytes in memory that remain locked in place. These
- * bytes are used during the call to the underlying DB C layer,
- * and are released and/or copied back by the destructor.
- * Thus, a LockedDBT must be declared as a stack object to
- * function properly.
+ * A stack variable LOCKED_DBT should be declared for each Dbt used in a
+ * native call to the DB API. Before the DBT can be used, locked_dbt_get()
+ * must be called to temporarily convert any java array found in the
+ * Dbt (which has a pointer to a DBT_JAVAINFO struct) to actual bytes
+ * in memory that remain locked in place. These bytes are used during
+ * the call to the DB C API, and are released and/or copied back when
+ * locked_dbt_put is called.
*/
-typedef struct _jdbt
+typedef struct _locked_dbt
{
- /* these are accessed externally to ldbt_ functions */
- DBT_JAVAINFO *dbt;
- unsigned int java_array_len_;
+ /* these are accessed externally to locked_dbt_ functions */
+ DBT_JAVAINFO *javainfo;
+ unsigned int java_array_len;
+ jobject jdbt;
- /* these are for used internally by ldbt_ functions */
- jobject obj_;
- jbyte *java_data_;
- jbyte *before_data_;
- int has_error_;
- int do_realloc_;
- OpKind kind_;
-} JDBT;
+ /* these are for used internally by locked_dbt_ functions */
+ jbyte *java_data;
+ jbyte *before_data;
+ OpKind kind;
-extern int jdbt_lock(JDBT *, JNIEnv *jnienv, jobject obj, OpKind kind);
-extern void jdbt_unlock(JDBT *, JNIEnv *jnienv); /* this unlocks and frees the memory */
-extern int jdbt_realloc(JDBT *, JNIEnv *jnienv); /* returns 1 if reallocation took place */
+#define LOCKED_ERROR 0x01 /* error occurred */
+#define LOCKED_CREATE_DATA 0x02 /* must create data on the fly */
+#define LOCKED_REALLOC_NONNULL 0x04 /* DB_DBT_REALLOC flag, nonnull data */
+ u_int32_t flags;
+} LOCKED_DBT;
-/****************************************************************
- *
- * Declaration of JSTR
- *
- * A JSTR exists temporarily to convert a java jstring object
- * to a char *. Because the memory for the char * string is
- * managed by the JVM, it must be released when we are done
- * looking at it. Typically, jstr_lock() is called at the
- * beginning of a function for each jstring object, and jstr_unlock
- * is called at the end of each function for each JSTR.
- */
-typedef struct _jstr
-{
- /* this accessed externally to jstr_ functions */
- const char *string;
+/* Fill the LOCKED_DBT struct and lock the Java byte array */
+extern int locked_dbt_get(LOCKED_DBT *, JNIEnv *, DB_ENV *, jobject, OpKind);
- /* this is used internally by jstr_ functions */
- jstring jstr_;
-} JSTR;
+/* unlock the Java byte array */
+extern void locked_dbt_put(LOCKED_DBT *, JNIEnv *, DB_ENV *);
-extern int jstr_lock(JSTR *, JNIEnv *jnienv, jstring jstr);
-extern void jstr_unlock(JSTR *, JNIEnv *jnienv); /* this unlocks and frees mem */
+/* realloc the Java byte array */
+extern int locked_dbt_realloc(LOCKED_DBT *, JNIEnv *, DB_ENV *);
-/****************************************************************
- *
- * Declaration of class LockedStrarray
+/*
+ * LOCKED_STRING
*
- * Given a java jobjectArray object (that must be a String[]),
- * we extract the individual strings and build a const char **
- * When the LockedStrarray object is destroyed, the individual
- * strings are released.
+ * A LOCKED_STRING exists temporarily to convert a java jstring object
+ * to a char *. Because the memory for the char * string is
+ * managed by the JVM, it must be released when we are done
+ * looking at it. Typically, locked_string_get() is called at the
+ * beginning of a function for each jstring object, and locked_string_put
+ * is called at the end of each function for each LOCKED_STRING.
*/
-typedef struct _jstrarray
+typedef struct _locked_string
{
- /* this accessed externally to jstrarray_ functions */
- const char **array;
+ /* this accessed externally to locked_string_ functions */
+ const char *string;
- /* this is used internally by jstrarray_ functions */
- jobjectArray arr_;
-} JSTRARRAY;
+ /* this is used internally by locked_string_ functions */
+ jstring jstr;
+} LOCKED_STRING;
-extern int jstrarray_lock(JSTRARRAY *, JNIEnv *jnienv, jobjectArray arr);
-extern void jstrarray_unlock(JSTRARRAY *, JNIEnv *jnienv); /* this unlocks and frees mem */
+extern int locked_string_get(LOCKED_STRING *, JNIEnv *jnienv, jstring jstr);
+extern void locked_string_put(LOCKED_STRING *, JNIEnv *jnienv); /* this unlocks and frees mem */
#endif /* !_JAVA_LOCKED_H_ */
diff --git a/bdb/libdb_java/java_stat_auto.c b/bdb/libdb_java/java_stat_auto.c
new file mode 100644
index 00000000000..c1412232e85
--- /dev/null
+++ b/bdb/libdb_java/java_stat_auto.c
@@ -0,0 +1,207 @@
+/* DO NOT EDIT: automatically built by dist/s_java. */
+#include "java_util.h"
+int __jv_fill_bt_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_bt_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_magic);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_version);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_metaflags);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_nkeys);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_ndata);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_pagesize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_maxkey);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_minkey);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_re_len);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_re_pad);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_levels);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_int_pg);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_leaf_pg);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_dup_pg);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_over_pg);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_free);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_int_pgfree);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_leaf_pgfree);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_dup_pgfree);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_over_pgfree);
+ return (0);
+}
+int __jv_fill_h_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_h_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_magic);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_version);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_metaflags);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_nkeys);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_ndata);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_pagesize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_ffactor);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_buckets);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_free);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_bfree);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_bigpages);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_big_bfree);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_overflows);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_ovfl_free);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_dup);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_dup_free);
+ return (0);
+}
+int __jv_fill_lock_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_lock_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_id);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cur_maxid);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxlocks);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxlockers);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxobjects);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nmodes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nlocks);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnlocks);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nlockers);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnlockers);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nobjects);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnobjects);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nconflicts);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nrequests);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nreleases);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nnowaits);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ndeadlocks);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_locktimeout);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nlocktimeouts);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_txntimeout);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ntxntimeouts);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
+ return (0);
+}
+int __jv_fill_log_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_log_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_magic);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_version);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_mode);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_lg_bsize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_lg_size);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_w_bytes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_w_mbytes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wc_bytes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wc_mbytes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wcount);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wcount_fill);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_scount);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cur_file);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cur_offset);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_disk_file);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_disk_offset);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxcommitperflush);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_mincommitperflush);
+ return (0);
+}
+int __jv_fill_mpool_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_mpool_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_gbytes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_bytes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ncache);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_map);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cache_hit);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cache_miss);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_create);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_in);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_out);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ro_evict);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_rw_evict);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_trickle);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_pages);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_clean);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_dirty);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_buckets);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_searches);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_longest);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_examined);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_nowait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_wait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_max_wait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_buckets);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_max_buckets);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_pages);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_max_pages);
+ return (0);
+}
+int __jv_fill_qam_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_qam_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_magic);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_version);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_metaflags);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_nkeys);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_ndata);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_pagesize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_extentsize);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_pages);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_re_len);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_re_pad);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_pgfree);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_first_recno);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_cur_recno);
+ return (0);
+}
+int __jv_fill_rep_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_rep_stat *statp) {
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_status);
+ JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_next_lsn);
+ JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_waiting_lsn);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_dupmasters);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_env_id);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_env_priority);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_gen);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_duplicated);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_queued);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_queued_max);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_queued_total);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_records);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_requested);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_master);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_master_changes);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_badgen);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_processed);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_recover);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_send_failures);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_sent);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_newsites);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nsites);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nthrottles);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_outdated);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_txns_applied);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_elections);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_elections_won);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_cur_winner);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_gen);
+ JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_election_lsn);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_nsites);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_priority);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_status);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_tiebreaker);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_votes);
+ return (0);
+}
+int __jv_fill_txn_stat(JNIEnv *jnienv, jclass cl,
+ jobject jobj, struct __db_txn_stat *statp) {
+ JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_last_ckp);
+ JAVADB_STAT_LONG(jnienv, cl, jobj, statp, st_time_ckp);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_last_txnid);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxtxns);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_naborts);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nbegins);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ncommits);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nactive);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nrestores);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnactive);
+ JAVADB_STAT_ACTIVE(jnienv, cl, jobj, statp, st_txnarray);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
+ JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
+ return (0);
+}
diff --git a/bdb/libdb_java/java_stat_auto.h b/bdb/libdb_java/java_stat_auto.h
new file mode 100644
index 00000000000..20eecf1e212
--- /dev/null
+++ b/bdb/libdb_java/java_stat_auto.h
@@ -0,0 +1,9 @@
+/* DO NOT EDIT: automatically built by dist/s_java. */
+extern int __jv_fill_bt_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_bt_stat *statp);
+extern int __jv_fill_h_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_h_stat *statp);
+extern int __jv_fill_lock_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_lock_stat *statp);
+extern int __jv_fill_log_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_log_stat *statp);
+extern int __jv_fill_mpool_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_mpool_stat *statp);
+extern int __jv_fill_qam_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_qam_stat *statp);
+extern int __jv_fill_rep_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_rep_stat *statp);
+extern int __jv_fill_txn_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_txn_stat *statp);
diff --git a/bdb/libdb_java/java_util.c b/bdb/libdb_java/java_util.c
index f42ceafbee8..5a538ee0785 100644
--- a/bdb/libdb_java/java_util.c
+++ b/bdb/libdb_java/java_util.c
@@ -1,21 +1,19 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: java_util.c,v 11.17 2000/10/28 13:09:39 dda Exp $";
+static const char revid[] = "$Id: java_util.c,v 11.49 2002/09/13 03:09:30 mjc Exp $";
#endif /* not lint */
#include <jni.h>
#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "db.h"
+#include "db_int.h"
#include "java_util.h"
#ifdef DB_WIN32
@@ -32,17 +30,22 @@ const char * const name_DB_EXCEPTION = "DbException";
const char * const name_DB_HASH_STAT = "DbHashStat";
const char * const name_DB_LOCK = "DbLock";
const char * const name_DB_LOCK_STAT = "DbLockStat";
+const char * const name_DB_LOCKNOTGRANTED_EX = "DbLockNotGrantedException";
+const char * const name_DB_LOGC = "DbLogc";
const char * const name_DB_LOG_STAT = "DbLogStat";
const char * const name_DB_LSN = "DbLsn";
const char * const name_DB_MEMORY_EX = "DbMemoryException";
const char * const name_DB_MPOOL_FSTAT = "DbMpoolFStat";
const char * const name_DB_MPOOL_STAT = "DbMpoolStat";
+const char * const name_DB_PREPLIST = "DbPreplist";
const char * const name_DB_QUEUE_STAT = "DbQueueStat";
+const char * const name_DB_REP_STAT = "DbRepStat";
const char * const name_DB_RUNRECOVERY_EX = "DbRunRecoveryException";
const char * const name_DBT = "Dbt";
const char * const name_DB_TXN = "DbTxn";
const char * const name_DB_TXN_STAT = "DbTxnStat";
const char * const name_DB_TXN_STAT_ACTIVE = "DbTxnStat$Active";
+const char * const name_DB_UTIL = "DbUtil";
const char * const name_DbAppendRecno = "DbAppendRecno";
const char * const name_DbBtreeCompare = "DbBtreeCompare";
const char * const name_DbBtreePrefix = "DbBtreePrefix";
@@ -50,24 +53,84 @@ const char * const name_DbDupCompare = "DbDupCompare";
const char * const name_DbEnvFeedback = "DbEnvFeedback";
const char * const name_DbErrcall = "DbErrcall";
const char * const name_DbHash = "DbHash";
+const char * const name_DbLockRequest = "DbLockRequest";
const char * const name_DbFeedback = "DbFeedback";
const char * const name_DbRecoveryInit = "DbRecoveryInit";
+const char * const name_DbRepTransport = "DbRepTransport";
+const char * const name_DbSecondaryKeyCreate = "DbSecondaryKeyCreate";
const char * const name_DbTxnRecover = "DbTxnRecover";
+const char * const name_RepElectResult = "DbEnv$RepElectResult";
+const char * const name_RepProcessMessage = "DbEnv$RepProcessMessage";
const char * const string_signature = "Ljava/lang/String;";
+jfieldID fid_Dbt_data;
+jfieldID fid_Dbt_offset;
+jfieldID fid_Dbt_size;
+jfieldID fid_Dbt_ulen;
+jfieldID fid_Dbt_dlen;
+jfieldID fid_Dbt_doff;
+jfieldID fid_Dbt_flags;
+jfieldID fid_Dbt_private_dbobj_;
+jfieldID fid_Dbt_must_create_data;
+jfieldID fid_DbLockRequest_op;
+jfieldID fid_DbLockRequest_mode;
+jfieldID fid_DbLockRequest_timeout;
+jfieldID fid_DbLockRequest_obj;
+jfieldID fid_DbLockRequest_lock;
+jfieldID fid_RepProcessMessage_envid;
+
/****************************************************************
*
* Utility functions used by "glue" functions.
- *
*/
-/* Get the private data from a Db* object that points back to a C DB_* object.
+/*
+ * Do any one time initialization, especially initializing any
+ * unchanging methodIds, fieldIds, etc.
+ */
+void one_time_init(JNIEnv *jnienv)
+{
+ jclass cl;
+
+ if ((cl = get_class(jnienv, name_DBT)) == NULL)
+ return; /* An exception has been posted. */
+ fid_Dbt_data = (*jnienv)->GetFieldID(jnienv, cl, "data", "[B");
+ fid_Dbt_offset = (*jnienv)->GetFieldID(jnienv, cl, "offset", "I");
+ fid_Dbt_size = (*jnienv)->GetFieldID(jnienv, cl, "size", "I");
+ fid_Dbt_ulen = (*jnienv)->GetFieldID(jnienv, cl, "ulen", "I");
+ fid_Dbt_dlen = (*jnienv)->GetFieldID(jnienv, cl, "dlen", "I");
+ fid_Dbt_doff = (*jnienv)->GetFieldID(jnienv, cl, "doff", "I");
+ fid_Dbt_flags = (*jnienv)->GetFieldID(jnienv, cl, "flags", "I");
+ fid_Dbt_must_create_data = (*jnienv)->GetFieldID(jnienv, cl,
+ "must_create_data", "Z");
+ fid_Dbt_private_dbobj_ =
+ (*jnienv)->GetFieldID(jnienv, cl, "private_dbobj_", "J");
+
+ if ((cl = get_class(jnienv, name_DbLockRequest)) == NULL)
+ return; /* An exception has been posted. */
+ fid_DbLockRequest_op = (*jnienv)->GetFieldID(jnienv, cl, "op", "I");
+ fid_DbLockRequest_mode = (*jnienv)->GetFieldID(jnienv, cl, "mode", "I");
+ fid_DbLockRequest_timeout =
+ (*jnienv)->GetFieldID(jnienv, cl, "timeout", "I");
+ fid_DbLockRequest_obj = (*jnienv)->GetFieldID(jnienv, cl, "obj",
+ "Lcom/sleepycat/db/Dbt;");
+ fid_DbLockRequest_lock = (*jnienv)->GetFieldID(jnienv, cl, "lock",
+ "Lcom/sleepycat/db/DbLock;");
+
+ if ((cl = get_class(jnienv, name_RepProcessMessage)) == NULL)
+ return; /* An exception has been posted. */
+ fid_RepProcessMessage_envid =
+ (*jnienv)->GetFieldID(jnienv, cl, "envid", "I");
+}
+
+/*
+ * Get the private data from a Db* object that points back to a C DB_* object.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
void *get_private_dbobj(JNIEnv *jnienv, const char *classname,
- jobject obj)
+ jobject obj)
{
jclass dbClass;
jfieldID id;
@@ -76,18 +139,20 @@ void *get_private_dbobj(JNIEnv *jnienv, const char *classname,
if (!obj)
return (0);
- dbClass = get_class(jnienv, classname);
+ if ((dbClass = get_class(jnienv, classname)) == NULL)
+ return (NULL); /* An exception has been posted. */
id = (*jnienv)->GetFieldID(jnienv, dbClass, "private_dbobj_", "J");
lp.java_long = (*jnienv)->GetLongField(jnienv, obj, id);
return (lp.ptr);
}
-/* Set the private data in a Db* object that points back to a C DB_* object.
+/*
+ * Set the private data in a Db* object that points back to a C DB_* object.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
void set_private_dbobj(JNIEnv *jnienv, const char *classname,
- jobject obj, void *value)
+ jobject obj, void *value)
{
long_to_ptr lp;
jclass dbClass;
@@ -95,12 +160,14 @@ void set_private_dbobj(JNIEnv *jnienv, const char *classname,
lp.java_long = 0; /* no junk in case sizes mismatch */
lp.ptr = value;
- dbClass = get_class(jnienv, classname);
+ if ((dbClass = get_class(jnienv, classname)) == NULL)
+ return; /* An exception has been posted. */
id = (*jnienv)->GetFieldID(jnienv, dbClass, "private_dbobj_", "J");
(*jnienv)->SetLongField(jnienv, obj, id, lp.java_long);
}
-/* Get the private data in a Db/DbEnv object that holds additional 'side data'.
+/*
+ * Get the private data in a Db/DbEnv object that holds additional 'side data'.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
@@ -112,15 +179,17 @@ void *get_private_info(JNIEnv *jnienv, const char *classname,
long_to_ptr lp;
if (!obj)
- return (0);
+ return (NULL);
- dbClass = get_class(jnienv, classname);
+ if ((dbClass = get_class(jnienv, classname)) == NULL)
+ return (NULL); /* An exception has been posted. */
id = (*jnienv)->GetFieldID(jnienv, dbClass, "private_info_", "J");
lp.java_long = (*jnienv)->GetLongField(jnienv, obj, id);
return (lp.ptr);
}
-/* Set the private data in a Db/DbEnv object that holds additional 'side data'.
+/*
+ * Set the private data in a Db/DbEnv object that holds additional 'side data'.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
@@ -133,7 +202,8 @@ void set_private_info(JNIEnv *jnienv, const char *classname,
lp.java_long = 0; /* no junk in case sizes mismatch */
lp.ptr = value;
- dbClass = get_class(jnienv, classname);
+ if ((dbClass = get_class(jnienv, classname)) == NULL)
+ return; /* An exception has been posted. */
id = (*jnienv)->GetFieldID(jnienv, dbClass, "private_info_", "J");
(*jnienv)->SetLongField(jnienv, obj, id, lp.java_long);
}
@@ -144,19 +214,48 @@ void set_private_info(JNIEnv *jnienv, const char *classname,
*/
jclass get_class(JNIEnv *jnienv, const char *classname)
{
- /* Note: PERFORMANCE: It should be possible to cache jclass's.
+ /*
+ * Note: PERFORMANCE: It should be possible to cache jclass's.
* If we do a NewGlobalRef on each one, we can keep them
* around in a table. A jclass is a jobject, and
* since NewGlobalRef returns a jobject, it isn't
* technically right, but it would likely work with
* most implementations. Possibly make it configurable.
*/
- char fullname[128] = DB_PACKAGE_NAME;
- strncat(fullname, classname, sizeof(fullname));
+ char fullname[128];
+
+ (void)snprintf(fullname, sizeof(fullname),
+ "%s%s", DB_PACKAGE_NAME, classname);
return ((*jnienv)->FindClass(jnienv, fullname));
}
-/* Set an individual field in a Db* object.
+/*
+ * Given a fully qualified name (e.g. "java.util.Hashtable")
+ * return the jclass object. If it can't be found, an
+ * exception is raised and NULL is return.
+ * This is appropriate to be used for classes that may
+ * not be present.
+ */
+jclass get_fully_qualified_class(JNIEnv *jnienv, const char *classname)
+{
+ jclass result;
+
+ result = ((*jnienv)->FindClass(jnienv, classname));
+ if (result == NULL) {
+ jclass cnfe;
+ char message[1024];
+
+ cnfe = (*jnienv)->FindClass(jnienv,
+ "java/lang/ClassNotFoundException");
+ strncpy(message, classname, sizeof(message));
+ strncat(message, ": class not found", sizeof(message));
+ (*jnienv)->ThrowNew(jnienv, cnfe, message);
+ }
+ return (result);
+}
+
+/*
+ * Set an individual field in a Db* object.
* The field must be a DB object type.
*/
void set_object_field(JNIEnv *jnienv, jclass class_of_this,
@@ -166,36 +265,39 @@ void set_object_field(JNIEnv *jnienv, jclass class_of_this,
char signature[512];
jfieldID id;
- strncpy(signature, "L", sizeof(signature));
- strncat(signature, DB_PACKAGE_NAME, sizeof(signature));
- strncat(signature, object_classname, sizeof(signature));
- strncat(signature, ";", sizeof(signature));
-
- id = (*jnienv)->GetFieldID(jnienv, class_of_this, name_of_field, signature);
+ (void)snprintf(signature, sizeof(signature),
+ "L%s%s;", DB_PACKAGE_NAME, object_classname);
+ id = (*jnienv)->GetFieldID(
+ jnienv, class_of_this, name_of_field, signature);
(*jnienv)->SetObjectField(jnienv, jthis, id, obj);
}
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be an integer type.
*/
void set_int_field(JNIEnv *jnienv, jclass class_of_this,
jobject jthis, const char *name_of_field, jint value)
{
- jfieldID id = (*jnienv)->GetFieldID(jnienv, class_of_this, name_of_field, "I");
+ jfieldID id =
+ (*jnienv)->GetFieldID(jnienv, class_of_this, name_of_field, "I");
(*jnienv)->SetIntField(jnienv, jthis, id, value);
}
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be an integer type.
*/
void set_long_field(JNIEnv *jnienv, jclass class_of_this,
jobject jthis, const char *name_of_field, jlong value)
{
- jfieldID id = (*jnienv)->GetFieldID(jnienv, class_of_this, name_of_field, "J");
+ jfieldID id = (*jnienv)->GetFieldID(jnienv, class_of_this,
+ name_of_field, "J");
(*jnienv)->SetLongField(jnienv, jthis, id, value);
}
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be an integer type.
*/
void set_lsn_field(JNIEnv *jnienv, jclass class_of_this,
@@ -205,89 +307,144 @@ void set_lsn_field(JNIEnv *jnienv, jclass class_of_this,
name_of_field, get_DbLsn(jnienv, value));
}
-/* Report an exception back to the java side.
+/*
+ * Report an exception back to the java side.
*/
-void report_exception(JNIEnv *jnienv, const char *text, int err,
- unsigned long expect_mask)
+void report_exception(JNIEnv *jnienv, const char *text,
+ int err, unsigned long expect_mask)
{
jstring textString;
jclass dbexcept;
jclass javaexcept;
- jmethodID constructId;
jthrowable obj;
textString = NULL;
dbexcept = NULL;
javaexcept = NULL;
- constructId = NULL;
- obj = NULL;
switch (err) {
- /* DB_JAVA_CALLBACK is returned by dbji_call_append_recno()
- * (the append_recno callback) when the Java version of the
- * callback has thrown an exception, and we want to pass the
- * exception on. The exception has already been thrown, we
+ /*
+ * DB_JAVA_CALLBACK is returned by
+ * dbji_call_append_recno() (the append_recno callback)
+ * when the Java version of the callback has thrown
+ * an exception, and we want to pass the exception on.
+ * The exception has already been thrown, we
* don't want to throw a new one.
*/
- case DB_JAVA_CALLBACK:
- break;
- case ENOMEM:
- dbexcept = get_class(jnienv, name_DB_MEMORY_EX);
- break;
- case ENOENT:
- /* In this case there is a corresponding standard java
- * exception type that we'll use. First we make sure
- * that the calling function expected this kind of error,
- * if not we give an 'internal error' DbException, since
- * we must not throw an exception type that isn't
- * declared in the signature.
- *
- * We'll make this a little more general if/when we add
- * more java standard exceptions.
- */
- if ((expect_mask & EXCEPTION_FILE_NOT_FOUND) == 0) {
- char errstr[1024];
-
- strncpy(errstr, "internal error: unexpected errno: ",
- sizeof(errstr));
- strncat(errstr, text, sizeof(errstr));
- textString = get_java_string(jnienv, errstr);
+ case DB_JAVA_CALLBACK:
+ break;
+ case ENOENT:
+ /*
+ * In this case there is a corresponding
+ * standard java exception type that we'll use.
+ * First we make sure that the calling function
+ * expected this kind of error, if not we give
+ * an 'internal error' DbException, since
+ * we must not throw an exception type that isn't
+ * declared in the signature.
+ *
+ * We'll make this a little more general if/when
+ * we add more java standard exceptions.
+ */
+ if ((expect_mask & EXCEPTION_FILE_NOT_FOUND) != 0) {
+ javaexcept = (*jnienv)->FindClass(jnienv,
+ "java/io/FileNotFoundException");
+ }
+ else {
+ char errstr[1024];
+
+ snprintf(errstr, sizeof(errstr),
+ "internal error: unexpected errno: %s",
+ text);
+ textString = get_java_string(jnienv,
+ errstr);
+ dbexcept = get_class(jnienv,
+ name_DB_EXCEPTION);
+ }
+ break;
+ case DB_RUNRECOVERY:
+ dbexcept = get_class(jnienv,
+ name_DB_RUNRECOVERY_EX);
+ break;
+ case DB_LOCK_DEADLOCK:
+ dbexcept = get_class(jnienv, name_DB_DEADLOCK_EX);
+ break;
+ default:
dbexcept = get_class(jnienv, name_DB_EXCEPTION);
- }
- else {
- javaexcept =
- (*jnienv)->FindClass(jnienv, "java/io/FileNotFoundException");
- }
- break;
- case DB_RUNRECOVERY:
- dbexcept = get_class(jnienv, name_DB_RUNRECOVERY_EX);
- break;
- case DB_LOCK_DEADLOCK:
- dbexcept = get_class(jnienv, name_DB_DEADLOCK_EX);
- break;
- default:
- dbexcept = get_class(jnienv, name_DB_EXCEPTION);
- break;
+ break;
}
if (dbexcept != NULL) {
if (textString == NULL)
textString = get_java_string(jnienv, text);
- constructId = (*jnienv)->GetMethodID(jnienv, dbexcept,
- "<init>",
- "(Ljava/lang/String;I)V");
- obj = (jthrowable)(*jnienv)->NewObject(jnienv, dbexcept,
- constructId, textString,
- err);
- (*jnienv)->Throw(jnienv, obj);
+ if ((obj = create_exception(jnienv, textString, err, dbexcept))
+ != NULL)
+ (*jnienv)->Throw(jnienv, obj);
+ /* Otherwise, an exception has been posted. */
}
- else if (javaexcept != NULL) {
- javaexcept =
- (*jnienv)->FindClass(jnienv, "java/io/FileNotFoundException");
+ else if (javaexcept != NULL)
(*jnienv)->ThrowNew(jnienv, javaexcept, text);
+ else
+ fprintf(stderr,
+ "report_exception: failed to create an exception\n");
+}
+
+/*
+ * Report an exception back to the java side, for the specific
+ * case of DB_LOCK_NOTGRANTED, as more things are added to the
+ * constructor of this type of exception.
+ */
+void report_notgranted_exception(JNIEnv *jnienv, const char *text,
+ db_lockop_t op, db_lockmode_t mode,
+ jobject jdbt, jobject jlock, int index)
+{
+ jstring textString;
+ jclass dbexcept;
+ jthrowable obj;
+ jmethodID mid;
+
+ if ((dbexcept = get_class(jnienv, name_DB_LOCKNOTGRANTED_EX)) == NULL)
+ return; /* An exception has been posted. */
+ textString = get_java_string(jnienv, text);
+
+ mid = (*jnienv)->GetMethodID(jnienv, dbexcept, "<init>",
+ "(Ljava/lang/String;II"
+ "Lcom/sleepycat/db/Dbt;"
+ "Lcom/sleepycat/db/DbLock;I)V");
+ if ((obj = (jthrowable)(*jnienv)->NewObject(jnienv, dbexcept,
+ mid, textString, op, mode, jdbt, jlock, index)) != NULL)
+ (*jnienv)->Throw(jnienv, obj);
+ else
+ fprintf(stderr,
+ "report_notgranted_exception: failed to create an exception\n");
+}
+
+/*
+ * Create an exception object and return it.
+ * The given class must have a constructor that has a
+ * constructor with args (java.lang.String text, int errno);
+ * DbException and its subclasses fit this bill.
+ */
+jobject create_exception(JNIEnv *jnienv, jstring text,
+ int err, jclass dbexcept)
+{
+ jthrowable obj;
+ jmethodID mid;
+
+ mid = (*jnienv)->GetMethodID(jnienv, dbexcept, "<init>",
+ "(Ljava/lang/String;I)V");
+ if (mid != NULL)
+ obj = (jthrowable)(*jnienv)->NewObject(jnienv, dbexcept, mid,
+ text, err);
+ else {
+ fprintf(stderr, "Cannot get exception init method ID!\n");
+ obj = NULL;
}
+
+ return (obj);
}
-/* Report an error via the errcall mechanism.
+/*
+ * Report an error via the errcall mechanism.
*/
void report_errcall(JNIEnv *jnienv, jobject errcall,
jstring prefix, const char *message)
@@ -296,7 +453,8 @@ void report_errcall(JNIEnv *jnienv, jobject errcall,
jclass errcall_class;
jstring msg;
- errcall_class = get_class(jnienv, name_DbErrcall);
+ if ((errcall_class = get_class(jnienv, name_DbErrcall)) == NULL)
+ return; /* An exception has been posted. */
msg = get_java_string(jnienv, message);
id = (*jnienv)->GetMethodID(jnienv, errcall_class,
@@ -311,7 +469,8 @@ void report_errcall(JNIEnv *jnienv, jobject errcall,
(*jnienv)->CallVoidMethod(jnienv, errcall, id, prefix, msg);
}
-/* If the object is null, report an exception and return false (0),
+/*
+ * If the object is null, report an exception and return false (0),
* otherwise return true (1).
*/
int verify_non_null(JNIEnv *jnienv, void *obj)
@@ -323,29 +482,70 @@ int verify_non_null(JNIEnv *jnienv, void *obj)
return (1);
}
-/* If the error code is non-zero, report an exception and return false (0),
+/*
+ * If the error code is non-zero, report an exception and return false (0),
* otherwise return true (1).
*/
int verify_return(JNIEnv *jnienv, int err, unsigned long expect_mask)
{
if (err == 0)
- return 1;
+ return (1);
report_exception(jnienv, db_strerror(err), err, expect_mask);
- return 0;
+ return (0);
}
-/* Create an object of the given class, calling its default constructor.
+/*
+ * Verify that there was no memory error due to undersized Dbt.
+ * If there is report a DbMemoryException, with the Dbt attached
+ * and return false (0), otherwise return true (1).
+ */
+int verify_dbt(JNIEnv *jnienv, int err, LOCKED_DBT *ldbt)
+{
+ DBT *dbt;
+ jobject exception;
+ jstring text;
+ jclass dbexcept;
+ jmethodID mid;
+
+ if (err != ENOMEM)
+ return (1);
+
+ dbt = &ldbt->javainfo->dbt;
+ if (!F_ISSET(dbt, DB_DBT_USERMEM) || dbt->size <= dbt->ulen)
+ return (1);
+
+ /* Create/throw an exception of type DbMemoryException */
+ if ((dbexcept = get_class(jnienv, name_DB_MEMORY_EX)) == NULL)
+ return (1); /* An exception has been posted. */
+ text = get_java_string(jnienv,
+ "Dbt not large enough for available data");
+ exception = create_exception(jnienv, text, ENOMEM, dbexcept);
+
+ /* Attach the dbt to the exception */
+ mid = (*jnienv)->GetMethodID(jnienv, dbexcept, "set_dbt",
+ "(L" DB_PACKAGE_NAME "Dbt;)V");
+ (*jnienv)->CallVoidMethod(jnienv, exception, mid, ldbt->jdbt);
+ (*jnienv)->Throw(jnienv, exception);
+ return (0);
+}
+
+/*
+ * Create an object of the given class, calling its default constructor.
*/
jobject create_default_object(JNIEnv *jnienv, const char *class_name)
{
- jclass dbclass = get_class(jnienv, class_name);
- jmethodID id = (*jnienv)->GetMethodID(jnienv, dbclass, "<init>", "()V");
- jobject object = (*jnienv)->NewObject(jnienv, dbclass, id);
- return (object);
+ jmethodID id;
+ jclass dbclass;
+
+ if ((dbclass = get_class(jnienv, class_name)) == NULL)
+ return (NULL); /* An exception has been posted. */
+ id = (*jnienv)->GetMethodID(jnienv, dbclass, "<init>", "()V");
+ return ((*jnienv)->NewObject(jnienv, dbclass, id));
}
-/* Convert an DB object to a Java encapsulation of that object.
+/*
+ * Convert an DB object to a Java encapsulation of that object.
* Note: This implementation creates a new Java object on each call,
* so it is generally useful when a new DB object has just been created.
*/
@@ -361,20 +561,24 @@ jobject convert_object(JNIEnv *jnienv, const char *class_name, void *dbobj)
return (jo);
}
-/* Create a copy of the string
+/*
+ * Create a copy of the string
*/
char *dup_string(const char *str)
{
int len;
char *retval;
+ int err;
len = strlen(str) + 1;
- retval = (char *)malloc(sizeof(char)*len);
+ if ((err = __os_malloc(NULL, sizeof(char)*len, &retval)) != 0)
+ return (NULL);
strncpy(retval, str, len);
return (retval);
}
-/* Create a java string from the given string
+/*
+ * Create a java string from the given string
*/
jstring get_java_string(JNIEnv *jnienv, const char* string)
{
@@ -383,21 +587,23 @@ jstring get_java_string(JNIEnv *jnienv, const char* string)
return ((*jnienv)->NewStringUTF(jnienv, string));
}
-/* Create a malloc'ed copy of the java string.
+/*
+ * Create a copy of the java string using __os_malloc.
* Caller must free it.
*/
char *get_c_string(JNIEnv *jnienv, jstring jstr)
{
- const jbyte *utf;
+ const char *utf;
char *retval;
utf = (*jnienv)->GetStringUTFChars(jnienv, jstr, NULL);
- retval = dup_string((const char *)utf);
+ retval = dup_string(utf);
(*jnienv)->ReleaseStringUTFChars(jnienv, jstr, utf);
- return retval;
+ return (retval);
}
-/* Convert a java object to the various C pointers they represent.
+/*
+ * Convert a java object to the various C pointers they represent.
*/
DB *get_DB(JNIEnv *jnienv, jobject obj)
{
@@ -406,7 +612,8 @@ DB *get_DB(JNIEnv *jnienv, jobject obj)
DB_BTREE_STAT *get_DB_BTREE_STAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_BTREE_STAT *)get_private_dbobj(jnienv, name_DB_BTREE_STAT, obj));
+ return ((DB_BTREE_STAT *)
+ get_private_dbobj(jnienv, name_DB_BTREE_STAT, obj));
}
DBC *get_DBC(JNIEnv *jnienv, jobject obj)
@@ -426,7 +633,8 @@ DB_ENV_JAVAINFO *get_DB_ENV_JAVAINFO(JNIEnv *jnienv, jobject obj)
DB_HASH_STAT *get_DB_HASH_STAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_HASH_STAT *)get_private_dbobj(jnienv, name_DB_HASH_STAT, obj));
+ return ((DB_HASH_STAT *)
+ get_private_dbobj(jnienv, name_DB_HASH_STAT, obj));
}
DB_JAVAINFO *get_DB_JAVAINFO(JNIEnv *jnienv, jobject obj)
@@ -439,29 +647,71 @@ DB_LOCK *get_DB_LOCK(JNIEnv *jnienv, jobject obj)
return ((DB_LOCK *)get_private_dbobj(jnienv, name_DB_LOCK, obj));
}
-DB_LOG_STAT *get_DB_LOG_STAT(JNIEnv *jnienv, jobject obj)
+DB_LOGC *get_DB_LOGC(JNIEnv *jnienv, jobject obj)
{
- return ((DB_LOG_STAT *)get_private_dbobj(jnienv, name_DB_LOG_STAT, obj));
+ return ((DB_LOGC *)get_private_dbobj(jnienv, name_DB_LOGC, obj));
}
-DB_LSN *get_DB_LSN(JNIEnv *jnienv, jobject obj)
+DB_LOG_STAT *get_DB_LOG_STAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_LSN *)get_private_dbobj(jnienv, name_DB_LSN, obj));
+ return ((DB_LOG_STAT *)
+ get_private_dbobj(jnienv, name_DB_LOG_STAT, obj));
+}
+
+DB_LSN *get_DB_LSN(JNIEnv *jnienv, /* DbLsn */ jobject obj) {
+ /*
+ * DbLsns that are created from within java (new DbLsn()) rather
+ * than from within C (get_DbLsn()) may not have a "private" DB_LSN
+ * structure allocated for them yet. We can't do this in the
+ * actual constructor (init_lsn()), because there's no way to pass
+ * in an initializing value in, and because the get_DbLsn()/
+ * convert_object() code path needs a copy of the pointer before
+ * the constructor gets called. Thus, get_DbLsn() allocates and
+ * fills a DB_LSN for the object it's about to create.
+ *
+ * Since "new DbLsn()" may reasonably be passed as an argument to
+ * functions such as DbEnv.log_put(), though, we need to make sure
+ * that DB_LSN's get allocated when the object was created from
+ * Java, too. Here, we lazily allocate a new private DB_LSN if
+ * and only if it turns out that we don't already have one.
+ *
+ * The only exception is if the DbLsn object is a Java null
+ * (in which case the jobject will also be NULL). Then a NULL
+ * DB_LSN is legitimate.
+ */
+ DB_LSN *lsnp;
+ int err;
+
+ if (obj == NULL)
+ return (NULL);
+
+ lsnp = (DB_LSN *)get_private_dbobj(jnienv, name_DB_LSN, obj);
+ if (lsnp == NULL) {
+ if ((err = __os_malloc(NULL, sizeof(DB_LSN), &lsnp)) != 0)
+ return (NULL);
+ memset(lsnp, 0, sizeof(DB_LSN));
+ set_private_dbobj(jnienv, name_DB_LSN, obj, lsnp);
+ }
+
+ return (lsnp);
}
DB_MPOOL_FSTAT *get_DB_MPOOL_FSTAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_MPOOL_FSTAT *)get_private_dbobj(jnienv, name_DB_MPOOL_FSTAT, obj));
+ return ((DB_MPOOL_FSTAT *)
+ get_private_dbobj(jnienv, name_DB_MPOOL_FSTAT, obj));
}
DB_MPOOL_STAT *get_DB_MPOOL_STAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_MPOOL_STAT *)get_private_dbobj(jnienv, name_DB_MPOOL_STAT, obj));
+ return ((DB_MPOOL_STAT *)
+ get_private_dbobj(jnienv, name_DB_MPOOL_STAT, obj));
}
DB_QUEUE_STAT *get_DB_QUEUE_STAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_QUEUE_STAT *)get_private_dbobj(jnienv, name_DB_QUEUE_STAT, obj));
+ return ((DB_QUEUE_STAT *)
+ get_private_dbobj(jnienv, name_DB_QUEUE_STAT, obj));
}
DB_TXN *get_DB_TXN(JNIEnv *jnienv, jobject obj)
@@ -471,7 +721,8 @@ DB_TXN *get_DB_TXN(JNIEnv *jnienv, jobject obj)
DB_TXN_STAT *get_DB_TXN_STAT(JNIEnv *jnienv, jobject obj)
{
- return ((DB_TXN_STAT *)get_private_dbobj(jnienv, name_DB_TXN_STAT, obj));
+ return ((DB_TXN_STAT *)
+ get_private_dbobj(jnienv, name_DB_TXN_STAT, obj));
}
DBT *get_DBT(JNIEnv *jnienv, jobject obj)
@@ -490,7 +741,8 @@ DBT_JAVAINFO *get_DBT_JAVAINFO(JNIEnv *jnienv, jobject obj)
return ((DBT_JAVAINFO *)get_private_dbobj(jnienv, name_DBT, obj));
}
-/* Convert a C pointer to the various Java objects they represent.
+/*
+ * Convert a C pointer to the various Java objects they represent.
*/
jobject get_DbBtreeStat(JNIEnv *jnienv, DB_BTREE_STAT *dbobj)
{
@@ -507,27 +759,109 @@ jobject get_DbHashStat(JNIEnv *jnienv, DB_HASH_STAT *dbobj)
return (convert_object(jnienv, name_DB_HASH_STAT, dbobj));
}
+jobject get_DbLogc(JNIEnv *jnienv, DB_LOGC *dbobj)
+{
+ return (convert_object(jnienv, name_DB_LOGC, dbobj));
+}
+
jobject get_DbLogStat(JNIEnv *jnienv, DB_LOG_STAT *dbobj)
{
return (convert_object(jnienv, name_DB_LOG_STAT, dbobj));
}
-/* LSNs are different since they are really normally
+/*
+ * LSNs are different since they are really normally
* treated as by-value objects. We actually create
* a pointer to the LSN and store that, deleting it
* when the LSN is GC'd.
*/
jobject get_DbLsn(JNIEnv *jnienv, DB_LSN dbobj)
{
- DB_LSN *lsnp = (DB_LSN *)malloc(sizeof(DB_LSN));
+ DB_LSN *lsnp;
+ int err;
+
+ if ((err = __os_malloc(NULL, sizeof(DB_LSN), &lsnp)) != 0)
+ return (NULL);
+
memset(lsnp, 0, sizeof(DB_LSN));
*lsnp = dbobj;
return (convert_object(jnienv, name_DB_LSN, lsnp));
}
-jobject get_Dbt(JNIEnv *jnienv, DBT *dbt)
+/*
+ * Shared code for get_Dbt and get_const_Dbt.
+ *
+ * XXX
+ * Currently we make no distinction in implementation of these
+ * two kinds of Dbts, although in the future we may want to.
+ * (It's probably easier to make the optimizations listed below
+ * with readonly Dbts).
+ *
+ * Dbt's created via this function are only used for a short lifetime,
+ * during callback functions. In the future, we should consider taking
+ * advantage of this by having a pool of Dbt objects instead of creating
+ * new ones each time. Because of multithreading, we may need an
+ * arbitrary number. We might also have sharing of the byte arrays
+ * used by the Dbts.
+ */
+static jobject get_Dbt_shared(JNIEnv *jnienv, const DBT *dbt, int readonly,
+ DBT_JAVAINFO **ret_info)
+{
+ jobject jdbt;
+ DBT_JAVAINFO *dbtji;
+
+ COMPQUIET(readonly, 0);
+
+ /* A NULL DBT should become a null Dbt. */
+ if (dbt == NULL)
+ return (NULL);
+
+ /*
+ * Note that a side effect of creating a Dbt object
+ * is the creation of the attached DBT_JAVAINFO object
+ * (see the native implementation of Dbt.init())
+ * A DBT_JAVAINFO object contains its own DBT.
+ */
+ jdbt = create_default_object(jnienv, name_DBT);
+ dbtji = get_DBT_JAVAINFO(jnienv, jdbt);
+ memcpy(&dbtji->dbt, dbt, sizeof(DBT));
+
+ /*
+ * Set the boolean indicator so that the Java side knows to
+ * call back when it wants to look at the array. This avoids
+ * needlessly creating/copying arrays that may never be looked at.
+ */
+ (*jnienv)->SetBooleanField(jnienv, jdbt, fid_Dbt_must_create_data, 1);
+ (*jnienv)->SetIntField(jnienv, jdbt, fid_Dbt_size, dbt->size);
+
+ if (ret_info != NULL)
+ *ret_info = dbtji;
+ return (jdbt);
+}
+
+/*
+ * Get a writeable Dbt.
+ *
+ * Currently we're sharing code with get_const_Dbt.
+ * It really shouldn't be this way, we have a DBT that we can
+ * change, and have some mechanism for copying back
+ * any changes to the original DBT.
+ */
+jobject get_Dbt(JNIEnv *jnienv, DBT *dbt,
+ DBT_JAVAINFO **ret_info)
+{
+ return (get_Dbt_shared(jnienv, dbt, 0, ret_info));
+}
+
+/*
+ * Get a Dbt that we promise not to change, or at least
+ * if there are changes, they don't matter and won't get
+ * seen by anyone.
+ */
+jobject get_const_Dbt(JNIEnv *jnienv, const DBT *dbt,
+ DBT_JAVAINFO **ret_info)
{
- return (convert_object(jnienv, name_DBT, dbt));
+ return (get_Dbt_shared(jnienv, dbt, 1, ret_info));
}
jobject get_DbMpoolFStat(JNIEnv *jnienv, DB_MPOOL_FSTAT *dbobj)
diff --git a/bdb/libdb_java/java_util.h b/bdb/libdb_java/java_util.h
index eb47dc67629..08187f6b51f 100644
--- a/bdb/libdb_java/java_util.h
+++ b/bdb/libdb_java/java_util.h
@@ -1,10 +1,10 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1997, 1998, 1999, 2000
+ * Copyright (c) 1997-2002
* Sleepycat Software. All rights reserved.
*
- * $Id: java_util.h,v 11.22 2001/01/11 18:19:53 bostic Exp $
+ * $Id: java_util.h,v 11.44 2002/08/29 14:22:24 margo Exp $
*/
#ifndef _JAVA_UTIL_H_
@@ -12,7 +12,8 @@
#ifdef _MSC_VER
-/* These are level 4 warnings that are explicitly disabled.
+/*
+ * These are level 4 warnings that are explicitly disabled.
* With Visual C++, by default you do not see above level 3 unless
* you use /W4. But we like to compile with the highest level
* warnings to catch other errors.
@@ -35,15 +36,15 @@
#include "db_config.h"
#include "db.h"
+#include "db_int.h"
+#include <jni.h>
#include "java_info.h"
#include "java_locked.h"
-#include <jni.h>
#include <string.h> /* needed for memset */
#define DB_PACKAGE_NAME "com/sleepycat/db/"
-/* Union to convert longs to pointers (see {get,set}_private_dbobj).
- */
+/* Union to convert longs to pointers (see {get,set}_private_dbobj). */
typedef union {
jlong java_long;
void *ptr;
@@ -52,13 +53,13 @@ typedef union {
/****************************************************************
*
* Utility functions and definitions used by "glue" functions.
- *
*/
#define NOT_IMPLEMENTED(str) \
report_exception(jnienv, str /*concatenate*/ ": not implemented", 0)
-/* Get, delete a global reference.
+/*
+ * Get, delete a global reference.
* Making this operation a function call allows for
* easier tracking for debugging. Global references
* are mostly grabbed at 'open' and 'close' points,
@@ -78,7 +79,7 @@ static void wrdebug(const char *str)
static jobject debug_new_global_ref(JNIEnv *jnienv, jobject obj, const char *s)
{
wrdebug(s);
- return (*jnienv)->NewGlobalRef(jnienv, obj);
+ return ((*jnienv)->NewGlobalRef(jnienv, obj));
}
static void debug_delete_global_ref(JNIEnv *jnienv, jobject obj, const char *s)
@@ -97,28 +98,45 @@ static void debug_delete_global_ref(JNIEnv *jnienv, jobject obj, const char *s)
#define wrdebug(x)
#endif
-/* Get the private data from a Db* object that points back to a C DB_* object.
+/*
+ * Do any one time initialization, especially initializing any
+ * unchanging methodIds, fieldIds, etc.
+ */
+void one_time_init(JNIEnv *jnienv);
+
+/*
+ * Get the current JNIEnv from the java VM.
+ * If the jvm argument is null, uses the default
+ * jvm stored during the first invocation.
+ */
+JNIEnv *get_jnienv(JavaVM *jvm);
+
+/*
+ * Get the private data from a Db* object that points back to a C DB_* object.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
void *get_private_dbobj(JNIEnv *jnienv, const char *classname,
jobject obj);
-/* Set the private data in a Db* object that points back to a C DB_* object.
+/*
+ * Set the private data in a Db* object that points back to a C DB_* object.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
void set_private_dbobj(JNIEnv *jnienv, const char *classname,
jobject obj, void *value);
-/* Get the private data in a Db/DbEnv object that holds additional 'side data'.
+/*
+ * Get the private data in a Db/DbEnv object that holds additional 'side data'.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
void *get_private_info(JNIEnv *jnienv, const char *classname,
jobject obj);
-/* Set the private data in a Db/DbEnv object that holds additional 'side data'.
+/*
+ * Set the private data in a Db/DbEnv object that holds additional 'side data'.
* The private data is stored in the object as a Java long (64 bits),
* which is long enough to store a pointer on current architectures.
*/
@@ -126,84 +144,126 @@ void set_private_info(JNIEnv *jnienv, const char *classname,
jobject obj, void *value);
/*
- * Given a non-qualified name (e.g. "foo"), get the class handl
+ * Given a non-qualified name (e.g. "foo"), get the class handle
* for the fully qualified name (e.g. "com.sleepycat.db.foo")
*/
jclass get_class(JNIEnv *jnienv, const char *classname);
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be a DB object type.
*/
void set_object_field(JNIEnv *jnienv, jclass class_of_this,
jobject jthis, const char *object_classname,
const char *name_of_field, jobject obj);
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be an integer type.
*/
void set_int_field(JNIEnv *jnienv, jclass class_of_this,
jobject jthis, const char *name_of_field, jint value);
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be an integer type.
*/
void set_long_field(JNIEnv *jnienv, jclass class_of_this,
jobject jthis, const char *name_of_field, jlong value);
-/* Set an individual field in a Db* object.
+/*
+ * Set an individual field in a Db* object.
* The field must be an DbLsn type.
*/
void set_lsn_field(JNIEnv *jnienv, jclass class_of_this,
jobject jthis, const char *name_of_field, DB_LSN value);
-/* Values of expect_mask
+/*
+ * Values of flags for verify_return() and report_exception().
+ * These indicate what sort of exceptions the method may throw
+ * (in addition to DbException).
+ */
+static const u_int32_t EXCEPTION_FILE_NOT_FOUND = 0x0001; /*FileNotFound*/
+
+/*
+ * Report an exception back to the java side.
+ */
+void report_exception(JNIEnv *jnienv, const char *text,
+ int err, unsigned long expect_mask);
+
+/*
+ * Report an exception back to the java side, for the specific
+ * case of DB_LOCK_NOTGRANTED, as more things are added to the
+ * constructor of this type of exception.
*/
-static const int EXCEPTION_FILE_NOT_FOUND = 0x0001;
+void report_notgranted_exception(JNIEnv *jnienv, const char *text,
+ db_lockop_t op, db_lockmode_t mode,
+ jobject jdbt, jobject jlock, int index);
-/* Report an exception back to the java side.
+/*
+ * Create an exception object and return it.
+ * The given class must have a constructor that has a
+ * constructor with args (java.lang.String text, int errno);
+ * DbException and its subclasses fit this bill.
*/
-void report_exception(JNIEnv *jnienv, const char *text, int err,
- unsigned long expect_mask);
+jobject create_exception(JNIEnv *jnienv, jstring text,
+ int err, jclass dbexcept);
-/* Report an error via the errcall mechanism.
+/*
+ * Report an error via the errcall mechanism.
*/
void report_errcall(JNIEnv *jnienv, jobject errcall,
jstring prefix, const char *message);
-/* If the object is null, report an exception and return false (0),
+/*
+ * If the object is null, report an exception and return false (0),
* otherwise return true (1).
*/
int verify_non_null(JNIEnv *jnienv, void *obj);
-/* If the error code is non-zero, report an exception and return false (0),
+/*
+ * If the error code is non-zero, report an exception and return false (0),
* otherwise return true (1).
*/
-int verify_return(JNIEnv *jnienv, int err, unsigned long expect_mask);
+int verify_return(JNIEnv *jnienv, int err, unsigned long flags);
-/* Create an object of the given class, calling its default constructor.
+/*
+ * Verify that there was no memory error due to undersized Dbt.
+ * If there is report a DbMemoryException, with the Dbt attached
+ * and return false (0), otherwise return true (1).
+ */
+int verify_dbt(JNIEnv *jnienv, int err, LOCKED_DBT *locked_dbt);
+
+/*
+ * Create an object of the given class, calling its default constructor.
*/
jobject create_default_object(JNIEnv *jnienv, const char *class_name);
-/* Convert an DB object to a Java encapsulation of that object.
+/*
+ * Create a Dbt object, , calling its default constructor.
+ */
+jobject create_dbt(JNIEnv *jnienv, const char *class_name);
+
+/*
+ * Convert an DB object to a Java encapsulation of that object.
* Note: This implementation creates a new Java object on each call,
* so it is generally useful when a new DB object has just been created.
*/
jobject convert_object(JNIEnv *jnienv, const char *class_name, void *dbobj);
-/* Create a copy of the string
- */
-char *dup_string(const char *str);
-
-/* Create a malloc'ed copy of the java string.
+/*
+ * Create a copy of the java string using __os_malloc.
* Caller must free it.
*/
char *get_c_string(JNIEnv *jnienv, jstring jstr);
-/* Create a java string from the given string
+/*
+ * Create a java string from the given string
*/
jstring get_java_string(JNIEnv *jnienv, const char* string);
-/* Convert a java object to the various C pointers they represent.
+/*
+ * Convert a java object to the various C pointers they represent.
*/
DB *get_DB (JNIEnv *jnienv, jobject obj);
DB_BTREE_STAT *get_DB_BTREE_STAT (JNIEnv *jnienv, jobject obj);
@@ -213,6 +273,7 @@ DB_ENV_JAVAINFO *get_DB_ENV_JAVAINFO (JNIEnv *jnienv, jobject obj);
DB_HASH_STAT *get_DB_HASH_STAT (JNIEnv *jnienv, jobject obj);
DB_JAVAINFO *get_DB_JAVAINFO (JNIEnv *jnienv, jobject obj);
DB_LOCK *get_DB_LOCK (JNIEnv *jnienv, jobject obj);
+DB_LOGC *get_DB_LOGC (JNIEnv *jnienv, jobject obj);
DB_LOG_STAT *get_DB_LOG_STAT (JNIEnv *jnienv, jobject obj);
DB_LSN *get_DB_LSN (JNIEnv *jnienv, jobject obj);
DB_MPOOL_FSTAT *get_DB_MPOOL_FSTAT(JNIEnv *jnienv, jobject obj);
@@ -223,17 +284,20 @@ DB_TXN_STAT *get_DB_TXN_STAT (JNIEnv *jnienv, jobject obj);
DBT *get_DBT (JNIEnv *jnienv, jobject obj);
DBT_JAVAINFO *get_DBT_JAVAINFO (JNIEnv *jnienv, jobject obj);
-/* From a C object, create a Java object.
+/*
+ * From a C object, create a Java object.
*/
jobject get_DbBtreeStat (JNIEnv *jnienv, DB_BTREE_STAT *dbobj);
jobject get_Dbc (JNIEnv *jnienv, DBC *dbobj);
jobject get_DbHashStat (JNIEnv *jnienv, DB_HASH_STAT *dbobj);
+jobject get_DbLogc (JNIEnv *jnienv, DB_LOGC *dbobj);
jobject get_DbLogStat (JNIEnv *jnienv, DB_LOG_STAT *dbobj);
jobject get_DbLsn (JNIEnv *jnienv, DB_LSN dbobj);
jobject get_DbMpoolStat (JNIEnv *jnienv, DB_MPOOL_STAT *dbobj);
jobject get_DbMpoolFStat (JNIEnv *jnienv, DB_MPOOL_FSTAT *dbobj);
jobject get_DbQueueStat (JNIEnv *jnienv, DB_QUEUE_STAT *dbobj);
-jobject get_Dbt (JNIEnv *jnienv, DBT *dbt);
+jobject get_const_Dbt (JNIEnv *jnienv, const DBT *dbt, DBT_JAVAINFO **retp);
+jobject get_Dbt (JNIEnv *jnienv, DBT *dbt, DBT_JAVAINFO **retp);
jobject get_DbTxn (JNIEnv *jnienv, DB_TXN *dbobj);
jobject get_DbTxnStat (JNIEnv *jnienv, DB_TXN_STAT *dbobj);
@@ -247,17 +311,22 @@ extern const char * const name_DB_EXCEPTION;
extern const char * const name_DB_HASH_STAT;
extern const char * const name_DB_LOCK;
extern const char * const name_DB_LOCK_STAT;
+extern const char * const name_DB_LOGC;
extern const char * const name_DB_LOG_STAT;
extern const char * const name_DB_LSN;
extern const char * const name_DB_MEMORY_EX;
extern const char * const name_DB_MPOOL_FSTAT;
extern const char * const name_DB_MPOOL_STAT;
+extern const char * const name_DB_LOCKNOTGRANTED_EX;
+extern const char * const name_DB_PREPLIST;
extern const char * const name_DB_QUEUE_STAT;
+extern const char * const name_DB_REP_STAT;
extern const char * const name_DB_RUNRECOVERY_EX;
extern const char * const name_DBT;
extern const char * const name_DB_TXN;
extern const char * const name_DB_TXN_STAT;
extern const char * const name_DB_TXN_STAT_ACTIVE;
+extern const char * const name_DB_UTIL;
extern const char * const name_DbAppendRecno;
extern const char * const name_DbBtreeCompare;
extern const char * const name_DbBtreePrefix;
@@ -267,93 +336,106 @@ extern const char * const name_DbErrcall;
extern const char * const name_DbFeedback;
extern const char * const name_DbHash;
extern const char * const name_DbRecoveryInit;
+extern const char * const name_DbRepTransport;
+extern const char * const name_DbSecondaryKeyCreate;
extern const char * const name_DbTxnRecover;
+extern const char * const name_RepElectResult;
+extern const char * const name_RepProcessMessage;
extern const char * const string_signature;
-#define JAVADB_RO_ACCESS(j_class, j_fieldtype, j_field, c_type, c_field) \
-JNIEXPORT j_fieldtype JNICALL \
- Java_com_sleepycat_db_##j_class##_get_1##j_field \
- (JNIEnv *jnienv, jobject jthis) \
-{ \
- c_type *db_this = get_##c_type(jnienv, jthis); \
- \
- if (verify_non_null(jnienv, db_this)) { \
- return db_this->c_field; \
- } \
- return 0; \
+extern jfieldID fid_Dbt_data;
+extern jfieldID fid_Dbt_offset;
+extern jfieldID fid_Dbt_size;
+extern jfieldID fid_Dbt_ulen;
+extern jfieldID fid_Dbt_dlen;
+extern jfieldID fid_Dbt_doff;
+extern jfieldID fid_Dbt_flags;
+extern jfieldID fid_Dbt_must_create_data;
+extern jfieldID fid_DbLockRequest_op;
+extern jfieldID fid_DbLockRequest_mode;
+extern jfieldID fid_DbLockRequest_timeout;
+extern jfieldID fid_DbLockRequest_obj;
+extern jfieldID fid_DbLockRequest_lock;
+extern jfieldID fid_RepProcessMessage_envid;
+
+#define JAVADB_ARGS JNIEnv *jnienv, jobject jthis
+
+#define JAVADB_GET_FLD(j_class, j_fieldtype, j_field, c_type, c_field) \
+JNIEXPORT j_fieldtype JNICALL \
+ Java_com_sleepycat_db_##j_class##_get_1##j_field \
+ (JAVADB_ARGS) \
+{ \
+ c_type *db= get_##c_type(jnienv, jthis); \
+ \
+ if (verify_non_null(jnienv, db)) \
+ return (db->c_field); \
+ return (0); \
}
-#define JAVADB_WO_ACCESS(j_class, j_fieldtype, j_field, c_type, c_field) \
-JNIEXPORT void JNICALL \
- Java_com_sleepycat_db_##j_class##_set_1##j_field \
- (JNIEnv *jnienv, jobject jthis, j_fieldtype value) \
-{ \
- c_type *db_this = get_##c_type(jnienv, jthis); \
- \
- if (verify_non_null(jnienv, db_this)) { \
- db_this->c_field = value; \
- } \
+#define JAVADB_SET_FLD(j_class, j_fieldtype, j_field, c_type, c_field) \
+JNIEXPORT void JNICALL \
+ Java_com_sleepycat_db_##j_class##_set_1##j_field \
+ (JAVADB_ARGS, j_fieldtype value) \
+{ \
+ c_type *db= get_##c_type(jnienv, jthis); \
+ \
+ if (verify_non_null(jnienv, db)) \
+ db->c_field = value; \
}
-/* This is a variant of the JAVADB_WO_ACCESS macro to define a simple set_
- * method using a C "method" call. These should be used with set_
- * methods that cannot invoke java 'callbacks' (no set_ method currently
- * does that). That assumption allows us to optimize (and simplify)
- * by not calling API_BEGIN/END macros.
- */
-#define JAVADB_WO_ACCESS_METHOD(j_class, j_fieldtype, \
- j_field, c_type, c_field) \
-JNIEXPORT void JNICALL \
- Java_com_sleepycat_db_##j_class##_set_1##j_field \
- (JNIEnv *jnienv, jobject jthis, j_fieldtype value) \
-{ \
- c_type *db_this; \
- int err; \
- \
- db_this = get_##c_type(jnienv, jthis); \
- if (verify_non_null(jnienv, db_this)) { \
- err = db_this->set_##c_field(db_this, value); \
- verify_return(jnienv, err, 0); \
- } \
+#define JAVADB_METHOD(_meth, _argspec, c_type, c_meth, _args) \
+JNIEXPORT void JNICALL Java_com_sleepycat_db_##_meth _argspec \
+{ \
+ c_type *c_this = get_##c_type(jnienv, jthis); \
+ int ret; \
+ \
+ if (!verify_non_null(jnienv, c_this)) \
+ return; \
+ ret = c_this->c_meth _args; \
+ if (!DB_RETOK_STD(ret)) \
+ report_exception(jnienv, db_strerror(ret), ret, 0); \
}
-#define JAVADB_RW_ACCESS(j_class, j_fieldtype, j_field, c_type, c_field) \
- JAVADB_RO_ACCESS(j_class, j_fieldtype, j_field, c_type, c_field) \
- JAVADB_WO_ACCESS(j_class, j_fieldtype, j_field, c_type, c_field)
-
-#define JAVADB_WO_ACCESS_STRING(j_class, j_field, c_type, c_field) \
-JNIEXPORT void JNICALL \
- Java_com_sleepycat_db_##j_class##_set_1##j_field \
- (JNIEnv *jnienv, jobject jthis, jstring value) \
-{ \
- c_type *db_this; \
- int err; \
- \
- db_this = get_##c_type(jnienv, jthis); \
- if (verify_non_null(jnienv, db_this)) { \
- err = db_this->set_##c_field(db_this, \
- (*jnienv)->GetStringUTFChars(jnienv, value, NULL)); \
- verify_return(jnienv, err, 0); \
- } \
+#define JAVADB_METHOD_INT(_meth, _argspec, c_type, c_meth, _args, _retok) \
+JNIEXPORT jint JNICALL Java_com_sleepycat_db_##_meth _argspec \
+{ \
+ c_type *c_this = get_##c_type(jnienv, jthis); \
+ int ret; \
+ \
+ if (!verify_non_null(jnienv, c_this)) \
+ return (0); \
+ ret = c_this->c_meth _args; \
+ if (!_retok(ret)) \
+ report_exception(jnienv, db_strerror(ret), ret, 0); \
+ return ((jint)ret); \
}
-#define JAVADB_API_BEGIN(db, jthis) \
- if ((db) != NULL) \
- ((DB_JAVAINFO*)(db)->cj_internal)->jdbref_ = \
- ((DB_ENV_JAVAINFO*)((db)->dbenv->cj_internal))->jdbref_ = (jthis)
+#define JAVADB_SET_METH(j_class, j_type, j_fld, c_type, c_field) \
+ JAVADB_METHOD(j_class##_set_1##j_fld, (JAVADB_ARGS, j_type val), c_type, \
+ set_##c_field, (c_this, val))
-#define JAVADB_API_END(db) \
- if ((db) != NULL) \
- ((DB_JAVAINFO*)(db)->cj_internal)->jdbref_ = \
- ((DB_ENV_JAVAINFO*)((db)->dbenv->cj_internal))->jdbref_ = 0
+#define JAVADB_SET_METH_STR(j_class, j_fld, c_type, c_field) \
+ JAVADB_METHOD(j_class##_set_1##j_fld, (JAVADB_ARGS, jstring val), c_type, \
+ set_##c_field, (c_this, (*jnienv)->GetStringUTFChars(jnienv, val, NULL)))
-#define JAVADB_ENV_API_BEGIN(dbenv, jthis) \
- if ((dbenv) != NULL) \
- ((DB_ENV_JAVAINFO*)((dbenv)->cj_internal))->jenvref_ = (jthis)
-#define JAVADB_ENV_API_END(dbenv) \
- if ((dbenv) != NULL) \
- ((DB_ENV_JAVAINFO*)((dbenv)->cj_internal))->jenvref_ = 0
+/*
+ * These macros are used by code generated by the s_java script.
+ */
+#define JAVADB_STAT_INT(env, cl, jobj, statp, name) \
+ set_int_field(jnienv, cl, jobj, #name, statp->name)
+
+#define JAVADB_STAT_LSN(env, cl, jobj, statp, name) \
+ set_lsn_field(jnienv, cl, jobj, #name, statp->name)
+
+#define JAVADB_STAT_LONG(env, cl, jobj, statp, name) \
+ set_long_field(jnienv, cl, jobj, #name, statp->name)
+
+/*
+ * We build the active list separately.
+ */
+#define JAVADB_STAT_ACTIVE(env, cl, jobj, statp, name) \
+ do {} while(0)
#endif /* !_JAVA_UTIL_H_ */