diff options
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java')
-rw-r--r-- | org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java index 0b400a7fd5..a412679a7f 100644 --- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java +++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java9ElementProcessor.java @@ -51,6 +51,7 @@ import javax.lang.model.type.TypeMirror; import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor; import org.eclipse.jdt.compiler.apt.tests.processors.util.TestDirectiveVisitor; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; /** * A processor that explores the java 9 specific elements and validates the lambda and @@ -63,6 +64,7 @@ public class Java9ElementProcessor extends BaseProcessor { boolean reportSuccessAlready = true; RoundEnvironment roundEnv = null; Messager _messager = null; + boolean isJre12; boolean isJre11; boolean isJre10; @Override @@ -70,19 +72,14 @@ public class Java9ElementProcessor extends BaseProcessor { super.init(processingEnv); _typeUtils = processingEnv.getTypeUtils(); _messager = processingEnv.getMessager(); - try { - SourceVersion.valueOf("RELEASE_11"); + String property = System.getProperty("java.specification.version"); + if (property.equals(CompilerOptions.VERSION_10)) { this.isJre10 = true; + } else if (property.equals(CompilerOptions.VERSION_11)) { this.isJre11 = true; - } catch(IllegalArgumentException iae) { - } - if (!this.isJre11) { - try { - SourceVersion.valueOf("RELEASE_10"); - this.isJre10 = true; - } catch(IllegalArgumentException iae) { - } - } + } else if (property.equals(CompilerOptions.VERSION_12)) { + this.isJre12 = true; + } } // Always return false from this processor, because it supports "*". // The return value does not signify success or failure! @@ -476,7 +473,7 @@ public class Java9ElementProcessor extends BaseProcessor { assertNotNull("java.base module null", base); List<? extends Directive> directives = base.getDirectives(); List<Directive> filterDirective = filterDirective(directives, DirectiveKind.USES); - assertEquals("incorrect no of uses", this.isJre11? 33 : 34, filterDirective.size()); + assertEquals("incorrect no of uses", (this.isJre11 || this.isJre12) ? 33 : 34, filterDirective.size()); } /* * Test java.base module can be loaded and verify its 'provides' attributes @@ -530,7 +527,7 @@ public class Java9ElementProcessor extends BaseProcessor { assertNotNull("java.sql module null", base); List<? extends Directive> directives = base.getDirectives(); List<Directive> filterDirective = filterDirective(directives, DirectiveKind.REQUIRES); - assertEquals("Incorrect no of requires", this.isJre11 ? 4 : 3, filterDirective.size()); + assertEquals("Incorrect no of requires", (this.isJre11 || this.isJre12) ? 4 : 3, filterDirective.size()); RequiresDirective req = null; for (Directive directive : filterDirective) { if (((RequiresDirective) directive).getDependency().getQualifiedName().toString().equals("java.logging")) { |