Browse Source

Updated with Java12 support

tags/V1_9_3
Andy Clement 5 years ago
parent
commit
0e2c95a369
35 changed files with 392 additions and 118 deletions
  1. 1
    0
      .gitignore
  2. 18
    0
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/AJDocConstants.java
  3. 2
    2
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/BugTest.java
  4. 20
    20
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java
  5. 15
    15
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/DeclareFormsTest.java
  6. 5
    0
      bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java
  7. 2
    1
      bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java
  8. 66
    0
      docs/dist/doc/README-193.html
  9. 1
    1
      org.aspectj.ajdt.core/src/main/resources/org/aspectj/ajdt/ajc/messages.properties
  10. 2
    3
      org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java
  11. 1
    1
      org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
  12. BIN
      org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
  13. BIN
      org.eclipse.jdt.core/jdtcore-for-aspectj.jar
  14. 3
    3
      taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
  15. 4
    1
      testing/src/test/java/org/aspectj/testing/AjcTest.java
  16. 6
    2
      testing/src/test/java/org/aspectj/testing/AntSpec.java
  17. 15
    0
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java
  18. 3
    3
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java
  19. 31
    0
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java
  20. BIN
      tests/bugs190/modules/ggg/foo2.jar
  21. 22
    0
      tests/features193/Switch1.java
  22. 28
    0
      tests/features193/Switch2.java
  23. 32
    0
      tests/features193/Switch3.java
  24. 4
    4
      tests/java5/ataspectj/ajc-ant.xml
  25. 2
    14
      tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java
  26. 0
    10
      tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java
  27. 0
    11
      tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java
  28. 0
    11
      tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java
  29. 0
    9
      tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
  30. 2
    3
      tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
  31. 46
    0
      tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java
  32. 5
    1
      tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml
  33. 39
    0
      tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml
  34. 4
    0
      util/src/main/java/org/aspectj/util/LangUtil.java
  35. 13
    3
      weaver/src/test/java/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java

+ 1
- 0
.gitignore View File

@@ -1,4 +1,5 @@
*/bin
*/pom.xml.versionsBackup
log.txt
.vscode
.DS_Store

+ 18
- 0
ajdoc/src/test/java/org/aspectj/tools/ajdoc/AJDocConstants.java View File

@@ -0,0 +1,18 @@
/* *******************************************************************
* 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";
}

+ 2
- 2
ajdoc/src/test/java/org/aspectj/tools/ajdoc/BugTest.java View File

@@ -69,7 +69,7 @@ public class BugTest extends AjdocTestCase {
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()) {
@@ -90,7 +90,7 @@ public class BugTest extends AjdocTestCase {
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()) {

+ 20
- 20
ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java View File

@@ -87,7 +87,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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?");
@@ -101,7 +101,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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?");
@@ -117,7 +117,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -205,7 +205,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -237,7 +237,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -290,7 +290,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -321,7 +321,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -358,7 +358,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -389,7 +389,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -420,7 +420,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -451,7 +451,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -500,7 +500,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -532,7 +532,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -553,7 +553,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -591,7 +591,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -637,7 +637,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -666,7 +666,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -748,7 +748,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -829,7 +829,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {
@@ -860,7 +860,7 @@ public class CoverageTestCase extends AjdocTestCase {
*/
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()) {

+ 15
- 15
ajdoc/src/test/java/org/aspectj/tools/ajdoc/DeclareFormsTest.java View File

@@ -49,7 +49,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -84,7 +84,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -116,7 +116,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -148,7 +148,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -181,7 +181,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -212,7 +212,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -235,7 +235,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -266,7 +266,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -305,7 +305,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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.
@@ -351,7 +351,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -384,7 +384,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -418,7 +418,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -452,7 +452,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -475,7 +475,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {
@@ -521,7 +521,7 @@ public class DeclareFormsTest extends AjdocTestCase {
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()) {

+ 5
- 0
bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java View File

@@ -86,6 +86,11 @@ public interface Constants {
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;

+ 2
- 1
bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java View File

@@ -226,7 +226,8 @@ public class ClassPath implements Serializable {
}

// 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);
}

+ 66
- 0
docs/dist/doc/README-193.html View File

@@ -20,6 +20,72 @@ All rights reserved.
<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>

+ 1
- 1
org.aspectj.ajdt.core/src/main/resources/org/aspectj/ajdt/ajc/messages.properties View File

@@ -5,7 +5,7 @@
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 =



+ 2
- 3
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java View File

@@ -57,18 +57,17 @@ public class AjBuildManagerTest extends TestCase {
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);

+ 1
- 1
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java View File

@@ -687,7 +687,7 @@ public abstract class AjcTestCase extends TestCase {
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) {

BIN
org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip View File


BIN
org.eclipse.jdt.core/jdtcore-for-aspectj.jar View File


+ 3
- 3
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java View File

@@ -254,9 +254,9 @@ public class AjcTask extends MatchingTask {

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;


+ 4
- 1
testing/src/test/java/org/aspectj/testing/AjcTest.java View File

@@ -1,5 +1,5 @@
/* *******************************************************************
* 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
@@ -29,6 +29,7 @@ public class AjcTest {
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();
@@ -39,6 +40,7 @@ public class AjcTest {
is19VMOrGreater = LangUtil.is19VMOrGreater();
is10VMOrGreater = LangUtil.is10VMOrGreater();
is11VMOrGreater = LangUtil.is11VMOrGreater();
is12VMOrGreater = LangUtil.is12VMOrGreater();
}

private List<ITestStep> testSteps = new ArrayList<ITestStep>();
@@ -84,6 +86,7 @@ public class AjcTest {
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"));

+ 6
- 2
testing/src/test/java/org/aspectj/testing/AntSpec.java View File

@@ -207,7 +207,7 @@ public class AntSpec implements ITestStep {
}
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","");
}
@@ -225,7 +225,11 @@ public class AntSpec implements ITestStep {
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);
}
}

+ 15
- 0
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java View File

@@ -208,6 +208,21 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
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

+ 3
- 3
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java View File

@@ -11,6 +11,8 @@
* ******************************************************************/
package org.aspectj.testing;

import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
@@ -20,9 +22,7 @@ public abstract class XMLBasedAjcTestCaseForJava11OrLater extends XMLBasedAjcTes

@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);

+ 31
- 0
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java View File

@@ -0,0 +1,31 @@
/* *******************************************************************
* 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);
}
}

BIN
tests/bugs190/modules/ggg/foo2.jar View File


+ 22
- 0
tests/features193/Switch1.java View File

@@ -0,0 +1,22 @@
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;
}

+ 28
- 0
tests/features193/Switch2.java View File

@@ -0,0 +1,28 @@
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;
}
}

+ 32
- 0
tests/features193/Switch3.java View File

@@ -0,0 +1,32 @@
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;
}
}

+ 4
- 4
tests/java5/ataspectj/ajc-ant.xml View File

@@ -10,7 +10,7 @@

<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"
@@ -75,7 +75,7 @@

<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">
@@ -125,7 +125,7 @@
</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">
@@ -171,7 +171,7 @@

<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">

+ 2
- 14
tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java View File

@@ -10,16 +10,14 @@
*******************************************************************************/
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.
@@ -136,16 +134,6 @@ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase {
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");

+ 0
- 10
tests/src/test/java/org/aspectj/systemtest/ajc190/ModuleTests.java View File

@@ -149,16 +149,6 @@ public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater {
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");

+ 0
- 11
tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java View File

@@ -10,7 +10,6 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc190;

import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;

import junit.framework.Test;
@@ -124,16 +123,6 @@ public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase {
// 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");

+ 0
- 11
tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java View File

@@ -7,7 +7,6 @@
*******************************************************************************/
package org.aspectj.systemtest.ajc191;

import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;

import junit.framework.Test;
@@ -73,16 +72,6 @@ public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase {
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);

+ 0
- 9
tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java View File

@@ -74,15 +74,6 @@ public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
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() {

+ 2
- 3
tests/src/test/java/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* 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
@@ -17,9 +17,8 @@ public class AllTestsAspectJ193 {

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;
}
}

+ 46
- 0
tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java View File

@@ -0,0 +1,46 @@
/*******************************************************************************
* 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");
}

}

+ 5
- 1
tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190.xml View File

@@ -111,8 +111,12 @@
<!-- 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>

+ 39
- 0
tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml View File

@@ -51,6 +51,45 @@ Method call
</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)"/>

+ 4
- 0
util/src/main/java/org/aspectj/util/LangUtil.java View File

@@ -161,6 +161,10 @@ public class LangUtil {
return 11 <= vmVersion;
}

public static boolean is12VMOrGreater() {
return 12 <= vmVersion;
}

/**
* Shorthand for "if null, throw IllegalArgumentException"
*

+ 13
- 3
weaver/src/test/java/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java View File

@@ -13,11 +13,14 @@ package org.aspectj.weaver.bcel;

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;

@@ -44,12 +47,19 @@ public class BcelGenericSignatureToTypeXTestCase extends TestCase {
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());
}


Loading…
Cancel
Save