Reported here:
https://mail.openjdk.org/pipermail/compiler-dev/2024-August/027572.html
Consider code like:
```
class C {
Undefined u1;
Undefined<UndefinedParam> u2;
}
```
And consider annotation processor like:
```
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementFilter;
@SupportedAnnotationTypes("*")
public class TestAP extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element root : roundEnv.getRootElements()) {
for (VariableElement field : ElementFilter.fieldsIn(root.getEnclosedElements())) {
System.err.println("" + field.getSimpleName() +
"'s type: " + field.asType() +
", of kind: " + field.asType().getKind() +
", with underlying Element:" + processingEnv.getTypeUtils().asElement(field.asType()));
}
}
return false;
}
}
```
Then running it leads to:
```
$ javac -classpath ... -processor TestAP /tmp/C.java
u1's type: Undefined, of kind: ERROR, with underlying Element:Undefined
u2's type: <any>, of kind: ERROR, with underlying Element:<any>
warning: No SupportedSourceVersion annotation found on TestAP, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'TestAP' less than -source '21'
/tmp/C.java:2: error: cannot find symbol
Undefined u1;
^
symbol: class Undefined
location: class C
/tmp/C.java:3: error: cannot find symbol
Undefined<UndefinedParam> u2;
^
symbol: class Undefined
location: class C
/tmp/C.java:3: error: cannot find symbol
Undefined<UndefinedParam> u2;
^
symbol: class UndefinedParam
location: class C
3 errors
2 warnings
```
Note that for the simple undefined type, the erroneous type has some potentially interesting information available, but there is no information available for the parameterized type - the type arguments are lost, as is any information related to the parameterized type itself. It would be good if more information about the type could be recovered.
https://mail.openjdk.org/pipermail/compiler-dev/2024-August/027572.html
Consider code like:
```
class C {
Undefined u1;
Undefined<UndefinedParam> u2;
}
```
And consider annotation processor like:
```
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementFilter;
@SupportedAnnotationTypes("*")
public class TestAP extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (Element root : roundEnv.getRootElements()) {
for (VariableElement field : ElementFilter.fieldsIn(root.getEnclosedElements())) {
System.err.println("" + field.getSimpleName() +
"'s type: " + field.asType() +
", of kind: " + field.asType().getKind() +
", with underlying Element:" + processingEnv.getTypeUtils().asElement(field.asType()));
}
}
return false;
}
}
```
Then running it leads to:
```
$ javac -classpath ... -processor TestAP /tmp/C.java
u1's type: Undefined, of kind: ERROR, with underlying Element:Undefined
u2's type: <any>, of kind: ERROR, with underlying Element:<any>
warning: No SupportedSourceVersion annotation found on TestAP, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'TestAP' less than -source '21'
/tmp/C.java:2: error: cannot find symbol
Undefined u1;
^
symbol: class Undefined
location: class C
/tmp/C.java:3: error: cannot find symbol
Undefined<UndefinedParam> u2;
^
symbol: class Undefined
location: class C
/tmp/C.java:3: error: cannot find symbol
Undefined<UndefinedParam> u2;
^
symbol: class UndefinedParam
location: class C
3 errors
2 warnings
```
Note that for the simple undefined type, the erroneous type has some potentially interesting information available, but there is no information available for the parameterized type - the type arguments are lost, as is any information related to the parameterized type itself. It would be good if more information about the type could be recovered.
- relates to
-
JDK-8340694 Erroneous parameterized qualified type representation
- New
- links to
-
Commit(master) openjdk/jdk/ff59532d
-
Review(master) openjdk/jdk/20716