Browse Source

Fix 'ajdoc' tests for Java 15 build

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tags/java16-add-opens
Alexander Kriegisch 3 years ago
parent
commit
2fd6804db8
26 changed files with 526 additions and 466 deletions
  1. 8
    8
      ajde.core/src/test/java/org/aspectj/ajde/core/TestCompilerConfiguration.java
  2. 8
    8
      ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java
  3. 45
    7
      ajdoc/pom.xml
  4. 11
    11
      ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java
  5. 40
    40
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
  6. 20
    20
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java
  7. 40
    30
      ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java
  8. 3
    3
      loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java
  9. 14
    14
      org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
  10. 11
    11
      org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java
  11. 1
    1
      org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
  12. 6
    0
      testing-drivers/pom.xml
  13. 78
    76
      testing-drivers/src/test/java/org/aspectj/testing/drivers/HarnessSelectionTest.java
  14. 1
    1
      testing/src/test/java/org/aspectj/testing/AjcTest.java
  15. 10
    10
      testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java
  16. 37
    37
      testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java
  17. 138
    138
      tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java
  18. 2
    2
      tests/src/test/java/org/aspectj/systemtest/apt/AptTests.java
  19. 9
    9
      tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java
  20. 1
    1
      tests/src/test/java/org/aspectj/tests/TestsModuleTests.java
  21. 10
    6
      util/src/main/java/org/aspectj/util/LangUtil.java
  22. 2
    2
      util/src/test/java/org/aspectj/util/LangUtilTest.java
  23. 1
    1
      weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java
  24. 2
    2
      weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java
  25. 10
    10
      weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java
  26. 18
    18
      weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java

+ 8
- 8
ajde.core/src/test/java/org/aspectj/ajde/core/TestCompilerConfiguration.java View File

@@ -1,11 +1,11 @@
/********************************************************************
* Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version
*******************************************************************/
package org.aspectj.ajde.core;
@@ -61,7 +61,7 @@ public class TestCompilerConfiguration implements ICompilerConfiguration {
public String getClasspath() {
StringBuilder classpath = new StringBuilder();
classpath.append(projectPath);
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath());
} else {
classpath.append(File.pathSeparator).append(System.getProperty("sun.boot.class.path"));

+ 8
- 8
ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java View File

@@ -1,11 +1,11 @@
/********************************************************************
* Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version (bug 148190)
*******************************************************************/
package org.aspectj.ajde.ui.utils;
@@ -67,7 +67,7 @@ public class TestCompilerConfiguration implements ICompilerConfiguration {
public String getClasspath() {
String cp = projectPath + File.pathSeparator + System.getProperty("sun.boot.class.path") + File.pathSeparator
+ TestUtil.aspectjrtClasspath();
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
cp = LangUtil.getJrtFsFilePath()+File.pathSeparator+cp;
}
return cp;

+ 45
- 7
ajdoc/pom.xml View File

@@ -35,13 +35,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
<!-- enables easy dependency on tools.jar -->
<groupId>com.github.olivergondza</groupId>
<artifactId>maven-jdk-tools-wrapper</artifactId>
<version>0.1</version>
</dependency>

<!-- enables easy dependency on tools.jar -->
<groupId>com.github.olivergondza</groupId>
<artifactId>maven-jdk-tools-wrapper</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
@@ -49,5 +47,45 @@
<scope>system</scope>
<systemPath>${project.basedir}/../lib/asm/asm-8.0.1.renamed.jar</systemPath>
</dependency>

<!-- Dependencies needed for running tests in this module independently of complete reactor build -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../org.eclipse.jdt.core/jdtcore-for-aspectj.jar</systemPath>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>org.aspectj.matcher</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>weaver</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>bcel-builder</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>runtime</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>testing-util</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>

+ 11
- 11
ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java View File

@@ -31,6 +31,7 @@ import org.aspectj.asm.AsmManager;
import org.aspectj.asm.HierarchyWalker;
import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationship;
import org.aspectj.util.LangUtil;
import org.aspectj.util.TypeSafeEnum;

/**
@@ -38,6 +39,10 @@ import org.aspectj.util.TypeSafeEnum;
*/
class HtmlDecorator {

public static final String TYPE_NAME_LABEL = LangUtil.is15VMOrGreater()
? "type-name-label"
: (LangUtil.is1dot8VMOrGreater() ? "typeNameLabel" : "strong");

private static final String POINTCUT_DETAIL = "Pointcut Detail";
private static final String ADVICE_DETAIL = "Advice Detail";
private static final String DECLARE_DETAIL = "Declare Detail";
@@ -267,19 +272,14 @@ class HtmlDecorator {
}
}
else {
// Java8:
// <pre>static class <span class="typeNameLabel">ClassA.InnerAspect</span>
classStartIndex = fileContents.toString().indexOf("class <span class=\"typeNameLabel\">");
if (classStartIndex == -1) {
// Java7: 464604
// <pre>public class <span class="strong">Azpect</span>
classStartIndex = fileContents.toString().indexOf("class <span class=\"strong\">");
}
// Java15: <pre>static class <span class="type-name-label">ClassA.InnerAspect</span>
// Java8: <pre>static class <span class="typeNameLabel">ClassA.InnerAspect</span>
// Java7 (464604): <pre>public class <span class="strong">Azpect</span>
classStartIndex = fileContents.toString().indexOf("class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">");
int classEndIndex = fileContents.toString().indexOf("</span>", classStartIndex);
if (classEndIndex != -1) {
// Convert it to "aspect <span class="typeNameLabel">ClassA.InnerAspect</span>"
String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
String aspectLine = "aspect"+fileContents.substring(classStartIndex+5,classEndIndex);
// Convert it to "aspect <span class="TYPE_NAME_LABEL">ClassA.InnerAspect</span>"
String aspectLine = "aspect" + fileContents.substring(classStartIndex + 5, classEndIndex);
fileContents.delete(classStartIndex, classEndIndex);
fileContents.insert(classStartIndex, aspectLine);
}

+ 40
- 40
ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java View File

@@ -1,11 +1,11 @@
/********************************************************************
* Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - iniital version
*******************************************************************/
package org.aspectj.tools.ajdoc;
@@ -25,8 +25,8 @@ import org.aspectj.util.LangUtil;
public class AjdocOutputChecker {

/**
* Checks whether the given html file contains the required String.
*
* Checks whether the given html file contains the required String.
*
* @param htmlFile
* @param requiredString
* @return true if the file contains the given string or
@@ -53,12 +53,12 @@ public class AjdocOutputChecker {

/**
* Returns those strings from the given array which aren't in the html file.
*
*
* @param htmlFile
* @param an array of requiredStrings
* @return a List of those strings not found
* @throws Exception
*/
*/
public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception {
List<String> missingStrings = new ArrayList<>();
for (String string : requiredStrings) {
@@ -68,16 +68,16 @@ public class AjdocOutputChecker {
}
return missingStrings;
}
/**
* Checks whether the section of the html file contains the
* required String
*
*
* @param htmlFile
* @param requiredString
* @param sectionHeader
* @return true if the file contains the given string within the
* required section or false otherwise (or if the file is null or
* @return true if the file contains the given string within the
* required section or false otherwise (or if the file is null or
* not an html file)
* @throws Exception
*/
@@ -91,7 +91,7 @@ public class AjdocOutputChecker {
while (line != null) {
if (line.contains(sectionHeader)) {
String nextLine = reader.readLine();
while (nextLine != null &&
while (nextLine != null &&
(!nextLine.contains("========"))) {
if (nextLine.contains(requiredString)) {
reader.close();
@@ -107,11 +107,11 @@ public class AjdocOutputChecker {
reader.close();
return false;
}
/**
* Returns those strings from the given array which aren't in the
* ajdoc html file
*
* ajdoc html file
*
* @param htmlFile
* @param an array of requiredStrings
* @param sectionHeader
@@ -130,10 +130,10 @@ public class AjdocOutputChecker {
}

/**
* Returns whether the class data section has the expected
* relationship and target i.e. have the relationships been
* Returns whether the class data section has the expected
* relationship and target i.e. have the relationships been
* applied to the type.
*
*
* @param the ajdoc html file
* @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY"
* @param the source of the relationship, for example "Point()"
@@ -143,7 +143,7 @@ public class AjdocOutputChecker {
* false otherwise
*/
public static boolean classDataSectionContainsRel(File htmlFile,
HtmlDecorator.HtmlRelationshipKind relationship,
HtmlDecorator.HtmlRelationshipKind relationship,
String target) throws Exception {
if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
return false;
@@ -154,7 +154,7 @@ public class AjdocOutputChecker {
if (line.contains("START OF CLASS DATA")) {
// found the required class data section
String subLine = reader.readLine();
while(subLine != null
while(subLine != null
&& (!subLine.contains("========"))){
int relIndex = subLine.indexOf(relationship.toString());
int targetIndex = subLine.indexOf(target);
@@ -175,11 +175,11 @@ public class AjdocOutputChecker {
reader.close();
return false;
}
/**
* Returns whether the supplied source has the expected
* Returns whether the supplied source has the expected
* relationship and target within the given detail section
*
*
* @param the ajdoc html file
* @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY"
* @param the source of the relationship, for example "Point()"
@@ -188,9 +188,9 @@ public class AjdocOutputChecker {
* @return true if the section contains the expected source/relationship/target,
* false otherwise
*/
public static boolean detailSectionContainsRel(File htmlFile,
String sectionHeader, String source,
HtmlDecorator.HtmlRelationshipKind relationship,
public static boolean detailSectionContainsRel(File htmlFile,
String sectionHeader, String source,
HtmlDecorator.HtmlRelationshipKind relationship,
String target) throws Exception {
if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
return false;
@@ -210,9 +210,9 @@ public class AjdocOutputChecker {
nextLine.contains("NAME=\"" + source + "\"") || nextLine.contains("name=\"" + source + "\"")) {
// found the required subsection
String subLine = reader.readLine();
while(subLine != null
while(subLine != null
&& (!subLine.contains("========"))
&& (!subLine.contains("NAME") && !subLine.contains("name"))) {
&& (!subLine.contains("NAME=") && !subLine.contains("name="))) {
int relIndex = subLine.indexOf(relationship.toString());
int targetIndex = subLine.indexOf(target);
if ((relIndex != -1) && (targetIndex != -1)) {
@@ -239,9 +239,9 @@ public class AjdocOutputChecker {
}

/**
* Returns whether the supplied source has the expected
* Returns whether the supplied source has the expected
* relationship and target within the given summary section
*
*
* @param the ajdoc html file
* @param the detail sectionHeader, for example "DECLARE SUMMARY"
* @param the source of the relationship, for example "Point()"
@@ -251,10 +251,10 @@ public class AjdocOutputChecker {
* false otherwise
*/
public static boolean summarySectionContainsRel(
File htmlFile,
String sectionHeader,
String source,
HtmlDecorator.HtmlRelationshipKind relationship,
File htmlFile,
String sectionHeader,
String source,
HtmlDecorator.HtmlRelationshipKind relationship,
String target) throws Exception {
if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
return false;
@@ -272,7 +272,7 @@ public class AjdocOutputChecker {
if (nextLine.contains(source)) {
// found the required subsection
String subLine = nextLine;
while(subLine != null
while(subLine != null
&& (!subLine.contains("========"))
&& (!subLine.contains("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">"))) {
int relIndex = subLine.indexOf(relationship.toString());
@@ -299,5 +299,5 @@ public class AjdocOutputChecker {
reader.close();
return false;
}
}

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

@@ -1,11 +1,11 @@
/********************************************************************
* Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - iniital version
*******************************************************************/
package org.aspectj.tools.ajdoc;
@@ -160,12 +160,12 @@ public abstract class AjdocTestCase extends TestCase {
if (inputFiles.length == 0) {
fail("need to pass some files into ajdoc");
}
if (!sourceLevel.equals("1.3") &&
!sourceLevel.equals("1.4") &&
!sourceLevel.equals("1.5") &&
!sourceLevel.equals("1.6") &&
!sourceLevel.equals("1.7") &&
!sourceLevel.equals("1.8") &&
if (!sourceLevel.equals("1.3") &&
!sourceLevel.equals("1.4") &&
!sourceLevel.equals("1.5") &&
!sourceLevel.equals("1.6") &&
!sourceLevel.equals("1.7") &&
!sourceLevel.equals("1.8") &&
!sourceLevel.equals("1.9") &&
!sourceLevel.equals("10")) {
fail("need to pass ajdoc '1.3' > '1.9' as the source level");
@@ -191,12 +191,12 @@ public abstract class AjdocTestCase extends TestCase {
if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) {
fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
}
if (!sourceLevel.equals("1.3") &&
!sourceLevel.equals("1.4") &&
!sourceLevel.equals("1.5") &&
!sourceLevel.equals("1.6") &&
!sourceLevel.equals("1.7") &&
!sourceLevel.equals("1.8") &&
if (!sourceLevel.equals("1.3") &&
!sourceLevel.equals("1.4") &&
!sourceLevel.equals("1.5") &&
!sourceLevel.equals("1.6") &&
!sourceLevel.equals("1.7") &&
!sourceLevel.equals("1.8") &&
!sourceLevel.equals("1.9") &&
!sourceLevel.startsWith("9") &&
!sourceLevel.startsWith("10")) {
@@ -217,7 +217,7 @@ public abstract class AjdocTestCase extends TestCase {
args[2] = sourceLevel;
args[3] = "-classpath";
StringBuilder classpath = new StringBuilder();
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
}
classpath.append(AjdocTests.ASPECTJRT_PATH.getPath());

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

@@ -131,9 +131,9 @@ public class CoverageTestCase extends AjdocTestCase {
String[] strings = null;
strings = new String[] {
"Aspect ClassA.InnerAspect",
"<pre>static aspect <span class=\"typeNameLabel\">ClassA.InnerAspect</span>",
"<pre>static aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>",
"Class ClassA.InnerAspect",
"<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"};
"<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>"};
List<String> missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
StringBuilder buf = new StringBuilder();
for (String str:missingStrings) {
@@ -144,7 +144,7 @@ public class CoverageTestCase extends AjdocTestCase {
assertTrue(htmlFile.getName() + " should not have Class as it's title",
missingStrings.contains("Class ClassA.InnerAspect"));
assertTrue(htmlFile.getName() + " should not have class in its subtitle",
missingStrings.contains("<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"));
missingStrings.contains("<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>"));

// get the html file for the enclosing class
File htmlFileClass = new File(getAbsolutePathOutdir() + "/foo/ClassA.html");
@@ -160,21 +160,21 @@ public class CoverageTestCase extends AjdocTestCase {
if (LangUtil.is13VMOrGreater()) {
classStrings = new String[] {
"Class ClassA</h1>",
"public abstract class <span class=\"typeNameLabel\">ClassA</span>",
"public abstract class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>",
"Aspect ClassA</H2>",
"public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"};
"public abstract aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>"};
} else {
classStrings = new String[] {
"Class ClassA</h2>",
"public abstract class <span class=\"typeNameLabel\">ClassA</span>",
"public abstract class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>",
"Aspect ClassA</H2>",
"public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"};
"public abstract aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>"};
}
List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size());
assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>"));
assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
classMissing.contains("public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"));
classMissing.contains("public abstract aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>"));
}

/**
@@ -657,14 +657,19 @@ public class CoverageTestCase extends AjdocTestCase {
String[] strings = null;
strings = new String[] {
"Aspect PkgVisibleClass.NestedAspect",
"<pre>static aspect <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>",
"<pre>static aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>",
"Class PkgVisibleClass.NestedAspect",
"<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"};
List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
assertEquals("There should be 2 missing strings",2,missing.size());
assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class PkgVisibleClass.NestedAspect"));
"<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>"};
List<String> missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
StringBuilder buf = new StringBuilder();
for (String str:missingStrings) {
buf.append(str).append("\n");
}
buf.append("HTMLFILE=\n").append(htmlFile).append("\n");
assertEquals("There should be 2 missing strings",2,missingStrings.size());
assertTrue(htmlFile.getName() + " should not have Class as it's title",missingStrings.contains("Class PkgVisibleClass.NestedAspect"));
assertTrue(htmlFile.getName() + " should not have class in its subtitle",
missing.contains("<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"));
missingStrings.contains("<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>"));
// get the html file for the enclosing class
File htmlFileClass = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.html");
if (!htmlFileClass.exists()) {
@@ -678,22 +683,22 @@ public class CoverageTestCase extends AjdocTestCase {
if (LangUtil.is13VMOrGreater()) {
classStrings = new String[] {
"Class PkgVisibleClass</h1>",
"<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>",
"<pre>class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
"Aspect PkgVisibleClass</h2>",
"<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"};
"<pre>aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"};
} else {
classStrings = new String[] {
"Class PkgVisibleClass</h2>",
"<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>",
"<pre>class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
"Aspect PkgVisibleClass</h2>",
"<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"};
"<pre>aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"};
}
List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
assertEquals("There should be 2 missing strings",2,classMissing.size());
assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
classMissing.contains("Aspect PkgVisibleClass</h2>"));
assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
classMissing.contains("<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"));
classMissing.contains("<pre>aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"));
}

/**
@@ -716,14 +721,19 @@ public class CoverageTestCase extends AjdocTestCase {
String[] strings = null;
strings = new String [] {
"Aspect ClassWithNestedAspect.NestedAspect",
"<pre>static aspect <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>",
"<pre>static aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>",
"Class ClassWithNestedAspect.NestedAspect",
"<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"};
List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
assertEquals("There should be 2 missing strings",2,missing.size());
assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class ClassWithNestedAspect.NestedAspect"));
"<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>"};
List<String> missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
StringBuilder buf = new StringBuilder();
for (String str:missingStrings) {
buf.append(str).append("\n");
}
buf.append("HTMLFILE=\n").append(htmlFile).append("\n");
assertEquals("There should be 2 missing strings",2,missingStrings.size());
assertTrue(htmlFile.getName() + " should not have Class as it's title",missingStrings.contains("Class ClassWithNestedAspect.NestedAspect"));
assertTrue(htmlFile.getName() + " should not have class in its subtitle",
missing.contains("<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"));
missingStrings.contains("<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>"));

// get the html file for the enclosing class
File htmlFileClass = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
@@ -738,22 +748,22 @@ public class CoverageTestCase extends AjdocTestCase {
if (LangUtil.is13VMOrGreater()) {
classStrings = new String[] {
"Class ClassWithNestedAspect</h1>",
"public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>",
"public class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
"Aspect ClassWithNestedAspect</h2>",
"public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"};
"public aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"};
} else {
classStrings = new String[] {
"Class ClassWithNestedAspect</h2>",
"public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>",
"public class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
"Aspect ClassWithNestedAspect</h2>",
"public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"};
"public aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"};
}
List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
assertEquals("There should be 2 missing strings",2,classMissing.size());
assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
classMissing.contains("Aspect ClassWithNestedAspect</h2>"));
assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
classMissing.contains("public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"));
classMissing.contains("public aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"));
}

/**

+ 3
- 3
loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java View File

@@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* 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:
* Matthew Webster - initial implementation
*******************************************************************************/
@@ -54,7 +54,7 @@ public class JRockitAgentTest extends TestCase {
}

public void testJrockitRecursionProtection() {
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
// Skip test, not castable to URLClassLoader
return;
}

+ 14
- 14
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java View File

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* 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:
* PARC initial implementation
* 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:
* PARC initial implementation
* ******************************************************************/

package org.aspectj.ajdt.ajc;
@@ -364,7 +364,7 @@ public class BuildArgParser extends Main {
List<String> ret = new ArrayList<>();

if (parser.bootclasspath == null) {
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
addClasspath(LangUtil.getJrtFsFilePath(),ret);
} else {
addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
@@ -374,7 +374,7 @@ public class BuildArgParser extends Main {
}
return ret;
}
public List<String> getModulepath(AjcConfigParser parser) {
List<String> ret = new ArrayList<>();
addClasspath(parser.modulepath, ret);
@@ -391,7 +391,7 @@ public class BuildArgParser extends Main {
public ArrayList<FileSystem.Classpath> handleClasspath(ArrayList<String> classpaths, String customEncoding) {
return super.handleClasspath(classpaths, customEncoding);
}
/**
* If the classpath is not set, we use the environment's java.class.path, but remove the aspectjtools.jar entry from that list
* in order to prevent wierd bootstrap issues (refer to bug#39959).
@@ -474,7 +474,7 @@ public class BuildArgParser extends Main {
public List getUnparsedArgs() {
return unparsedArgs;
}
public String getModuleInfoArgument() {
return this.moduleInfoArgument;
}
@@ -914,12 +914,12 @@ public class BuildArgParser extends Main {
}

}
@Override
public boolean checkVMVersion(long minimalSupportedVersion) {
return super.checkVMVersion(minimalSupportedVersion);
}
@Override
public void initRootModules(LookupEnvironment environment, FileSystem fileSystem) {
super.initRootModules(environment, fileSystem);

+ 11
- 11
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java View File

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* 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:
* PARC initial implementation
* 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:
* PARC initial implementation
* ******************************************************************/

package org.aspectj.ajdt.internal.compiler.batch;
@@ -33,7 +33,7 @@ public abstract class CommandTestCase extends TestCase {

/**
* Constructor for CommandTestCase.
*
*
* @param name
*/
public CommandTestCase(String name) {
@@ -52,7 +52,7 @@ public abstract class CommandTestCase extends TestCase {
protected void runMain(String className) {
TestUtil.runMain(getSandboxName(), className);
}
public void checkCompile(String source, String[] extraArgs, int[] expectedErrors) {
checkCompile(source,extraArgs,expectedErrors,getSandboxName());
}
@@ -169,7 +169,7 @@ public abstract class CommandTestCase extends TestCase {
/** get the location of the org.aspectj.lang & runtime classes */
protected static String getRuntimeClasspath() {
StringBuilder classpath = new StringBuilder();
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator);
}
classpath.append(Constants.aspectjrtClasspath());

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

@@ -947,7 +947,7 @@ public abstract class AjcTestCase extends TestCase {
args = newargs;
}
}
boolean needsJRTFS = LangUtil.is19VMOrGreater();
boolean needsJRTFS = LangUtil.is9VMOrGreater();
if (needsJRTFS) {
if (!args[cpIndex].contains(LangUtil.JRT_FS)) {
String jrtfsPath = LangUtil.getJrtFsFilePath();

+ 6
- 0
testing-drivers/pom.xml View File

@@ -29,6 +29,12 @@
<artifactId>testing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>testing-util</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>testing-client</artifactId>

+ 78
- 76
testing-drivers/src/test/java/org/aspectj/testing/drivers/HarnessSelectionTest.java View File

@@ -1,14 +1,14 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* 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:
* Xerox/PARC initial implementation
* 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:
* Xerox/PARC initial implementation
* ******************************************************************/

package org.aspectj.testing.drivers;
@@ -41,23 +41,23 @@ import junit.framework.TestCase;
*/
public class HarnessSelectionTest extends TestCase {
private static final String TESTDATA = "../testing-drivers/testdata";
private static final String INC_HARNESS_DIR
private static final String INC_HARNESS_DIR
= TESTDATA + "/incremental/harness";
private static final String SELECT
private static final String SELECT
= INC_HARNESS_DIR + "/selectionTest.xml";
/** @see testIncrementalSuite() */
private static final String INCREMENTAL
private static final String INCREMENTAL
= INC_HARNESS_DIR + "/suite.xml";

private static final String TITLE_LIST_ONE
private static final String TITLE_LIST_ONE
= INC_HARNESS_DIR + "/titleListOne.txt";

private static final String TITLE_LIST_PLURAL
private static final String TITLE_LIST_PLURAL
= INC_HARNESS_DIR + "/titleListPlural.txt";
private static Hashtable SPECS = new Hashtable();
private static Hashtable SPECS = new Hashtable();
private static AjcTest.Suite.Spec getSpec(String suiteFile) {
AjcTest.Suite.Spec result = (AjcTest.Suite.Spec) SPECS.get(suiteFile);
if (null == result) {
@@ -67,7 +67,7 @@ public class HarnessSelectionTest extends TestCase {
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
}
try {
return (AjcTest.Suite.Spec) result.clone();
} catch (CloneNotSupportedException e) {
@@ -76,13 +76,13 @@ public class HarnessSelectionTest extends TestCase {
return null; // keep compiler happy
}
}
private boolean verbose;

public HarnessSelectionTest(String name) {
super(name);
}
public void testFilesAvailable() {
String[] files = new String[] {
SELECT, INCREMENTAL, TITLE_LIST_ONE, TITLE_LIST_PLURAL
@@ -99,20 +99,20 @@ public class HarnessSelectionTest extends TestCase {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
String[] options = new String[]
{ "!verbose", "!eclipse",
};
Exp exp = new Exp(6, 6, 0, 6, 0, 0, 0);
checkSelection(INCREMENTAL, options, "INFIX IGNORED", exp);
}
public void testKeywordSelectionBoth() {
if (!eclipseAvailable()) {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "-ajctestRequireKeywords=requireKeyword",
String[] options = new String[]
{ "-ajctestRequireKeywords=requireKeyword",
"-ajctestSkipKeywords=skipKeyword,skipUnenforcedAjcLimit",
"!verbose",
"-eclipse",
@@ -120,14 +120,14 @@ public class HarnessSelectionTest extends TestCase {
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 1);
checkSelection(SELECT, options, "keyword skipKeyword was found", exp);
}
public void testKeywordSelectionRequire() {
if (!eclipseAvailable()) {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "-ajctestRequireKeywords=skipKeyword",
String[] options = new String[]
{ "-ajctestRequireKeywords=skipKeyword",
"!verbose",
"-eclipse",
};
@@ -140,21 +140,21 @@ public class HarnessSelectionTest extends TestCase {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "-ajctestSkipKeywords=requireKeyword",
String[] options = new String[]
{ "-ajctestSkipKeywords=requireKeyword",
"!verbose",
"-eclipse",
};
Exp exp = new Exp(17, 0, 17, 0, 0, 0, 17);
checkSelection(SELECT, options, "keyword requireKeyword was found", exp);
}
public void testNoOptions() {
if (!ajcAvailable()) {
System.err.println("skipping test - ajc classes not available");
return;
}
String[] options = new String[]
String[] options = new String[]
{ "!ajc"
};
Exp exp = new Exp(17, 3, 14, 3, 0, 0, 4);
@@ -162,107 +162,107 @@ public class HarnessSelectionTest extends TestCase {
}

public void testEclipseOptionsSkip() {
String[] options = new String[]
String[] options = new String[]
{ "-eclipse",
"-ajctestRequireKeywords=eclipseOptionSkip"
};
Exp exp = new Exp(17, 0, 17, 0, 0, 0, 6);
checkSelection(SELECT, options, "old ajc 1.0 option", exp);
}
public void testAjcEclipseConflict() {
if (!ajcAvailable()) {
System.err.println("skipping test - ajc classes not available");
return;
}
String[] options = new String[]
String[] options = new String[]
{ "!ajc"
};
Exp exp = new Exp(17, 3, 14, 3, 0, 0, 6);
checkSelection(SELECT, options, "conflict between !eclipse and !ajc", exp);
}
public void testEclipseConflict() {
String[] options = new String[]
String[] options = new String[]
{ "^eclipse",
"-ajctestSkipKeywords=skipUnenforcedAjcLimit"
};
};
Exp exp = new Exp(17, 3, 14, 3, 0, 0, 6);
checkSelection(SELECT, options, "force conflict between eclipse", exp);
}
public void testSinglePR() {
String[] options = new String[]
String[] options = new String[]
{ "-eclipse", "-ajctestPR=100"
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 16);
checkSelection(SELECT, options, "bugId required", exp);
}
public void testTwoPR() {
String[] options = new String[]
String[] options = new String[]
{ "-eclipse", "-ajctestPR=100,101"
};
Exp exp = new Exp(17, 2, 15, 2, 0, 0, 15);
checkSelection(SELECT, options, "bugId required", exp);
}
public void testTitleContainsSubstringSelection() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleContains=run and ",
"-eclipse"
"-eclipse"
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 16);
checkSelection(SELECT, options, "run and", exp);
}
public void testTitleContainsSubstringSelectionPlural() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleContains= run and , if skipKeyword ",
"-eclipse"
"-eclipse"
};
Exp exp = new Exp(17, 2, 15, 2, 0, 0, 15);
checkSelection(SELECT, options, "title", exp);
}

public void testTitleContainsExactSelection() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleContains=run and pass",
"-eclipse"
"-eclipse"
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 16);
checkSelection(SELECT, options, "run and pass", exp);
}
public void testTitleContainsExactSelectionPlural() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleContains= run and pass , omit if skipKeyword ",
"-eclipse"
"-eclipse"
};
Exp exp = new Exp(17, 2, 15, 2, 0, 0, 15);
checkSelection(SELECT, options, "title", exp);
}

public void testTitleListSelection() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleList=run and pass",
"-eclipse"
"-eclipse"
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 16);
checkSelection(SELECT, options, "run and pass", exp);
}
public void testTitleListSelectionPlural() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleList= run and pass , omit if skipKeyword ",
"-eclipse"
"-eclipse"
};
Exp exp = new Exp(17, 2, 15, 2, 0, 0, 15);
checkSelection(SELECT, options, "title", exp);
}

public void testTitleListFileSelection() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleList=" + TITLE_LIST_ONE,
"-eclipse"
};
@@ -271,15 +271,15 @@ public class HarnessSelectionTest extends TestCase {
}

public void testTitleListFileSelectionPlural() {
String[] options = new String[]
String[] options = new String[]
{ "-ajctestTitleList=" + TITLE_LIST_PLURAL,
"-eclipse"
};
Exp exp = new Exp(17, 2, 15, 2, 0, 0, 15);
checkSelection(SELECT, options, TITLE_LIST_PLURAL, exp);
// Now check the "fail only" path
options = new String[]
// Now check the "fail only" path
options = new String[]
{ "-ajctestTitleFailList=" + TITLE_LIST_PLURAL,
"-eclipse"
};
@@ -289,7 +289,7 @@ public class HarnessSelectionTest extends TestCase {
checkSelection(SELECT, options, "skip", exp);
}

/**
/**
* Run the static test suite with the given options.
* @param setupHolder the IMessageHolder for any setup messages
* @return null if setup failed or Harness.RunResult if suite completed.
@@ -305,15 +305,15 @@ public class HarnessSelectionTest extends TestCase {
assertTrue("expected 17 kids, got " + kids.size(), false);
}
if (!spec.adoptParentValues(runtime, setupHolder)) {
return null;
return null;
} else {
class TestHarness extends Harness {
public RunResult run(AjcTest.Suite.Spec spec) {
return super.run(spec);
}
}
}
TestHarness h = new TestHarness();
return h.run(spec);
return h.run(spec);
}
}

@@ -334,8 +334,8 @@ public class HarnessSelectionTest extends TestCase {
this.incomplete = incomplete;
this.infix = infix;
}
}
}
public void checkSelection(String suiteFile, String[] options, String infoInfix, Exp exp) {
MessageHandler holder = new MessageHandler();
Harness.RunResult result = runSuite(suiteFile, options, holder);
@@ -345,7 +345,7 @@ public class HarnessSelectionTest extends TestCase {
assertNotNull("Harness.RunResult", result);
// XXX sync hack snooping of message text with skip messages, harness
final List skipList = MessageUtil.getMessages(holder, IMessage.INFO, false, "skip");
final int numSkipped = skipList.size();
final int numSkipped = skipList.size();
IRunStatus status = result.status;
assertNotNull(status);
if (verbose) {
@@ -355,7 +355,7 @@ public class HarnessSelectionTest extends TestCase {
assertEquals("skips", exp.skipped, numSkipped);
IRunStatus[] children = status.getChildren();
assertNotNull(children);
assertTrue(children.length + "!= expRun=" + exp.testsRun,
assertTrue(children.length + "!= expRun=" + exp.testsRun,
exp.testsRun == children.length);
int actPass = 0;
for (IRunStatus child : children) {
@@ -369,25 +369,27 @@ public class HarnessSelectionTest extends TestCase {
if (!LangUtil.isEmpty(infoInfix)) {
int actInfix = MessageUtil.getMessages(holder, IMessage.INFO, false, infoInfix).size();
if (actInfix != exp.infix) {
String s = "for infix \"" + infoInfix
String s = "for infix \"" + infoInfix
+ "\" actInfix=" + actInfix + " != expInfix=" + exp.infix;
assertTrue(s, false);
}
}
}
private boolean ajcAvailable() { // XXX util
try {
return (null != Class.forName("org.aspectj.compiler.base.JavaCompiler"));
Class.forName("org.aspectj.compiler.base.JavaCompiler");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}

private boolean eclipseAvailable() { // XXX util
try {
return (null != Class.forName("org.aspectj.ajdt.ajc.AjdtCommand"));
Class.forName("org.aspectj.ajdt.ajc.AjdtCommand");
return true;
} catch (ClassNotFoundException e) {
return false;
}

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

@@ -39,7 +39,7 @@ public class AjcTest {
is16VMOrGreater = true;
is17VMOrGreater = true;
is18VMOrGreater = true;
is19VMOrGreater = LangUtil.is19VMOrGreater();
is19VMOrGreater = LangUtil.is9VMOrGreater();
is10VMOrGreater = LangUtil.is10VMOrGreater();
is11VMOrGreater = LangUtil.is11VMOrGreater();
is12VMOrGreater = LangUtil.is12VMOrGreater();

+ 10
- 10
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java View File

@@ -1,12 +1,12 @@
/* *******************************************************************
* 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:
* 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;
@@ -15,7 +15,7 @@ import org.aspectj.util.LangUtil;

/**
* Makes sure tests are running on the right level of JDK.
*
*
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTestCase {
@@ -23,10 +23,10 @@ public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTest
@Override
public void runTest(String title) {
// Check we are on Java9 or later
if (!LangUtil.is19VMOrGreater()) {
if (!LangUtil.is9VMOrGreater()) {
throw new IllegalStateException("These tests should be run on Java 9 or later");
}
super.runTest(title);
}
}

+ 37
- 37
testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java View File

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2003 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:
* Wes Isberg initial implementation
* 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:
* Wes Isberg initial implementation
* ******************************************************************/

package org.aspectj.testing.taskdefs;
@@ -35,7 +35,7 @@ public class AjcTaskCompileCommandTest extends TestCase {
static boolean loggedWarning = false;
static boolean runAllTests = true;
static List<File> tempFiles = new ArrayList<>();
private static File getClassesDir() {
File tempDir = FileUtil.getTempDir("AjcTaskCompileCommandTest-classes");
tempFiles.add(tempDir);
@@ -48,7 +48,7 @@ public class AjcTaskCompileCommandTest extends TestCase {
list.add("-classpath");
StringBuilder classpath = new StringBuilder();
classpath.append(Globals.F_aspectjrt_jar.getAbsolutePath());
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath());
}
list.add(classpath.toString());
@@ -56,7 +56,7 @@ public class AjcTaskCompileCommandTest extends TestCase {

static boolean doWait(IMessageHolder holder, int seconds, int timeout) {
return AjcTaskCompileCommand
.waitUntilMessagesQuiet(holder, seconds, timeout);
.waitUntilMessagesQuiet(holder, seconds, timeout);
}

public AjcTaskCompileCommandTest(String name) {
@@ -85,30 +85,30 @@ public class AjcTaskCompileCommandTest extends TestCase {
public void testDefaultList() {
runSimpleTest("../taskdefs/testdata/default.lst", 0);
}
public void testCompileErrorList() {
runSimpleTest("../taskdefs/testdata/compileError.lst", 1);
}

public void testWaitUntilMessagesQuiet_1_2() {
if (runAllTests) checkWait(1, 2, 0, 0);
}
public void testWaitUntilMessagesQuiet_1_10() {
if (runAllTests) checkWait(1, 10, 0, 0);
}
public void testWaitUntilMessagesQuiet_8_10() {
checkWait(8, 10, 0, 0);
}
// XXX two async tests might fail if adder thread starved
public void testWaitUntilMessagesQuiet_1_10_4_1() {
if (runAllTests) checkWait(1, 10, 4, 1);
}
public void testWaitUntilMessagesQuiet_8_10_2_1() {
if (runAllTests) checkWait(8, 20, 2, 1);
}
@@ -129,7 +129,7 @@ public class AjcTaskCompileCommandTest extends TestCase {
}
runTest(list, expectedErrors);
}
void runTest(ArrayList<String> args, int expectedErrors) {
AjcTaskCompileCommand command =
new AjcTaskCompileCommand();
@@ -140,14 +140,14 @@ public class AjcTaskCompileCommandTest extends TestCase {
final boolean pass = (result == expectPass);
if (!pass) {
String m = expectPass ? "pass" : "fail";
assertTrue("expected " + m + ": " + args+"\n Messages:"+handler.getUnmodifiableListView(), false);
}
}

void checkWait(final int seconds, final int timeout, int toAdd, int addInterval) {
final String testCase = "checkWait(seconds="
+ seconds + ", timeout=" + timeout;
final String testCase = "checkWait(seconds="
+ seconds + ", timeout=" + timeout;
final MessageHandler mhandler = new MessageHandler();
final long startTime = System.currentTimeMillis();
final long testTimeout = startTime + (timeout * 2000l);
@@ -160,7 +160,7 @@ public class AjcTaskCompileCommandTest extends TestCase {
System.out.println("warning - test will fail if adder thread starved");
loggedWarning = true;
}
final MessageAdder adder
final MessageAdder adder
= new MessageAdder(mhandler, toAdd, addInterval);
final String label = testCase + " wait(" + toAdd + ", " + addInterval + ")";
class Result {
@@ -173,15 +173,15 @@ public class AjcTaskCompileCommandTest extends TestCase {
waitResult.addedThread
= new Thread(adder, label + "-child");
waitResult.addedThread.start();
waitResult.result =
waitResult.result =
AjcTaskCompileCommandTest.doWait(mhandler, seconds, timeout);
}
}, label);
testThread.start();
try {
testThread.join(testTimeout - startTime);
testThread.join(testTimeout - startTime);
} catch (InterruptedException e) {
// ignore
}
@@ -190,13 +190,13 @@ public class AjcTaskCompileCommandTest extends TestCase {
long wait = testTimeout - System.currentTimeMillis();
if (0 < wait) {
waitResult.addedThread.join(wait);
}
}
}
} catch (InterruptedException e) {
// ignore
}
result = waitResult.result;
int added = adder.getNumAdded();
int added = adder.getNumAdded();
assertEquals(testCase + " added", added, toAdd);
if (!result) {
assertTrue(testCase + " result " + adder, false);
@@ -215,12 +215,12 @@ class MessageAdder implements Runnable {
public static long MAX_MILLIS = 1000 * 30;
public boolean stop;
public boolean wait;
private final IMessageHolder messages;
private final int numToAdd;
private final int interval;
private int numAdded;
/**
* @param holder the IMessageHolder to add to
* @param num the int number of messages to add
@@ -242,7 +242,7 @@ class MessageAdder implements Runnable {
final long timeout = curTime + MAX_MILLIS;
// final Thread thread = Thread.currentThread();
int numAdded = 0;
while (!stop && (timeout > curTime)
while (!stop && (timeout > curTime)
&& (numAdded < numToAdd)) {
long targetTime = curTime + waitBetweenAdds;
while (!stop && (curTime < timeout)
@@ -264,7 +264,7 @@ class MessageAdder implements Runnable {
int getNumAdded() {
return numAdded;
}
public String toString() {
return "MessageAdder("
+ "numAdded=" + numAdded
@@ -273,9 +273,9 @@ class MessageAdder implements Runnable {
+ ", stop=" + stop
+ ", wait=" + wait
+ ", numMessages="
+ (null == messages
? 0
+ (null == messages
? 0
: messages.numMessages(null, true))
+ ")";
}
}
}
}

+ 138
- 138
tests/src/test/java/org/aspectj/systemtest/ajc150/GenericsTests.java View File

@@ -22,7 +22,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {

/*==========================================
* Generics test plan for pointcuts.
*
*
* handler PASS
* - does not permit type var spec
* - does not permit generic type (fail with type not found)
@@ -54,7 +54,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* staticinitialization PASS
* - error on parameterized type PASS N/A
* - permit parameterized type + PASS N/A
* - matching with parameterized type + N/A
* - matching with parameterized type + N/A
* - wrong number of parameters in parameterized type PASS N/A
* - generic type with one type parameter N/A
* - generic type with n type parameters N/A
@@ -64,7 +64,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* within PASS
* - as above, but allows parameterized type (disallowed in simplified plan)
* - wildcards in type parameters N/A
* this PASS
* this PASS
* - no type vars
* - parameterized types - disallowed in simplification plan
* - implements
@@ -115,20 +115,20 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* - parameter as parameterized type PASS
* - no join points for bridge methods PASS
* call PASS
* - no generic or parameterized declaring type patterns PASS
* - no generic or parameterized declaring type patterns PASS
* - no parameterized throws patterns PASS
* - return type as type variable PASS
* - return type as parameterized type PASS
* - return type as parameterized type PASS
* - parameter as type variable PASS
* - parameter as parameterized type PASS
* - calls to a bridge methods PASS
* after throwing - can't use parameterized type pattern
* after returning - same as for args
*/
/* ==========================================
* Generics test plan for ITDs.
*
*
* think about:
* - 'visibility' default/private/public
* - static/nonstatic
@@ -148,7 +148,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* - super/extends with parameterized types <? extends List<String>>
* - multiple ITDs defined in one type that reuse type variable letters, specifying different bounds
* - generic aspects
*
*
* PASS parsing generic ITDs
* PASS generic methods
* PASS generic constructors
@@ -170,15 +170,15 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* PASS parameterizing ITDs with type variables
* PASS using type variables from the target type in your *STATIC* ITD (field/method/ctor) (error scenario)
* PASS basic binary weaving of generic itds
*
*
* TODO generic aspect binary weaving (or at least multi source file weaving)
* TODO binary weaving with changing types (moving between generic and simple)
* TODO bridge method creation (also relates to covariance overrides..)
* TODO exotic class/interface bounds ('? extends List<String>','? super anything')
* TODO signature attributes for generic ITDs (public only?)
*
*
*/
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(GenericsTests.class);
}
@@ -186,15 +186,15 @@ public class GenericsTests extends XMLBasedAjcTestCase {
protected java.net.URL getSpecFile() {
return getClassResource("ajc150.xml");
}
public void testITDReturningParameterizedType() {
runTest("ITD with parameterized type");
}
public void testPR91267_1() {
runTest("NPE using generic methods in aspects 1");
}
public void testParameterizedTypeAndAroundAdvice_PR115250() {
runTest("parameterized type and around advice");
}
@@ -202,29 +202,29 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testParameterizedTypeAndAroundAdvice_PR115250_2() {
runTest("parameterized type and around advice - 2");
}
public void testPR91267_2() {
runTest("NPE using generic methods in aspects 2");
}
public void testPR91053() {
runTest("Generics problem with Set");
}
public void testPR87282() {
runTest("Compilation error on generic member introduction");
}
public void testGenericsOverrides_1() { runTest("generics and ITD overrides - 1"); }
public void testGenericsOverrides_2() { runTest("generics and ITD overrides - 2"); }
public void testGenericsOverrides_3() { runTest("generics and ITD overrides - 3"); }
public void testGenericsOverrides_4() { runTest("generics and ITD overrides - 4"); }

public void testSelfBoundGenerics_pr117296() {

public void testSelfBoundGenerics_pr117296() {
runTest("self bounding generic types");
}
public void testPR88606() {
runTest("Parameterized types on introduced fields not correctly recognized");
}
@@ -235,14 +235,14 @@ public class GenericsTests extends XMLBasedAjcTestCase {

public void testGenericsBang_pr95993() {
runTest("NPE at ClassScope.java:660 when compiling generic class");
}
}
// generic aspects
public void testPR96220_GenericAspects1() {runTest("generic aspects - 1");}
public void testPR96220_GenericAspects2() {runTest("generic aspects - 2");}
public void testPR96220_GenericAspects3() {runTest("generic aspects - 3");}
public void testGenericAspects4() {runTest("generic aspects - 4");}
public void testGenericAspects4() {runTest("generic aspects - 4");}
public void testGenericAspects5() {runTest("generic aspects - 5 (ajdk)");} // in separate files
public void testGenericAspects6() {runTest("generic aspects - 6 (ajdk)");} // all in one file
public void testTypeVariablesInDeclareWarning() { runTest("generic aspect with declare warning using type vars");}
@@ -254,12 +254,12 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testDeclareSoftInGenericAspect() {
runTest("generic aspect declare soft");
}
//////////////////////////////////////////////////////////////////////////////
// Generic/Parameterized ITDs - includes scenarios from developers notebook //
//////////////////////////////////////////////////////////////////////////////
// parsing of generic ITD members
public void testParseItdNonStaticMethod() {runTest("Parsing generic ITDs - 1");}
public void testParseItdStaticMethod() {runTest("Parsing generic ITDs - 2");}
@@ -267,8 +267,8 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testParseItdComplexMethod() {runTest("Parsing generic ITDs - 4");}
public void testParseItdSharingVars1() {runTest("Parsing generic ITDs - 5");}
public void testParseItdSharingVars2() {runTest("Parsing generic ITDs - 6");}
// non static
public void testGenericMethodITD1() {runTest("generic method itd - 1");} // <E> ... (List<? extends E>)
public void testGenericMethodITD2() {runTest("generic method itd - 2");} // <E extends Number> ... (List<? extends E>) called incorrectly
@@ -285,7 +285,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testGenericMethodITD13() {runTest("generic method itd - 13");} // <R extends Comparable<? extends R>> ... (List<R>) called correctly in a clever way ;)
public void testGenericMethodITD14() {runTest("generic method itd - 14");} // <R extends Comparable<? super R>> ... (List<R>) called incorrectly in a clever way
public void testGenericMethodITD15() {runTest("generic method itd - 15");} // <R extends Comparable<? super R>> ... (List<R>) called correctly in a clever way


// generic ctors
@@ -293,29 +293,29 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testGenericCtorITD2() {runTest("generic ctor itd - 2");} // <T> new(List<T>,List<? extends T>)
public void testGenericCtorITD3() {runTest("generic ctor itd - 3");} // <T> new(List<T>,Comparator<? super T>)

// parameterized ITDs
public void testParameterizedMethodITD1() {runTest("parameterized method itd - 1");} // (List<? extends Super>)
public void testParameterizedMethodITD2() {runTest("parameterized method itd - 2");} // (List<? extends Number>) called incorrectly
public void testParameterizedMethodITD3() {runTest("parameterized method itd - 3");} // (List<? super A>) called incorrectly
public void testParameterizedMethodITD4() {runTest("parameterized method itd - 4");} // (List<? super B>)
// differing visibilities
public void testPublicITDs() {runTest("public itds");}
public void testPublicITDsErrors() {runTest("public itds with errors");}
public void testPrivateITDs() {runTest("private itds");}
public void testPackageITDs() {runTest("package itds");}
// targetting different types (interface/class/aspect)
public void testTargettingInterface() {runTest("targetting interface");}
public void testTargettingAspect() {runTest("targetting aspect");}
public void testTargettingClass() {runTest("targetting class");}
// using a type variable from the target generic type in your ITD
// using a type variable from the target generic type in your ITD
public void testFieldITDsUsingTargetTypeVars1() {runTest("field itd using type variable from target type - 1");}
public void testFieldITDsUsingTargetTypeVars2() {runTest("field itd using type variable from target type - 2");}
public void testFieldITDsUsingTargetTypeVars3() {runTest("field itd using type variable from target type - 3");}
@@ -333,7 +333,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testFieldITDsUsingTargetTypeVars15(){runTest("field itd using type variable from target type -15");}
public void testFieldITDsUsingTargetTypeVars16(){runTest("field itd using type variable from target type -16");}
public void testFieldITDsUsingTargetTypeVars17(){runTest("field itd using type variable from target type -17");}

public void testMethodITDsUsingTargetTypeVarsA1() {runTest("method itd using type variable from target type - A1");}
public void testMethodITDsUsingTargetTypeVarsA2() {runTest("method itd using type variable from target type - A2");}
@@ -358,7 +358,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testMethodITDsUsingTargetTypeVarsO2() {runTest("method itd using type variable from target type - O2");}
public void testMethodITDsUsingTargetTypeVarsP1() {runTest("method itd using type variable from target type - P1");}
public void testMethodITDsUsingTargetTypeVarsQ1() {runTest("method itd using type variable from target type - Q1");}
public void testCtorITDsUsingTargetTypeVarsA1() {runTest("ctor itd using type variable from target type - A1");}
public void testCtorITDsUsingTargetTypeVarsB1() {runTest("ctor itd using type variable from target type - B1");}
public void testCtorITDsUsingTargetTypeVarsC1() {runTest("ctor itd using type variable from target type - C1");}
@@ -368,7 +368,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testCtorITDsUsingTargetTypeVarsG1() {runTest("ctor itd using type variable from target type - G1");}
public void testCtorITDsUsingTargetTypeVarsH1() {runTest("ctor itd using type variable from target type - H1");}
public void testCtorITDsUsingTargetTypeVarsI1() {runTest("ctor itd using type variable from target type - I1");}
public void testSophisticatedAspectsA() {runTest("uberaspects - A");}
public void testSophisticatedAspectsB() {runTest("uberaspects - B");}
public void testSophisticatedAspectsC() {runTest("uberaspects - C");}
@@ -395,13 +395,13 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testSophisticatedAspectsW() {runTest("uberaspects - W");}
public void testSophisticatedAspectsX() {runTest("uberaspects - X");} // from the AJDK
public void testSophisticatedAspectsY() {runTest("uberaspects - Y");} // pointcut matching
public void testSophisticatedAspectsZ() {runTest("uberaspects - Z");}
public void testSophisticatedAspectsZ() {runTest("uberaspects - Z");}
// FIXME asc these two tests have peculiar error messages - generic aspect related
// public void testItdUsingTypeParameter() {runTest("itd using type parameter");}
// public void testItdIncorrectlyUsingTypeParameter() {runTest("itd incorrectly using type parameter");}
public void testUsingSameTypeVariable() {runTest("using same type variable in ITD");}

public void testBinaryWeavingITDsA() {runTest("binary weaving ITDs - A");}
@@ -409,17 +409,17 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testBinaryWeavingITDs1() {runTest("binary weaving ITDs - 1");}
public void testBinaryWeavingITDs2() {runTest("binary weaving ITDs - 2");}
public void testBinaryWeavingITDs3() {runTest("binary weaving ITDs - 3");}
public void testGenericITFSharingTypeVariable() {runTest("generic intertype field declaration, sharing type variable");}
public void testGenericITFSharingTypeVariable() {runTest("generic intertype field declaration, sharing type variable");}
// general tests ... usually just more complex scenarios
public void testReusingTypeVariableLetters() {runTest("reusing type variable letters");}
public void testMultipleGenericITDsInOneFile() {runTest("multiple generic itds in one file");}
public void testItdNonStaticMember() {runTest("itd of non static member");}
public void testItdStaticMember() {runTest("itd of static member");}
public void testStaticGenericMethodITD() {runTest("static generic method itd");}
public void testAtOverride0() {runTest("atOverride used with ITDs");}
public void testAtOverride1() {runTest("atOverride used with ITDs - 1");}
public void testAtOverride2() {runTest("atOverride used with ITDs - 2");}
@@ -428,8 +428,8 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testAtOverride5() {runTest("atOverride used with ITDs - 5");}
public void testAtOverride6() {runTest("atOverride used with ITDs - 6");}
public void testAtOverride7() {runTest("atOverride used with ITDs - 7");}
// bridge methods
public void testITDBridgeMethodsCovariance1() {runTest("bridging with covariance 1 - normal");}
public void testITDBridgeMethodsCovariance2() {runTest("bridging with covariance 1 - itd");}
@@ -438,8 +438,8 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testITDBridgeMethods2Normal() {runTest("basic bridging with type vars - 2 - normal");}
public void testITDBridgeMethods2Itd() {runTest("basic bridging with type vars - 2 - itd");}
public void testITDBridgeMethodsPr91381() {runTest("Abstract intertype method and covariant returns");}
// Just normal source compile of two types with a method override between them
public void testGenericITDsBridgeMethods1() {
runTest("bridge methods - 1");
@@ -450,7 +450,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
// Now the same thing but the aspect (which doesn't do much!) is binary woven in.
public void testGenericITDsBridgeMethods1binary() {
runTest("bridge methods - 1 - binary");
checkMethodsExist("Sub1",new String[]{
checkMethodsExist("Sub1",new String[]{
"java.lang.Integer Sub1.m()",
"java.lang.Object Sub1.m() [BridgeMethod]"});
}
@@ -482,7 +482,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
"java.lang.Integer Sub3.m()",
"java.lang.Object Sub3.m() [BridgeMethod]"});
}
// Now the two types are disconnected until the aspect supplies a declare parents relationship -
// Now the two types are disconnected until the aspect supplies a declare parents relationship -
// the bridge method should still be created in the subtype
public void testGenericITDSBridgeMethods4() {
runTest("bridge methods - 4");
@@ -497,7 +497,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
"java.lang.Integer Sub4.m()",
"java.lang.Object Sub4.m() [BridgeMethod]"});
}
public void testBinaryBridgeMethodsOne() {
runTest("binary bridge methods - one");
checkMethodsExist("OneB",new String[]{
@@ -526,21 +526,21 @@ public class GenericsTests extends XMLBasedAjcTestCase {
"java.lang.Double ThreeB.m()"
});
}
public void testGenericITDsBridgeMethodsPR91381() {runTest("abstract intertype methods and covariant returns");}
public void testGenericITDsBridgeMethodsPR91381_2() {runTest("abstract intertype methods and covariant returns - error");}

// ----------------------------------------------------------------------------------------
// generic declare parents tests
// ----------------------------------------------------------------------------------------
public void testPR96220_GenericDecp() {
runTest("generic decp - simple");
checkOneSignatureAttribute(ajc,"Basic");
verifyClassSignature(ajc,"Basic","Ljava/lang/Object;LJ<Ljava/lang/Double;>;LI<Ljava/lang/Double;>;");
}
// Both the existing type decl and the one adding via decp are parameterized
public void testGenericDecpMultipleVariantsOfAParameterizedType1() {
runTest("generic decp - implementing two variants #1");
@@ -560,12 +560,12 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testGenericDecpMultipleVariantsOfAParameterizedType4() {
runTest("generic decp - implementing two variants #4");
}
// same as above four tests for binary weaving
public void testGenericDecpMultipleVariantsOfAParameterizedType1_binaryWeaving() {
runTest("generic decp binary - implementing two variants #1");
}
public void testGenericDecpMultipleVariantsOfAParameterizedType2_binaryWeaving() {
runTest("generic decp binary - implementing two variants #2");
}
@@ -585,19 +585,19 @@ public class GenericsTests extends XMLBasedAjcTestCase {
checkOneSignatureAttribute(ajc,"Basic6");
verifyClassSignature(ajc,"Basic6","<J:Ljava/lang/Object;>Ljava/lang/Object;LI<TJ;>;LK<Ljava/lang/Integer;>;");
}
public void testGenericDecpIncorrectNumberOfTypeParams() {
runTest("generic decp - incorrect number of type parameters");
}
public void testGenericDecpSpecifyingBounds() {
runTest("generic decp - specifying bounds");
}
public void testGenericDecpViolatingBounds() {
runTest("generic decp - specifying bounds but breaking them");
}
// need separate compilation test to verify signatures are ok
//
// public void testIllegalGenericDecp() {
@@ -607,18 +607,18 @@ public class GenericsTests extends XMLBasedAjcTestCase {
// public void testPR95992_TypeResolvingProblemWithGenerics() {
// runTest("Problems resolving type name inside generic class");
// }

// -- Pointcut tests...

public void testHandlerWithGenerics() {
runTest("handler pcd and generics / type vars");
}
public void testPointcutsThatDontAllowTypeVars() {
runTest("pointcuts that dont allow type vars");
}
public void testParameterizedTypesInAtPCDs() {
runTest("annotation pcds with parameterized types");
}
@@ -626,7 +626,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testAnnotationPatternsWithParameterizedTypes() {
runTest("annotation patterns with parameterized types");
}
public void testStaticInitializationWithParameterizedTypes() {
runTest("staticinitialization and parameterized types");
}
@@ -643,9 +643,9 @@ public class GenericsTests extends XMLBasedAjcTestCase {

// no longer a valid test in simplified design
// public void testStaticInitializationWithGenericTypesAdvanced() {
// runTest("staticinitialization with generic types - advanced");
// runTest("staticinitialization with generic types - advanced");
// }
public void testWithinPointcutErrors() {
runTest("within pcd with various parameterizations and generic types - errors");
}
@@ -653,7 +653,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testWithinPointcutWarnings() {
runTest("within pcd with various parameterizations and generic types - warnings");
}
public void testThisTargetPointcutErrors() {
runTest("this and target with various parameterizations and generic types - errors");
}
@@ -661,47 +661,47 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testThisTargetPointcutRuntime() {
runTest("this and target with various parameterizations and generic types - runtime");
}
public void testInitAndPreInitPointcutErrors() {
runTest("init and preinit with parameterized declaring types");
}
public void testInitAndPreInitPointcutMatchingWithGenericDeclaringTypes() {
runTest("init and preinit with raw declaring type pattern");
}
public void testInitAndPreInitPointcutMatchingWithParameterizedParameterTypes() {
runTest("init and preinit with parameterized parameter types");
}
public void testWithinCodePointcutErrors() {
runTest("withincode with various parameterizations and generic types - errors");
}
public void testWithinCodeMatching() {
runTest("withincode with various parameterizations and generic types - matching");
}
public void testWithinCodeOverrideMatchingWithGenericMembers() {
runTest("withincode with overriding of inherited generic members");
}
public void testExecutionWithRawType() {
runTest("execution pcd with raw type matching");
}
public void testExecutionWithRawSignature() {
runTest("execution pcd with raw signature matching");
}
public void testExecutionPointcutErrors() {
runTest("execution with various parameterizations and generic types - errors");
}
public void testExecutionMatching() {
runTest("execution with various parameterizations and generic types - matching");
}
public void testExecutionOverrideMatchingWithGenericMembers() {
runTest("execution with overriding of inherited generic members");
}
@@ -709,15 +709,15 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testCallPointcutErrors() {
runTest("call with various parameterizations and generic types - errors");
}
public void testCallMatching() {
runTest("call with various parameterizations and generic types - matching");
}
public void testCallOverrideMatchingWithGenericMembers() {
runTest("call with overriding of inherited generic members");
}
public void testCallWithBridgeMethods() {
runTest("call with bridge methods");
}
@@ -725,47 +725,47 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testGetAndSetPointcutErrors() {
runTest("get and set with various parameterizations and generic types - errors");
}
public void testGetAndSetPointcutMatchingWithGenericAndParameterizedTypes() {
runTest("get and set with various parameterizations and generic declaring types");
}
public void testGetAndSetPointcutMatchingWithGenericAndParameterizedFieldTypes() {
runTest("get and set with various parameterizations and generic field types");
}
public void testArgsWithRawType() {
runTest("args with raw type and generic / parameterized sigs");
}
public void testArgsParameterizedType() {
runTest("args with parameterized type and generic / parameterized sigs");
}
public void testArgsParameterizedAndWildcards() {
runTest("args with parameterized type and wildcards");
}
public void testArgsWithWildcardVar() {
runTest("args with generic wildcard");
}
public void testArgsWithWildcardExtendsVar() {
runTest("args with generic wildcard extends");
}
public void testArgsWithWildcardSuperVar() {
runTest("args with generic wildcard super");
}
public void testGenericMethodMatching() {
runTest("generic method matching");
}
public void testGenericWildcardsInSignatureMatching() {
runTest("generic wildcards in signature matching");
}
public void testAfterThrowing() {
runTest("after throwing with parameterized throw type");
}
@@ -773,108 +773,108 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public void testAfterReturningWithRawType() {
runTest("after returning with raw type and generic / parameterized sigs");
}
public void testAfterReturningParameterizedType() {
runTest("after returning with parameterized type and generic / parameterized sigs");
}
public void testAfterReturningParameterizedAndWildcards() {
runTest("after returning with parameterized type and wildcards");
}

public void testAfterReturningWithWildcardVar() {
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
// See ReferenceType.isCoerceableFrom comments
return;
}
// Something to investigate here. The implementation of isCoerceable
runTest("after returning with generic wildcard");
}
public void testAfterReturningWithWildcardExtendsVar() {
runTest("after returning with generic wildcard extends");
}
public void testAfterReturningWithWildcardSuperVar() {
runTest("after returning with generic wildcard super");
}
public void testAJDKErasureMatchingExamples() {
runTest("ajdk notebook: erasure matching examples");
}
public void testAJDKParameterizedMatchingSimpleExamples() {
runTest("ajdk notebook: simple parameterized type matching examples");
}
public void testAJDKMixedTypeVarsAndParametersExample() {
runTest("ajdk notebook: mixed parameterized types and generic methods");
}
public void testAJDKSignatureAndWildcardExamples() {
runTest("ajdk notebook: signature matching with generic wildcards");
}
// had to remove at e37 level - although pointcuts are likely to work, we can't compile the code
// that invokes the bridge methods - seems the compiler is too smart and won't let them through.
// public void testAJDKBridgeMethodExamples() {
// runTest("ajdk notebook: bridge method examples");
// }
public void testAJDKArgsExamples() {
runTest("ajdk notebook: args examples");
}
public void testAJDKArgsAndWildcardsExamples() {
runTest("ajdk notebook: args and wildcards examples");
}
public void testAJDKAfterReturningExamples() {
runTest("ajdk notebook: after returning examples");
}
public void testAJDKPointcutInGenericClassExample() {
runTest("ajdk notebook: pointcut in generic class example");
}
// TESTS for generic abstract aspects that get extended and parameterized...
public void testStaticPointcutParameterization() {
runTest("static pointcut parameterization suite");
}
public void testDynamicPointcutParameterization() {
runTest("dynamic pointcut parameterization suite");
}
public void testReferenceToPointcutInGenericClass() {
runTest("reference to pointcut in generic class");
}
public void testReferenceToPointcutInGenericClass2() {
runTest("reference to non-parameterized pointcut in generic class");
}
public void testDeclareParentsParameterized() {
runTest("declare parents parameterized");
}
public void testDeclarePrecedenceParameterized() {
public void testDeclarePrecedenceParameterized() {
runTest("declare precedence parameterized");
}
public void testDeclareAnnotationParameterized() {
runTest("declare annotation parameterized");
}
public void testMultiLevelGenericAspects() {
runTest("multi-level generic abstract aspects");
}
// --- helpers
/**
* When a class has been written to the sandbox directory, you can ask this method to
* When a class has been written to the sandbox directory, you can ask this method to
* verify it contains a particular set of methods. Typically this is used to verify that
* bridge methods have been created.
*/
@@ -899,7 +899,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
} catch (MalformedURLException e) {
e.printStackTrace();
}
// check the methods specified do exist
for (String string : methods) {
if (!methodsFound.remove(string)) {
@@ -913,9 +913,9 @@ public class GenericsTests extends XMLBasedAjcTestCase {
}
fail("These methods weren't expected: "+unexpectedMethods);
}
}
/**
* Use 1.5 API isBridge if available.
* See JLS3 15.12.4.5 Create Frame, Synchronize, Transfer Control
@@ -924,7 +924,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
// why not importing java.lang.reflect.Method? No BCEL clash?
try {
final Class<?>[] noparms = new Class[0];
java.lang.reflect.Method isBridge
java.lang.reflect.Method isBridge
= java.lang.reflect.Method.class.getMethod("isBridge", noparms);
Boolean result = (Boolean) isBridge.invoke(m, new Object[0]);
return result;
@@ -934,7 +934,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
}
public static JavaClass getClass(Ajc ajc, String classname) {
try {
ClassPath cp =
ClassPath cp =
new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path"));
SyntheticRepository sRepos = SyntheticRepository.getInstance(cp);
JavaClass clazz = sRepos.loadClass(classname);
@@ -944,7 +944,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
}
return null;
}
public static Signature getClassSignature(Ajc ajc,String classname) {
JavaClass clazz = getClass(ajc,classname);
Signature sigAttr = null;
@@ -954,7 +954,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
}
return sigAttr;
}
public static void checkOneSignatureAttribute(Ajc ajc,String classname) {
JavaClass clazz = getClass(ajc,classname);
Attribute[] attrs = clazz.getAttributes();
@@ -968,15 +968,15 @@ public class GenericsTests extends XMLBasedAjcTestCase {
}
if (signatureCount>1) fail("Should be only one signature attribute but found "+signatureCount+sb.toString());
}
// Check the signature attribute on a class is correct
public static void verifyClassSignature(Ajc ajc,String classname,String sig) {
Signature sigAttr = getClassSignature(ajc,classname);
assertTrue("Failed to find signature attribute for class "+classname,sigAttr!=null);
assertTrue("Expected signature to be '"+sig+"' but was '"+sigAttr.getSignature()+"'",
sigAttr.getSignature().equals(sig));
sigAttr.getSignature().equals(sig));
}
private static String stringify(Class<?>[] clazzes) {
if (clazzes==null) return "";
StringBuffer sb = new StringBuffer();

+ 2
- 2
tests/src/test/java/org/aspectj/systemtest/apt/AptTests.java View File

@@ -23,7 +23,7 @@ import junit.framework.Test;
public class AptTests extends XMLBasedAjcTestCase {

public void testAptWithSpecifiedProcessor() {
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
return;
}
runTest("annotation processing with specified processor");
@@ -33,7 +33,7 @@ public class AptTests extends XMLBasedAjcTestCase {
* SPI - http://docs.oracle.com/javase/tutorial/sound/SPI-intro.html
*/
public void testAptUsingSPI() {
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
return;
}
runTest("annotation processing in action using SPI");

+ 9
- 9
tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java View File

@@ -1,11 +1,11 @@
/********************************************************************
* Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version (bug 148190)
*******************************************************************/
package org.aspectj.systemtest.incremental.tools;
@@ -75,7 +75,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio
+ "c:/batik/batik-1.6/lib/batik-svggen.jar;" + File.pathSeparator + ".." + File.separator + "lib" + File.separator
+ "test" + File.separator + "aspectjrt.jar";
verifyClasspath(cp);
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
cp = LangUtil.getJrtFsFilePath() + File.pathSeparator + cp;
}

@@ -178,7 +178,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio
this.outjar = outjar;
this.changed |= ICompilerConfiguration.OUTJAR_CHANGED;
}
public void setProcessor(String processor) {
this.processor = processor;
this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;

+ 1
- 1
tests/src/test/java/org/aspectj/tests/TestsModuleTests.java View File

@@ -26,7 +26,7 @@ public class TestsModuleTests extends TestCase {
String name = TestsModuleTests.class.getName();
TestSuite suite = new TestSuite(name);
// compiler tests, wrapped for JUnit
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
suite.addTest(AllTests19.suite());
} else {
suite.addTest(AllTests18.suite());

+ 10
- 6
util/src/main/java/org/aspectj/util/LangUtil.java View File

@@ -126,7 +126,7 @@ public class LangUtil {
}

@Deprecated
public static boolean isOnePointThreeVMOrGreater() {
public static boolean is1dot3VMOrGreater() {
return 1.3 <= vmVersion;
}

@@ -136,25 +136,25 @@ public class LangUtil {
}

@Deprecated
public static boolean is15VMOrGreater() {
public static boolean is1dot5VMOrGreater() {
return 1.5 <= vmVersion;
}

@Deprecated
public static boolean is16VMOrGreater() {
public static boolean is1dot6VMOrGreater() {
return 1.6 <= vmVersion;
}

@Deprecated
public static boolean is17VMOrGreater() {
public static boolean is1dot7VMOrGreater() {
return 1.7 <= vmVersion;
}

public static boolean is18VMOrGreater() {
public static boolean is1dot8VMOrGreater() {
return 1.8 <= vmVersion;
}

public static boolean is19VMOrGreater() {
public static boolean is9VMOrGreater() {
return 9 <= vmVersion;
}

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

public static boolean is15VMOrGreater() {
return 15 <= vmVersion;
}

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

+ 2
- 2
util/src/test/java/org/aspectj/util/LangUtilTest.java View File

@@ -101,9 +101,9 @@ public class LangUtilTest extends TestCase {
// }

public void testVersion() {
assertTrue(LangUtil.is18VMOrGreater()); // min vm now - floor may change
assertTrue(LangUtil.is1dot8VMOrGreater()); // min vm now - floor may change
if (LangUtil.is11VMOrGreater()) {
assertTrue(LangUtil.is19VMOrGreater());
assertTrue(LangUtil.is9VMOrGreater());
assertTrue(LangUtil.is10VMOrGreater());
}
}

+ 1
- 1
weaver/src/main/java/org/aspectj/weaver/bcel/ClassPathManager.java View File

@@ -351,7 +351,7 @@ public class ClassPathManager {
String jdkHome = new File(jrtFsPath).getParentFile().getParent();
FileSystem fs = null;
try {
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
Map<String, String> env = new HashMap<>();
env.put("java.home", jdkHome);
fs = FileSystems.newFileSystem(JRT_URI, env);

+ 2
- 2
weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java View File

@@ -149,7 +149,7 @@ public class WeavingAdaptor implements IMessageContext {
}
// On Java9 it is possible to fail to find a URLClassLoader from which to derive a suitable classpath
// For now we can determine it from the java.class.path:
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
list.add(0, LangUtil.getJrtFsFilePath());
List<String> javaClassPathEntries = makeClasspath(System.getProperty("java.class.path"));
for (int i=javaClassPathEntries.size()-1;i>=0;i--) {
@@ -945,4 +945,4 @@ public class WeavingAdaptor implements IMessageContext {
public void setActiveProtectionDomain(ProtectionDomain protectionDomain) {
activeProtectionDomain = protectionDomain;
}
}
}

+ 10
- 10
weaver/src/test/java/org/aspectj/weaver/WeaverModuleTests.java View File

@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* 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:
* PARC initial implementation
* 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:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver;

@@ -110,7 +110,7 @@ public class WeaverModuleTests extends TestCase {
suite.addTestSuite(FieldSetTestCase.class);
suite.addTestSuite(HierarchyDependsTestCase.class);
suite.addTestSuite(IdWeaveTestCase.class);
if (LangUtil.is19VMOrGreater()) {
if (LangUtil.is9VMOrGreater()) {
suite.addTestSuite(JImageTestCase.class);
}
suite.addTestSuite(MegaZipTestCase.class);
@@ -125,7 +125,7 @@ public class WeaverModuleTests extends TestCase {
suite.addTestSuite(WorldTestCase.class);
suite.addTestSuite(ZipTestCase.class);
suite.addTestSuite(TypeXTestCase.class);
suite.addTestSuite(AnnotationPatternMatchingTestCase.class);
suite.addTestSuite(AnnotationPatternTestCase.class);
suite.addTestSuite(ConcretizationTestCase.class);

+ 18
- 18
weaver/src/test/java/org/aspectj/weaver/bcel/JImageTestCase.java View File

@@ -1,10 +1,10 @@
/* *******************************************************************
* Copyright (c) 2017 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
* 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.weaver.bcel;

@@ -35,7 +35,7 @@ import junit.framework.TestCase;

/**
* Exercise the JImage handling in @link {@link org.aspectj.weaver.bcel.ClassPathManager}.
*
*
* @author Andy Clement
*/
public class JImageTestCase extends TestCase {
@@ -47,15 +47,15 @@ public class JImageTestCase extends TestCase {
paths.add(LangUtil.getJrtFsFilePath());
cpm = new ClassPathManager(paths,new TestMessageHandler());
}
public void testOnJava9() {
if (!LangUtil.is19VMOrGreater()) {
if (!LangUtil.is9VMOrGreater()) {
System.out.println("SKIPPING JIMAGE TESTS AS NOT ON 1.9 OR LATER");
}
}
public void testBasicStructureAndCapabilities() {
if (!LangUtil.is19VMOrGreater()) return;
public void testBasicStructureAndCapabilities() {
if (!LangUtil.is9VMOrGreater()) return;
// Should be one entry for finding JRT contents
List<Entry> entries = cpm.getEntries();
assertEquals(1,entries.size());
@@ -65,11 +65,11 @@ public class JImageTestCase extends TestCase {
assertNotNull(stringClassFile);
assertEquals("java/lang/String.class",stringClassFile.getPath());
}
public void testBehaviour() throws Exception {
if (!LangUtil.is19VMOrGreater()) return;
if (!LangUtil.is9VMOrGreater()) return;
JImageEntry jie = getJImageEntry();
Map<String, Path> packageCache = jie.getPackageCache();
assertTrue(packageCache.size()>0);
// Note: seems to be about 1625 entries in it for Java9
@@ -77,12 +77,12 @@ public class JImageTestCase extends TestCase {
assertEquals("modules/java.base/java/lang", path.toString());
path = packageCache.get("java/io");
assertEquals("modules/java.base/java/io", path.toString());
assertNotNull(jie.find("java/lang/String"));
assertNotNull(jie.find("java/io/File"));
// TODO test the filecache, hard because difficult to simulate collection of SoftReferences
}

static class TestMessageHandler implements IMessageHandler {

@@ -103,11 +103,11 @@ public class JImageTestCase extends TestCase {
@Override
public void ignore(Kind kind) {
}
}

// ---
private JImageEntry getJImageEntry() {
return (JImageEntry) cpm.getEntries().get(0);
}

Loading…
Cancel
Save