On Tue, 18 Oct 2022 05:21:47 GMT, Ioi Lam <ik...@openjdk.org> wrote: >> src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java >> line 346: >> >>> 344: >>> 345: /** >>> 346: * Returns an object to pass this.classData to the <clinit> method >>> of the >> >> What about: >> >> Suggestion: >> >> * Returns the class data object that will be passed to >> `Lookup.defineHiddenClass`. >> * The classData is loaded in the <clinit> method of the generated class. >> * If the class data contains only one single object, this method >> returns that single object. >> * If the class data contains more than one objects, this method returns >> a List. >> * >> * This method returns null if no class data. > > Actually, the classData is passed here: > > > private MemberName loadMethod(byte[] classFile) { > Class<?> invokerClass = LOOKUP.makeHiddenClassDefiner(className, > classFile, Set.of()) > .defineClass(true, classDataValues()); > return resolveInvokerMember(invokerClass, invokerName, invokerType); > } > > > So it doesn't go through `Lookup.defineHiddenClass`.
yes, it's an internal version that defines a hidden class, equivalent to calling `Lookup::defineHiddenClassWithClassData` (typo in my suggested wording), but it will bypass the security permission check and also returns the Class instead of Lookup (saving not to allocate a Lookup object). ------------- PR: https://git.openjdk.org/jdk/pull/10706