-
Enhancement
-
Resolution: Fixed
-
P3
-
None
-
None
-
b27
A class may also be initialized as a result of execution of other bytecodes such as getstatic, new, putstatic, invokestatic etc as specified in JVMS 5.5.
`Class::forName` and `Unsafe::ensureClassInitialized` are existing workaround to initialize a Class. It's cumbersome to use Class::forName to initialize a class and many JDK classes use `Unsafe::ensureClassInitialized` rather than Class::forName to initialize a class.
One typical use of `Unsafe::ensureClassInitialized` to force class initialization is to enable JIT inlining as well as the method handle can avoid the class initialization barrier.
The other use of `Unsafe::ensureClassInitialized` to force class initialization is to ensure that private static members are initialized and published to other classes (outside its nest) to access, e.g. shared secrets.
`Class::forName` and `Unsafe::ensureClassInitialized` are existing workaround to initialize a Class. It's cumbersome to use Class::forName to initialize a class and many JDK classes use `Unsafe::ensureClassInitialized` rather than Class::forName to initialize a class.
One typical use of `Unsafe::ensureClassInitialized` to force class initialization is to enable JIT inlining as well as the method handle can avoid the class initialization barrier.
The other use of `Unsafe::ensureClassInitialized` to force class initialization is to ensure that private static members are initialized and published to other classes (outside its nest) to access, e.g. shared secrets.
- csr for
-
JDK-8245871 Define Lookup::ensureInitialized as a replacement API for Unsafe::ensureClassInitialized
- Closed
- relates to
-
JDK-8247247 JFR tests fail due to JDK-8235521 missing doPrivileged block
- Resolved
-
JDK-8254046 Remove double semicolon introduced by JDK-8235521
- Resolved
-
JDK-8246634 Consider Lookup::ensureInitialized(Class target, MethodHandle mh)
- Open
-
JDK-8243287 Removal of Unsafe::defineAnonymousClass
- Resolved
-
JDK-8171335 MethodHandle.Lookup functionality to define a nestmate class
- Closed
(1 relates to)