Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8365439

Cross-classloader module-related IllegalAccessErrors messages are hard to decipher

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • hotspot

      We have come across situations where IllegalAccessErrors of the following kind were seen:

      java.lang.IllegalAccessError: class org.graalvm.jniutils.JNI$JNIInvokeInterface (in module org.graalvm.jniutils) cannot access class org.graalvm.jniutils.JNI (in module org.graalvm.jniutils) because module org.graalvm.jniutils does not read module org.graalvm.jniutils
              at java.base/java.lang.Class.getDeclaringClass0(Native Method)

      If we would not have known from the context where we were getting these, it might have been hard to come to the conclusion that the error message refers to modules named "org.graalvm.jniutils", that were loaded by different classloaders. I.e. although having the same name, they are different modules. From the error message we cannot make out that the first mention of module org.graalvm.jniutils does not refer to the same module as the second mention.

      In such cases it would be very helpful to either
      * add an additional sentence that explains that those modules belong to different classloaders
      * or to prefix the module names with "@" + Integer.toHexString(hashCode()) so that it is easy to see that they are not the same.

      A similar issue was also reported previously as JDK-8199940.

            Unassigned Unassigned
            pwoegerer Paul Woegerer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: