Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8356058

PrintingProcessor (-Xprint) does not print type variable bounds and type annotations for Object supertypes

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25
    • tools
    • None
    • behavioral
    • minimal
    • Programs relying on the exact format of `-Xprint` are unlikely.
    • Other
    • Implementation

      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 whole extends <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 whole extends <bound> will be elided if there's no non-elided bound.
      • annotated supertype of type java.lang.Object.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: