Skip to content

Commit

Permalink
revise string encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
twall committed May 20, 2013
1 parent 95c7be8 commit 1492546
Show file tree
Hide file tree
Showing 43 changed files with 899 additions and 492 deletions.
8 changes: 5 additions & 3 deletions CHANGES.md
@@ -1,8 +1,8 @@
Next Release (3.6)
Next Release (4.0)
==================

NOTE: as of JNA 3.6, JNA is now dual-licensed under LGPL and ASL (see LICENSE)
NOTE: JNI native support is typically incompatible between minor versions
NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and ASL (see LICENSE)
NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.

Features
--------
Expand All @@ -12,6 +12,7 @@ Features
* Use predictable names for CPU arch prefix (namely x86, x86-64); names correspond to OSGI processor values - [@twall](https://github.com/twall).
* Avoid superfluous Structure memory allocation from native - [@twall](https://github.com/twall).
* Added `Library.OPTION_CLASSLOADER`, which enables loading native libraries from any class loader (including JNA's native library). This enables parallel dependencies on JNA (e.g. within a tomcat deployment without having to include JNA in the app server environment) - [@twall](https://github.com/twall).
* Use per-library String encoding settings (see [`Native.getDefaultStringEncoding()`](http://twall.github.com/jna/4.0.0/javadoc/com/sun/jna/Native#getDefaultStringEncoding()) and [`Structure.getStringEncoding()`](http://twall.github.com/jna/4.0.0/javadoc/com/sun/jna/Structure.html#getStringEncoding())) - [@twall](https://github.com/twall).

Bug Fixes
---------
Expand All @@ -24,6 +25,7 @@ Bug Fixes
* [#223](https://github.com/twall/jna/issues/223): Fix layout/size derivation for unions - [@twall](https://github.com/twall).
* [#229](https://github.com/twall/jna/issues/229): Add `CreateProcessW` (unicode version) - [@twall](https://github.com/twall).
* Avoid solaris/x86 JVM bug w/library open flags - [@twall](https://github.com/twall).
* Fix NPE returning wide string from a direct-mapped function - [@twall](https://github.com/twall).

Release 3.5.2
=============
Expand Down
10 changes: 5 additions & 5 deletions build.xml
Expand Up @@ -54,8 +54,8 @@
value="Copyright © 2007-${year} Timothy Wall. All Rights Reserved."/>
<buildnumber/>
<!-- JNA library release version -->
<property name="jna.major" value="3"/>
<property name="jna.minor" value="6"/>
<property name="jna.major" value="4"/>
<property name="jna.minor" value="0"/>
<property name="jna.revision" value="0"/>
<property name="jna.build" value="${build.number}"/>
<condition property="version.suffix" value="" else="-SNAPSHOT">
Expand All @@ -66,12 +66,12 @@
</condition>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}${version.suffix}"/>
<!-- jnidispatch library release version -->
<property name="jni.major" value="3"/>
<property name="jni.minor" value="6"/>
<property name="jni.major" value="4"/>
<property name="jni.minor" value="0"/>
<property name="jni.revision" value="0"/>
<property name="jni.build" value="${build.number}"/>
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
<property name="jni.md5" value="e1ef1f9431f659b9adfbf981f169c5d5"/>
<property name="jni.md5" value="059b6e5f0534df9b7f28dd7a87485721"/>
<property name="spec.title" value="Java Native Access (JNA)"/>
<property name="spec.vendor" value="${vendor}"/>
<property name="spec.version" value="${jna.major}"/>
Expand Down
Binary file added lib/bsh.jar
Binary file not shown.
Binary file modified lib/native/android-arm.jar
Binary file not shown.
Binary file added lib/native/android-x86.jar
Binary file not shown.
Binary file modified lib/native/bsd-x86-64.jar
Binary file not shown.
Binary file modified lib/native/bsd-x86.jar
Binary file not shown.
Binary file modified lib/native/darwin.jar
Binary file not shown.
Binary file modified lib/native/linux-x86-64.jar
Binary file not shown.
Binary file modified lib/native/linux-x86.jar
Binary file not shown.
Binary file modified lib/native/sunos-sparc.jar
Binary file not shown.
Binary file modified lib/native/sunos-sparcv9.jar
Binary file not shown.
Binary file modified lib/native/sunos-x86-64.jar
Binary file not shown.
Binary file modified lib/native/sunos-x86.jar
Binary file not shown.
Binary file modified lib/native/win32-x86-64.jar
Binary file not shown.
Binary file modified lib/native/win32-x86.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions native/Makefile 100644 → 100755
Expand Up @@ -47,8 +47,8 @@ OS=$(shell uname | sed -e 's/CYGWIN.*/win32/g' \
-e 's/AIX.*/aix/g' \
-e 's/Linux.*/linux/g')

JNA_JNI_VERSION=3.6.0 # auto-generated by ant
CHECKSUM=e1ef1f9431f659b9adfbf981f169c5d5 # auto-generated by ant
JNA_JNI_VERSION=4.0.0 # auto-generated by ant
CHECKSUM=059b6e5f0534df9b7f28dd7a87485721 # auto-generated by ant

JAVA_INCLUDES=-I"$(JAVA_HOME)/include" \
-I"$(JAVA_HOME)/include/$(OS)"
Expand Down
9 changes: 7 additions & 2 deletions native/callback.c
Expand Up @@ -80,7 +80,8 @@ static jclass classObject;
callback*
create_callback(JNIEnv* env, jobject obj, jobject method,
jobjectArray param_types, jclass return_type,
callconv_t calling_convention, jint options) {
callconv_t calling_convention, jint options,
jstring encoding) {
jboolean direct = options & CB_OPTION_DIRECT;
jboolean in_dll = options & CB_OPTION_IN_DLL;
callback* cb;
Expand Down Expand Up @@ -119,6 +120,7 @@ create_callback(JNIEnv* env, jobject obj, jobject method,

cb->direct = direct;
cb->java_arg_types[0] = cb->java_arg_types[1] = cb->java_arg_types[2] = &ffi_type_pointer;
cb->encoding = newCStringUTF8(env, encoding);

for (i=0;i < argc;i++) {
int jtype;
Expand Down Expand Up @@ -294,6 +296,7 @@ free_callback(JNIEnv* env, callback *cb) {
}
}
#endif
free((void *)cb->encoding);
free(cb);
}

Expand Down Expand Up @@ -362,7 +365,7 @@ callback_invoke(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbar
*((void **)args[i+3]) = newJavaPointer(env, *(void **)cbargs[i]);
break;
case CVT_STRING:
*((void **)args[i+3]) = newJavaString(env, *(void **)cbargs[i], JNI_FALSE);
*((void **)args[i+3]) = newJavaString(env, *(void **)cbargs[i], cb->encoding);
break;
case CVT_WSTRING:
*((void **)args[i+3]) = newJavaWString(env, *(void **)cbargs[i]);
Expand Down Expand Up @@ -610,6 +613,8 @@ callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
else {
attach_status = (*jvm)->AttachCurrentThread(jvm, (void *)&env, &args);
}
// Dispose of allocated memory
free(args.name);
if (attach_status != JNI_OK) {
fprintf(stderr, "JNA: Can't attach native thread to VM for callback: %d\n", attach_status);
return;
Expand Down

0 comments on commit 1492546

Please sign in to comment.