|
|
|
Mladen Turk-3
|
Author: mturk
Date: Fri Jul 3 12:22:08 2009 New Revision: 790884 URL: http://svn.apache.org/viewvc?rev=790884&view=rev Log: Remove ByReferencePointer. API not suitable Removed: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReferencePointer.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReferencePointer32.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReferencePointer64.java commons/sandbox/runtime/trunk/src/main/native/shared/refptr.c Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReference.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativePointer.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java commons/sandbox/runtime/trunk/src/main/native/Makefile.in commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c commons/sandbox/runtime/trunk/src/main/native/shared/memory.c commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c commons/sandbox/runtime/trunk/src/main/native/test/testcase.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReference.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReference.java?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReference.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ByReference.java Fri Jul 3 12:22:08 2009 @@ -24,8 +24,8 @@ * </p> * @since Runtime 1.0 */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.PARAMETER) public @interface ByReference { Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativePointer.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativePointer.java?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativePointer.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativePointer.java Fri Jul 3 12:22:08 2009 @@ -106,17 +106,6 @@ public abstract boolean isNull(); /** - * Check if the pointer is to be used by reference. - * @return true if the pointer has {@code ByReference} annotation. - * @see ByReference - */ - public final boolean isByReference() - { - return getClass().isAnnotationPresent(ByReference.class); - } - - - /** * Compares this {@code Pointer} to the specified object. * * @param other a {@code Pointer} Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java Fri Jul 3 12:22:08 2009 @@ -60,13 +60,6 @@ public boolean isNull(); /** - * Check if the pointer is to be used by reference - * @return true if the pointer has {@code ByReference} annotation. - * @see ByReference - */ - public boolean isByReference(); - - /** * Compares this {@code Pointer} to the specified object. * * @param other a {@code Pointer} Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Fri Jul 3 12:22:08 2009 @@ -85,7 +85,6 @@ $(SRCDIR)/shared/native.$(OBJ) \ $(SRCDIR)/shared/nbb.$(OBJ) \ $(SRCDIR)/shared/pointer.$(OBJ) \ - $(SRCDIR)/shared/refptr.$(OBJ) \ $(SRCDIR)/shared/object.$(OBJ) \ $(SRCDIR)/shared/string.$(OBJ) \ $(SRCDIR)/shared/tables.$(OBJ) \ Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Fri Jul 3 12:22:08 2009 @@ -79,7 +79,6 @@ $(SRCDIR)/shared/native.$(OBJ) \ $(SRCDIR)/shared/nbb.$(OBJ) \ $(SRCDIR)/shared/pointer.$(OBJ) \ - $(SRCDIR)/shared/refptr.$(OBJ) \ $(SRCDIR)/shared/object.$(OBJ) \ $(SRCDIR)/shared/string.$(OBJ) \ $(SRCDIR)/shared/tables.$(OBJ) \ Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h Fri Jul 3 12:22:08 2009 @@ -91,7 +91,19 @@ * @return Callback pointer. */ ACR_DECLARE(acr_pointer_cleanup_fn_t *) ACR_PointerCallbackGet(JNIEnv *env, - jobject ptr); + jobject ptr); + +/** + * Attach the native pointer to the existing (empty) Pointer object. + * @param env Current JNI environment + * @param ptr Java Pointer object use. + * @param val Value to set. + * @param len length of the pointer. + * @param cb callback function to use on Pointer.finalize() + * @return ACR error code on failure. + */ +ACR_DECLARE(int) ACR_PointerAttach(JNIEnv *env, jobject ptr, void *p, + size_t len, acr_pointer_cleanup_fn_t *cb); /** * Create new DirectBuffer class instance @@ -110,23 +122,6 @@ */ ACR_DECLARE(jobjectArray) ACR_NewDirectBufferArray(JNIEnv *env, jsize len); -/** - * Create new ByReferencePointer class instance - * @param env Current JNI environment - * @param p Native pointer to wrap into Pointer class - * @param len Length of the pointer. - * @param cb callback function to use on Pointer.finalize() - */ -ACR_DECLARE(jobject) ACR_NewByReferencePointer(JNIEnv *env, void *p, size_t len, - acr_pointer_cleanup_fn_t *cb); - -/** - * Create new ByReferencePointer array - * @param env Current JNI environment - * @param len Size of the new ByReferencePointer array - */ -ACR_DECLARE(jobjectArray) ACR_NewByReferencePointerArray(JNIEnv *env, - jsize len); #ifdef __cplusplus } Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Fri Jul 3 12:22:08 2009 @@ -372,7 +372,6 @@ /* Forward class loading declarations */ ACR_CLASS_LDEC(Descriptor); ACR_CLASS_LDEC(NativePointer); -ACR_CLASS_LDEC(ByReferencePointer); ACR_CLASS_LDEC(DirectBuffer); ACR_CLASS_LDEC(MbString); ACR_CLASS_LDEC(Group); @@ -384,7 +383,6 @@ ACR_CLASS_LRUN(Descriptor); ACR_CLASS_LRUN(NativePointer); - ACR_CLASS_LRUN(ByReferencePointer); ACR_CLASS_LRUN(DirectBuffer); ACR_CLASS_LRUN(MbString); ACR_CLASS_LRUN(Group); @@ -402,7 +400,6 @@ ACR_CLASS_URUN(Descriptor); ACR_CLASS_URUN(NativePointer); - ACR_CLASS_URUN(ByReferencePointer); ACR_CLASS_URUN(DirectBuffer); ACR_CLASS_URUN(MbString); ACR_CLASS_URUN(Group); Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Fri Jul 3 12:22:08 2009 @@ -251,7 +251,7 @@ ACR_JNI_EXPORT_DECLARE(jobject, Memory, nullp0)(ACR_JNISTDARGS) { UNREFERENCED_O; - return ACR_NewByReferencePointer(_E, NULL, 0, memory_pointer_cleanup); + return ACR_NewPointer(_E, NULL, 0, memory_pointer_cleanup); } ACR_JNI_EXPORT_DECLARE(jobject, Memory, malloc)(ACR_JNISTDARGS, jlong siz) Modified: commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Fri Jul 3 12:22:08 2009 @@ -302,6 +302,27 @@ } } +ACR_DECLARE(int) ACR_PointerAttach(ACR_JNISTDARGS, void *p, size_t len, + acr_pointer_cleanup_fn_t *cb) +{ + if (_clazzn.i && J4MID(0000) && _O) { + if ((*_E)->MonitorEnter(_E, _O)) { + /* Object locking failed */ + return ACR_ENOLOCK; + } + + SET_IFIELD_P(0000, _O, p); + SET_IFIELD_P(0001, _O, cb); + SET_IFIELD_P(0002, _O, len); + + (*_E)->MonitorExit(_E, _O); + return ACR_SUCCESS; + } + else { + return ACR_ECLASSNOTFOUND; + } +} + ACR_DECLARE(acr_pointer_cleanup_fn_t *) ACR_PointerCallbackGet(ACR_JNISTDARGS) { if (_clazzn.i && J4MID(0000) && _O) { Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Fri Jul 3 12:22:08 2009 @@ -227,13 +227,6 @@ return 0; } -static int refcallback(void *p, size_t s) -{ - fprintf(stderr, "[native] ByReferencePointer callback called: %p - %d\n", p, s); - fflush(stderr); - return 0; -} - ACR_JNI_EXPORT_DECLARE(jobject, TestPrivate, test017)(ACR_JNISTDARGS, jint d) { @@ -246,12 +239,6 @@ return ACR_NewDirectBuffer(_E, I2P(d, void *), 0, dbbcallback); } -ACR_JNI_EXPORT_DECLARE(jobject, TestPrivate, test039)(ACR_JNISTDARGS, jint d) -{ - - return ACR_NewByReferencePointer(_E, I2P(d, void *), 0, refcallback); -} - ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test018)(ACR_JNISTDARGS, jobject p) { Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java Fri Jul 3 12:22:08 2009 @@ -123,14 +123,6 @@ p.free(); } - public void testByReference() - throws Throwable - { - Pointer p = Memory.malloc(); - assertNotNull("Pointer", p); - assertTrue("ByReference", p.isByReference()); - } - public void testExecutableMalloc() throws Throwable { Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=790884&r1=790883&r2=790884&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Fri Jul 3 12:22:08 2009 @@ -64,7 +64,6 @@ private static native int test016(int d); private static native Pointer test017(int d); private static native DirectBuffer test038(int d); - private static native Pointer test039(int d); private static native int test018(Pointer p); private static native int test019(Pointer p); @@ -409,25 +408,6 @@ b.free(); } - public void testByrefNativePtrGet() - throws Throwable - { - Pointer b = test039(0xcafebabe); - assertNotNull("ByRefPointer", b); - int r = test019(b); - assertEquals("Result ", 1, r); - b.free(); - int c = test019(b); - // Second call must return NULL - assertEquals("Result ", 0, c); - - b = null; - System.gc(); - // This should be enough for a gc - // from Pointer.finalize() - Thread.sleep(200); - } - public void testDescClassLoad() throws Exception { |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |