You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/12/21 06:05:48 UTC
svn commit: r892687 - in /commons/sandbox/runtime/trunk: ./
src/main/java/org/apache/commons/runtime/ src/main/native/os/win32/
src/main/native/shared/ src/test/org/apache/commons/runtime/
Author: mturk
Date: Mon Dec 21 05:05:47 2009
New Revision: 892687
URL: http://svn.apache.org/viewvc?rev=892687&view=rev
Log:
Where possible pass the args directly instead using JNI callbacks
Modified:
commons/sandbox/runtime/trunk/build.xml
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java
commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp
commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=892687&r1=892686&r2=892687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Mon Dec 21 05:05:47 2009
@@ -52,6 +52,10 @@
<property name="compile.debug" value="off"/>
<property name="compile.optimize" value="on"/>
<property name="compile.deprecation" value="on"/>
+ <!-- Arguments passed to test and run targets
+ Useage: ant <target> -Dargs="-d64 -verbose:jni"
+ -->
+ <property name="args" value="" />
<!-- The base directory for component sources -->
<property name="source.home" value="java"/>
@@ -121,6 +125,11 @@
<condition property="java5.code.end" value="//*/" else="*/">
<equals arg1="${compile.source}" arg2="1.5"/>
</condition>
+ <tstamp>
+ <format property="version.year" pattern="yyyy" locale="en"/>
+ <format property="TODAY" pattern="MMM d yyyy" locale="en"/>
+ <format property="TSTAMP" pattern="HH:mm:ss"/>
+ </tstamp>
</target>
<!-- =================================================================== -->
@@ -137,7 +146,7 @@
packagenames="${build.package.name}.*"
windowtitle="${title} (Version ${version})"
doctitle="<h2>${title}</h2>"
- bottom="Copyright 2009 The Apache Software Foundation<!--
+ bottom="Copyright © ${version.year} The Apache Software Foundation<!--
Apache Commons Runtime
This product includes software developed by
@@ -215,10 +224,6 @@
<!-- Delete *.properties so that we always get the correct stamp -->
<fileset dir="${build.src}/java/${build.package.path}" includes="*.properties"/>
</delete>
- <tstamp>
- <format property="TODAY" pattern="MMM d yyyy" locale="en"/>
- <format property="TSTAMP" pattern="HH:mm:ss"/>
- </tstamp>
<!-- Copy static resource files -->
<filter token="VERSION" value="${version}"/>
<filter token="VERSION_MAJOR" value="${version.major}"/>
@@ -412,6 +417,7 @@
<env key="Path" path="${runtime.library.path}${path.separator}${java.library.path}"/>
<jvmarg value="-Djava.library.path=${runtime.library.path}"/>
<jvmarg value="-Xmx512m"/>
+ <jvmarg line="${args}"/>
</java>
</sequential>
<sequential>
@@ -424,6 +430,7 @@
<env key="Path" path="${runtime.library.path}${path.separator}${java.library.path}"/>
<jvmarg value="-Djava.library.path=${runtime.library.path}"/>
<jvmarg value="-Xmx512m"/>
+ <jvmarg line="${args}"/>
</java>
</sequential>
<echo message="Started Commons Runtime package tests ..."/>
@@ -431,40 +438,6 @@
</target>
<!-- =================================================================== -->
- <!-- Junit tests for 64-bit JVM -->
- <!-- =================================================================== -->
- <target name="test64" depends="tests">
- <parallel>
- <sequential>
- <echo message="Running Child Commons Runtime package tests (64-bit) ..."/>
- <java dir="${test.dir}" classname="${test.child}" fork="yes"
- failonerror="${test.failonerror}">
- <classpath refid="test.classpath"/>
- <env key="PATH" path="${runtime.library.path}${path.separator}${java.library.path}"/>
- <env key="Path" path="${runtime.library.path}${path.separator}${java.library.path}"/>
- <jvmarg value="-Djava.library.path=${runtime.library.path}"/>
- <jvmarg value="-Xmx512m"/>
- <jvmarg value="-d64"/>
- </java>
- </sequential>
- <sequential>
- <echo message="Running Main Commons Runtime package tests (64-bit) ..."/>
- <sleep seconds="2" />
- <java dir="${test.dir}" classname="${test.entry}" fork="yes"
- failonerror="${test.failonerror}">
- <classpath refid="test.classpath"/>
- <env key="PATH" path="${runtime.library.path}${path.separator}${java.library.path}"/>
- <env key="Path" path="${runtime.library.path}${path.separator}${java.library.path}"/>
- <jvmarg value="-Djava.library.path=${runtime.library.path}"/>
- <jvmarg value="-Xmx512m"/>
- <jvmarg value="-d64"/>
- </java>
- </sequential>
- <echo message="Started Commons Runtime package tests (64-bit) ..."/>
- </parallel>
- </target>
-
- <!-- =================================================================== -->
<!-- Run Example -->
<!-- =================================================================== -->
<target name="run" depends="examples">
@@ -478,23 +451,8 @@
<env key="Path" path="${runtime.library.path}${path.separator}${java.library.path}"/>
<jvmarg value="-Djava.library.path=${runtime.library.path}"/>
<jvmarg value="-Xmx512m"/>
- </java>
- </target>
- <!-- =================================================================== -->
- <!-- Run Example with 64-bit JVM -->
- <!-- =================================================================== -->
- <target name="run64" depends="examples">
- <echo message="Running Commons Runtime package example ${example} ..."/>
- <java dir="${examples.dir}"
- classname="${build.package.name}.${example}"
- fork="yes"
- failonerror="${test.failonerror}">
- <classpath refid="examples.classpath"/>
- <env key="PATH" path="${runtime.library.path}${path.separator}${java.library.path}"/>
- <env key="Path" path="${runtime.library.path}${path.separator}${java.library.path}"/>
- <jvmarg value="-Djava.library.path=${runtime.library.path}"/>
- <jvmarg value="-Xmx512m"/>
- <jvmarg value="-d64"/>
+ <jvmarg line="${args}"/>
</java>
</target>
</project>
+
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java?rev=892687&r1=892686&r2=892687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java Mon Dec 21 05:05:47 2009
@@ -93,15 +93,16 @@
CONTEXT = null;
}
- private native void close0()
+ private native void close0(int i, long l, long h, Object c)
throws IOException;
-
- private native void close1()
+ private native void close1(int i, long l, long h, Object c)
+ throws IOException;
+ private native void close2(int i, long l, long h)
throws Throwable;
- private native void sync0()
+ private native void sync0(int i, long l, long h, Object c)
throws SyncFailedException, IOException;
- private native void flush0()
+ private native void flush0(int i, long l, long h, Object c)
throws SyncFailedException, IOException;
private static native Descriptor nulld0();
@@ -125,7 +126,8 @@
protected final void finalize()
throws Throwable
{
- close1();
+ CONTEXT = null;
+ close2(IHANDLE, PHANDLE, HANDLER);
}
/**
@@ -142,13 +144,39 @@
throws IOException
{
try {
- close0();
+ close0(IHANDLE, PHANDLE, HANDLER, CONTEXT);
} finally {
+ ISVALID = 0;
+ PHANDLE = 0L;
CONTEXT = null;
}
}
/**
+ * Free the allocated resource by the Operating system.
+ * <p>
+ * Note that {@code Object.finalize()} method will call
+ * this function. However if the native code can block for
+ * long time explicit {@code close()} should be called.
+ * </p>
+ * @see java.io.Closeable#close()
+ * @throws IOException if an I/O error occurs.
+ */
+ public final void destroy()
+ throws IOException
+ {
+ try {
+ close1(IHANDLE, PHANDLE, HANDLER, CONTEXT);
+ } finally {
+ IHANDLE = -1;
+ ISVALID = 0;
+ PHANDLE = 0L;
+ HANDLER = 0L;
+ CONTEXT = null;
+ }
+ }
+
+ /**
* Force the underlying object to synchonize it's state with the storage
* device.
* <p>
@@ -171,7 +199,7 @@
public final void sync()
throws SyncFailedException, IOException
{
- sync0();
+ sync0(IHANDLE, PHANDLE, HANDLER, CONTEXT);
}
/**
@@ -191,7 +219,7 @@
public final void flush()
throws SyncFailedException, IOException
{
- flush0();
+ flush0(IHANDLE, PHANDLE, HANDLER, CONTEXT);
}
/**
@@ -311,7 +339,7 @@
@Override
public String toString()
{
- if (PHANDLE != 0) {
+ if (PHANDLE != 0L) {
return Utils.hex(PHANDLE);
}
else if (IHANDLE >= 0) {
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=892687&r1=892686&r2=892687&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 Mon Dec 21 05:05:47 2009
@@ -62,14 +62,14 @@
// No Instance
}
- private native void cleanup0()
+ private native void cleanup0(long p, long c, long s)
throws Throwable;
/* Used for finalize only.
* Doesn't throw exception in case of error
* returned from internal cleanup callback.
*/
- private native void cleanup1()
+ private native void cleanup1(long p, long c, long s)
throws Throwable;
private static native Pointer nullp0();
@@ -174,7 +174,12 @@
protected final void finalize()
throws Throwable
{
- cleanup1();
+ try {
+ cleanup1(POINTER, CLEANUP, PLENGTH);
+ } finally {
+ POINTER = 0L;
+ CLEANUP = 0L;
+ }
}
/**
@@ -190,7 +195,11 @@
public final void free()
throws Throwable
{
- cleanup0();
+ try {
+ cleanup0(POINTER, CLEANUP, PLENGTH);
+ } finally {
+ POINTER = 0L;
+ }
}
/**
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c?rev=892687&r1=892686&r2=892687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c Mon Dec 21 05:05:47 2009
@@ -463,10 +463,10 @@
return (int)RegFlushKey(J2P(key, HKEY));
}
-ACR_JNI_PLATFORM_DECLARE(jint, RegistryKey, open0)(ACR_JNISTDARGS,
- jlong key,
- jstring name,
- jint sam)
+ACR_JNI_PLATFORM_DECLARE(jlong, RegistryKey, open0)(ACR_JNISTDARGS,
+ jlong key,
+ jstring name,
+ jint sam)
{
int rc = ACR_EINVAL;
HKEY skey = NULL;
@@ -489,10 +489,10 @@
return P2J(skey);
}
-ACR_JNI_PLATFORM_DECLARE(jint, RegistryKey, create0)(ACR_JNISTDARGS,
- jlong key,
- jstring name,
- jint sam)
+ACR_JNI_PLATFORM_DECLARE(jlong, RegistryKey, create0)(ACR_JNISTDARGS,
+ jlong key,
+ jstring name,
+ jint sam)
{
int rc = ACR_EINVAL;
HKEY skey = NULL;
@@ -518,3 +518,4 @@
}
return P2J(skey);
}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp?rev=892687&r1=892686&r2=892687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/variant.cpp Mon Dec 21 05:05:47 2009
@@ -21,59 +21,58 @@
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
-#include "acr_pointer.h"
#define STRSAFE_NO_DEPRECATE
#include <comdef.h>
#include <strsafe.h>
-/* Pointer object callback function
- */
-static int variant_callback(void *p, size_t unused)
+extern "C"
+ACR_JNI_PLATFORM_DECLARE(void, VARIANT, clear0)(ACR_JNISTDARGS, jlong vp)
{
- VARIANT *v = (VARIANT *)p;
+ VARIANT *v = J2P(vp, VARIANT *);
+
+ UNREFERENCED_O;
if (v) {
VariantClear(v);
free(v);
}
- return 0;
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jobject, VARIANT, alloc0)(ACR_JNISTDARGS)
+ACR_JNI_PLATFORM_DECLARE(jlong, VARIANT, alloc0)(ACR_JNISTDARGS)
{
VARIANT *v = (VARIANT *)ACR_Calloc(_E, THROW_FMARK, sizeof(VARIANT));
UNREFERENCED_O;
if (!v)
- return 0;
+ return 0L;
VariantInit(v);
- return ACR_NewGenericPointer(_E, v, 0, variant_callback);
+ return P2J(v);
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jobject, VARIANT, alloc1)(ACR_JNISTDARGS, jstring str)
+ACR_JNI_PLATFORM_DECLARE(jlong, VARIANT, alloc1)(ACR_JNISTDARGS, jstring str)
{
- jobject r = NULL;
+ jlong r = 0L;
VARIANT *v = (VARIANT *)ACR_Calloc(_E, THROW_FMARK, sizeof(VARIANT));
UNREFERENCED_O;
if (!v)
- return 0;
+ return 0L;
WITH_WSTR(str) {
VariantInit(v);
V_VT(v) = VT_BSTR;
V_BSTR(v) = SysAllocString(J2W(str));
- r = ACR_NewGenericPointer(_E, v, 0, variant_callback);
+ r = P2J(v);
} END_WITH_WSTR(str);
return r;
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jint, VARIANT, vtype0)(ACR_JNISTDARGS)
+ACR_JNI_PLATFORM_DECLARE(jint, VARIANT, vtype0)(ACR_JNISTDARGS, jlong vp)
{
- VARIANT *v = (VARIANT *)ACR_PointerGet(_E, _O, NULL);
+ VARIANT *v = J2P(vp, VARIANT *);
if (v)
return V_VT(v);
@@ -82,9 +81,9 @@
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jint, VARIANT, getiv0)(ACR_JNISTDARGS)
+ACR_JNI_PLATFORM_DECLARE(jint, VARIANT, getiv0)(ACR_JNISTDARGS, jlong vp)
{
- VARIANT *v = (VARIANT *)ACR_PointerGet(_E, _O, NULL);
+ VARIANT *v = J2P(vp, VARIANT *);
if (!v)
return 0;
@@ -141,9 +140,9 @@
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jlong, VARIANT, getjv0)(ACR_JNISTDARGS)
+ACR_JNI_PLATFORM_DECLARE(jlong, VARIANT, getjv0)(ACR_JNISTDARGS, jlong vp)
{
- VARIANT *v = (VARIANT *)ACR_PointerGet(_E, _O, NULL);
+ VARIANT *v = J2P(vp, VARIANT *);
if (!v)
return 0;
@@ -212,9 +211,9 @@
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jdouble, VARIANT, getdv0)(ACR_JNISTDARGS)
+ACR_JNI_PLATFORM_DECLARE(jdouble, VARIANT, getdv0)(ACR_JNISTDARGS, jlong vp)
{
- VARIANT *v = (VARIANT *)ACR_PointerGet(_E, _O, NULL);
+ VARIANT *v = J2P(vp, VARIANT *);
if (!v)
return 0.0;
@@ -270,12 +269,12 @@
}
extern "C"
-ACR_JNI_PLATFORM_DECLARE(jstring, VARIANT, getsv0)(ACR_JNISTDARGS)
+ACR_JNI_PLATFORM_DECLARE(jstring, VARIANT, getsv0)(ACR_JNISTDARGS, jlong vp)
{
jstring s = NULL;
HRESULT r;
VARIANT c;
- VARIANT *v = (VARIANT *)ACR_PointerGet(_E, _O, NULL);
+ VARIANT *v = J2P(vp, VARIANT *);
if (!v)
return 0;
@@ -306,3 +305,75 @@
}
return s;
}
+
+extern "C"
+ACR_JNI_PLATFORM_DECLARE(jboolean, VARIANT, getzv0)(ACR_JNISTDARGS, jlong vp)
+{
+ VARIANT *v = J2P(vp, VARIANT *);
+
+ if (!v)
+ return JNI_FALSE;
+ switch (V_VT(v)) {
+ case VT_BOOL:
+ return V2Z(V_BOOL(v));
+ break;
+ case VT_I1:
+ case VT_UI1:
+ return V2Z(V_UI1(v));
+ break;
+ case VT_I2:
+ return V2Z(V_I2(v));
+ break;
+ case VT_UI2:
+ return V2Z(V_UI2(v));
+ break;
+ case VT_I4:
+ return V2Z(V_I4(v));
+ break;
+ case VT_UI4:
+ return V2Z(V_UI4(v));
+ break;
+ case VT_I8:
+ return V2Z(V_I8(v));
+ break;
+ case VT_UI8:
+ return V2Z(V_I8(v));
+ break;
+ case VT_INT:
+ return V2Z(V_INT(v));
+ break;
+ case VT_UINT:
+ return V2Z(V_UINT(v));
+ break;
+ case VT_R4:
+ return V2Z(V_R4(v));
+ break;
+ case VT_R8:
+ return V2Z(V_R8(v));
+ break;
+ case VT_CY:
+ return V2Z(V_CY(v).int64);
+ break;
+ case VT_ERROR:
+ return V2Z(V_ERROR(v));
+ break;
+ case VT_DATE:
+ return V2Z(V_DATE(v));
+ break;
+ case VT_BSTR:
+ return V2Z(SysStringLen(V_BSTR(v)));
+ break;
+ }
+ if (V_ISARRAY(v)) {
+ SAFEARRAY *sa = V_ARRAY(v);
+ long lb, ub;
+
+ SafeArrayGetLBound(sa, 1, &lb);
+ SafeArrayGetUBound(sa, 1, &ub);
+ return V2Z(ub - lb + 1);
+ }
+ else {
+ return JNI_FALSE;
+ }
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c?rev=892687&r1=892686&r2=892687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c Mon Dec 21 05:05:47 2009
@@ -137,24 +137,22 @@
return nd;
}
-ACR_JNI_EXPORT_DECLARE(void, Descriptor, close0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Descriptor, close0)(ACR_JNISTDARGS,
+ jint di, jlong dp, jlong cp,
+ jobject co)
{
if (_clazzn.i && J4MID(0000)) {
acr_descriptor_cb_t cb;
acr_descriptor_handler_fn_t *handler;
- cb.di = GET_IFIELD_I(0001, _O);
- cb.dp = GET_IFIELD_V(0002, _O, void *);
- handler = GET_IFIELD_V(0003, _O, acr_descriptor_handler_fn_t *);
+ cb.di = di;
+ cb.dp = J2P(dp, void *);
+ handler = J2P(cp, acr_descriptor_handler_fn_t *);
- SET_IFIELD_I(0000, _O, 0);
- if (cb.dp) {
- SET_IFIELD_P(0002, _O, NULL);
- }
if (handler) {
int rc;
cb.thiz = _O;
- cb.data = GET_IFIELD_O(0006, _O);
+ cb.data = co;
if ((rc = (*handler)(_E, _O, ACR_DESC_CLOSE, &cb))) {
/* Throw IOException with errno message */
ACR_THROW_IO_IF_ERR(rc);
@@ -165,44 +163,67 @@
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EINIT);
}
-ACR_JNI_EXPORT_DECLARE(void, Descriptor, close1)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Descriptor, close1)(ACR_JNISTDARGS,
+ jint di, jlong dp, jlong cp,
+ jobject co)
{
if (_clazzn.i && J4MID(0000)) {
acr_descriptor_cb_t cb;
acr_descriptor_handler_fn_t *handler;
- cb.di = GET_IFIELD_I(0001, _O);
- cb.dp = GET_IFIELD_V(0002, _O, void *);
- handler = GET_IFIELD_V(0003, _O, acr_descriptor_handler_fn_t *);
+ cb.di = di;
+ cb.dp = J2P(dp, void *);
+ handler = J2P(cp, acr_descriptor_handler_fn_t *);
- if (cb.di >= 0) {
- SET_IFIELD_I(0001, _O, -1);
- }
- if (cb.dp) {
- SET_IFIELD_P(0002, _O, NULL);
+ if (handler) {
+ int rc;
+ cb.thiz = _O;
+ cb.data = co;
+ if ((rc = (*handler)(_E, _O, ACR_DESC_FINALIZE, &cb))) {
+ /* Throw IOException with errno message */
+ ACR_THROW_IO_IF_ERR(rc);
+ }
}
+ }
+ else
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EINIT);
+}
+
+ACR_JNI_EXPORT_DECLARE(void, Descriptor, close2)(ACR_JNISTDARGS,
+ jint di, jlong dp, jlong cp)
+{
+ if (_clazzn.i && J4MID(0000)) {
+ acr_descriptor_cb_t cb;
+ acr_descriptor_handler_fn_t *handler;
+
+ cb.di = di;
+ cb.dp = J2P(dp, void *);
+ handler = J2P(cp, acr_descriptor_handler_fn_t *);
+
if (handler) {
cb.thiz = _O;
- cb.data = GET_IFIELD_O(0006, _O);
+ cb.data = NULL;
(*handler)(_E, _O, ACR_DESC_FINALIZE, &cb);
}
}
}
-ACR_JNI_EXPORT_DECLARE(void, Descriptor, sync0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Descriptor, sync0)(ACR_JNISTDARGS,
+ jint di, jlong dp, jlong cp,
+ jobject co)
{
if (_clazzn.i && J4MID(0000)) {
acr_descriptor_cb_t cb;
acr_descriptor_handler_fn_t *handler;
- cb.di = GET_IFIELD_I(0001, _O);
- cb.dp = GET_IFIELD_V(0002, _O, void *);
- handler = GET_IFIELD_V(0003, _O, acr_descriptor_handler_fn_t *);
+ cb.di = di;
+ cb.dp = J2P(dp, void *);
+ handler = J2P(cp, acr_descriptor_handler_fn_t *);
if (handler) {
int rc;
cb.thiz = _O;
- cb.data = GET_IFIELD_O(0006, _O);
+ cb.data = co;
if ((rc = (*handler)(_E, _O, ACR_DESC_SYNC, &cb))) {
if (rc == ACR_ENOTIMPL) {
ACR_THROW_EX_IF_ERR(ACR_EX_ESYNC, rc);
@@ -218,20 +239,22 @@
}
-ACR_JNI_EXPORT_DECLARE(void, Descriptor, flush0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Descriptor, flush0)(ACR_JNISTDARGS,
+ jint di, jlong dp, jlong cp,
+ jobject co)
{
if (_clazzn.i && J4MID(0000)) {
acr_descriptor_cb_t cb;
acr_descriptor_handler_fn_t *handler;
- cb.di = GET_IFIELD_I(0001, _O);
- cb.dp = GET_IFIELD_V(0002, _O, void *);
- handler = GET_IFIELD_V(0003, _O, acr_descriptor_handler_fn_t *);
+ cb.di = di;
+ cb.dp = J2P(dp, void *);
+ handler = J2P(cp, acr_descriptor_handler_fn_t *);
if (handler) {
int rc;
cb.thiz = _O;
- cb.data = GET_IFIELD_O(0006, _O);
+ cb.data = co;
if ((rc = (*handler)(_E, _O, ACR_DESC_FLUSH, &cb))) {
if (rc == ACR_ENOTIMPL) {
ACR_THROW_EX_IF_ERR(ACR_EX_ESYNC, rc);
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=892687&r1=892686&r2=892687&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Mon Dec 21 05:05:47 2009
@@ -109,21 +109,18 @@
return ACR_NewGenericPointer(_E, 0, 0, NULL);
}
-ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup0)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup0)(ACR_JNISTDARGS,
+ jlong p, jlong c, jlong s)
{
if (_clazzn.i && J4MID(0000)) {
acr_pointer_cleanup_fn_t *cleanup;
void *pointer;
- pointer = GET_IFIELD_V(0000, _O, void *);
- cleanup = GET_IFIELD_V(0001, _O, acr_pointer_cleanup_fn_t *);
- if (pointer) {
- SET_IFIELD_P(0000, _O, NULL);
- }
+ pointer = J2P(p, void *);
+ cleanup = J2P(c, acr_pointer_cleanup_fn_t *);
if (cleanup) {
int rc;
- size_t plength = GET_IFIELD_P(0002, _O, size_t);
- if ((rc = (*cleanup)(pointer, plength))) {
+ if ((rc = (*cleanup)(pointer, (size_t)s))) {
/* Throw RuntimeException with errno message */
ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ERUNTIME, rc);
}
@@ -134,20 +131,17 @@
}
-ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup1)(ACR_JNISTDARGS)
+ACR_JNI_EXPORT_DECLARE(void, Pointer, cleanup1)(ACR_JNISTDARGS,
+ jlong p, jlong c, jlong s)
{
if (_clazzn.i && J4MID(0000)) {
acr_pointer_cleanup_fn_t *cleanup;
void *pointer;
- pointer = GET_IFIELD_V(0000, _O, void *);
- cleanup = GET_IFIELD_V(0001, _O, acr_pointer_cleanup_fn_t *);
- if (pointer) {
- SET_IFIELD_P(0000, _O, NULL);
- }
+ pointer = J2P(p, void *);
+ cleanup = J2P(c, acr_pointer_cleanup_fn_t *);
if (cleanup) {
- size_t plength = GET_IFIELD_P(0002, _O, size_t);
- (*cleanup)(pointer, plength);
+ (*cleanup)(pointer, (size_t)s);
}
}
}
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=892687&r1=892686&r2=892687&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 Mon Dec 21 05:05:47 2009
@@ -826,7 +826,7 @@
// They always match if both closed
assertTrue("Both closed", d1.equals(d2));
// If closed equals to NULL
- d1.finalize();
+ d1.destroy();
assertTrue("Not NULL", d1.equals(Descriptor.NULL));
d1 = null;