JDK-8238664 : Develop unit tests for hidden classes
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: repo-valhalla
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2020-02-07
  • Updated: 2020-03-25
  • Resolved: 2020-03-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaFixed
Description
Unit tests this JEP covers should verify the following functionalities.

1. Discoverability

- A hidden class cannot be found by any class loader e.g. Class::forName with the name of a hidden class will throw CNFE.
- A hidden class cannot self reference from a descriptor for example method parameter or declaring type of its field
- A hidden class can access its member via `this_class` item.

2. Name of a hidden class

- Class::getName returns a string which is not a binary name, containing `/` character as specified in `Lookup::defineHiddenClass`
- JVMTI GetClassSignature returns a string containing `.` character as specified in `Lookup::defineHiddenClass`

3. Test Verification to resolve itself if IsAssignable test with self's class name.

4. Test a hidden class calling `Lookup::defineHiddenClass` to create another hidden class with and without NESTMATE to verify the access.

5. Test a hidden class with and without STRONG to verify if it will have the same lifecycle as the class loader or not.

6. If a classfile that can be defined and linked as a normal class and it does not reference itself as any descriptor, it should be created as a hidden class and linked successfully including the following cases:
  - it can be an abstract class
  - it can be an interface
  - the classfile contains `InnerClasses` attribute (i.e. if it's defined as a normal class, it represents an enclosing class, or outer class or inner class).    The reflection API may fail when resolving a named class listed in `InnerClasses` attribute if it's a hidden class.

7. A hidden class is hidden from the stack trace, same behavior as `@Hidden`

8. Identify the regression tests added for VM anonymous class and determine if a similar test should be added for hidden classes.