RFR: 8318457: Use prefix-less prepend methods directly to reduce branches in String concat expressions [v2]

Claes Redestad redestad at openjdk.org
Thu Oct 19 11:43:34 UTC 2023


On Thu, 19 Oct 2023 02:16:03 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - dropLookupMode PRIVATE to ensure we don't accidentally use private methods
>>  - Make all prepend methods package-private
>
> src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 725:
> 
>> 723:     }
>> 724: 
>> 725:     private static MethodHandle noPrefixPrepender(Class<?> cl) {
> 
> Should the no-prefix prependers be declared package-private now that they are accessed via JLA? Otherwise we might accidentally change those APIs and break stuff.
> 
> Another way to guard is to make stringConcatHelper find methods with a lookup restricted to package access by changing this line: https://github.com/openjdk/jdk/blob/e25a49a993f270c33f7929e629fb3075a11fdec9/src/java.base/share/classes/java/lang/StringConcatHelper.java#L589
> to
> 
> return MethodHandles.lookup()
>         .dropLookupMode(MethodHandles.Lookup.PRIVATE)
>         .findStatic(StringConcatHelper.class, name, methodType);

Good points, adjusted accordingly. Will rerun tier1+2 testing.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16244#discussion_r1365364910


More information about the core-libs-dev mailing list