Summary
The -Xprint
javac feature does not print:
- type variable bounds
- class super type, when the super type is
java.lang.Object
, even if the supertype is annotated
This leads to loss of information from -Xprint
. Herein, the proposal is to fix this.
Problem
Consider code like:
import java.lang.annotation.*;
public class PrintingTest<T extends CharSequence> extends @TA Object {
}
@Target(ElementType.TYPE_USE)
@interface TA {}
Printing this using -Xprint
leads to:
public class PrintingTest<T> {
public PrintingTest();
}
@java.lang.annotation.Target({TYPE_USE})
@interface TA {
}
Note the missing bound for T
and the missing @TA Object
as a supertype of PrintingTest
.
Solution
javac -Xprint
will print:
- bounds for type variables, filtering out non-annotated
java.lang.Object
bounds. The wholeextends <bound>
will be elided if there's no non-elided bound. - annotated supertype of type
java.lang.Object
.
E.g. the output for the example above will look like:
public class PrintingTest<T extends java.lang.CharSequence> extends java.lang.@TA Object {
public PrintingTest();
}
@java.lang.annotation.Target({TYPE_USE})
@interface TA {
}
Specification
javac -Xprint
will print:
- bounds for type variables, filtering out non-annotated
java.lang.Object
bounds. The wholeextends <bound>
will be elided if there's no non-elided bound. - annotated supertype of type
java.lang.Object
.
- csr of
-
JDK-8356057 PrintingProcessor (-Xprint) does not print type variable bounds and type annotations for Object supertypes
-
- Open
-