On Wed, 2 Nov 2022 17:53:03 GMT, Jorn Vernee <jver...@openjdk.org> wrote:

>> Jim Laskey has updated the pull request with a new target base due to a 
>> merge or a rebase. The incremental webrev excludes the unrelated changes 
>> brought in by the merge/rebase. The pull request contains 22 additional 
>> commits since the last revision:
>> 
>>  - Merge branch 'master' into 8285932
>>  - Add @SafeVarargs declarations
>>  - Move template bootstrap
>>  - Requested changes #2
>>  - Requested changes
>>  - Remove .orig file
>>  - Update TemplateRuntime::combine
>>  - Move StringConcatItem to FormatConcatItem
>>  - Tabs to spaces
>>  - Force processor before template string expression
>>  - ... and 12 more: https://git.openjdk.org/jdk/compare/ab757cc6...6cea084b
>
> src/java.base/share/classes/java/lang/template/TemplateRuntime.java line 118:
> 
>> 116:         List<Class<?>> result = new ArrayList<>();
>> 117:         Class<?> tsClass = st.getClass();
>> 118:         if (tsClass.isSynthetic()) {
> 
> This check seems pretty ad-hoc... What happens if a synthetic class is passed 
> that declares some `x0` field that doesn't correspond to the type of the 
> value? i.e. someone could generating an implementation of `StringTemplate`, 
> slap `ACC_SYNTHETIC` on it, and it seems that could have the potential to 
> break this code.
> 
> I suggest generating an override of `valueTypes` in the synthetic class 
> emitted by javac instead.

I've mentioned TemplateProcessorFactorys and TemplateProcessorBuilders as the 
long term solution. I think I'll just pull these methods. Optimizing processors 
is something that needs more discussion.

> src/java.base/share/classes/java/lang/template/TemplateRuntime.java line 160:
> 
>> 158:                 for (int i = 0; ; i++) {
>> 159:                     Field field = tsClass.getDeclaredField("x" + i);
>> 160:                     MethodHandle mh = JLIA.unreflectField(field, false);
> 
> This by-passes any access checks by using `IMPL_LOOKUP`.
> 
> This seems problematic. e.g. there's a class that has some `x0` field that I 
> can't access, but the class is not `final`. I generate an impl of 
> `StringTemplate` that extends that class (with `ACC_SYNTHETIC`), and call 
> `valueAccessors` to get a getter that bypasses all access checks.
> 
> I think the synthetic class generated by javac should generate an override of 
> this method as well.

See previous.

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

PR: https://git.openjdk.org/jdk/pull/10889

Reply via email to