RFR: 8336856: Optimize String Concat [v11]
Shaojin Wen
duke at openjdk.org
Thu Jul 25 00:45:39 UTC 2024
On Wed, 24 Jul 2024 15:08:50 GMT, Chen Liang <liach at openjdk.org> wrote:
>> If you do not use TRUSTED Lookup, errors will occur when processing records.
>>
>> You can see this build error https://github.com/wenshao/jdk/actions/runs/10049344961/job/27775952878
>>
>> TEST: java/lang/reflect/records/RecordReflectionTest.java
>>
>>
>> Caused by: java.lang.IllegalAccessException: no such method: java.lang.StringConcatHelper$$StringConcat/0xad1b77c0.concat(R1,R2,R3)String/invokeStatic
>> at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:906)
>> at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:989)
>> at java.base/java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:3750)
>> at java.base/java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:2648)
>> at java.base/java.lang.invoke.StringConcatFactory$SimpleStringBuilderStrategy.generate(StringConcatFactory.java:727)
>> ... 41 more
>> Caused by: java.lang.LinkageError: bad method type alias: (R1,R2,R3)String not visible from class java.lang.StringConcatHelper$$StringConcat/0xad1b77c0
>> at java.base/java.lang.invoke.MemberName.ensureTypeVisible(MemberName.java:812)
>> at java.base/java.lang.invoke.MemberName$Factory.resolve(MemberName.java:961)
>> at java.base/java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:986)
>> ... 44 more
>>
>>
>>
>> record R1() {}
>>
>> record R2(int i, int j) {}
>>
>> record R3(List<String> ls) {}
>>
>> // error
>> record R4(R1 r1, R2 r2, R3 r3) {}
>>
>>
>> This PR also fixes the issue with TRUSTED not working in MemberName.java after using TRUSTED Lookup.
>
> The solution is to call `.erase()` on the input method handle, and call `viewAsType` on the result method handle.
Sorry, I don't understand what you mean. The following code can't solve the above build error
public static CallSite makeConcatWithConstants() {
// line 383
return new ConstantCallSite(
SimpleStringBuilderStrategy.generate(lookup, concatType, constantStrings)
.viewAsType(concatType, true));
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20273#discussion_r1690626588
More information about the core-libs-dev
mailing list