RFR: 8340831: Simplify simple validation for class definition in MethodHandles.Lookup
Claes Redestad
redestad at openjdk.org
Wed Sep 25 10:06:41 UTC 2024
On Tue, 24 Sep 2024 22:07:25 GMT, Chen Liang <liach at openjdk.org> wrote:
> `MethodHandles.Lookup` defines a `ClassFile` for simple validations; it is unnecessary and can be scalarized manually. The removal of `ClassFile` class is also slightly helpful for bootstrap by reducing class loading. Also improved class file version checking in `VM` class.
Changes requested by redestad (Reviewer).
src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 2276:
> 2274: var thisClass = cm.thisClass();
> 2275: name = thisClass.asInternalName();
> 2276: sym = thisClass.asSymbol();
We only use this for determining package name are equal, and sym.packageName() does the similar transformations plus a bit more. Likely not a significant cost compared to the `ClassFile::parse` - but perhaps there's room for a utility method to get the package name directly from an internal name?
src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 2440:
> 2438: }
> 2439:
> 2440: record ClassDefiner(Lookup lookup, String name, byte[] bytes, int classFlags, ClassFileDumper dumper) {
Rename `name` to `internalName`, dropping the explicit `internalName()` method.
-------------
PR Review: https://git.openjdk.org/jdk/pull/21170#pullrequestreview-2327774125
PR Review Comment: https://git.openjdk.org/jdk/pull/21170#discussion_r1774943742
PR Review Comment: https://git.openjdk.org/jdk/pull/21170#discussion_r1774934606
More information about the core-libs-dev
mailing list