RFR: 8268148: unchecked warnings handle ? and ? extends Object differently

Jan Lahoda jlahoda at openjdk.java.net
Fri Sep 3 08:46:27 UTC 2021


On Mon, 23 Aug 2021 16:17:36 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> Please review this PR. Currently javac handles differently `?` and `? extends Object` when reporting unchecked warnings when according to the spec they should be handled the same way. This PR is fixing this.
> 
> TIA

Overall, looks reasonable. A few questions/comments inline.

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java line 882:

> 880:             // is it `?` or `? extends Object`?
> 881:             return kind == UNBOUND ||
> 882:                     (kind == EXTENDS && type.hasTag(CLASS) && ((ClassType)type).supertype_field == Type.noType);

For the test on whether `type` is j.l.Object, would something like this work better?
Suggestion:

                    (kind == EXTENDS && type.tsym.flatName() == type.tsym.name.table.names.java_lang_Object);


Just an idea. (Sadly, we can't use `Symtab` here, that would be ideal.)

test/langtools/tools/javac/warnings/UnboundAndBoundByObjectTest.java line 28:

> 26:  * @bug 8268148
> 27:  * @summary unchecked warnings handle ? and ? extends Object differently
> 28:  * @compile -Xlint:all UnboundAndBoundByObjectTest.java

Should there be a verification of the output? Possibly `-Werror`?

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

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


More information about the compiler-dev mailing list