diff options
50 files changed, 575 insertions, 202 deletions
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b4d9fe615..546d4286b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - java: [ 8, 11, 16 ] + java: [ 11, 14, 17 ] steps: - uses: actions/checkout@v2 diff --git a/docs/dist/doc/README-197.html b/docs/dist/doc/README-197.html index 734882597..0b39b40cb 100644 --- a/docs/dist/doc/README-197.html +++ b/docs/dist/doc/README-197.html @@ -26,7 +26,7 @@ <p> Please note that going forward Bugzilla for issue management is deprecated and new issues should be filed as <a href="https://github.com/eclipse/org.aspectj/issues/new">GitHub issues</a>. - The list of issues addressed for 1.9.7 can be found + The list of issues addressed for 1.9.7 can be found <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.7">here for Bugzilla</a> and <a href="https://github.com/eclipse/org.aspectj/issues?q=is%3Aissue+is%3Aclosed++milestone%3A1.9.7">here for GitHub issues</a>. </p> @@ -35,7 +35,7 @@ <p> AspectJ 1.9.7 supports <a href="https://openjdk.java.net/projects/jdk/15/">Java 15</a> & - <a href="https://openjdk.java.net/projects/jdk/16/">Java 16</a> and their respective final and review features: + <a href="https://openjdk.java.net/projects/jdk/16/">Java 16</a> and their respective final and preview features: </p> <ul> <li>text blocks (final 15)</li> diff --git a/docs/dist/doc/README-198.html b/docs/dist/doc/README-198.html new file mode 100644 index 000000000..825d872ef --- /dev/null +++ b/docs/dist/doc/README-198.html @@ -0,0 +1,105 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + +<head> +<title>AspectJ 1.9.8 Readme</title> +<style type="text/css"> + <!-- + P { margin-left: 20px; } + PRE { margin-left: 20px; } + LI { margin-left: 20px; } + H4 { margin-left: 20px; } + H3 { margin-left: 10px; } + --> +</style> +</head> + +<body> +<div align="right"><small>© Copyright 2021 Contributors. All rights reserved.</small></div> + +<h1>AspectJ 1.9.8</h1> + +<p> + Please note that Bugzilla for issue management is deprecated and new issues should be filed as + <a href="https://github.com/eclipse/org.aspectj/issues/new">GitHub issues</a>. + The list of issues addressed for 1.9.8 can be found + <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.8">here for Bugzilla</a> + and <a href="https://github.com/eclipse/org.aspectj/issues?q=is%3Aissue+is%3Aclosed++milestone%3A1.9.8">here for GitHub issues</a>. +</p> + +<h2>New features</h2> + +<p> + AspectJ 1.9.8 supports <a href="https://openjdk.java.net/projects/jdk/17/">Java 17</a> and its final and preview + features, such as: +</p> +<ul> + <li>sealed classes (final in Java 17, previews in Java 15, 16 and AspectJ 1.9.7)</li> + <li>pattern matching for switch</li> +</ul> +<p> + For features marked as preview on a given JDK, you need to compile with <tt>ajc --enable-preview</tt> and run with + <tt>java --enable-preview</tt> on that JDK. +</p> +<p> + Please note that you cannot run code compiled with preview features on any other JDK than the one used for + compilation. For example, records compiled with preview on JDK 15 cannot be used on JDK 16 without recompilation. This + is a JVM limitation unrelated to AspectJ. Also, e.g. sealed classes are preview-1 on JDK 15 and preview-2 on JDK 16. + You still need to recompile, no matter what. +</p> +<p> + Furthermore, the <tt>--release N</tt> compiler option for correct cross-compilation to previous JDK bytecode + API + versions is now supported by AJC. Previously, the option existed (inherited by ECJ) but did not work correctly. +</p> + +<h3>Code examples</h3> + +<p> + You can find some sample code in the AspectJ test suite under the respective AspectJ version in which the features + were first supported (possibly as JVM preview features): +</p> +<ul> + <li> + <a href="https://github.com/eclipse/org.aspectj/tree/master/tests/features198/compiler_release"> + Cross-compilation to legacy JDK + </a>: + An example class which only works correctly on JDK 8 when compiled with <tt>--release 8</tt> due to API changes in + the JDK. Simply <tt>-source 8 -target 8</tt> would not be enough in this case.</li> + <li> + <a href="https://github.com/eclipse/org.aspectj/tree/master/tests/features198/java17"> + Pattern matching for switch + </a> + </li> +</ul> + +<h2>Using LTW on Java 16+</h2> + +<p> + Please note that if you want to use load-time weaving on Java 16+, the weaving agent collides with + <a href="https://openjdk.java.net/jeps/396">JEP 396 (Strongly Encapsulate JDK Internals by Default)</a>. Therefore, + you need to set the JVM parameter <tt>--add-opens java.base/java.lang=ALL-UNNAMED</tt> in order to enable aspect + weaving. This is due to the fact that the weaver uses internal APIs for which we have not found an adequate + replacement yet when defining classes in different classloaders. +</p> + +<h2>Other changes and bug fixes</h2> + +<ul> + <li> + The AspectJ compiler no longer works on JDK 8-10. The minimum compile-time requirement for AspectJ is JDK 11 due + to upstream changes in the Eclipse Java Compiler (subset of JDT Core), which AspectJ is a fork of. You can still + compile to legacy target versions as low as Java 1.3, but the compiler itself (and probably also the load-time + weaver) needs JDK 11. + </li> + <li>Document build profiles and properties in <i>docs/developer/BUILD.md</i></li> + <li>Add a guide for setting up an AspectJ development environment in <i>docs/developer/IDE.md</i></li> + <li>Allowed JAR saving if <tt>-proceedOnError</tt> is specified</li> +</ul> + +<p> + Available: 1.9.8 available DD-MMM-2021 +</p> + +</body> + +</html> diff --git a/docs/dist/doc/index.html b/docs/dist/doc/index.html index 94e13fe96..36bba4821 100644 --- a/docs/dist/doc/index.html +++ b/docs/dist/doc/index.html @@ -1,18 +1,18 @@ -<html> +<html> <head> <title>AspectJ Documentation and Resources</title> </head> -<body> +<body> <a name="top"></a> <h1>AspectJ Documentation and Resources</h1> -<p/> +<p/> AspectJ <sup><small>tm</small></sup> - is a seamless aspect-oriented extension to + is a seamless aspect-oriented extension to Java<sup><small>tm</small></sup>. - The compiler and development tools are available under + The compiler and development tools are available under an open-source license, require Java 1.3 to run, and produce - code that runs in JDK 1.1 and later VM's. + code that runs in JDK 1.1 and later VM's. For the latest materials, see <a href="http://eclipse.org/aspectj">http://eclipse.org/aspectj</a>. Not all of these materials have been updated for AspectJ 5. @@ -21,28 +21,28 @@ <table> <tr><td><u>Section</u></td><td><u>Contents</u></td></tr> <tr><td><a href="#documentation">docs</a></td><td> - <a href="faq.html">FAQ</a>, + <a href="faq.html">FAQ</a>, <a href="quick5.pdf">Quick Reference (AspectJ 5)</a>, - <a href="quick.pdf">Quick Reference (1.2.1)</a>, + <a href="quick.pdf">Quick Reference (1.2.1)</a>, <a href="adk15notebook/index.html">AspectJ 5 Developer's Notebook</a>, - <a href="progguide/index.html">programming</a>, - <a href="devguide/index.html">development</a> and - <a href="pdguide/index.html">problem diagnosis</a> guides, + <a href="progguide/index.html">programming</a>, + <a href="devguide/index.html">development</a> and + <a href="pdguide/index.html">problem diagnosis</a> guides, <a href="runtime-api/index.html">API</a> and <a href="examples/">example code</a>. </td></tr> - <tr><td><a href="#distributions">distributions</a></td><td> + <tr><td><a href="#distributions">distributions</a></td><td> <a href="http://eclipse.org/aspectj">AspectJ</a>; - development environment support for - <a href="http://eclipse.org/ajdt">Eclipse</a> + development environment support for + <a href="http://eclipse.org/ajdt">Eclipse</a> and - <a href="https://jdeveloperaop.dev.java.net/">JDeveloper</a>. + <a href="https://jdeveloperaop.dev.java.net/">JDeveloper</a>. </td></tr> <tr><td><a href="#resources">resources</a></td><td> <a href="http://aosd.net">aosd.net</a>; <a href="http://eclipse.org/aspectj">AspectJ project</a> the bug <a href="http://bugs.eclipse.org/bugs">db</a>, - and mailing lists for + and mailing lists for <a href="mailto:aspectj-users@eclipse.org">users</a> and <a href="mailto:aspectj-dev@eclipse.org">developers</a>. </td></tr> @@ -54,37 +54,37 @@ <a name="documentation"></a> <h3>AspectJ documentation</h3> <table border="1"> -<tr> <th>Documentation</th><th>Description</th> +<tr> <th>Documentation</th><th>Description</th> </tr> <tr> <td><a href="quick5.pdf"> AspectJ 5 Quick Reference</a> </td> - <td>This is a four-page quick reference for the AspectJ 5 language. + <td>This is a four-page quick reference for the AspectJ 5 language. </td> </tr> <tr> <td><a href="quick.pdf"> AspectJ Quick Reference</a> </td> - <td>This is a two-page quick reference for the AspectJ language. + <td>This is a two-page quick reference for the AspectJ language. </td> </tr> <tr> <td><a href="adk15notebook/index.html">AspectJ 5 Developer's Notebook</a> (printable <a href="adk15notebook/printable.html">html</a>) </td> <td>This describes the changes to the AspectJ language and tools introduced - in the AspectJ 5 Development Kit. These changes are additive, and are not yet + in the AspectJ 5 Development Kit. These changes are additive, and are not yet reflected in the programming guide or quick reference.</td> </tr> <tr> <td><a href="progguide/index.html">Programming Guide</a> (printable <a href="progguide/printable.html">html</a>) </td> - <td>This introduces AOP and the AspectJ language. + <td>This introduces AOP and the AspectJ language. <a href="progguide/starting.html">Getting Started</a> describes basic semantics, and shows development- and production-time applications. <a href="progguide/language.html">The AspectJ Language</a> - describes join points, pointcuts, advice, and introduction, all features new to AOP. - <a href="progguide/examples.html">Examples</a> walks you through the + describes join points, pointcuts, advice, and introduction, all features new to AOP. + <a href="progguide/examples.html">Examples</a> walks you through the examples included with the documentation, and there are two short chapters on useful <a href="progguide/idioms.html">Idioms</a> and a few <a href="progguide/pitfalls.html">Pitfalls</a> @@ -92,7 +92,7 @@ the <a href="progguide/quick.html">Quick Reference</a> summarizes AspectJ syntax, the <a href="progguide/semantics.html">Language Semantics</a> - best describes AspectJ usage, and + best describes AspectJ usage, and <a href="progguide/implementation.html">Implementation Notes</a> describes how the current version is limited to code the compiler controls.</td> @@ -100,13 +100,13 @@ <tr> <td><a href="devguide/index.html">Development Environment Guide</a> <br/> - + (printable <a href="devguide/printable.html">html</a>) </td> - <td>This is a guide to + <td>This is a guide to <a href="devguide/ajc-ref.html">ajc</a>, the command-line compiler; <a href="devguide/ajbrowser.html">ajbrowser</a>, the stand-alone - GUI for compiling and viewing crosscutting structure; + GUI for compiling and viewing crosscutting structure; and the <a href="devguide/antTasks.html">Ant tasks</a> for building AspectJ programs. </td> @@ -114,10 +114,10 @@ <tr> <td><a href="pdguide/index.html">Problem Diagnosis Guide</a> <br/> - + (printable <a href="pdguide/printable.html">html</a>) </td> - <td>This has a guide to + <td>This has a guide to the various features available such as messages and trace to help you both solve problems with you own programs and report bugs to the AspectJ team. </td> @@ -137,7 +137,8 @@ <tr> <td>README's </td> - <td>Changes and porting guide for AspectJ + <td>Changes and porting guide for AspectJ + <a href="README-198.html">1.9.8</a>, <a href="README-197.html">1.9.7</a>, <a href="README-196.html">1.9.6</a>, <a href="README-195.html">1.9.5</a>, @@ -196,7 +197,7 @@ <tr> <td><a href="examples/">Examples</a> </td> <td>AspectJ code to demonstrate some language features and implement - JavaBean properties, the Observer pattern, a tracing library, + JavaBean properties, the Observer pattern, a tracing library, and a game application where aspects handle display updating. </td> </tr> @@ -215,8 +216,8 @@ </tr> <tr> <td><a href="http://eclipse.org/aspectj">AspectJ</a> source code </td> - <td>Source code for AspectJ is available - under the open-source + <td>Source code for AspectJ is available + under the open-source <a href="https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt">Eclipse Public License v 2.0</a> license from the Git repositories for the AspectJ project. See the @@ -250,9 +251,9 @@ <a name="resources"></a> <h3>Other AspectJ resources</h3> <table border="1"> -<tr> <th>Resources</th><th>Description</th> +<tr> <th>Resources</th><th>Description</th> </tr> -<tr> <td>Mail lists +<tr> <td>Mail lists </td> <td> AspectJ users discuss tips and @@ -262,14 +263,14 @@ AspectJ developers discuss issues with developing the AspectJ tools on <a href="mailto:aspectj-dev@eclipse.org"> - aspectj-dev@eclipse.org</a>. + aspectj-dev@eclipse.org</a>. To get occasional emails about AspectJ releases - and relevant events, subscribe to + and relevant events, subscribe to <tt>aspectj-announce@eclipse.org</tt>. - To view list archives or subscribe to the list, go to + To view list archives or subscribe to the list, go to <a href="http://eclipse.org/aspectj"> the AspectJ home page</a>. - To find archived emails, use the Eclipse site + To find archived emails, use the Eclipse site <a href="http://www.eclipse.org/search/search.cgi">search page</a>. </td></tr> <tr> <td><a href="http://bugs.eclipse.org/bugs">Bug database</a> @@ -288,15 +289,15 @@ Bugs all users should know about are <a href="http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&keywords=info"> flagged with the "info" keyword</a>. - See the + See the <a href="faq.html#q:ajcbugs"> - FAQ entry</a> for instructions on submitting compiler bugs. + FAQ entry</a> for instructions on submitting compiler bugs. </td> </tr> <tr> <td> <a href="http://aosd.net">http://aosd.net</a> - the AOSD web site </td> <td>This site has discussion and announcements related to - aspect-oriented software development (AOSD) in general. + aspect-oriented software development (AOSD) in general. Use <a href="mailto:announce@aosd.net">announce@aosd.net</a> to get and publish notices about AOSD workshops, conferences, and technology releases. @@ -309,39 +310,39 @@ <a name="paths"></a> <h3>Suggested paths for those new to AspectJ</h3> <p/> - To learn the AspectJ language, read the + To learn the AspectJ language, read the <a href="progguide/index.html">Programming Guide</a>, keeping the <a href="progguide/semantics.html">Semantics appendix</a> nearby as the best reference for AspectJ usage. Focus initially on the join point model and pointcuts, concepts AOP adds to OOP. - To read about how the <a href="examples/">examples</a> work, + To read about how the <a href="examples/">examples</a> work, see the <a href="progguide/examples.html">Examples </a> section in the <a href="progguide/index.html">Programming Guide</a>. - View and navigate the crosscutting structure using + View and navigate the crosscutting structure using <a href="http://eclipse.org/ajdt">AJDT</a>; if you can't use Eclipse, try the <code>ajbrowser</code> structure viewer, as described in the <a href="devguide/ajbrowser.html">AspectJ Browser</a> section of the <a href="devguide/index.html">Development Environment Guide</a>. <p/> - To start using AspectJ with your own code, + To start using AspectJ with your own code, modify the example aspects to apply to your classes. As you learn, - use the compiler's <code>-Xlint</code> flags to catch some common - mistakes. (Understand that the + use the compiler's <code>-Xlint</code> flags to catch some common + mistakes. (Understand that the <a href="progguide/implementation.html">current implementation</a> is limited to code the compiler controls.) <p> - To plan how to adopt AspectJ into a project, read the + To plan how to adopt AspectJ into a project, read the <a href="progguide/index.html">Programming Guide</a> - on development- and production-time aspects - and the <a href="faq.html">FAQ</a> entries for + on development- and production-time aspects + and the <a href="faq.html">FAQ</a> entries for <a href="faq.html#q:startUsingAJ">How should I start using AspectJ?</a>, <a href="faq.html#adoption">Deciding to adopt AspectJ</a>, the Development tools sections (<a href="faq.html#q:integrateWithDevTools">one</a>, - <a href="faq.html#devtools">two</a>, - <a href="faq.html#ltw">Load-time weaving</a> + <a href="faq.html#devtools">two</a>, + <a href="faq.html#ltw">Load-time weaving</a> ), and <a href="faq.html#q:opensource">AspectJ as open-source</a>. </p> diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java index 43f98336d..47be96344 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java @@ -61,6 +61,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchExpression; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SwitchStatement; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThisReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ThrowStatement; @@ -617,6 +618,8 @@ public class CommonPrinter { return output; } else if (statement instanceof LocalDeclaration) { return printLocalDeclaration((LocalDeclaration) statement, indent); + } else if (statement instanceof SwitchExpression) { + return printSwitchExpression((SwitchExpression) statement, indent); } else if (statement instanceof SwitchStatement) { return printSwitchStatement((SwitchStatement) statement, indent); } else if (statement instanceof CaseStatement) { @@ -754,22 +757,44 @@ public class CommonPrinter { } private StringBuilder printBreakStatement(BreakStatement statement, int indent) { - printIndent(indent).append("break "); //$NON-NLS-1$ + printIndent(indent).append("break"); //$NON-NLS-1$ if (statement.label != null) { - output.append(statement.label); + output.append(' ').append(statement.label); } return output.append(';'); } private StringBuilder printCaseStatement(CaseStatement statement, int indent) { printIndent(indent); - if (statement.constantExpression == null) { - output.append("default : "); //$NON-NLS-1$ + if (statement.constantExpressions == null) { + output.append("default "); //$NON-NLS-1$ + output.append(statement.isExpr ? "->" : ":"); //$NON-NLS-1$ //$NON-NLS-2$ } else { output.append("case "); //$NON-NLS-1$ - printExpression(statement.constantExpression).append(" : "); //$NON-NLS-1$ + for (int i = 0, l = statement.constantExpressions.length; i < l; ++i) { + printExpression(statement.constantExpressions[i]); + if (i < l -1) output.append(','); + } + output.append(statement.isExpr ? " ->" : " :"); //$NON-NLS-1$ //$NON-NLS-2$ } - return output;// output.append(';'); + return output; + } + + private StringBuilder printSwitchExpression(SwitchExpression statement, int indent) { + printIndent(indent).append("switch ("); //$NON-NLS-1$ + printExpression(statement.expression).append(") {"); //$NON-NLS-1$ + if (statement.statements != null) { + for (int i = 0; i < statement.statements.length; i++) { + output.append('\n'); + if (statement.statements[i] instanceof CaseStatement) { + printCaseStatement((CaseStatement) statement.statements[i], indent); + } else { + printStatement(statement.statements[i], indent + 2); + } + } + } + output.append("\n"); //$NON-NLS-1$ + return printIndent(indent).append('}'); } private StringBuilder printSwitchStatement(SwitchStatement statement, int indent) { @@ -779,7 +804,7 @@ public class CommonPrinter { for (int i = 0; i < statement.statements.length; i++) { output.append('\n'); if (statement.statements[i] instanceof CaseStatement) { - printStatement(statement.statements[i], indent); + printCaseStatement((CaseStatement) statement.statements[i], indent); } else { printStatement(statement.statements[i], indent + 2); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java index 5a2038f75..16182762c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java @@ -192,7 +192,8 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration { } InterTypeScope newParent = new InterTypeScope(scope, onTypeBinding); - pre.scope.parent = newParent; + // Use setter in order to also update member 'compilationUnitScope' + pre.scope.setParent(newParent); pre.resolveStatements(); // newParent); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java index ff765515a..75e0a20e3 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeDeclaration.java @@ -146,7 +146,8 @@ public abstract class InterTypeDeclaration extends AjMethodDeclaration { if (!scopeSetup) { interTypeScope = new InterTypeScope(upperScope, onTypeBinding,typeVariableAliases); - scope.parent = interTypeScope; + // Use setter in order to also update member 'compilationUnitScope' + scope.setParent(interTypeScope); this.scope.isStatic = Modifier.isStatic(declaredModifiers); scopeSetup = true; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IntertypeMemberClassDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IntertypeMemberClassDeclaration.java index fe95dd53e..9fa9456aa 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IntertypeMemberClassDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/IntertypeMemberClassDeclaration.java @@ -203,7 +203,8 @@ public class IntertypeMemberClassDeclaration extends TypeDeclaration { // this is the original version in case tricking the JDT causes grief (if you reinstate this variant, you // will need to change the expected messages output for some of the generic ITD tests) // scope.isStatic = Modifier.isStatic(declaredModifiers); - scope.parent = interTypeScope; + // Use setter in order to also update member 'compilationUnitScope' + scope.setParent(interTypeScope); } scopeSetup = true; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AbstractBooleanTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AbstractBooleanTypePattern.java index 4163210cb..045e7fd2d 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AbstractBooleanTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AbstractBooleanTypePattern.java @@ -9,23 +9,23 @@ *******************************************************************/ package org.aspectj.org.eclipse.jdt.core.dom; -public abstract class AbstractBooleanTypePattern extends TypePattern { +public abstract class AbstractBooleanTypePattern extends AbstractTypePattern { - private TypePattern left; - private TypePattern right; + private AbstractTypePattern left; + private AbstractTypePattern right; - AbstractBooleanTypePattern(AST ast, TypePattern left, TypePattern right, - String booleanOperator) { + AbstractBooleanTypePattern(AST ast, AbstractTypePattern left, AbstractTypePattern right, + String booleanOperator) { super(ast, booleanOperator); this.left = left; this.right = right; } - public TypePattern getLeft() { + public AbstractTypePattern getLeft() { return left; } - public TypePattern getRight() { + public AbstractTypePattern getRight() { return right; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/TypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AbstractTypePattern.java index d296dbef3..cff152fa7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/TypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AbstractTypePattern.java @@ -14,17 +14,17 @@ package org.aspectj.org.eclipse.jdt.core.dom; /** * abstract TypePattern DOM AST node. */ -public abstract class TypePattern extends PatternNode { +public abstract class AbstractTypePattern extends PatternNode { private String typePatternExpression; public static final String EMPTY_EXPRESSION = ""; - TypePattern(AST ast) { + AbstractTypePattern(AST ast) { super(ast); } - TypePattern(AST ast, String typePatternExpression) { + AbstractTypePattern(AST ast, String typePatternExpression) { super(ast); this.typePatternExpression = typePatternExpression; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java index 02ca4544f..64bb9cefe 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java @@ -659,9 +659,9 @@ public class AjASTConverter extends ASTConverter { DeclareParents dp = (DeclareParents) declare; declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration(this.ast, dp.isExtends()); org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(dp.getChild()); - if (pNode instanceof org.aspectj.org.eclipse.jdt.core.dom.TypePattern) { + if (pNode instanceof AbstractTypePattern) { ((DeclareParentsDeclaration) declareDeclaration) - .setChildTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern) pNode); + .setChildTypePattern((AbstractTypePattern) pNode); } TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns(); List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns(); @@ -681,9 +681,9 @@ public class AjASTConverter extends ASTConverter { DeclareSoft ds = (DeclareSoft) declare; ((DeclareSoftDeclaration) declareDeclaration).setPointcut(convert(ds.getPointcut())); org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(ds.getException()); - if (pNode instanceof org.aspectj.org.eclipse.jdt.core.dom.TypePattern) { + if (pNode instanceof AbstractTypePattern) { ((DeclareSoftDeclaration) declareDeclaration) - .setTypePattern((org.aspectj.org.eclipse.jdt.core.dom.TypePattern) pNode); + .setTypePattern((AbstractTypePattern) pNode); } } @@ -866,12 +866,12 @@ public class AjASTConverter extends ASTConverter { } - public org.aspectj.org.eclipse.jdt.core.dom.TypePattern convert( + public AbstractTypePattern convert( TypePattern weaverNode) { // First check if the node is a Java type (WildType, ExactType, // BindingType) - org.aspectj.org.eclipse.jdt.core.dom.TypePattern domNode = createIdentifierTypePattern(weaverNode); + AbstractTypePattern domNode = createIdentifierTypePattern(weaverNode); if (domNode == null) { if (weaverNode instanceof org.aspectj.weaver.patterns.EllipsisTypePattern) { @@ -907,7 +907,7 @@ public class AjASTConverter extends ASTConverter { // nottypepattern is 1, NOT 0. TypePattern negatedTypePattern = ((org.aspectj.weaver.patterns.NotTypePattern) weaverNode) .getNegatedPattern(); - org.aspectj.org.eclipse.jdt.core.dom.TypePattern negatedDomTypePattern = convert(negatedTypePattern); + AbstractTypePattern negatedDomTypePattern = convert(negatedTypePattern); domNode = new org.aspectj.org.eclipse.jdt.core.dom.NotTypePattern( ast, negatedDomTypePattern); } else if (weaverNode instanceof org.aspectj.weaver.patterns.TypeCategoryTypePattern) { @@ -945,11 +945,11 @@ public class AjASTConverter extends ASTConverter { * to convert to a DOM equivalent * @return DOM node or null if it was not created */ - protected org.aspectj.org.eclipse.jdt.core.dom.TypePattern createIdentifierTypePattern( + protected AbstractTypePattern createIdentifierTypePattern( TypePattern weaverTypePattern) { String typeExpression = weaverTypePattern.toString(); - org.aspectj.org.eclipse.jdt.core.dom.TypePattern domTypePattern = null; + AbstractTypePattern domTypePattern = null; if (weaverTypePattern instanceof org.aspectj.weaver.patterns.WildTypePattern) { // Use the expression for wild type patterns as a Name may not be // constructed diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java index 36f95a109..dd5511fc9 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java @@ -1661,7 +1661,7 @@ public class AjNaiveASTFlattener extends AjASTVisitor { } for (Iterator it = node.parentTypePatterns().iterator(); it.hasNext();) { - TypePattern typePat = (TypePattern) it.next(); + AbstractTypePattern typePat = (AbstractTypePattern) it.next(); typePat.accept(this); if(it.hasNext()){ this.buffer.append(", "); @@ -1711,7 +1711,7 @@ public class AjNaiveASTFlattener extends AjASTVisitor { this.buffer.append("declare precedence: "); for (Iterator it = node.typePatterns().iterator(); it.hasNext();) { - TypePattern typePat = (TypePattern) it.next(); + AbstractTypePattern typePat = (AbstractTypePattern) it.next(); typePat.accept(this); if(it.hasNext()){ this.buffer.append(", "); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AndTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AndTypePattern.java index 87d96868d..84ab558a7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AndTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AndTypePattern.java @@ -15,7 +15,7 @@ public class AndTypePattern extends AbstractBooleanTypePattern { public static final String AND_OPERATOR = "&&"; - AndTypePattern(AST ast, TypePattern left, TypePattern right) { + AndTypePattern(AST ast, AbstractTypePattern left, AbstractTypePattern right) { super(ast, left, right, AND_OPERATOR); } @@ -25,7 +25,7 @@ public class AndTypePattern extends AbstractBooleanTypePattern { ASTNode clone0(AST target) { AndTypePattern cloned = new AndTypePattern(target, - (TypePattern) getLeft().clone(target), (TypePattern) getRight() + (AbstractTypePattern) getLeft().clone(target), (AbstractTypePattern) getRight() .clone(target)); cloned.setSourceRange(getStartPosition(), getLength()); return cloned; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyTypePattern.java index b2355da3c..4d327e33d 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyTypePattern.java @@ -11,7 +11,7 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.List; -public class AnyTypePattern extends TypePattern { +public class AnyTypePattern extends AbstractTypePattern { public static final String ANYTYPE_DETAIL = "*"; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyWithAnnotationTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyWithAnnotationTypePattern.java index 678537df5..e9a8adcda 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyWithAnnotationTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AnyWithAnnotationTypePattern.java @@ -16,7 +16,7 @@ import java.util.List; * expression * */ -public class AnyWithAnnotationTypePattern extends TypePattern { +public class AnyWithAnnotationTypePattern extends AbstractTypePattern { AnyWithAnnotationTypePattern(AST ast, String annotationExpression) { // Is this correct? should the "*" be added diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java index 3443fb5a9..7ba035ad7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareParentsDeclaration.java @@ -27,13 +27,13 @@ public class DeclareParentsDeclaration extends DeclareDeclaration { internalJavadocPropertyFactory(DeclareParentsDeclaration.class); public static final ChildPropertyDescriptor CHILD_TYPE_PATTERN_PROPERTY = - new ChildPropertyDescriptor(DeclareParentsDeclaration.class, "childTypePattern", TypePattern.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + new ChildPropertyDescriptor(DeclareParentsDeclaration.class, "childTypePattern", AbstractTypePattern.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ public static final SimplePropertyDescriptor IS_EXTENDS_PROPERTY = new SimplePropertyDescriptor(DeclareParentsDeclaration.class, "isExtends", boolean.class, MANDATORY); //$NON-NLS-1$ public static final ChildListPropertyDescriptor PARENTS_TYPE_PATTERNS_LIST_PROPERTY = - new ChildListPropertyDescriptor(DeclareParentsDeclaration.class, "typePatternsList", TypePattern.class, NO_CYCLE_RISK); //$NON-NLS-1$ + new ChildListPropertyDescriptor(DeclareParentsDeclaration.class, "typePatternsList", AbstractTypePattern.class, NO_CYCLE_RISK); //$NON-NLS-1$ private static final List PROPERTY_DESCRIPTORS_2_0; private static final List PROPERTY_DESCRIPTORS_3_0; @@ -57,7 +57,7 @@ public class DeclareParentsDeclaration extends DeclareDeclaration { } private boolean isExtends; - private TypePattern childTypePattern; + private AbstractTypePattern childTypePattern; protected ASTNode.NodeList parentTypePatterns =new ASTNode.NodeList(PARENTS_TYPE_PATTERNS_LIST_PROPERTY); @@ -76,7 +76,7 @@ public class DeclareParentsDeclaration extends DeclareDeclaration { result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); result.setChildTypePattern( - (TypePattern) ASTNode.copySubtree(target, getChildTypePattern())); + (AbstractTypePattern) ASTNode.copySubtree(target, getChildTypePattern())); result.setExtends(isExtends()); result.parentTypePatterns().addAll( ASTNode.copySubtrees(target, parentTypePatterns())); @@ -172,7 +172,7 @@ public class DeclareParentsDeclaration extends DeclareDeclaration { if (get) { return getChildTypePattern(); } else { - setChildTypePattern((TypePattern) child); + setChildTypePattern((AbstractTypePattern) child); return null; } } @@ -218,11 +218,11 @@ public class DeclareParentsDeclaration extends DeclareDeclaration { } - public TypePattern getChildTypePattern(){ + public AbstractTypePattern getChildTypePattern(){ return childTypePattern; } - public void setChildTypePattern(TypePattern typePattern) { + public void setChildTypePattern(AbstractTypePattern typePattern) { if (typePattern == null) { throw new IllegalArgumentException(); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java index 1b50f431e..0b614a010 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclarePrecedenceDeclaration.java @@ -26,7 +26,7 @@ public class DeclarePrecedenceDeclaration extends DeclareDeclaration { internalJavadocPropertyFactory(DeclarePrecedenceDeclaration.class); public static final ChildListPropertyDescriptor TYPE_PATTERNS_LIST_PROPERTY = - new ChildListPropertyDescriptor(DeclarePrecedenceDeclaration.class, "parentTypePatterns", TypePattern.class, NO_CYCLE_RISK); //$NON-NLS-1$ + new ChildListPropertyDescriptor(DeclarePrecedenceDeclaration.class, "parentTypePatterns", AbstractTypePattern.class, NO_CYCLE_RISK); //$NON-NLS-1$ private static final List PROPERTY_DESCRIPTORS_2_0; private static final List PROPERTY_DESCRIPTORS_3_0; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java index ae760e84b..6c1256236 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DeclareSoftDeclaration.java @@ -26,7 +26,7 @@ public class DeclareSoftDeclaration extends DeclareDeclaration { internalJavadocPropertyFactory(DeclareSoftDeclaration.class); public static final ChildPropertyDescriptor TYPE_PATTERN_PROPERTY = - new ChildPropertyDescriptor(DeclareSoftDeclaration.class, "typePattern", TypePattern.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ + new ChildPropertyDescriptor(DeclareSoftDeclaration.class, "typePattern", AbstractTypePattern.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ public static final ChildPropertyDescriptor POINTCUT_PROPERTY = new ChildPropertyDescriptor(DeclareSoftDeclaration.class, "pointcut", PointcutDesignator.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ @@ -51,7 +51,7 @@ public class DeclareSoftDeclaration extends DeclareDeclaration { PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); } - private TypePattern typePattern; + private AbstractTypePattern typePattern; private PointcutDesignator pointcut; DeclareSoftDeclaration(AST ast) { @@ -64,7 +64,7 @@ public class DeclareSoftDeclaration extends DeclareDeclaration { result.setJavadoc( (Javadoc) ASTNode.copySubtree(target, getJavadoc())); result.setPointcut((PointcutDesignator)ASTNode.copySubtree(target,getPointcut())); - result.setTypePattern((TypePattern)ASTNode.copySubtree(target,getTypePattern())); + result.setTypePattern((AbstractTypePattern)ASTNode.copySubtree(target,getTypePattern())); return result; } @@ -166,7 +166,7 @@ public class DeclareSoftDeclaration extends DeclareDeclaration { if (get) { return getTypePattern(); } else { - setTypePattern((TypePattern) child); + setTypePattern((AbstractTypePattern) child); return null; } } @@ -174,11 +174,11 @@ public class DeclareSoftDeclaration extends DeclareDeclaration { return super.internalGetSetChildProperty(property, get, child); } - public TypePattern getTypePattern(){ + public AbstractTypePattern getTypePattern(){ return typePattern; } - public void setTypePattern(TypePattern typePattern) { + public void setTypePattern(AbstractTypePattern typePattern) { if (typePattern == null) { throw new IllegalArgumentException(); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java index eae206a46..005a3b2fd 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/DefaultTypePattern.java @@ -18,7 +18,7 @@ import java.util.List; * * This class is a stub and should be deleted when concrete subclasses exist for all the different TypePattern's in AspectJ. */ -public class DefaultTypePattern extends TypePattern { +public class DefaultTypePattern extends AbstractTypePattern { private String detail; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/EllipsisTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/EllipsisTypePattern.java index 6e6d78813..66e196167 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/EllipsisTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/EllipsisTypePattern.java @@ -11,7 +11,7 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.List; -public class EllipsisTypePattern extends TypePattern { +public class EllipsisTypePattern extends AbstractTypePattern { public static final String ELLIPSIS_DETAIL = ".."; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/HasMemberTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/HasMemberTypePattern.java index a98a1d5b8..a6b3266bc 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/HasMemberTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/HasMemberTypePattern.java @@ -14,7 +14,7 @@ import java.util.List; /** * */ -public class HasMemberTypePattern extends TypePattern { +public class HasMemberTypePattern extends AbstractTypePattern { private SignaturePattern signaturePattern; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/IdentifierTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/IdentifierTypePattern.java index 5c18f9450..7eea167b7 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/IdentifierTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/IdentifierTypePattern.java @@ -9,7 +9,7 @@ *******************************************************************/ package org.aspectj.org.eclipse.jdt.core.dom; -public abstract class IdentifierTypePattern extends TypePattern { +public abstract class IdentifierTypePattern extends AbstractTypePattern { private Type type; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NoTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NoTypePattern.java index 5fdec4e3a..28c31e1f9 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NoTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NoTypePattern.java @@ -11,7 +11,7 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.List; -public class NoTypePattern extends TypePattern { +public class NoTypePattern extends AbstractTypePattern { NoTypePattern(AST ast) { super(ast); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NotTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NotTypePattern.java index 882aadb02..e2231f6f0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NotTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/NotTypePattern.java @@ -11,9 +11,9 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.List; -public class NotTypePattern extends TypePattern { +public class NotTypePattern extends AbstractTypePattern { - private TypePattern negatedPattern; + private AbstractTypePattern negatedPattern; /** * The negated type pattern cannot be null @@ -23,7 +23,7 @@ public class NotTypePattern extends TypePattern { * @param negatedPattern * not null */ - NotTypePattern(AST ast, TypePattern negatedPattern) { + NotTypePattern(AST ast, AbstractTypePattern negatedPattern) { super(ast, "!"); this.negatedPattern = negatedPattern; } @@ -32,13 +32,13 @@ public class NotTypePattern extends TypePattern { return null; } - public TypePattern getNegatedTypePattern() { + public AbstractTypePattern getNegatedTypePattern() { return negatedPattern; } ASTNode clone0(AST target) { ASTNode node = new NotTypePattern(target, - (TypePattern) getNegatedTypePattern().clone(target)); + (AbstractTypePattern) getNegatedTypePattern().clone(target)); node.setSourceRange(getStartPosition(), getLength()); return node; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/OrTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/OrTypePattern.java index 68239ffcd..cd5320aa3 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/OrTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/OrTypePattern.java @@ -16,8 +16,8 @@ public class OrTypePattern extends AbstractBooleanTypePattern { public static final String OR_OPERATOR = "||"; OrTypePattern(AST ast, - org.aspectj.org.eclipse.jdt.core.dom.TypePattern left, - org.aspectj.org.eclipse.jdt.core.dom.TypePattern right) { + AbstractTypePattern left, + AbstractTypePattern right) { super(ast, left, right, OR_OPERATOR); } @@ -27,7 +27,7 @@ public class OrTypePattern extends AbstractBooleanTypePattern { ASTNode clone0(AST target) { OrTypePattern cloned = new OrTypePattern(target, - (TypePattern) getLeft().clone(target), (TypePattern) getRight() + (AbstractTypePattern) getLeft().clone(target), (AbstractTypePattern) getRight() .clone(target)); cloned.setSourceRange(getStartPosition(), getLength()); return cloned; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/TypeCategoryTypePattern.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/TypeCategoryTypePattern.java index d932caab3..4efae9133 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/TypeCategoryTypePattern.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/TypeCategoryTypePattern.java @@ -11,7 +11,7 @@ package org.aspectj.org.eclipse.jdt.core.dom; import java.util.List; -public class TypeCategoryTypePattern extends TypePattern { +public class TypeCategoryTypePattern extends AbstractTypePattern { private int typeCategory; diff --git a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties index 36e9597a5..a54d7ec22 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties @@ -1,5 +1,5 @@ compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler a00b62fa3572b0 (17Mar2021) - Java16 +compiler.version = Eclipse Compiler f8768b6899a6a2 (15Sep2021) - Java17 compiler.copyright = misc.version = {0} {1} - {2} {3} diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java index 65fca0097..c76a3f4d3 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjAST5Test.java @@ -14,6 +14,7 @@ package org.aspectj.tools.ajc; import java.util.List; import org.aspectj.org.eclipse.jdt.core.dom.AST; +import org.aspectj.org.eclipse.jdt.core.dom.AbstractTypePattern; import org.aspectj.org.eclipse.jdt.core.dom.AjAST; import org.aspectj.org.eclipse.jdt.core.dom.AjTypeDeclaration; import org.aspectj.org.eclipse.jdt.core.dom.AspectDeclaration; @@ -23,8 +24,6 @@ import org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration; import org.aspectj.org.eclipse.jdt.core.dom.DefaultTypePattern; import org.aspectj.org.eclipse.jdt.core.dom.PerTypeWithin; import org.aspectj.org.eclipse.jdt.core.dom.SimplePropertyDescriptor; -import org.aspectj.org.eclipse.jdt.core.dom.TypePattern; - public class AjAST5Test extends AjASTTestCase { @@ -113,7 +112,7 @@ public class AjAST5Test extends AjASTTestCase { "should not be null since it is a list", d.getStructuralProperty(element)); assertEquals("should only be able to put TypePattern's into the list", - TypePattern.class, element.getElementType()); + AbstractTypePattern.class, element.getElementType()); } else if (o instanceof SimplePropertyDescriptor) { SimplePropertyDescriptor element = (SimplePropertyDescriptor) o; assertNotNull("DeclareParentsDeclaration's " + element.getId() + " property" + diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java index 3c8d57a20..f946b96c5 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java @@ -19,6 +19,7 @@ import org.aspectj.org.eclipse.jdt.core.dom.AST; import org.aspectj.org.eclipse.jdt.core.dom.ASTNode; import org.aspectj.org.eclipse.jdt.core.dom.ASTParser; import org.aspectj.org.eclipse.jdt.core.dom.AbstractBooleanTypePattern; +import org.aspectj.org.eclipse.jdt.core.dom.AbstractTypePattern; import org.aspectj.org.eclipse.jdt.core.dom.AfterAdviceDeclaration; import org.aspectj.org.eclipse.jdt.core.dom.AfterReturningAdviceDeclaration; import org.aspectj.org.eclipse.jdt.core.dom.AfterThrowingAdviceDeclaration; @@ -73,7 +74,6 @@ import org.aspectj.org.eclipse.jdt.core.dom.StringLiteral; import org.aspectj.org.eclipse.jdt.core.dom.Type; import org.aspectj.org.eclipse.jdt.core.dom.TypeCategoryTypePattern; import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration; -import org.aspectj.org.eclipse.jdt.core.dom.TypePattern; /** * For each AspectJ ASTNode there is a test for: @@ -1439,7 +1439,7 @@ public class AjASTTest extends AjASTTestCase { ChildListPropertyDescriptor element = (ChildListPropertyDescriptor) o; assertNotNull("DeclareErrorDeclaration's " + element.getId() + " property" + "should not be null since it is a list", d.getStructuralProperty(element)); - assertEquals("should only be able to put TypePattern's into the list", TypePattern.class, element.getElementType()); + assertEquals("should only be able to put TypePattern's into the list", AbstractTypePattern.class, element.getElementType()); } else { fail("unknown PropertyDescriptor associated with DeclareErrorDeclaration: " + o); } @@ -1820,12 +1820,12 @@ public class AjASTTest extends AjASTTestCase { } - protected void assertExpression(String expectedExpression, TypePattern node) { + protected void assertExpression(String expectedExpression, AbstractTypePattern node) { assertTrue("Expected: " + expectedExpression + ". Actual: " + node.getTypePatternExpression(), node.getTypePatternExpression().equals(expectedExpression)); } - protected void assertNodeType(Class<?> expected, TypePattern node) { + protected void assertNodeType(Class<?> expected, AbstractTypePattern node) { assertTrue("Expected " + expected.toString() + ". Actual: " + node.getClass().toString(), node.getClass().equals(expected)); } } @@ -21,8 +21,8 @@ <maven.javadoc.skip>true</maven.javadoc.skip> <!-- Dependency versions --> - <jdt.core.version>1.9.7.M2</jdt.core.version> - <asm.version>9.1</asm.version> + <jdt.core.version>1.9.8.RC1</jdt.core.version> + <asm.version>9.2</asm.version> <lib.ant.version>1.6.3</lib.ant.version> <lib.ant.xerces.version>2.6.2</lib.ant.xerces.version> <lib.regexp.version>1.2</lib.regexp.version> @@ -81,6 +81,48 @@ <updatePolicy>never</updatePolicy> </releases> </repository> + <repository> + <id>ossrh-snapshots-classic</id> + <name>Sonatype OSSRH snapshots classic</name> + <url>https://oss.sonatype.org/content/repositories/snapshots</url> + <layout>default</layout> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + </repository> + <repository> + <id>ossrh-snapshots-new</id> + <name>Sonatype OSSRH snapshots new</name> + <url> https://s01.oss.sonatype.org/content/repositories/snapshots</url> + <layout>default</layout> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + </repository> + <repository> + <id>ossrh-snapshots</id> + <name>Sonatype OSSRH snapshots</name> + <url>https://oss.sonatype.org/content/repositories/snapshots</url> + <layout>default</layout> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + </repository> </repositories> <pluginRepositories> @@ -104,6 +146,20 @@ </releases> </pluginRepository> <pluginRepository> + <id>ossrh-snapshots</id> + <name>Sonatype OSSRH snapshots</name> + <url>https://oss.sonatype.org/content/repositories/snapshots</url> + <layout>default</layout> + <snapshots> + <enabled>true</enabled> + <updatePolicy>always</updatePolicy> + </snapshots> + <releases> + <enabled>true</enabled> + <updatePolicy>never</updatePolicy> + </releases> + </pluginRepository> + <pluginRepository> <id>aspectj-dev</id> <name>AspectJ artifacts on aspectj.dev</name> <url>https://aspectj.dev/maven</url> diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java index ece127651..70ebef477 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java @@ -17,11 +17,13 @@ public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { + // Activate this block after upgrading to JDT Core Java 15 throw new IllegalStateException( "These tests need a Java 14 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); + // Activate this block before upgrading to JDT Core Java 15 /* if (!LangUtil.is14VMOrGreater() || LangUtil.is15VMOrGreater()) { throw new IllegalStateException( diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java index 868ece1e3..5b64445a9 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java @@ -17,11 +17,13 @@ public abstract class XMLBasedAjcTestCaseForJava15Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { + // Activate this block after upgrading to JDT Core Java 16 throw new IllegalStateException( "These tests need a Java 15 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); + // Activate this block before upgrading to JDT Core Java 16 /* if (!LangUtil.is15VMOrGreater() || LangUtil.is16VMOrGreater()) { throw new IllegalStateException( diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java index 0a4e31b6f..115e01289 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java @@ -20,13 +20,13 @@ public abstract class XMLBasedAjcTestCaseForJava16Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { // Activate this block after upgrading to JDT Core Java 17 - /* throw new IllegalStateException( "These tests need a Java 16 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); - */ + // Activate this block before upgrading to JDT Core Java 17 + /* if (!LangUtil.is16VMOrGreater() || LangUtil.is17VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 16 only " + @@ -34,6 +34,7 @@ public abstract class XMLBasedAjcTestCaseForJava16Only extends XMLBasedAjcTestCa ); } super.setUp(); + */ } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java index e20ee7af7..0c351c69a 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java @@ -27,6 +27,7 @@ public abstract class XMLBasedAjcTestCaseForJava17Only extends XMLBasedAjcTestCa "This compiler does not support preview features of a previous version anymore." ); */ + // Activate this block before upgrading to JDT Core Java 18 if (!LangUtil.is17VMOrGreater() || LangUtil.is18VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 17 only " + diff --git a/tests/features198/java17/SwitchPatternAspect.aj b/tests/features198/java17/SwitchPatternAspect.aj new file mode 100644 index 000000000..bf19b8468 --- /dev/null +++ b/tests/features198/java17/SwitchPatternAspect.aj @@ -0,0 +1,68 @@ +import java.util.List; +import java.util.Locale; + +aspect SwitchPatternAspect { + Object around(Object o) : execution(* doSomethingWithObject(*)) && args(o) { + System.out.println(switch (o) { + case null -> "null"; + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format(Locale.ENGLISH, "double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }); + return proceed(o); + } + + before(Shape s) : execution(* doSomethingWithShape(*)) && args(s) { + System.out.println(switch (s) { + case Circle c && (c.calculateArea() > 100) -> "Large circle"; + case Circle c -> "Small circle"; + default -> "Non-circle"; + }); + } + + after(S s) : execution(* doSomethingWithSealedClass(*)) && args(s) { + System.out.println(switch (s) { + case A a -> "Sealed sub-class A"; + case B b -> "Sealed sub-class B"; + case C c -> "Sealed sub-record C"; + }); + } +} + +class Shape {} +class Rectangle extends Shape {} +class Circle extends Shape { + private final double radius; + public Circle(double radius) { this.radius = radius; } + double calculateArea() { return Math.PI * radius * radius; } +} + +sealed interface S permits A, B, C {} +final class A implements S {} +final class B implements S {} +record C(int i) implements S {} // Implicitly final + +class Application { + public static void main(String[] args) { + doSomethingWithObject(null); + doSomethingWithObject(123); + doSomethingWithObject(999L); + doSomethingWithObject(12.34); + doSomethingWithObject("foo"); + doSomethingWithObject(List.of(123, "foo", 999L, 12.34)); + + doSomethingWithShape(new Rectangle()); + doSomethingWithShape(new Circle(5)); + doSomethingWithShape(new Circle(6)); + + doSomethingWithSealedClass(new A()); + doSomethingWithSealedClass(new B()); + doSomethingWithSealedClass(new C(5)); + } + + public static Object doSomethingWithObject(Object o) { return o; } + public static void doSomethingWithSealedClass(S s) {} + public static void doSomethingWithShape(Shape s) {} +} diff --git a/tests/features198/java17/SwitchPatternError.java b/tests/features198/java17/SwitchPatternError.java new file mode 100644 index 000000000..745fd375c --- /dev/null +++ b/tests/features198/java17/SwitchPatternError.java @@ -0,0 +1,16 @@ +/** + * Inspired by examples in https://openjdk.java.net/jeps/406 + */ +public class SwitchPatternError { + static void error(Object o) { + switch(o) { + case CharSequence cs -> + System.out.println("A sequence of length " + cs.length()); + case String s -> // Error - pattern is dominated by previous pattern + System.out.println("A string: " + s); + default -> { + break; + } + } + } +} diff --git a/tests/features198/java17/SwitchPatternOK.java b/tests/features198/java17/SwitchPatternOK.java new file mode 100644 index 000000000..586dfe020 --- /dev/null +++ b/tests/features198/java17/SwitchPatternOK.java @@ -0,0 +1,64 @@ +import java.util.List; +import java.util.Locale; + +/** + * Inspired by examples in https://openjdk.java.net/jeps/406 + */ +public class SwitchPatternOK { + public static void main(String[] args) { + System.out.println(formatterPatternSwitch(null)); + System.out.println(formatterPatternSwitch(123)); + System.out.println(formatterPatternSwitch(999L)); + System.out.println(formatterPatternSwitch(12.34)); + System.out.println(formatterPatternSwitch("foo")); + System.out.println(formatterPatternSwitch(List.of(123, "foo", 999L, 12.34))); + + System.out.println(testCircle(new Rectangle())); + System.out.println(testCircle(new Circle(5))); + System.out.println(testCircle(new Circle(6))); + + System.out.println(testSealedCoverage(new A())); + System.out.println(testSealedCoverage(new B())); + System.out.println(testSealedCoverage(new C(5))); + } + + static String formatterPatternSwitch(Object o) { + return switch (o) { + case null -> "null"; + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format(Locale.ENGLISH, "double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + static class Shape {} + static class Rectangle extends Shape {} + static class Circle extends Shape { + private final double radius; + public Circle(double radius) { this.radius = radius; } + double calculateArea() { return Math.PI * radius * radius; } + } + + static String testCircle(Shape s) { + return switch (s) { + case Circle c && (c.calculateArea() > 100) -> "Large circle"; + case Circle c -> "Small circle"; + default -> "Non-circle"; + }; + } + + sealed interface S permits A, B, C {} + final static class A implements S {} + final static class B implements S {} + static record C(int i) implements S {} // Implicitly final + + static String testSealedCoverage(S s) { + return switch (s) { + case A a -> "Sealed sub-class A"; + case B b -> "Sealed sub-class B"; + case C c -> "Sealed sub-record C"; + }; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java index 806cdc55b..329b3f880 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java @@ -14,7 +14,7 @@ import junit.framework.Test; /* * 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 + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -11 option * to check code generation and modification with that version specified. * * @author Andy Clement diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java index c3acd04b2..f8cffca69 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java @@ -14,7 +14,7 @@ import junit.framework.Test; /* * 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 + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -13 option * to check code generation and modification with that version specified. * * @author Andy Clement diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java index 08013d697..c2e13b550 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java @@ -24,11 +24,11 @@ public class AllTestsAspectJ196 { 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()) { suite.addTest(Ajc196PreviewFeaturesTests.suite()); } -*/ + */ return suite; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java index 554832dd2..6857b4d8a 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java @@ -14,7 +14,7 @@ import junit.framework.Test; /* * 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 + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -14 option * to check code generation and modification with that version specified. * * @author Andy Clement diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java index 9aaed7eb8..fe767e639 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java @@ -25,9 +25,12 @@ public class AllTestsAspectJ197 { 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()) { suite.addTest(Java16PreviewFeaturesTests.suite()); } + */ return suite; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java index a91d5c240..9622e7364 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java @@ -13,7 +13,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater; /* * 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 + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -15 option * to check code generation and modification with that version specified. * * @author Alexander Kriegisch diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java index ab28b080f..52950b4dd 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java @@ -13,7 +13,7 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater; /* * 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 + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -16 option * to check code generation and modification with that version specified. * * @author Alexander Kriegisch diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java index 172d6e14e..8fa9110f2 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java @@ -17,40 +17,24 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; */ 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 void testSealedClassWithLegalSubclasses() { + runTest("sealed class with legal subclasses"); + // TODO: replace 0 by Constants.PREVIEW_MINOR_VERSION after no longer using EA build, but final JDK version + checkVersion("Employee", Constants.MAJOR_17, 0 /*Constants.PREVIEW_MINOR_VERSION*/); + checkVersion("Manager", Constants.MAJOR_17, 0 /*Constants.PREVIEW_MINOR_VERSION*/); + } + + public void testSealedClassWithIllegalSubclass() { + runTest("sealed class with illegal subclass"); + // TODO: replace 0 by Constants.PREVIEW_MINOR_VERSION after no longer using EA build, but final JDK version + checkVersion("Person", Constants.MAJOR_17, 0 /*Constants.PREVIEW_MINOR_VERSION*/); + } + + public void testWeaveSealedClass() { + runTest("weave sealed class"); + // TODO: replace 0 by Constants.PREVIEW_MINOR_VERSION after no longer using EA build, but final JDK version + checkVersion("PersonAspect", Constants.MAJOR_17, 0 /*Constants.PREVIEW_MINOR_VERSION*/); + } public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Ajc198TestsJava.class); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java index d99042a3f..69ed09593 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java @@ -19,7 +19,7 @@ public class AllTestsAspectJ198 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ 1.9.8 tests"); if (LangUtil.is9VMOrGreater()) { - suite.addTest(org.aspectj.systemtest.ajc198.CompileWithReleaseTests.suite()); + suite.addTest(CompileWithReleaseTests.suite()); } if (LangUtil.is17VMOrGreater()) { suite.addTest(SanityTestsJava17.suite()); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java index fab787724..c1b0f8c44 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java @@ -17,23 +17,22 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava17Only; */ 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 testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { + runTest("switch pattern matching error"); } - public void testSealedClassWithIllegalSubclass() { - runTest("sealed class with illegal subclass"); - checkVersion("Person", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); + public void testSwitchPatternMatchingJava() { + runTest("switch pattern matching java"); + checkVersion("SwitchPatternOK", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION); } - public void testWeaveSealedClass() { - runTest("weave sealed class"); - checkVersion("PersonAspect", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION); + public void testSwitchPatternMatchingAspect() { + runTest("switch pattern matching aspect"); + checkVersion("SwitchPatternAspect", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Application", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Shape", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION); + checkVersion("S", Constants.MAJOR_17, Constants.PREVIEW_MINOR_VERSION); } -*/ public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Java17PreviewFeaturesTests.class); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java index 4fac5f375..0769be83b 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java @@ -13,7 +13,7 @@ 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 + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -17 option * to check code generation and modification with that version specified. * * @author Alexander Kriegisch diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml index 06ca7d048..c182b58b9 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml @@ -3,34 +3,78 @@ <suite> - <!-- Java ?? final, Java 16, 15 preview --> -<!-- + <!-- Java 17 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" /> + <compile files="Person.java Employee.java Manager.java" options="-17" /> </ajc-test> ---> - <!-- Java ?? final, Java 16, 15 preview --> -<!-- + <!-- Java 17 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"> + <compile files="Person.java Employee.java Manager.java PersonaNonGrata.java" options="-17"> <message kind="error" file="PersonaNonGrata.java" text="should be a permitted subtype of Person"/> </compile> </ajc-test> ---> - <!-- Java ?? final, Java 16, 15 preview --> -<!-- + <!-- Java 17 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"> + <compile files="Person.java Employee.java Manager.java TopManager.java PersonAspect.aj" options="-17" /> + <run class="TopManager"> <stdout> <line text="Hello Sir John" /> <line text="CEO" /> </stdout> </run> </ajc-test> ---> + + <!-- Java ?? final, Java 17 preview --> + <ajc-test dir="features198/java17" vm="17" title="switch pattern matching error"> + <compile files="SwitchPatternError.java" options="--enable-preview -17"> + <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it --> + <message kind="error" file="SwitchPatternError.java" text="This case label is dominated by one of the preceding case label"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 17 preview --> + <ajc-test dir="features198/java17" vm="17" title="switch pattern matching java"> + <compile files="SwitchPatternOK.java" options="--enable-preview -17" /> + <run class="SwitchPatternOK" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 17 preview --> + <ajc-test dir="features198/java17" vm="17" title="switch pattern matching aspect"> + <compile files="SwitchPatternAspect.aj" options="--enable-preview -17" /> + <run class="Application" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + </stdout> + </run> + </ajc-test> <!-- Javac/ECJ 9+ compiler option, but belated implementation in AJC 1.9.7 --> <ajc-test dir="features198/compiler_release" vm="9" title="compile to older JDK release"> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml index 70f52fafa..adb339a41 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml @@ -48,14 +48,14 @@ <compile files="SimpleI.java" options="-17"/> </ajc-test> - <!-- check class file version is 60.0 (Java 16) --> + <!-- check class file version is 61.0 (Java 17) --> <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) --> + <!-- check class file version is 61.0 (Java 17) --> <ajc-test dir="bugs160/simplejava" title="simple - k"> - <compile files="SimpleJ.java" options="-source 16"/> + <compile files="SimpleJ.java" options="-source 17"/> </ajc-test> <!-- check class file version is 49.0 --> |