RFR: 8245456: MacPasteboard throws ClassCastException on static builds

Jose Pereda jpereda at openjdk.java.net
Wed May 20 11:52:50 UTC 2020


Trying to paste on a JavaFX app statically built on Mac OS throws:

Exception in thread "JavaFX Application Thread" java.lang.ClassCastException
        at         at com.sun.glass.ui.mac.MacPasteboard._getUTFs(MacPasteboard.java)
 

Checking the native method signature a `String[][]` type is expected. However the native method implementation uses:
jobjectArray utfs = (*env)->NewObjectArray(env, size, (*env)->FindClass(env, "java/lang/Object"), NULL);
for (items) {
     jobjectArray array = (*env)->NewObjectArray(env, size, (*env)->FindClass(env, "java/lang/String"), NULL);
}

This PR fixes the issue by applying the correct array type signature according to [JNI
specs](https://docs.oracle.com/en/java/javase/11/docs/specs/jni/functions.html#findclass).

It has been tested on Mac OS, both with and without static build.

-------------

Commit messages:
 - Use correct array type signature

Changes: https://git.openjdk.java.net/jfx/pull/228/files
 Webrev: https://webrevs.openjdk.java.net/jfx/228/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8245456
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jfx/pull/228.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/228/head:pull/228

PR: https://git.openjdk.java.net/jfx/pull/228


More information about the openjfx-dev mailing list