changeset 7571:d25bb186c36c 8u11-b10

RT-37115: Ensemble8. CRASH in Media Samples and 3D Samples
author Kirill Kirichenko <kirill.kirichenko@oracle.com>
date Fri, 23 May 2014 11:06:28 +0400
parents 008935480ace
children 1d1807c06caa
files modules/media/src/main/native/jfxmedia/jni/JavaInputStreamCallbacks.cpp modules/media/src/main/native/jfxmedia/jni/JavaInputStreamCallbacks.h
diffstat 2 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/media/src/main/native/jfxmedia/jni/JavaInputStreamCallbacks.cpp	Mon May 19 22:13:05 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/jni/JavaInputStreamCallbacks.cpp	Fri May 23 11:06:28 2014 +0400
@@ -31,7 +31,6 @@
 #include <string.h>
 #endif // TARGET_OS_LINUX
 
-bool      CJavaInputStreamCallbacks::m_areJMethodIDsInitialized = false;
 jfieldID  CJavaInputStreamCallbacks::m_BufferFID = 0;
 jmethodID CJavaInputStreamCallbacks::m_NeedBufferMID = 0;
 jmethodID CJavaInputStreamCallbacks::m_ReadNextBlockMID = 0;
@@ -70,9 +69,13 @@
         return false;
     }
 
-    if (!m_areJMethodIDsInitialized)
+    static bool methodIDsInitialized = false;
+    if (!methodIDsInitialized)
     {
-        jclass klass = env->GetObjectClass(m_ConnectionHolder);
+        // Get the parent abstract class. It's wrong to get method ids from the concrete implementation
+        // because it crashes jvm when it tries to call virtual methods. 
+        // See https://javafx-jira.kenai.com/browse/RT-37115
+        jclass klass = env->FindClass("com/sun/media/jfxmedia/locator/ConnectionHolder"); 
 
         m_BufferFID = env->GetFieldID(klass, "buffer", "Ljava/nio/ByteBuffer;");
         m_NeedBufferMID = env->GetMethodID(klass, "needBuffer", "()Z");
@@ -85,7 +88,7 @@
         m_PropertyMID = env->GetMethodID(klass, "property", "(II)I");
         m_GetStreamSizeMID = env->GetMethodID(klass, "getStreamSize", "()I");
 
-        m_areJMethodIDsInitialized = true;
+        methodIDsInitialized = true;
         env->DeleteLocalRef(klass);
     }
 
--- a/modules/media/src/main/native/jfxmedia/jni/JavaInputStreamCallbacks.h	Mon May 19 22:13:05 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/jni/JavaInputStreamCallbacks.h	Fri May 23 11:06:28 2014 +0400
@@ -52,7 +52,6 @@
     jobject          m_ConnectionHolder;
 
     JavaVM           *m_jvm;
-    static bool      m_areJMethodIDsInitialized;
     static jfieldID  m_BufferFID;
     static jmethodID m_NeedBufferMID;
     static jmethodID m_ReadNextBlockMID;