RFR: 8341548: More concise use of classfile API

ExE Boss duke at openjdk.org
Fri Oct 4 17:06:50 UTC 2024


On Fri, 4 Oct 2024 12:05:02 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> java.base should provide best practices for Class File API
> 
> 1. Use fluent coding style
> 2. Use aconst_null instead of oadConstant(null)
> 3. use astore intead of 'storeLocal(REFERENCE'
> 4. use aload instead of 'loadLocal(REFERENCE'
> 5. 'lload/lstore' instead of 'loadLocal(LONG)/storeLocal(LONG)'

src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java line 399:

> 397:                    // call ensureOriginalLookup to verify the given Lookup has access
> 398:                    .aload(1)
> 399:                    .invokestatic(proxyDesc, "ensureOriginalLookup", MTD_void_Lookup)

Since this class has the `ENSURE_ORIGINAL_LOOKUP` constant, it might be better to use it here:

Suggestion:

                   .invokestatic(proxyDesc, ENSURE_ORIGINAL_LOOKUP, MTD_void_Lookup)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21355#discussion_r1787778114


More information about the core-libs-dev mailing list