RFR: JDK-8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release & JDK-8209058: Cannot find annotation method 'value()' in type 'Profile+Annotation'

Jan Lahoda jan.lahoda at oracle.com
Wed Sep 19 15:54:12 UTC 2018


Hi,

I'd like to ask for a review of two related --release related bugs:

The first bug is:
https://bugs.openjdk.java.net/browse/JDK-8209865

Incorrect 'multiple elements' notes with Elements#getTypeElement and 
--release

The issue here is that 
Elements.getTypeElement("javax.annotation.processing.Generated") returns 
null. The cause is the structure of ct.sym: to share classfile used for 
--release 8 and --release 9, the --release 9 is implemented in a way 
that every module gets a plain directory with all classfiles (whether 
they belong to the given module or not) on its path, and when compiling, 
javac picks the correct packages/classes from this directory based on 
module exports. But for the "unbound" search using getTypeElement, all 
modules are searched, ignoring module exports, so the Generated class is 
found in multiple modules.

The proposed patch drops this ct.sym structure, and creates a simple 
module-path-like structure for --release 9+ data:
9/java.base
  /java.compiler
...

9A/java.base
   /java.compiler
...

The paths for a module M for --release N are all directories in the form 
".*N.*/M". These contain only classes that belong to the given module.

For --release <= 8, the original approach remains. As a consequence, 
there are no shared classfiles between JDK 8 and JDK 9 data, but the 
size increase seems acceptable compared to the much cleaner structure of 
ct.sym (originally about 6.2MB with JDK 11 data, about 7.9MB with this 
patch and JDK 11 data).

JBS: https://bugs.openjdk.java.net/browse/JDK-8209865
Webrev: http://cr.openjdk.java.net/~jlahoda/8209865/webrev.00/


The second bug is:
https://bugs.openjdk.java.net/browse/JDK-8209058

Cannot find annotation method 'value()' in type 'Profile+Annotation'

The problem is that compiling code like:
---
import javax.annotation.processing.ProcessingEnvironment;

public class NoProfileAnnotationWarning {
     void t(ProcessingEnvironment pe) {
         pe.getElementUtils().getTypeElement("a");
     }
}
---
with --release 10 and -Xlint:all may lead to warnings like:
---
/9A/java.compiler/javax/annotation/processing/ProcessingEnvironment.sig: 
warning: Cannot find annotation method 'value()' in type 
'Profile+Annotation': class file for jdk.Profile+Annotation not found
---

The reason is that ct.sym still uses the synthetic 
jdk/Profile+Annotation annotation to assign classes to profiles. While 
this is only relevant for --release 8, to maximize data/classfile reuse, 
the annotation is present also in classfiles for other versions, for 
both the 'make/data/symbols/*.sym.txt' files and in ct.sym. This causes 
problem for --release >= 9, as the synthetic annotation is not always 
properly removed from the symbols as it is read in ClassReader (as it is 
in a non-exported package). As, after the first patch above, there is no 
sharing between classfiles for <= 8 and >= 9 in ct.sym, the proposal is 
to simply remove this annotation for classfiles in ct.sym that are not 
used for --release 8.

JBS: https://bugs.openjdk.java.net/browse/JDK-8209058
Webrev: http://cr.openjdk.java.net/~jlahoda/8209058/webrev.00/

How does this look?

Thanks,
     Jan


More information about the compiler-dev mailing list