Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -55,18 +55,23 @@ public boolean process(Set<? extends TypeElement> annotations,
}

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())) {
Expand Down