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

[TESTBUG] some AppCDS tests rely on illegal reflective access

XMLWordPrintable

    • b11

      The following AppCDS tests rely on the non-public ClassLoader.defineClass to load the class.
          test/hotspot/jtreg/runtime/cds/appcds/RewriteBytecodesTest.java
          test/hotspot/jtreg/runtime/cds/appcds/customLoader/LoaderSegregationTest.java

      The tests will break with the following exception once java.base is fully encapsulated at run-time:

      Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @4a574795
              at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:349)
              at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:289)
              at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
              at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
              at Util.defineClassFromJAR(Util.java:139)
              at Util.defineClassFromJAR(Util.java:111)
              at LoaderSegregation.main(LoaderSegregation.java:85)

      The tests are working currently with the following warning because they have the --add-opens java.base/java.lang=ALL-UNNAMED set.

      WARNING: An illegal reflective access operation has occurred
      WARNING: Illegal reflective access by Util (file:/scratch/jtreg_test/JTwork/classes/0/runtime/cds/appcds/customLoader/LoaderSegregationTest.d/LoaderSegregation_app.jar) to method java.lang.ClassLoader.defineClass(byte[],int,int)
      WARNING: Please consider reporting this to the maintainers of Util
      WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
      WARNING: All illegal access operations will be denied in a future release

      The test should be fixed to use Lookup.defineClass.

            ccheung Calvin Cheung
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: