mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-23 21:30:26 +00:00
8379156: Specify behavior of Types.asElement() on array types
Reviewed-by: hannesw, liach
This commit is contained in:
parent
0aa52d633a
commit
ea4a151245
@ -74,6 +74,7 @@ public interface Types {
|
||||
* Types <em>without</em> corresponding elements include:
|
||||
* <ul>
|
||||
* <li>{@linkplain TypeKind#isPrimitive() primitive types}
|
||||
* <li>{@linkplain TypeKind#ARRAY array types}
|
||||
* <li>{@linkplain TypeKind#EXECUTABLE executable types}
|
||||
* <li>{@linkplain TypeKind#NONE "none"} pseudo-types
|
||||
* <li>{@linkplain TypeKind#NULL null types}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8300857
|
||||
* @bug 8300857 8379156
|
||||
* @summary Test Types.asElement in cases specified to return null
|
||||
* @library /tools/javac/lib
|
||||
* @build JavacTestingAbstractProcessor TestAsElement
|
||||
@ -55,18 +55,23 @@ public class TestAsElement extends JavacTestingAbstractProcessor {
|
||||
}
|
||||
|
||||
private void testNullCases() {
|
||||
// Test all primitive types
|
||||
// Test all primitive types and arrays of primitive types
|
||||
for (TypeKind typeKind : TypeKind.values()) {
|
||||
if (typeKind.isPrimitive() ) {
|
||||
expectNullAsElement(typeUtils.getPrimitiveType(typeKind));
|
||||
var primType = typeUtils.getPrimitiveType(typeKind);
|
||||
expectNullAsElement(primType);
|
||||
expectNullAsElement(typeUtils.getArrayType(primType));
|
||||
}
|
||||
}
|
||||
expectNullAsElement(typeUtils.getNoType(TypeKind.VOID));
|
||||
expectNullAsElement(typeUtils.getNoType(TypeKind.NONE));
|
||||
expectNullAsElement(typeUtils.getNullType());
|
||||
|
||||
Element objectElement = eltUtils.getTypeElement("java.lang.Object");
|
||||
expectNullAsElement(typeUtils.getWildcardType(objectElement.asType(), null));
|
||||
Element objectElement = eltUtils.getTypeElement("java.lang.Object");
|
||||
TypeMirror objectType = objectElement.asType();
|
||||
expectNullAsElement(typeUtils.getWildcardType(objectType, null));
|
||||
// check Object[]
|
||||
expectNullAsElement(typeUtils.getArrayType(objectType));
|
||||
|
||||
// Loop over the ExecutableTypes for Object's methods
|
||||
for(var methodElt : ElementFilter.methodsIn(objectElement.getEnclosedElements())) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user