Skip to content

Commit 4a01bbe

Browse files
committed
change most native methods in Transaction and Cursor to non-static, remove Cursor.getKey() which was never implemented in JNI
1 parent 6cb96f4 commit 4a01bbe

2 files changed

Lines changed: 25 additions & 32 deletions

File tree

objectbox-java/src/main/java/io/objectbox/Cursor.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,27 @@ public abstract class Cursor<T> implements Closeable {
4141
protected static final int PUT_FLAG_FIRST = 1;
4242
protected static final int PUT_FLAG_COMPLETE = 1 << 1;
4343

44-
static native void nativeDestroy(long cursor);
44+
native void nativeDestroy(long cursor);
4545

4646
static native boolean nativeDeleteEntity(long cursor, long key);
4747

48-
static native void nativeDeleteAll(long cursor);
48+
native void nativeDeleteAll(long cursor);
4949

5050
static native boolean nativeSeek(long cursor, long key);
5151

52-
static native Object nativeGetAllEntities(long cursor);
52+
native Object nativeGetAllEntities(long cursor);
5353

5454
static native Object nativeGetEntity(long cursor, long key);
5555

5656
static native Object nativeNextEntity(long cursor);
5757

5858
static native Object nativeFirstEntity(long cursor);
5959

60-
static native long nativeCount(long cursor, long maxCountOrZero);
61-
62-
// TODO not implemented
63-
static native long nativeGetKey(long cursor);
60+
native long nativeCount(long cursor, long maxCountOrZero);
6461

6562
static native long nativeLookupKeyUsingIndex(long cursor, int propertyId, String value);
6663

67-
static native long nativeRenew(long cursor);
64+
native long nativeRenew(long cursor);
6865

6966
protected static native long collect313311(long cursor, long keyIfComplete, int flags,
7067
int idStr1, @Nullable String valueStr1,
@@ -108,21 +105,21 @@ protected static native long collect004000(long cursor, long keyIfComplete, int
108105
int idLong3, long valueLong3, int idLong4, long valueLong4
109106
);
110107

111-
static native int nativePropertyId(long cursor, String propertyValue);
108+
native int nativePropertyId(long cursor, String propertyValue);
112109

113-
static native List nativeGetBacklinkEntities(long cursor, int entityId, int propertyId, long key);
110+
native List nativeGetBacklinkEntities(long cursor, int entityId, int propertyId, long key);
114111

115-
static native long[] nativeGetBacklinkIds(long cursor, int entityId, int propertyId, long key);
112+
native long[] nativeGetBacklinkIds(long cursor, int entityId, int propertyId, long key);
116113

117-
static native List nativeGetRelationEntities(long cursor, int sourceEntityId, int relationId, long key, boolean backlink);
114+
native List nativeGetRelationEntities(long cursor, int sourceEntityId, int relationId, long key, boolean backlink);
118115

119-
static native long[] nativeGetRelationIds(long cursor, int sourceEntityId, int relationId, long key, boolean backlink);
116+
native long[] nativeGetRelationIds(long cursor, int sourceEntityId, int relationId, long key, boolean backlink);
120117

121-
static native void nativeModifyRelations(long cursor, int relationId, long key, long[] targetKeys, boolean remove);
118+
native void nativeModifyRelations(long cursor, int relationId, long key, long[] targetKeys, boolean remove);
122119

123-
static native void nativeModifyRelationsSingle(long cursor, int relationId, long key, long targetKey, boolean remove);
120+
native void nativeModifyRelationsSingle(long cursor, int relationId, long key, long targetKey, boolean remove);
124121

125-
static native void nativeSetBoxStoreForEntities(long cursor, Object boxStore);
122+
native void nativeSetBoxStoreForEntities(long cursor, Object boxStore);
126123

127124
protected final Transaction tx;
128125
protected final long cursor;
@@ -206,10 +203,6 @@ public void deleteAll() {
206203
nativeDeleteAll(cursor);
207204
}
208205

209-
public long getKey() {
210-
return nativeGetKey(cursor);
211-
}
212-
213206
public boolean seek(long key) {
214207
return nativeSeek(cursor, key);
215208
}

objectbox-java/src/main/java/io/objectbox/Transaction.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ public class Transaction implements Closeable {
4242
/** volatile because finalizer thread may interfere with "one thread, one TX" rule */
4343
private volatile boolean closed;
4444

45-
static native void nativeDestroy(long transaction);
45+
native void nativeDestroy(long transaction);
4646

47-
static native int[] nativeCommit(long transaction);
47+
native int[] nativeCommit(long transaction);
4848

49-
static native void nativeAbort(long transaction);
49+
native void nativeAbort(long transaction);
5050

51-
static native void nativeReset(long transaction);
51+
native void nativeReset(long transaction);
5252

53-
static native void nativeRecycle(long transaction);
53+
native void nativeRecycle(long transaction);
5454

55-
static native void nativeRenew(long transaction);
55+
native void nativeRenew(long transaction);
5656

57-
static native long nativeCreateKeyValueCursor(long transaction);
57+
native long nativeCreateKeyValueCursor(long transaction);
5858

59-
static native long nativeCreateCursor(long transaction, String entityName, Class entityClass);
59+
native long nativeCreateCursor(long transaction, String entityName, Class entityClass);
6060

61-
//static native long nativeGetStore(long transaction);
61+
// native long nativeGetStore(long transaction);
6262

63-
static native boolean nativeIsActive(long transaction);
63+
native boolean nativeIsActive(long transaction);
6464

65-
static native boolean nativeIsRecycled(long transaction);
65+
native boolean nativeIsRecycled(long transaction);
6666

67-
static native boolean nativeIsReadOnly(long transaction);
67+
native boolean nativeIsReadOnly(long transaction);
6868

6969
public Transaction(BoxStore store, long transaction, int initialCommitCount) {
7070
this.store = store;

0 commit comments

Comments
 (0)