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

Investigate if class loading by javac could be reduced when generating new classes using annotation processor

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25
    • 24, 25
    • tools
    • None

      When an annotation processor generates a new class, javac performs several checks to verify sanity and validity of the request. For the purpose of this investigation, there are two of interest:

      https://github.com/openjdk/jdk/blob/31ceec7cd55b455cddf0953cc23aaa64612bd6e7/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java#L755

      where javac will attempt to load the given class, and will check if it was or wasn't part of the initial inputs, producing an error if it was, as per specification.

      https://github.com/openjdk/jdk/blob/31ceec7cd55b455cddf0953cc23aaa64612bd6e7/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacFiler.java#L733

      where javac will optionally report a warning when the newly generated class would overwrite a class from the classpath.

      It should be investigated if this class loading can be reduced, namely:
      - in the first case, is it possible to avoid loading the class if the originating file is not the initial input?
      - in the second case, is it possible to avoid loading the class if the originating file is part of the class output (and hence the newly created file is incrementally re-generating file from a previous build round)?

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: