mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8189747: JDK9 javax.lang.model.util.Elements#getTypeElement regressed 1000x in performance
Caching the results of Elements.getTypeElement/getPackageElement Reviewed-by: darcy
This commit is contained in:
parent
2131cb484e
commit
fe80e55647
3 changed files with 78 additions and 31 deletions
|
@ -23,7 +23,7 @@
|
|||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119
|
||||
* @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 8189747
|
||||
* @summary Verify that annotation processing works.
|
||||
* @library /tools/lib
|
||||
* @modules
|
||||
|
@ -1389,6 +1389,19 @@ public class AnnotationProcessing extends ModuleTestBase {
|
|||
.run()
|
||||
.writeAll();
|
||||
|
||||
//from source:
|
||||
new JavacTask(tb)
|
||||
.options("--module-source-path", moduleSrc.toString(),
|
||||
"--source-path", src.toString(),
|
||||
"-processorpath", System.getProperty("test.class.path"),
|
||||
"-processor", UnboundLookupGenerate.class.getName(),
|
||||
"-XDrawDiagnostics")
|
||||
.outdir(classes)
|
||||
.files(findJavaFiles(moduleSrc))
|
||||
.run()
|
||||
.writeAll()
|
||||
.getOutput(OutputKind.DIRECT);
|
||||
|
||||
}
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
|
@ -1486,6 +1499,29 @@ public class AnnotationProcessing extends ModuleTestBase {
|
|||
|
||||
}
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
public static final class UnboundLookupGenerate extends AbstractProcessor {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
if (processingEnv.getElementUtils().getTypeElement("nue.Nue") == null) {
|
||||
try (Writer w = processingEnv.getFiler().createSourceFile("m1x/nue.Nue").openWriter()) {
|
||||
w.write("package nue; public class Nue {}");
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
return SourceVersion.latest();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongDefaultTargetModule(Path base) throws Exception {
|
||||
Path src = base.resolve("src");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue