RFR: 8340721: Clarify special case handling of unboxedType and getWildcardType

Pavel Rappo prappo at openjdk.org
Thu Sep 26 11:37:43 UTC 2024


On Wed, 25 Sep 2024 22:32:03 GMT, Joe Darcy <darcy at openjdk.org> wrote:

> First piece of a larger set of updates that may be made for JDK-8055219 to clarify the exceptional behavior of `javax.lang.model.util.Types`.

src/java.compiler/share/classes/javax/lang/model/util/Types.java line 56:

> 54:  * In the reference implementation, handling {@linkplain ErrorType
> 55:  * error types} generally does not cause an {@code
> 56:  * UnsupportedOperationException} from the methods in this interface.

Did you really mean `UnsupportedOperationException` and not `IllegalArgumentException`?

test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java line 50:

> 48:     private TypeMirror       stringType;
> 49:     private ArrayType        arrayType;
> 50:     private DeclaredType     declaredType;

`declaredType` is assigned but never used.

test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java line 51:

> 49:     private ArrayType        arrayType;
> 50:     private DeclaredType     declaredType;
> 51:     // private ErrorType        errorType; // skip for now

Any plans on how to test `ErrorType` in the future?

test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java line 137:

> 135:      */
> 136:     void testUnboxedType() {
> 137:         // Only DeclaredType's for wrapper classes should have unboxing converions defined.

converSions

test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java line 149:

> 147:             try {
> 148:                 PrimitiveType pt = types.unboxedType(tm);
> 149:             } catch(IllegalArgumentException iae) {

Here and elsewhere in this file: if some of the calls didn't throw IAE, the test would still pass. Is this your goal?

test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java line 171:

> 169:         for (TypeMirror tm : invalidInputs) {
> 170:             try {
> 171:                 WildcardType wc1 = types.getWildcardType(tm,   null);

Calling getWildcardType for an array type does not throw IAE; is this expected?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21193#discussion_r1776773575
PR Review Comment: https://git.openjdk.org/jdk/pull/21193#discussion_r1776806233
PR Review Comment: https://git.openjdk.org/jdk/pull/21193#discussion_r1776807030
PR Review Comment: https://git.openjdk.org/jdk/pull/21193#discussion_r1776811918
PR Review Comment: https://git.openjdk.org/jdk/pull/21193#discussion_r1776879313
PR Review Comment: https://git.openjdk.org/jdk/pull/21193#discussion_r1776883671


More information about the compiler-dev mailing list