-
Bug
-
Resolution: Fixed
-
P2
-
9.0.1
-
b23
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8207337 | 12 | Jan Lahoda | P2 | Resolved | Fixed | b03 |
JDK-8207422 | 11.0.2 | Jan Lahoda | P2 | Resolved | Fixed | b01 |
JDK-8207637 | 11.0.1 | Jan Lahoda | P2 | Resolved | Fixed | b02 |
We are running annotation processors that use javax.lang.model.util.Elements#getTypeElement a lot. It seems that the performance regressed almost 1000x when using --release 9 instead of --release 8 on the recent JDK9.
Test Code:
@SupportedAnnotationTypes(value = "mypackage.MyAnnotation")
public class MyAnnotationProcessor extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
String name = "mypackage.MyClass";
Elements elementUtils = processingEnv.getElementUtils();
long time = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
elementUtils.getTypeElement(name);
}
System.out.println((System.currentTimeMillis() - time) + "ms");
return false;
}
}
I've tested this also with a single iteration, where --release 8 took 0ms and --release 9 was 18ms.
Steps to reproduce on Linux Ubuntu:
unpack MyAnnotationProcessor.tar.gz
set JAVA_HOME to JDK 9.0.1
sh ./run.sh
The expected output is:
Running with --release 8
71ms
27ms
Running with --release 9
2325ms
1711ms
Test Code:
@SupportedAnnotationTypes(value = "mypackage.MyAnnotation")
public class MyAnnotationProcessor extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
String name = "mypackage.MyClass";
Elements elementUtils = processingEnv.getElementUtils();
long time = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
elementUtils.getTypeElement(name);
}
System.out.println((System.currentTimeMillis() - time) + "ms");
return false;
}
}
I've tested this also with a single iteration, where --release 8 took 0ms and --release 9 was 18ms.
Steps to reproduce on Linux Ubuntu:
unpack MyAnnotationProcessor.tar.gz
set JAVA_HOME to JDK 9.0.1
sh ./run.sh
The expected output is:
Running with --release 8
71ms
27ms
Running with --release 9
2325ms
1711ms
- backported by
-
JDK-8207337 JDK9 javax.lang.model.util.Elements#getTypeElement regressed 1000x in performance.
-
- Resolved
-
-
JDK-8207422 JDK9 javax.lang.model.util.Elements#getTypeElement regressed 1000x in performance.
-
- Resolved
-
-
JDK-8207637 JDK9 javax.lang.model.util.Elements#getTypeElement regressed 1000x in performance.
-
- Resolved
-