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)?
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)?
- relates to
-
JDK-8345302 Building microbenchmarks require larger Java heap
- Resolved