changeset 3772:b17e961ecd38

iOS: Checking available JNI_VERSION @ runtime to be able to run with various JDK8 mobile promotions
author Oldrich Maticka <oldrich.maticka@oracle.com>
date Thu, 30 May 2013 16:54:41 +0200
parents c48aba5f8936
children 9b21f61edda7
files glass/glass-lib-ios/src/GlassApplication.m javafx-iio-native/src/ios/com_sun_javafx_iio_ios_IosImageLoader.m javafx-iio-native/src/jpegloader.c prism-common-native/src/Helpers.c prism-es2-native/src/ios/IOSGLFactory.c
diffstat 5 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/glass/glass-lib-ios/src/GlassApplication.m	Thu May 30 07:00:55 2013 -0700
+++ b/glass/glass-lib-ios/src/GlassApplication.m	Thu May 30 16:54:41 2013 +0200
@@ -110,10 +110,15 @@
 static int haveIDs = 0;
 
 //Library entrypoint
-jint JNI_OnLoad_glass(JavaVM *vm, void *reserved)
+JNIEXPORT jint JNICALL
+JNI_OnLoad_glass(JavaVM *vm, void *reserved)
 {
 #ifdef JNI_VERSION_1_8
     //min. returned JNI_VERSION required by JDK8 for builtin libraries
+    JNIEnv *env;
+    if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_8) != JNI_OK) {
+        return JNI_VERSION_1_4;
+    }
     return JNI_VERSION_1_8;
 #else
     return JNI_VERSION_1_4;
--- a/javafx-iio-native/src/ios/com_sun_javafx_iio_ios_IosImageLoader.m	Thu May 30 07:00:55 2013 -0700
+++ b/javafx-iio-native/src/ios/com_sun_javafx_iio_ios_IosImageLoader.m	Thu May 30 16:54:41 2013 +0200
@@ -53,10 +53,14 @@
     JNIEXPORT jint JNICALL
     JNI_OnLoad_nativeiio(JavaVM *vm, void *reserved) {
 #ifdef JNI_VERSION_1_8
-        //min. returned JNI_VERSION required by JDK8 for builtin libraries
-        return JNI_VERSION_1_8;
+    //min. returned JNI_VERSION required by JDK8 for builtin libraries
+    JNIEnv *env;
+    if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_8) != JNI_OK) {
+        return JNI_VERSION_1_2;
+    }
+    return JNI_VERSION_1_8;
 #else
-        return JNI_VERSION_1_2;
+    return JNI_VERSION_1_2;
 #endif
     }
 
--- a/javafx-iio-native/src/jpegloader.c	Thu May 30 07:00:55 2013 -0700
+++ b/javafx-iio-native/src/jpegloader.c	Thu May 30 16:54:41 2013 +0200
@@ -103,6 +103,10 @@
     jvm = vm;
 #ifdef JNI_VERSION_1_8
     //min. returned JNI_VERSION required by JDK8 for builtin libraries
+    JNIEnv *env;
+    if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_8) != JNI_OK) {
+            return JNI_VERSION_1_2;
+    }
     return JNI_VERSION_1_8;
 #else
     return JNI_VERSION_1_2;
--- a/prism-common-native/src/Helpers.c	Thu May 30 07:00:55 2013 -0700
+++ b/prism-common-native/src/Helpers.c	Thu May 30 16:54:41 2013 +0200
@@ -36,8 +36,13 @@
 #if TARGET_OS_IPHONE /* iOS */
 
 JNIEXPORT jint JNICALL
- JNI_OnLoad_prism_common(JavaVM* vm, void* reserved) {
+JNI_OnLoad_prism_common(JavaVM* vm, void* reserved) {
 #ifdef JNI_VERSION_1_8
+    //min. returned JNI_VERSION required by JDK8 for builtin libraries
+    JNIEnv *env;
+    if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_8) != JNI_OK) {
+        return JNI_VERSION_1_4;
+    }
     return JNI_VERSION_1_8;
 #else
     return JNI_VERSION_1_4;
--- a/prism-es2-native/src/ios/IOSGLFactory.c	Thu May 30 07:00:55 2013 -0700
+++ b/prism-es2-native/src/ios/IOSGLFactory.c	Thu May 30 16:54:41 2013 +0200
@@ -37,6 +37,11 @@
 JNIEXPORT jint JNICALL
 JNI_OnLoad_prism_es2(JavaVM *vm, void * reserved) {
 #ifdef JNI_VERSION_1_8
+    //min. returned JNI_VERSION required by JDK8 for builtin libraries
+    JNIEnv *env;
+    if ((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_8) != JNI_OK) {
+        return JNI_VERSION_1_4;
+    }
     return JNI_VERSION_1_8;
 #else
     return JNI_VERSION_1_4;