Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>tags/V1_9_8_M1
short MINOR_15 = 0; | short MINOR_15 = 0; | ||||
short MAJOR_16 = 60; | short MAJOR_16 = 60; | ||||
short MINOR_16 = 0; | short MINOR_16 = 0; | ||||
// short MAJOR_17 = 61; | |||||
// short MINOR_17 = 0; | |||||
short MAJOR_17 = 61; | |||||
short MINOR_17 = 0; | |||||
// short MAJOR_18 = 62; | |||||
// short MINOR_18 = 0; | |||||
int PREVIEW_MINOR_VERSION = 65535; | int PREVIEW_MINOR_VERSION = 65535; | ||||
/* ******************************************************************* | |||||
* Copyright (c) 2021 Contributors | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v 2.0 | |||||
* which accompanies this distribution and is available at | |||||
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | |||||
* ******************************************************************/ | |||||
package org.aspectj.testing; | |||||
import org.aspectj.util.LangUtil; | |||||
/** | |||||
* Makes sure tests are running on the right level of JDK. | |||||
* | |||||
* @author Alexander Kriegisch | |||||
*/ | |||||
public abstract class XMLBasedAjcTestCaseForJava17Only extends XMLBasedAjcTestCase { | |||||
@Override | |||||
public void setUp() throws Exception { | |||||
// Activate this block after upgrading to JDT Core Java 18 | |||||
/* | |||||
throw new IllegalStateException( | |||||
"These tests need a Java 17 level AspectJ compiler " + | |||||
"(e.g. because they use version-specific preview features). " + | |||||
"This compiler does not support preview features of a previous version anymore." | |||||
); | |||||
*/ | |||||
if (!LangUtil.is17VMOrGreater() || LangUtil.is18VMOrGreater()) { | |||||
throw new IllegalStateException( | |||||
"These tests should be run on Java 17 only " + | |||||
"(e.g. because they use version-specific preview features)" | |||||
); | |||||
} | |||||
super.setUp(); | |||||
} | |||||
} |
/* ******************************************************************* | |||||
* Copyright (c) 2021 Contributors | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v 2.0 | |||||
* which accompanies this distribution and is available at | |||||
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | |||||
* ******************************************************************/ | |||||
package org.aspectj.testing; | |||||
import org.aspectj.util.LangUtil; | |||||
/** | |||||
* Makes sure tests are running on the right level of JDK. | |||||
* | |||||
* @author Alexander Kriegisch | |||||
*/ | |||||
public abstract class XMLBasedAjcTestCaseForJava17OrLater extends XMLBasedAjcTestCase { | |||||
@Override | |||||
public void setUp() throws Exception { | |||||
if (!LangUtil.is17VMOrGreater()) | |||||
throw new IllegalStateException("These tests should be run on Java 17 or later"); | |||||
super.setUp(); | |||||
} | |||||
} |
import junit.framework.Test; | import junit.framework.Test; | ||||
import junit.framework.TestSuite; | import junit.framework.TestSuite; | ||||
import org.aspectj.systemtest.ajc197.AllTestsAspectJ197; | import org.aspectj.systemtest.ajc197.AllTestsAspectJ197; | ||||
import org.aspectj.systemtest.ajc198.AllTestsAspectJ198; | |||||
/** | /** | ||||
* @author Andy Clement | * @author Andy Clement | ||||
suite.addTest(AllTestsAspectJ195.suite()); | suite.addTest(AllTestsAspectJ195.suite()); | ||||
suite.addTest(AllTestsAspectJ196.suite()); | suite.addTest(AllTestsAspectJ196.suite()); | ||||
suite.addTest(AllTestsAspectJ197.suite()); | suite.addTest(AllTestsAspectJ197.suite()); | ||||
suite.addTest(AllTestsAspectJ198.suite()); | |||||
suite.addTest(AllTests18.suite()); | suite.addTest(AllTests18.suite()); | ||||
// $JUnit-END$ | // $JUnit-END$ | ||||
return suite; | return suite; |
/******************************************************************************* | |||||
* Copyright (c) 2021 Contributors | |||||
* All rights reserved. This program and the accompanying materials | |||||
* are made available under the terms of the Eclipse Public License v 2.0 | |||||
* which accompanies this distribution, and is available at | |||||
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | |||||
*******************************************************************************/ | |||||
package org.aspectj.systemtest.ajc198; | |||||
import junit.framework.Test; | |||||
import org.aspectj.apache.bcel.Constants; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||||
import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; | |||||
/** | |||||
* @author Alexander Kriegisch | |||||
*/ | |||||
public class Ajc198TestsJava extends XMLBasedAjcTestCaseForJava17OrLater { | |||||
public void testHiddenClass() { | |||||
runTest("hidden class"); | |||||
checkVersion("HiddenClassDemo", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public void testTextBlock1() { | |||||
runTest("textblock 1"); | |||||
checkVersion("Code", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public void testTextBlock2() { | |||||
runTest("textblock 2"); | |||||
checkVersion("Code2", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public void testRecords() { | |||||
runTest("simple record"); | |||||
checkVersion("Person", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public void testRecords2() { | |||||
runTest("using a record"); | |||||
checkVersion("UsingPersonRecord", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public void testAdvisingRecords() { | |||||
runTest("advising records"); | |||||
checkVersion("TraceRecordComponents", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public void testInstanceofPatterns() { | |||||
runTest("instanceof patterns"); | |||||
checkVersion("Jep305", Constants.MAJOR_17, Constants.MINOR_17); | |||||
} | |||||
public static Test suite() { | |||||
return XMLBasedAjcTestCase.loadSuite(Ajc198TestsJava.class); | |||||
} | |||||
@Override | |||||
protected java.net.URL getSpecFile() { | |||||
return getClassResource("ajc198.xml"); | |||||
} | |||||
} |
/******************************************************************************* | |||||
* Copyright (c) 2021 Contributors | |||||
* All rights reserved. This program and the accompanying materials | |||||
* are made available under the terms of the Eclipse Public License v 2.0 | |||||
* which accompanies this distribution, and is available at | |||||
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | |||||
*******************************************************************************/ | |||||
package org.aspectj.systemtest.ajc198; | |||||
import junit.framework.Test; | |||||
import junit.framework.TestSuite; | |||||
import org.aspectj.util.LangUtil; | |||||
/** | |||||
* @author Alexander Kriegisch | |||||
*/ | |||||
public class AllTestsAspectJ198 { | |||||
public static Test suite() { | |||||
TestSuite suite = new TestSuite("AspectJ 1.9.8 tests"); | |||||
if (LangUtil.is17VMOrGreater()) { | |||||
suite.addTest(SanityTestsJava17.suite()); | |||||
suite.addTest(Ajc198TestsJava.suite()); | |||||
} | |||||
if (LangUtil.is17VMOrGreater() && !LangUtil.is18VMOrGreater()) { | |||||
suite.addTest(Java17PreviewFeaturesTests.suite()); | |||||
} | |||||
return suite; | |||||
} | |||||
} |
/******************************************************************************* | |||||
* Copyright (c) 2021 Contributors | |||||
* All rights reserved. This program and the accompanying materials | |||||
* are made available under the terms of the Eclipse Public License v 2.0 | |||||
* which accompanies this distribution, and is available at | |||||
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | |||||
*******************************************************************************/ | |||||
package org.aspectj.systemtest.ajc198; | |||||
import junit.framework.Test; | |||||
import org.aspectj.apache.bcel.Constants; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||||
import org.aspectj.testing.XMLBasedAjcTestCaseForJava17Only; | |||||
/** | |||||
* @author Alexander Kriegisch | |||||
*/ | |||||
public class Java17PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava17Only { | |||||
/* | |||||
public void testSealedClassWithLegalSubclasses() { | |||||
runTest("sealed class with legal subclasses"); | |||||
checkVersion("Employee", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); | |||||
checkVersion("Manager", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); | |||||
} | |||||
public void testSealedClassWithIllegalSubclass() { | |||||
runTest("sealed class with illegal subclass"); | |||||
checkVersion("Person", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); | |||||
} | |||||
public void testWeaveSealedClass() { | |||||
runTest("weave sealed class"); | |||||
checkVersion("PersonAspect", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); | |||||
} | |||||
*/ | |||||
public static Test suite() { | |||||
return XMLBasedAjcTestCase.loadSuite(Java17PreviewFeaturesTests.class); | |||||
} | |||||
@Override | |||||
protected java.net.URL getSpecFile() { | |||||
return getClassResource("ajc198.xml"); | |||||
} | |||||
} |
/******************************************************************************* | |||||
* Copyright (c) 2021 Contributors | |||||
* All rights reserved. This program and the accompanying materials | |||||
* are made available under the terms of the Eclipse Public License v 2.0 | |||||
* which accompanies this distribution, and is available at | |||||
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | |||||
*******************************************************************************/ | |||||
package org.aspectj.systemtest.ajc198; | |||||
import junit.framework.Test; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||||
import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; | |||||
/* | |||||
* Some very trivial tests that help verify things are OK. | |||||
* These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option | |||||
* to check code generation and modification with that version specified. | |||||
* | |||||
* @author Alexander Kriegisch | |||||
*/ | |||||
public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater { | |||||
public static final int bytecode_version_for_JDK_level = 61; | |||||
// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) | |||||
public void testSimpleJava_A() { | |||||
runTest("simple - a"); | |||||
} | |||||
public void testSimpleJava_B() { | |||||
runTest("simple - b"); | |||||
} | |||||
public void testSimpleCode_C() { | |||||
runTest("simple - c"); | |||||
} | |||||
public void testSimpleCode_D() { | |||||
runTest("simple - d"); | |||||
} | |||||
public void testSimpleCode_E() { | |||||
runTest("simple - e"); | |||||
} | |||||
public void testSimpleCode_F() { | |||||
runTest("simple - f"); | |||||
} | |||||
public void testSimpleCode_G() { | |||||
runTest("simple - g"); | |||||
} | |||||
public void testSimpleCode_H() { | |||||
runTest("simple - h", true); | |||||
} | |||||
public void testSimpleCode_I() { | |||||
runTest("simple - i"); | |||||
} | |||||
public void testVersionCorrect1() { | |||||
runTest("simple - j"); | |||||
checkVersion("A", bytecode_version_for_JDK_level, 0); | |||||
} | |||||
public void testVersionCorrect2() { | |||||
runTest("simple - k"); | |||||
checkVersion("A", bytecode_version_for_JDK_level, 0); | |||||
} | |||||
public void testVersionCorrect4() { | |||||
runTest("simple - m"); | |||||
// Must be 49.0 when -1.5 is specified | |||||
checkVersion("A", 49, 0); | |||||
} | |||||
public static Test suite() { | |||||
return XMLBasedAjcTestCase.loadSuite(SanityTestsJava17.class); | |||||
} | |||||
@Override | |||||
protected java.net.URL getSpecFile() { | |||||
return getClassResource("sanity-tests-17.xml"); | |||||
} | |||||
} |
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> | |||||
<suite> | |||||
<!-- Java ?? final, Java 16, 15 preview --> | |||||
<!-- | |||||
<ajc-test dir="features197/java15" vm="17" title="sealed class with legal subclasses"> | |||||
<compile files="Person.java Employee.java Manager.java" options="--enable-preview -16" /> | |||||
</ajc-test> | |||||
--> | |||||
<!-- Java ?? final, Java 16, 15 preview --> | |||||
<!-- | |||||
<ajc-test dir="features197/java15" vm="17" title="sealed class with illegal subclass"> | |||||
<compile files="Person.java Employee.java Manager.java PersonaNonGrata.java" options="--enable-preview -16"> | |||||
<message kind="error" file="PersonaNonGrata.java" text="should be a permitted subtype of Person"/> | |||||
</compile> | |||||
</ajc-test> | |||||
--> | |||||
<!-- Java ?? final, Java 16, 15 preview --> | |||||
<!-- | |||||
<ajc-test dir="features197/java15" vm="17" title="weave sealed class"> | |||||
<compile files="Person.java Employee.java Manager.java TopManager.java PersonAspect.aj" options="--enable-preview -16" /> | |||||
<run class="TopManager" vmargs="--enable-preview"> | |||||
<stdout> | |||||
<line text="Hello Sir John" /> | |||||
<line text="CEO" /> | |||||
</stdout> | |||||
</run> | |||||
</ajc-test> | |||||
--> | |||||
</suite> |
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> | |||||
<suite> | |||||
<!-- empty class --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - a"> | |||||
<compile files="SimpleA.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- class with one method --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - b"> | |||||
<compile files="SimpleB.java" options="-17"/> | |||||
<run class="SimpleB"/> | |||||
</ajc-test> | |||||
<!-- empty aspect --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - c"> | |||||
<compile files="SimpleC.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- simple before --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - d"> | |||||
<compile files="SimpleD.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- simple itd field --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - e"> | |||||
<compile files="SimpleE.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- aspect with main calling a static method --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - f"> | |||||
<compile files="SimpleF.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- pertarget --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - g"> | |||||
<compile files="SimpleG.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- generic ctor itds --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - h"> | |||||
<compile files="SimpleH.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- overriding generic itd methods --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - i"> | |||||
<compile files="SimpleI.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- check class file version is 60.0 (Java 16) --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - j"> | |||||
<compile files="SimpleJ.java" options="-17"/> | |||||
</ajc-test> | |||||
<!-- check class file version is 60.0 (Java 16) --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - k"> | |||||
<compile files="SimpleJ.java" options="-source 16"/> | |||||
</ajc-test> | |||||
<!-- check class file version is 49.0 --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - m"> | |||||
<compile files="SimpleJ.java" options="-1.5"/> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - n"> | |||||
<compile files="SimpleN.java" options="-17"/> | |||||
</ajc-test> | |||||
</suite> |
return 17 <= vmVersion; | return 17 <= vmVersion; | ||||
} | } | ||||
public static boolean is18VMOrGreater() { | |||||
return 18 <= vmVersion; | |||||
} | |||||
/** | /** | ||||
* Shorthand for "if null, throw IllegalArgumentException" | * Shorthand for "if null, throw IllegalArgumentException" | ||||
* | * |