public String getClasspath() {
StringBuilder classpath = new StringBuilder();
classpath.append(projectPath);
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath());
} else {
classpath.append(File.pathSeparator).append(System.getProperty("sun.boot.class.path"));
public String getClasspath() {
String cp = projectPath + File.pathSeparator + System.getProperty("sun.boot.class.path") + File.pathSeparator
+ TestUtil.aspectjrtClasspath();
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
cp = LangUtil.getJrtFsFilePath()+File.pathSeparator+cp;
}
return cp;
public static final String CLOSING_SPAN;
static {
- if (LangUtil.is16VMOrGreater())
+ if (LangUtil.isVMGreaterOrEqual(16))
TYPE_NAME_LABEL = "element-name type-name-label";
- else if (LangUtil.is15VMOrGreater())
+ else if (LangUtil.isVMGreaterOrEqual(15))
TYPE_NAME_LABEL = "type-name-label";
- else if (LangUtil.is1dot8VMOrGreater())
+ else if (LangUtil.isVMGreaterOrEqual(1.8))
TYPE_NAME_LABEL = "typeNameLabel";
else
TYPE_NAME_LABEL = "strong";
- if (LangUtil.is16VMOrGreater())
+ if (LangUtil.isVMGreaterOrEqual(16))
CLOSING_SPAN = "</span>";
else
CLOSING_SPAN = "";
for (int k = 0; k < fileList.size(); k++) {
javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k);
}
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
options = new Vector<>();
Collections.addAll(options, javadocargs);
}
Locale defaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.ENGLISH);
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
JavadocRunner.callJavadocViaToolProvider(options, files);
} else {
JavadocRunner.callJavadoc(javadocargs);
String nextLine = reader.readLine();
while (nextLine != null && (!nextLine.contains("========"))) {
// On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit">
- if ((LangUtil.is11VMOrGreater() && nextLine.contains("ID=\"" + source + "\"") || nextLine.contains("id=\"" + source + "\"")) ||
+ if ((LangUtil.isVMGreaterOrEqual(11) && nextLine.contains("ID=\"" + source + "\"") || nextLine.contains("id=\"" + source + "\"")) ||
nextLine.contains("NAME=\"" + source + "\"") || nextLine.contains("name=\"" + source + "\"")) {
// found the required subsection
String subLine = reader.readLine();
args[2] = sourceLevel;
args[3] = "-classpath";
StringBuilder classpath = new StringBuilder();
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
}
classpath.append(AjdocTests.ASPECTJRT_PATH.getPath());
}
String[] strings = {
- LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
+ LangUtil.isVMGreaterOrEqual(11)?"<init>()":toName("Point()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""};
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== CONSTRUCTOR DETAIL",
// <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Point</a></span>()</code></th>
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
+ LangUtil.isVMGreaterOrEqual(11)?"#%3Cinit%3E()":toName("Point()"),
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b);
b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== CONSTRUCTOR DETAIL",
- LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
+ LangUtil.isVMGreaterOrEqual(11)?"<init>()":toName("Point()"),
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
href);
assertTrue("the Constructor Detail should have advised by " + href,b);
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
+ LangUtil.isVMGreaterOrEqual(11)?"#%3Cinit%3E()":toName("Point()"),
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
href);
assertTrue("the Constructor Summary should have advised by " + href,b);
}
String[] strings = {
- LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
+ LangUtil.isVMGreaterOrEqual(11)?"<init>()":toName("Point()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""};
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,
"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":strings[0],
+ LangUtil.isVMGreaterOrEqual(11)?"#%3Cinit%3E()":strings[0],
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Summary should have 'setX(int) advised by ... before()'",b);
}
private String toName(String name) {
- if (!LangUtil.is11VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(11)) {
name = name.replace('(','-');
name = name.replace(')','-');
}
// ensure that the file is entitled "Class PkgVisibleClass" and
// has not been changed to "Aspect PkgVisibleClass"
String[] classStrings = null;
- if (LangUtil.is13VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(13)) {
classStrings = new String[] {
"Class PkgVisibleClass</h1>",
"class " + CLOSING_SPAN + "<span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
// ensure that the file is entitled "Class ClassWithNestedAspect" and
// has not been changed to "Aspect ClassWithNestedAspect"
String[] classStrings = null;
- if (LangUtil.is13VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(13)) {
classStrings = new String[] {
"Class ClassWithNestedAspect</h1>",
"public class " + CLOSING_SPAN + "<span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== METHOD DETAIL",
toName("setX(int)"),
-// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)",
+// LangUtil.isVMGreaterOrEqual(18)?"setX-int-":"setX(int)",
HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
"declare warning: quot;blahquot;");
assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
toName("setX(int)"),
-// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)",
+// LangUtil.isVMGreaterOrEqual(18)?"setX-int-":"setX(int)",
HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE,
"declare warning: quot;blahquot;");
assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" +
}
private String toName(String name) {
- if (!LangUtil.is11VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(11)) {
name = name.replace('(','-');
name = name.replace(')','-');
}
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== CONSTRUCTOR DETAIL",
- LangUtil.is11VMOrGreater()?"<init>(java.lang.String)":toName("C(java.lang.String)"),
+ LangUtil.isVMGreaterOrEqual(11)?"<init>(java.lang.String)":toName("C(java.lang.String)"),
HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
"declare @constructor: foo.C.new(..) : @MyAnnotation");
assertTrue("Should have '" + doIt + " annotated by " +
"' in the Method Detail section", b);
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== CONSTRUCTOR SUMMARY",
- LangUtil.is11VMOrGreater()?"#%3Cinit%3E(java.lang.String)":toName("C(java.lang.String)"),
+ LangUtil.isVMGreaterOrEqual(11)?"#%3Cinit%3E(java.lang.String)":toName("C(java.lang.String)"),
HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY,
"declare @constructor: foo.C.new(..) : @MyAnnotation");
assertTrue("Should have '" + doIt + " annotated by " +
}
public void testVersion() {
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
return;
}
if (Version.getTimeText().equals("")) {
List<String> ret = new ArrayList<>();
if (parser.bootclasspath == null) {
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
addClasspath(LangUtil.getJrtFsFilePath(),ret);
} else {
addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
/** get the location of the org.aspectj.lang & runtime classes */
protected static String getRuntimeClasspath() {
StringBuilder classpath = new StringBuilder();
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
}
classpath.append(Constants.aspectjrtClasspath());
args = newargs;
}
}
- boolean needsJRTFS = LangUtil.is9VMOrGreater();
+ boolean needsJRTFS = LangUtil.isVMGreaterOrEqual(9);
if (needsJRTFS) {
if (!args[cpIndex].contains(LangUtil.JRT_FS)) {
String jrtfsPath = LangUtil.getJrtFsFilePath();
private ReflectionWorld() {
// super();
// this.setMessageHandler(new ExceptionBasedMessageHandler());
- // setBehaveInJava5Way(LangUtil.is15VMOrGreater());
+ // setBehaveInJava5Way(LangUtil.isVMGreaterOrEqual(15));
// this.classLoaderReference = new
// WeakClassLoaderReference(ReflectionWorld.class.getClassLoader());
// this.annotationFinder =
// assertFalse("Matches maybe", ex.matchesMethodExecution(foo).alwaysMatches());
// // never match
// ex = p.parsePointcutExpression("args(String,Integer,Number)");
- // if (LangUtil.is15VMOrGreater()) {
+ // if (LangUtil.isVMGreaterOrEqual(15)) {
// assertTrue("matches", ex.matchesMethodExecution(foo).alwaysMatches());
// } else {
// assertTrue("Does not match", ex.matchesMethodExecution(foo).neverMatches());
// assertFalse("Matches maybe", ex.matchesMethodExecution(foo).alwaysMatches());
// // never match
// ex = p.parsePointcutExpression("args(String,Integer,Number)");
- // if (LangUtil.is15VMOrGreater()) {
+ // if (LangUtil.isVMGreaterOrEqual(15)) {
// assertTrue("matches", ex.matchesMethodExecution(foo).alwaysMatches());
// } else {
// assertTrue("Does not match", ex.matchesMethodExecution(foo).neverMatches());
private static boolean is1dot6VMOrGreater = true;
private static boolean is1dot7VMOrGreater = true;
private static boolean is1dot8VMOrGreater = true;
- private static boolean is9VMOrGreater = LangUtil.is9VMOrGreater();
- private static boolean is10VMOrGreater = LangUtil.is10VMOrGreater();
- private static boolean is11VMOrGreater = LangUtil.is11VMOrGreater();
- private static boolean is12VMOrGreater = LangUtil.is12VMOrGreater();
- private static boolean is13VMOrGreater = LangUtil.is13VMOrGreater();
- private static boolean is14VMOrGreater = LangUtil.is14VMOrGreater();
- private static boolean is15VMOrGreater = LangUtil.is15VMOrGreater();
+ private static boolean is9VMOrGreater = LangUtil.isVMGreaterOrEqual(9);
+ private static boolean is10VMOrGreater = LangUtil.isVMGreaterOrEqual(10);
+ private static boolean is11VMOrGreater = LangUtil.isVMGreaterOrEqual(11);
+ private static boolean is12VMOrGreater = LangUtil.isVMGreaterOrEqual(12);
+ private static boolean is13VMOrGreater = LangUtil.isVMGreaterOrEqual(13);
+ private static boolean is14VMOrGreater = LangUtil.isVMGreaterOrEqual(14);
+ private static boolean is15VMOrGreater = LangUtil.isVMGreaterOrEqual(15);
private List<ITestStep> testSteps = new ArrayList<>();
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.aspectj.tools.ajc.AjcTestCase;
-
-import static org.aspectj.util.LangUtil.is16VMOrGreater;
+import org.aspectj.util.LangUtil;
/**
* Element that allow to run an abritrary Ant target in a sandbox.
//
// Attention: Ant 1.6.3 under Linux neither likes "" (empty string) nor " " (space), on Windows it would not be
// a problem. So we use "_dummy" Java system properties, even though they pollute the command line.
- p.setUserProperty("aj.addOpensKey", is16VMOrGreater() ? "--add-opens" : "-D_dummy");
- p.setUserProperty("aj.addOpensValue", is16VMOrGreater() ? "java.base/java.lang=ALL-UNNAMED" : "-D_dummy");
+ p.setUserProperty(
+ "aj.addOpensKey",
+ LangUtil.isVMGreaterOrEqual(16) ? "--add-opens" : "-D_dummy"
+ );
+ p.setUserProperty(
+ "aj.addOpensValue",
+ LangUtil.isVMGreaterOrEqual(16) ? "java.base/java.lang=ALL-UNNAMED" : "-D_dummy"
+ );
// create the test implicit path aj.path that contains the sandbox + regular test infra path
Path path = new Path(p, inTestCase.getSandboxDirectory().getAbsolutePath());
import org.aspectj.tools.ajc.AjcTestCase;
import org.aspectj.util.FileUtil;
-
-import static org.aspectj.util.LangUtil.is16VMOrGreater;
+import org.aspectj.util.LangUtil;
/**
* @author Adrian Colyer
// unwanted illegal access warnings during weaving in 'useFullLTW' mode, either making existing tests fail or
// having to assert on the warning messages.
//
- // vmargs += is16VMOrGreater() ? " --add-opens java.base/java.lang=ALL-UNNAMED" : "";
+ // vmargs += LangUtil.isVMGreaterOrEqual(16) ? " --add-opens java.base/java.lang=ALL-UNNAMED" : "";
AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(), getModuleToRun(), args, vmargs, getClasspath(), getModulepath(), useLtw, "true".equalsIgnoreCase(usefullltw));
@Override
public void setUp() throws Exception {
- if (!LangUtil.is10VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(10))
throw new IllegalStateException("These tests should be run on Java 10 or later");
super.setUp();
}
@Override
public void setUp() throws Exception {
- if (!LangUtil.is11VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(11))
throw new IllegalStateException("These tests should be run on Java 11 or later");
super.setUp();
}
@Override
public void setUp() throws Exception {
- if (!LangUtil.is12VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(12))
throw new IllegalStateException("These tests should be run on Java 12 or later");
super.setUp();
}
@Override
public void setUp() throws Exception {
- if (!LangUtil.is13VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(13))
throw new IllegalStateException("These tests should be run on Java 13 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 15
/*
- if (!LangUtil.is14VMOrGreater() || LangUtil.is15VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(14) || LangUtil.isVMGreaterOrEqual(15)) {
throw new IllegalStateException(
"These tests should be run on Java 14 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is14VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(14))
throw new IllegalStateException("These tests should be run on Java 14 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 16
/*
- if (!LangUtil.is15VMOrGreater() || LangUtil.is16VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(15) || LangUtil.isVMGreaterOrEqual(16)) {
throw new IllegalStateException(
"These tests should be run on Java 15 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is15VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(15))
throw new IllegalStateException("These tests should be run on Java 15 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 17
/*
- if (!LangUtil.is16VMOrGreater() || LangUtil.is17VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(16) || LangUtil.isVMGreaterOrEqual(17)) {
throw new IllegalStateException(
"These tests should be run on Java 16 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is16VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(16))
throw new IllegalStateException("These tests should be run on Java 16 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 18
/*
- if (!LangUtil.is17VMOrGreater() || LangUtil.is18VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(17) || LangUtil.isVMGreaterOrEqual(18)) {
throw new IllegalStateException(
"These tests should be run on Java 17 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is17VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(17))
throw new IllegalStateException("These tests should be run on Java 17 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 19
/*
- if (!LangUtil.is18VMOrGreater() || LangUtil.is19VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(18) || LangUtil.isVMGreaterOrEqual(19)) {
throw new IllegalStateException(
"These tests should be run on Java 18 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is18VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(18))
throw new IllegalStateException("These tests should be run on Java 18 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 20
/*
- if (!LangUtil.is19VMOrGreater() || LangUtil.is20VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(19) || LangUtil.isVMGreaterOrEqual(20)) {
throw new IllegalStateException(
"These tests should be run on Java 19 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is19VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(19))
throw new IllegalStateException("These tests should be run on Java 19 or later");
super.setUp();
}
);
// Activate this block before upgrading to JDT Core Java 21
/*
- if (!LangUtil.is20VMOrGreater() || LangUtil.is21VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(20) || LangUtil.isVMGreaterOrEqual(21)) {
throw new IllegalStateException(
"These tests should be run on Java 20 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is20VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(20))
throw new IllegalStateException("These tests should be run on Java 20 or later");
super.setUp();
}
*/
// AspectJ_JDK_Update
// Activate this block before upgrading to JDT Core Java 22
- if (!LangUtil.is21VMOrGreater() || LangUtil.is22VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(21) || LangUtil.isVMGreaterOrEqual(22)) {
throw new IllegalStateException(
"These tests should be run on Java 21 only " +
"(e.g. because they use version-specific preview features)"
@Override
public void setUp() throws Exception {
- if (!LangUtil.is21VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(21))
throw new IllegalStateException("These tests should be run on Java 21 or later");
super.setUp();
}
@Override
public void setUp() throws Exception {
- if (!LangUtil.is9VMOrGreater())
+ if (!LangUtil.isVMGreaterOrEqual(9))
throw new IllegalStateException("These tests should be run on Java 9 or later");
super.setUp();
}
list.add("-classpath");
StringBuilder classpath = new StringBuilder();
classpath.append(Globals.F_aspectjrt_jar.getAbsolutePath());
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath());
}
list.add(classpath.toString());
}
public void testAfterReturningWithWildcardVar() {
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
// See ReferenceType.isCoerceableFrom comments
return;
}
import org.aspectj.util.FileUtil;
import junit.framework.Test;
-
-import static org.aspectj.util.LangUtil.is16VMOrGreater;
+import org.aspectj.util.LangUtil;
/**
* @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
//
// TODO: A better solution would be a recursive filtered search via Files.walk, ideally added as a recursive search
// option for CountingFilenameFilter.
- String proxyDir = is16VMOrGreater() ? "jdk/proxy1" : "com/sun/proxy";
+ String proxyDir = LangUtil.isVMGreaterOrEqual(16) ? "jdk/proxy1" : "com/sun/proxy";
File f = new File(dir, "_ajdump/_before/" + proxyDir);
CountingFilenameFilter cff = new CountingFilenameFilter(".class");
// This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK)
// that it can be found without needing to set --module-path (this seems to be implicitly included by javac too)
public void testAddModules1() {
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
// java.xml.bind is gone in Java11
return;
}
// This tests that we can use add-modules to pull in something from the JDK jmods package and that
// when subsequently weaving we can see types from those modules
public void testWovenAfterAddModules() {
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
// java.xml.bind is gone in Java11
return;
}
// --limit-modules
public void testLimitModules1() {
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
// java.xml.bind is gone in Java11
return;
}
// --add-reads
public void testAddReads1() {
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
// java.xml.bind is gone in Java11
return;
}
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.19 tests");
suite.addTest(Bugs1919Tests.suite());
- if (LangUtil.is19VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(19)) {
suite.addTest(SanityTestsJava19.suite());
suite.addTest(Ajc1919TestsJava.suite());
}
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
- if (LangUtil.is19VMOrGreater() && !LangUtil.is20VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(19) && !LangUtil.isVMGreaterOrEqual(20)) {
suite.addTest(Java19PreviewFeaturesTests.suite());
}
*/
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.20 tests");
suite.addTest(Bugs1920Tests.suite());
- if (LangUtil.is20VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(20)) {
suite.addTest(SanityTestsJava20.suite());
suite.addTest(Ajc1920TestsJava.suite());
}
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
- if (LangUtil.is20VMOrGreater() && !LangUtil.is21VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(20) && !LangUtil.isVMGreaterOrEqual(21)) {
suite.addTest(Java20PreviewFeaturesTests.suite());
}
*/
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.21 tests");
suite.addTest(Bugs1921Tests.suite());
- if (LangUtil.is21VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(21)) {
suite.addTest(SanityTestsJava21.suite());
suite.addTest(Ajc1921TestsJava.suite());
}
// AspectJ_JDK_Update
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
// TODO: Comment out the following block when upgrading JDT Core to Java 22
- if (LangUtil.is21VMOrGreater() && !LangUtil.is22VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(21) && !LangUtil.isVMGreaterOrEqual(22)) {
suite.addTest(Java21PreviewFeaturesTests.suite());
}
return suite;
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.5 tests");
suite.addTest(Ajc195Tests.suite());
- if (LangUtil.is13VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(13)) {
suite.addTest(SanityTestsJava13.suite());
}
return suite;
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.6 tests");
- if (LangUtil.is14VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(14)) {
suite.addTest(Ajc196Tests.suite());
suite.addTest(SanityTestsJava14.suite());
}
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
- if (LangUtil.is14VMOrGreater() && !LangUtil.is15VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(14) && !LangUtil.isVMGreaterOrEqual(15)) {
suite.addTest(Java14PreviewFeaturesTests.suite());
}
*/
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.7 tests");
- if (LangUtil.is15VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(15)) {
suite.addTest(SanityTestsJava15.suite());
}
- if (LangUtil.is16VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(16)) {
suite.addTest(SanityTestsJava16.suite());
suite.addTest(Ajc197TestsJava.suite());
}
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
- if (LangUtil.is16VMOrGreater() && !LangUtil.is17VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(16) && !LangUtil.isVMGreaterOrEqual(17)) {
suite.addTest(Java16PreviewFeaturesTests.suite());
}
*/
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.8 tests");
suite.addTest(Bugs198Tests.suite());
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
suite.addTest(CompileWithReleaseTests.suite());
}
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
suite.addTest(Bugs198Java11Tests.suite());
}
- if (LangUtil.is17VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(17)) {
suite.addTest(SanityTestsJava17.suite());
suite.addTest(Ajc198TestsJava.suite());
}
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
- if (LangUtil.is17VMOrGreater() && !LangUtil.is18VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(17) && !LangUtil.isVMGreaterOrEqual(18)) {
suite.addTest(Java17PreviewFeaturesTests.suite());
}
*/
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.9 tests");
suite.addTest(Bugs199Tests.suite());
- if (LangUtil.is18VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(18)) {
suite.addTest(SanityTestsJava18.suite());
suite.addTest(Ajc199TestsJava.suite());
}
// Do not run tests using a previous compiler's preview features anymore. They would all fail.
/*
- if (LangUtil.is18VMOrGreater() && !LangUtil.is19VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(18) && !LangUtil.isVMGreaterOrEqual(19)) {
suite.addTest(Java18PreviewFeaturesTests.suite());
}
*/
public class AptTests extends XMLBasedAjcTestCase {
public void testAptWithSpecifiedProcessor() {
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
return;
}
runTest("annotation processing with specified processor");
* SPI - https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html
*/
public void testAptUsingSPI() {
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
return;
}
runTest("annotation processing in action using SPI");
}
public void testDisabledApt() {
- if (LangUtil.is11VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(11)) {
// javax.annotation.Generated not in Java11
return;
}
+ "../lib/junit/junit.jar" + File.pathSeparator
+ ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar";
verifyClasspath(cp);
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
cp = LangUtil.getJrtFsFilePath() + File.pathSeparator + cp;
}
String name = TestsModuleTests.class.getName();
TestSuite suite = new TestSuite(name);
// compiler tests, wrapped for JUnit
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
suite.addTest(AllTests19.suite());
} else {
suite.addTest(AllTests18.suite());
return result;
}
- @Deprecated
- public static boolean is1dot3VMOrGreater() {
- return 1.3 <= vmVersion;
+ public static boolean isVMGreaterOrEqual(int javaVersion) {
+ return isVMGreaterOrEqual((double) javaVersion);
}
- @Deprecated
- public static boolean is1dot4VMOrGreater() {
- return 1.4 <= vmVersion;
- }
-
- @Deprecated
- public static boolean is1dot5VMOrGreater() {
- return 1.5 <= vmVersion;
- }
-
- @Deprecated
- public static boolean is1dot6VMOrGreater() {
- return 1.6 <= vmVersion;
- }
-
- @Deprecated
- public static boolean is1dot7VMOrGreater() {
- return 1.7 <= vmVersion;
- }
-
- public static boolean is1dot8VMOrGreater() {
- return 1.8 <= vmVersion;
- }
-
- public static boolean is9VMOrGreater() {
- return 9 <= vmVersion;
- }
-
- public static boolean is10VMOrGreater() {
- return 10 <= vmVersion;
- }
-
- public static boolean is11VMOrGreater() {
- return 11 <= vmVersion;
- }
-
- public static boolean is12VMOrGreater() {
- return 12 <= vmVersion;
- }
-
- public static boolean is13VMOrGreater() {
- return 13 <= vmVersion;
- }
-
- public static boolean is14VMOrGreater() {
- return 14 <= vmVersion;
- }
-
- public static boolean is15VMOrGreater() {
- return 15 <= vmVersion;
- }
-
- public static boolean is16VMOrGreater() {
- return 16 <= vmVersion;
- }
-
- public static boolean is17VMOrGreater() {
- return 17 <= vmVersion;
- }
-
- public static boolean is18VMOrGreater() {
- return 18 <= vmVersion;
- }
-
- public static boolean is19VMOrGreater() {
- return 19 <= vmVersion;
- }
-
- public static boolean is20VMOrGreater() {
- return 20 <= vmVersion;
- }
-
- public static boolean is21VMOrGreater() {
- return 21 <= vmVersion;
- }
-
- // AspectJ_JDK_Update
- public static boolean is22VMOrGreater() {
- return 22 <= vmVersion;
+ public static boolean isVMGreaterOrEqual(double javaVersion) {
+ return javaVersion <= vmVersion;
}
/**
// }
public void testVersion() {
- assertTrue(LangUtil.is1dot8VMOrGreater()); // min vm now - floor may change
- if (LangUtil.is11VMOrGreater()) {
- assertTrue(LangUtil.is9VMOrGreater());
- assertTrue(LangUtil.is10VMOrGreater());
+ assertTrue(LangUtil.isVMGreaterOrEqual(1.8)); // min vm now - floor may change
+ if (LangUtil.isVMGreaterOrEqual(11)) {
+ assertTrue(LangUtil.isVMGreaterOrEqual(9));
+ assertTrue(LangUtil.isVMGreaterOrEqual(10));
}
}
String jdkHome = new File(jrtFsPath).getParentFile().getParent();
FileSystem fs = null;
try {
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
Map<String, String> env = new HashMap<>();
env.put("java.home", jdkHome);
fs = FileSystems.newFileSystem(JRT_URI, env);
}
// On Java9 it is possible to fail to find a URLClassLoader from which to derive a suitable classpath
// For now we can determine it from the java.class.path:
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
list.add(0, LangUtil.getJrtFsFilePath());
List<String> javaClassPathEntries = makeClasspath(System.getProperty("java.class.path"));
for (int i=javaClassPathEntries.size()-1;i>=0;i--) {
suite.addTestSuite(FieldSetTestCase.class);
suite.addTestSuite(HierarchyDependsTestCase.class);
suite.addTestSuite(IdWeaveTestCase.class);
- if (LangUtil.is9VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(9)) {
suite.addTestSuite(JImageTestCase.class);
}
suite.addTestSuite(MegaZipTestCase.class);
cSig.formalTypeParameters, world);
assertEquals("Ljava/lang/Object;", superclass.getSignature());
System.out.println(Arrays.toString(cSig.superInterfaceSignatures));
- if (LangUtil.is12VMOrGreater()) {
+ if (LangUtil.isVMGreaterOrEqual(12)) {
// [Ljava/lang/constant/Constable;, Ljava/lang/Comparable<TE;>;, Ljava/io/Serializable;]
assertEquals("3 superinterfaces but "+Arrays.toString(cSig.superInterfaceSignatures), 3, cSig.superInterfaceSignatures.length);
} else {
assertEquals("2 superinterfaces", 2, cSig.superInterfaceSignatures.length);
}
- int idx = LangUtil.is12VMOrGreater()?1:0;
+ int idx = LangUtil.isVMGreaterOrEqual(12)?1:0;
UnresolvedType comparable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[idx++],
cSig.formalTypeParameters, world);
assertEquals("Pjava/lang/Comparable<TE;>;", comparable.getSignature());
}
public void testOnJava9() {
- if (!LangUtil.is9VMOrGreater()) {
+ if (!LangUtil.isVMGreaterOrEqual(9)) {
System.out.println("SKIPPING JIMAGE TESTS AS NOT ON 1.9 OR LATER");
}
}
public void testBasicStructureAndCapabilities() {
- if (!LangUtil.is9VMOrGreater()) return;
+ if (!LangUtil.isVMGreaterOrEqual(9)) return;
// Should be one entry for finding JRT contents
List<Entry> entries = cpm.getEntries();
assertEquals(1,entries.size());
}
public void testBehaviour() throws Exception {
- if (!LangUtil.is9VMOrGreater()) return;
+ if (!LangUtil.isVMGreaterOrEqual(9)) return;
JImageEntry jie = getJImageEntry();
Map<String, Path> packageCache = jie.getPackageCache();