RFR: 8263642: javac emits duplicate checkcast for first bound of intersection type in cast [v2]

Guoxiong Li gli at openjdk.java.net
Wed Jun 2 15:26:29 UTC 2021


On Wed, 2 Jun 2021 04:44:21 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Guoxiong Li 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 four additional commits since the last revision:
>> 
>>  - Remove the duplicated typecast nodes in the AST instead of ignoring it
>>  - Check the type of the checkcast
>>  - Merge branch 'master' into JDK-8263642
>>  - 8263642: javac emits duplicate checkcast for first bound of intersection type in cast
>
> Changes requested by vromero (Reviewer).

@vicente-romero-oracle Thanks for your review. I updated the patch just now.

> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java line 2225:
> 
>> 2223:            !types.isSameType(tree.expr.type, tree.clazz.type) &&
>> 2224:            types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null &&
>> 2225:            tree.clazz.getTag() != TYPEINTERSECTION) {
> 
> I think that if the right form of the AST is one that have only two type casts, then that's what the fix should be doing

I revised the patch to adjust the AST. Now it has only two type casts instead of three.

> test/langtools/tools/javac/cast/intersection/DuplicatedCheckcastTest.java line 83:
> 
>> 81:                 for (Instruction instruction : code_attribute.getInstructions()) {
>> 82:                     if ("checkcast".equals(instruction.getMnemonic())) {
>> 83:                         checkcastNumber++;
> 
> I think that the test should check not only for the number of checkcast but also for the type the checkcast is checking against.

Added.

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

PR: https://git.openjdk.java.net/jdk/pull/3399


More information about the compiler-dev mailing list