*/bin
+*/pom.xml.versionsBackup
log.txt
.vscode
.DS_Store
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2019 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * ******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+/**
+ * @author Andy Clement
+ */
+public class AJDocConstants {
+
+ public final static String VERSION = "1.7";
+
+}
initialiseProject("pr148906");
File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
String[] ajOptions = {new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
- runAjdoc(files,"1.6",ajOptions);
+ runAjdoc(files,AJDocConstants.VERSION,ajOptions);
assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
if (!html.exists()) {
initialiseProject("pr148906");
File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
String[] ajOptions = {new String("-outxml"),new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
- runAjdoc(files,"1.6",ajOptions);
+ runAjdoc(files,AJDocConstants.VERSION,ajOptions);
assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
if (!html.exists()) {
*/
public void testAJdocHasAspectTitle() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/A.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
*/
public void testAJdocHasClassTitle() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/C.java")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
*/
public void testInnerAspect() throws Exception {
File[] files = {file1, file2};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/ClassA.InnerAspect.html");
if (!htmlFile.exists()) {
*/
public void testAdviceNamingCoverage() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html");
if (!htmlFile.exists()) {
*/
public void testAdvisesRelationshipCoverage() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByMethodExecution() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByConstructorExecution() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByMethodCall() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByConstructorCall() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByGet() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedBySet() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByInitialization() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByStaticInitialization() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByHandler() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
*/
public void testTwoBeforeAdvice() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C2.html");
if (!htmlFile.exists()) {
*/
public void testNoSpuriousAdvisedByRels() throws Exception {
File[] files = {file4};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
if (!htmlFile.exists()) {
*/
public void testNestedAspect() throws Exception {
File[] files = {file9};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.NestedAspect.html");
if (!htmlFile.exists()) {
*/
public void testNestedAspectWithSimilarName() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
if (!htmlFile.exists()) {
*/
public void testAdviceInNestedAspect() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
if (!htmlFile.exists()) {
*/
public void testAdvisedByInNestedAspect() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
if (!htmlFile.exists()) {
public void testDeclareStatments() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
if (!htmlFile.exists()) {
public void testDeclareWarning() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
if (!htmlFile.exists()) {
public void testMatchesDeclareCall() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
if (!htmlFile.exists()) {
public void testMatchesDeclareExecution() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
if (!htmlFile.exists()) {
public void testDeclareParents() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
if (!htmlFile.exists()) {
public void testAspectDeclarations() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html");
if (!htmlFile.exists()) {
public void testDeclareSoft() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
if (!htmlFile.exists()) {
public void testSoftenedBy() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html");
if (!htmlFile.exists()) {
public void testDeclareAnnotation() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
// Aspect AnnotationTest should contain within it's declare
// detail and summary the declare annotation statement.
public void testMethodAnnotatedBy() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtMethod.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
if (!htmlFile.exists()) {
public void testConstructorAnnotatedBy() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtConstructor.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
if (!htmlFile.exists()) {
public void testFieldAnnotatedBy() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtField.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
if (!htmlFile.exists()) {
public void testTypeAnnotatedBy() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
if (!htmlFile.exists()) {
public void testMatchesDeclareAndAdvisedBy() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "A.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html");
if (!htmlFile.exists()) {
public void testTwoDeclareParents() throws Exception {
initialiseProject("declareForms");
File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareParents.aj")};
- runAjdoc("private","1.6",files);
+ runAjdoc("private",AJDocConstants.VERSION,files);
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareParents.html");
if (!htmlFile.exists()) {
public final static short MINOR_10 = 0;
public final static short MAJOR_11 = 55;
public final static short MINOR_11 = 0;
+ public final static short MAJOR_12 = 56;
+ public final static short MINOR_12 = 0;
+
+ public final static int PREVIEW_MINOR_VERSION = 65535;
+
// Defaults
public final static short MAJOR = MAJOR_1_1;
public final static short MINOR = MINOR_1_1;
}
// On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem
- if (vm_version.startsWith("9") || vm_version.startsWith("10") || vm_version.startsWith("11")) {
+ if (vm_version.startsWith("9") || vm_version.startsWith("10")
+ || vm_version.startsWith("11") || vm_version.startsWith("12")) {
buf.insert(0, File.pathSeparatorChar);
buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS);
}
<p>The full list of resolved issues in 1.9.3 is available
<a href="https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&f0=OP&f1=OP&f3=CP&f4=CP&j1=OR&list_id=16866879&product=AspectJ&query_format=advanced&target_milestone=1.9.3">here</a></h2>.</p>
+<p>AspectJ 1.9.3 supports Java12. Java12 introduces the new switch expression syntax, but you must activate support for that via
+an <tt>--enable-preview</tt> flag when using the compiler and attempting to run the resultant classes:
+
+Here is <tt>Switch3.java</tt>:
+<pre><code>
+=========8<=========
+public class Switch3 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> foo(0);
+ case G -> foo(1);
+ case B -> foo(2);
+ default -> foo(3);
+ };
+ return result;
+ }
+
+ public static final int foo(int i) {
+ return i+1;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+}
+
+aspect X {
+ int around(): call(* foo(..)) {
+ return proceed()*3;
+ }
+}
+=========8<=========
+</code></pre>
+
+Compile it with:
+<pre><code>
+$ ajc --enable-preview -showWeaveInfo -12 Switch3.java
+
+Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:12) advised by around advice from 'X' (Switch3.java:30)
+
+Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:13) advised by around advice from 'X' (Switch3.java:30)
+
+Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:14) advised by around advice from 'X' (Switch3.java:30)
+
+Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:15) advised by around advice from 'X' (Switch3.java:30)
+
+</code></pre>
+
+Now run it:
+<pre><code>
+$ java --enable-preview Switch3
+3
+6
+9
+12
+</code></pre>
+
+
+
<p>Available: 1.9.3.RC1 available 7-Mar-2019</p>
<br><br>
org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy.
### AspectJ-specific messages
compiler.name = AspectJ Compiler
-compiler.version = Eclipse Compiler #6373b82afa49b(1-Oct-2018), 3.16
+compiler.version = Eclipse Compiler #a9ab0710a01b2b(28-Mar-2019), 3.18
compiler.copyright =
super(name);
}
- public void testSimpleStructure() throws IOException /* , CoreException */{
+ public void testSimpleStructure() throws IOException {
AjBuildManager manager = new AjBuildManager(messageWriter);
BuildArgParser parser = new BuildArgParser(messageWriter);
String javaClassPath = System.getProperty("java.class.path");
- System.out.println(javaClassPath);
String sandboxName = TestUtil.createEmptySandbox().getAbsolutePath();
AjBuildConfig buildConfig = parser.genBuildConfig(new String[] { "-d", sandboxName, "-1.4", "-classpath", javaClassPath,
Constants.TESTDATA_PATH + "/src1/A.java",
// EajcModuleTests.TESTDATA_PATH + "/src1/Hello.java",
});
String err = parser.getOtherMessages(true);
- assertTrue(err, null == err);
+ assertTrue(err, null == err || err.startsWith("incorrect classpath") && err.endsWith("run-all-junit-tests/target/classes"));
// manager.setStructureModel(AsmManager.getDefault().getHierarchy());
MessageHandler handler = new MessageHandler();
manager.batchBuild(buildConfig, handler);
e.printStackTrace();
}
return lastRunResult;
- } else if (vmargs!=null && (vmargs.contains("--add-modules") || vmargs.contains("--limit-modules") || vmargs.contains("--add-reads"))) {
+ } else if (vmargs!=null && (vmargs.contains("--enable-preview") || vmargs.contains("--add-modules") || vmargs.contains("--limit-modules") || vmargs.contains("--add-reads"))) {
// If --add-modules supplied, need to fork the test
try {
// if (mp.indexOf("$runtime") != -1) {
public static final String COMMAND_EDITOR_NAME = AjcTask.class.getName() + ".COMMAND_EDITOR";
- static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11" };
- static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11"};
- static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", "-10", "-11" };
+ static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11", "12" };
+ static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11", "12" };
+ static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", "-10", "-11", "-12" };
private static final ICommandEditor COMMAND_EDITOR;
/* *******************************************************************
- * Copyright (c) 2004,2018 IBM Corporation, contributors
+ * Copyright (c) 2004,2019 IBM Corporation, contributors
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
private static boolean is19VMOrGreater = false;
private static boolean is10VMOrGreater = false;
private static boolean is11VMOrGreater = false;
+ private static boolean is12VMOrGreater = false;
static { // matching logic is also in org.aspectj.util.LangUtil
is14VMOrGreater = LangUtil.is14VMOrGreater();
is19VMOrGreater = LangUtil.is19VMOrGreater();
is10VMOrGreater = LangUtil.is10VMOrGreater();
is11VMOrGreater = LangUtil.is11VMOrGreater();
+ is12VMOrGreater = LangUtil.is12VMOrGreater();
}
private List<ITestStep> testSteps = new ArrayList<ITestStep>();
if (vmLevel.equals("1.9")) canRun = is19VMOrGreater;
if (vmLevel.equals("10")) canRun = is10VMOrGreater;
if (vmLevel.equals("11")) canRun = is11VMOrGreater;
+ if (vmLevel.equals("12")) canRun = is12VMOrGreater;
if (!canRun) {
System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
+ ", currently running on " + System.getProperty("java.vm.version"));
}
if (m_stdErrSpec != null) {
String stderr2 = stderr.toString();
- // Working around this rediculous message that still comes out of Java7 builds:
+ // Working around this ridiculous message that still comes out of Java7 builds:
if (stderr2.indexOf("Class JavaLaunchHelper is implemented in both")!=-1 && stderr2.indexOf('\n')!=-1) {
stderr2 = stderr2.replaceAll("objc\\[[0-9]*\\]: Class JavaLaunchHelper is implemented in both [^\n]*\n","");
}
stderr2 = stderr2.replaceAll("WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\n","");
stderr2 = stderr2.replaceAll("WARNING: All illegal access operations will be denied in a future release\n","");
}
-
+ // J12
+ String msg = "Java HotSpot(TM) 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = \"org.aspectj.weaver.loadtime.WeavingURLClassLoader\"). To use archived non-system classes, this property must not be set";
+ if (stderr2.contains(msg)) {
+ stderr2 = stderr2.replace(msg+"\n","");
+ }
m_stdErrSpec.matchAgainst(stderr2);
}
}
return result;
}
+ protected void checkVersion(String classname, int major, int minor) {
+ JavaClass jc;
+ try {
+ jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException("Cannot find class "+classname,e);
+ }
+ if (jc.getMajor() != major) {
+ fail("Expected major version to be " + major + " but was " + jc.getMajor());
+ }
+ if (jc.getMinor() != minor) {
+ fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
+ }
+ }
+
/*
* The rules for parsing a suite spec file. The Digester using bean properties to match attributes in the XML document to
* properties in the associated classes, so this simple implementation should be very easy to maintain and extend should you
* ******************************************************************/
package org.aspectj.testing;
+import org.aspectj.util.LangUtil;
+
/**
* Makes sure tests are running on the right level of JDK.
*
@Override
public void runTest(String title) {
- // Check we are on Java11
- String property = System.getProperty("java.version");
- if (!property.startsWith("11")) {
+ if (!LangUtil.is11VMOrGreater()) {
throw new IllegalStateException("These tests should be run on Java 11 or later");
}
super.runTest(title);
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2018 Contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.testing;
+
+import org.aspectj.util.LangUtil;
+
+/**
+ * Ensure sure tests are running on the right level of JDK.
+ *
+ * @author Andy Clement
+ */
+public abstract class XMLBasedAjcTestCaseForJava12OrLater extends XMLBasedAjcTestCase {
+
+ @Override
+ public void runTest(String title) {
+ if (!LangUtil.is12VMOrGreater()) {
+ throw new IllegalStateException("These tests should be run on Java 12 or later");
+ }
+ super.runTest(title);
+ }
+
+}
--- /dev/null
+public class Switch1 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> 0;
+ case G -> 1;
+ case B -> 2;
+ default -> 3;
+ };
+ return result;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+}
\ No newline at end of file
--- /dev/null
+public class Switch2 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> 0;
+ case G -> 1;
+ case B -> 2;
+ default -> 3;
+ };
+ return result;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+}
+
+aspect X {
+ int around(): call(* one(..)) {
+ return proceed()*2;
+ }
+}
\ No newline at end of file
--- /dev/null
+public class Switch3 {
+ public static void main(String[] argv) {
+ System.out.println(one(Color.R));
+ System.out.println(one(Color.G));
+ System.out.println(one(Color.B));
+ System.out.println(one(Color.Y));
+ }
+
+ public static int one(Color color) {
+ int result = switch(color) {
+ case R -> foo(0);
+ case G -> foo(1);
+ case B -> foo(2);
+ default -> foo(3);
+ };
+ return result;
+ }
+
+ public static final int foo(int i) {
+ return i+1;
+ }
+}
+
+enum Color {
+ R, G, B, Y;
+}
+
+aspect X {
+ int around(): call(* foo(..)) {
+ return proceed()*3;
+ }
+}
\ No newline at end of file
<target name="compile:javac">
<!-- compile only javac compilable stuff, exclude the one that needs other dependencies -->
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}" classpathref="aj.path"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}" classpathref="aj.path"
srcdir="${basedir}"
includes="ataspectj/*"
excludes="ataspectj/UnweavableTest.java"
<target name="ltw.Aspect2MainTest">
<!-- javac Aspect2 -->
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}" classpathref="aj.path"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}" classpathref="aj.path"
srcdir="${basedir}"
includes="ataspectj/ltwreweavable/Aspect2.java"
debug="true">
</target>
<target name="ltw.Unweavable">
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}"
srcdir="${basedir}"
includes="ataspectj/UnweavableTest.java, ataspectj/TestHelper.java"
debug="true">
<target name="ltw.Decp2">
<!-- javac compile the 2nd aspect -->
- <javac source="1.6" target="1.6" destdir="${aj.sandbox}"
+ <javac source="1.7" target="1.7" destdir="${aj.sandbox}"
srcdir="${basedir}"
includes="ataspectj/DeclareParentsImplementsReweavableTestAspect.java"
debug="true">
*******************************************************************************/
package org.aspectj.systemtest.ajc160;
-import java.io.File;
-
-import junit.framework.Test;
-
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.Code;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import junit.framework.Test;
+
/*
* Some very trivial tests that help verify things are OK.
* Followed by some Java6 specific checks to ensure the class files are well formed.
return false;
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// Check the stackmap stuff is removed when a method gets woven (for now...)
// public void testStackMapAttributesDeletedInWovenCode() {
// fail("Not implemented");
return false;
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// Check the stackmap stuff is removed when a method gets woven (for now...)
// public void testStackMapAttributesDeletedInWovenCode() {
// fail("Not implemented");
*******************************************************************************/
package org.aspectj.systemtest.ajc190;
-import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
import junit.framework.Test;
// return false;
// }
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// Check the stackmap stuff is removed when a method gets woven (for now...)
// public void testStackMapAttributesDeletedInWovenCode() {
// fail("Not implemented");
*******************************************************************************/
package org.aspectj.systemtest.ajc191;
-import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
import junit.framework.Test;
checkVersion("A", 49, 0);
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
-
// ///////////////////////////////////////
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(SanityTestsJava10.class);
checkVersion("A", 49, 0);
}
- private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
- JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
- if (jc.getMajor() != major) {
- fail("Expected major version to be " + major + " but was " + jc.getMajor());
- }
- if (jc.getMinor() != minor) {
- fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
- }
- }
// ///////////////////////////////////////
public static Test suite() {
/*******************************************************************************
- * Copyright (c) 2018 Contributors
+ * Copyright (c) 2018-2019 Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.3 tests");
- // $JUnit-BEGIN$
suite.addTest(Ajc193Tests.suite());
- // $JUnit-END$
+ suite.addTest(Java12Tests.suite());
return suite;
}
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2019 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc193;
+
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava12OrLater;
+
+import junit.framework.Test;
+
+/**
+ * @author Andy Clement
+ */
+public class Java12Tests extends XMLBasedAjcTestCaseForJava12OrLater {
+
+ public void testSwitch1() {
+ runTest("switch 1");
+ checkVersion("Switch1", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testSwitch2() {
+ runTest("switch 2");
+ checkVersion("Switch2", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testSwitch3() {
+ runTest("switch 3");
+ checkVersion("Switch3", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ }
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Java12Tests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc193.xml");
+ }
+
+}
<!-- this fails because if you start working with modules you commit to the modules story and classpath
becomes irrelevant -->
<compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="module.jar" classpath="foo.jar">
- <message kind="error" text="The import ddd cannot be resolved"/>
+ <message kind="error" text="The type ddd.D is not accessible"/>
<message kind="error" text="D cannot be resolved"/>
+ <!--
+ <message kind="error" text="The import ddd cannot be resolved"/>
+ <message kind="error" text="package ddd is not visible"/>
+ -->
</compile>
</ajc-test>
</run>
</ajc-test>
+ <ajc-test dir="features193" vm="12" title="switch 1">
+ <compile files="Switch1.java" options="-12 --enable-preview">
+ </compile>
+ <run class="Switch1" vmargs="--enable-preview">
+ <stdout>
+ <line text="0"/>
+ <line text="1"/>
+ <line text="2"/>
+ <line text="3"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features193" vm="12" title="switch 2">
+ <compile files="Switch2.java" options="--enable-preview -source 12">
+ </compile>
+ <run class="Switch2" vmargs="--enable-preview">
+ <stdout>
+ <line text="0"/>
+ <line text="2"/>
+ <line text="4"/>
+ <line text="6"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features193" vm="12" title="switch 3">
+ <compile files="Switch3.java" options="--enable-preview -source 12">
+ </compile>
+ <run class="Switch3" vmargs="--enable-preview">
+ <stdout>
+ <line text="3"/>
+ <line text="6"/>
+ <line text="9"/>
+ <line text="12"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<ajc-test dir="bugs193/543657" vm="1.8" title="overweaving decm - reweaving">
<compile files="MoodIndicator.java,Code1.java" options="-showWeaveInfo -1.8" outjar="one.jar">
<message kind="weave" text="Mixing interface 'MoodIndicator$Moody' (MoodIndicator.java) into type 'Code1' (Code1.java)"/>
return 11 <= vmVersion;
}
+ public static boolean is12VMOrGreater() {
+ return 12 <= vmVersion;
+ }
+
/**
* Shorthand for "if null, throw IllegalArgumentException"
*
import junit.framework.TestCase;
+import java.util.Arrays;
+
import org.aspectj.apache.bcel.Repository;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Signature;
import org.aspectj.util.GenericSignature;
import org.aspectj.util.GenericSignatureParser;
+import org.aspectj.util.LangUtil;
import org.aspectj.util.GenericSignature.ClassSignature;
import org.aspectj.weaver.UnresolvedType;
UnresolvedType superclass = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superclassSignature,
cSig.formalTypeParameters, world);
assertEquals("Ljava/lang/Object;", superclass.getSignature());
- assertEquals("2 superinterfaces", 2, cSig.superInterfaceSignatures.length);
- UnresolvedType comparable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[0],
+ System.out.println(Arrays.toString(cSig.superInterfaceSignatures));
+ if (LangUtil.is12VMOrGreater()) {
+ // [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;
+ UnresolvedType comparable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[idx++],
cSig.formalTypeParameters, world);
assertEquals("Pjava/lang/Comparable<TE;>;", comparable.getSignature());
UnresolvedType serializable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
- cSig.superInterfaceSignatures[1], cSig.formalTypeParameters, world);
+ cSig.superInterfaceSignatures[idx++], cSig.formalTypeParameters, world);
assertEquals("Ljava/io/Serializable;", serializable.getSignature());
}