/********************************************************************
- * 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;
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"));
/********************************************************************
- * 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;
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;
<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>
<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>
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;
/**
*/
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";
}
}
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);
}
/********************************************************************
- * 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;
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
/**
* 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) {
}
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
*/
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();
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
}
/**
- * 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()"
* 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;
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);
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()"
* @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;
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)) {
}
/**
- * 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()"
* 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;
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());
reader.close();
return false;
}
-
+
}
/********************************************************************
- * 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;
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");
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")) {
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());
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) {
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");
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>"));
}
/**
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()) {
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>"));
}
/**
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");
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>"));
}
/**
/*******************************************************************************
* 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
*******************************************************************************/
}
public void testJrockitRecursionProtection() {
- if (LangUtil.is19VMOrGreater()) {
+ if (LangUtil.is9VMOrGreater()) {
// Skip test, not castable to URLClassLoader
return;
}
/* *******************************************************************
* 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;
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);
}
return ret;
}
-
+
public List<String> getModulepath(AjcConfigParser parser) {
List<String> ret = new ArrayList<>();
addClasspath(parser.modulepath, ret);
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).
public List getUnparsedArgs() {
return unparsedArgs;
}
-
+
public String getModuleInfoArgument() {
return this.moduleInfoArgument;
}
}
}
-
+
@Override
public boolean checkVMVersion(long minimalSupportedVersion) {
return super.checkVMVersion(minimalSupportedVersion);
}
-
+
@Override
public void initRootModules(LookupEnvironment environment, FileSystem fileSystem) {
super.initRootModules(environment, fileSystem);
/* *******************************************************************
* 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;
/**
* Constructor for CommandTestCase.
- *
+ *
* @param name
*/
public CommandTestCase(String name) {
protected void runMain(String className) {
TestUtil.runMain(getSandboxName(), className);
}
-
+
public void checkCompile(String source, String[] extraArgs, int[] expectedErrors) {
checkCompile(source,extraArgs,expectedErrors,getSandboxName());
}
/** 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());
args = newargs;
}
}
- boolean needsJRTFS = LangUtil.is19VMOrGreater();
+ boolean needsJRTFS = LangUtil.is9VMOrGreater();
if (needsJRTFS) {
if (!args[cpIndex].contains(LangUtil.JRT_FS)) {
String jrtfsPath = LangUtil.getJrtFsFilePath();
<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>
/* *******************************************************************
- * 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;
*/
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) {
} catch (IOException e) {
e.printStackTrace(System.err);
}
- }
+ }
try {
return (AjcTest.Suite.Spec) result.clone();
} catch (CloneNotSupportedException e) {
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
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",
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",
};
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);
}
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"
};
}
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"
};
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.
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);
}
}
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);
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) {
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) {
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;
}
is16VMOrGreater = true;
is17VMOrGreater = true;
is18VMOrGreater = true;
- is19VMOrGreater = LangUtil.is19VMOrGreater();
+ is19VMOrGreater = LangUtil.is9VMOrGreater();
is10VMOrGreater = LangUtil.is10VMOrGreater();
is11VMOrGreater = LangUtil.is11VMOrGreater();
is12VMOrGreater = LangUtil.is12VMOrGreater();
/* *******************************************************************
* 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;
/**
* Makes sure tests are running on the right level of JDK.
- *
+ *
* @author Andy Clement
*/
public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTestCase {
@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);
}
-
+
}
/* *******************************************************************
* 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;
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);
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());
static boolean doWait(IMessageHolder holder, int seconds, int timeout) {
return AjcTaskCompileCommand
- .waitUntilMessagesQuiet(holder, seconds, timeout);
+ .waitUntilMessagesQuiet(holder, seconds, timeout);
}
public AjcTaskCompileCommandTest(String name) {
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);
}
}
runTest(list, expectedErrors);
}
-
+
void runTest(ArrayList<String> args, int expectedErrors) {
AjcTaskCompileCommand command =
new AjcTaskCompileCommand();
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);
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 {
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
}
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);
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
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)
int getNumAdded() {
return numAdded;
}
-
+
public String toString() {
return "MessageAdder("
+ "numAdded=" + numAdded
+ ", stop=" + stop
+ ", wait=" + wait
+ ", numMessages="
- + (null == messages
- ? 0
+ + (null == messages
+ ? 0
: messages.numMessages(null, true))
+ ")";
- }
-}
\ No newline at end of file
+ }
+}
/*==========================================
* Generics test plan for pointcuts.
- *
+ *
* handler PASS
* - does not permit type var spec
* - does not permit generic type (fail with type not found)
* 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
* 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
* - 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
* - 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
* 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);
}
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");
}
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");
}
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");}
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");}
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
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
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");}
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");}
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");}
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");}
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");}
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");}
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");}
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");
// 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]"});
}
"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");
"java.lang.Integer Sub4.m()",
"java.lang.Object Sub4.m() [BridgeMethod]"});
}
-
+
public void testBinaryBridgeMethodsOne() {
runTest("binary bridge methods - one");
checkMethodsExist("OneB",new String[]{
"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");
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");
}
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() {
// 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");
}
public void testAnnotationPatternsWithParameterizedTypes() {
runTest("annotation patterns with parameterized types");
}
-
+
public void testStaticInitializationWithParameterizedTypes() {
runTest("staticinitialization and parameterized types");
}
// 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");
}
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");
}
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");
}
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");
}
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");
}
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.
*/
} catch (MalformedURLException e) {
e.printStackTrace();
}
-
+
// check the methods specified do exist
for (String string : methods) {
if (!methodsFound.remove(string)) {
}
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
// 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;
}
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);
}
return null;
}
-
+
public static Signature getClassSignature(Ajc ajc,String classname) {
JavaClass clazz = getClass(ajc,classname);
Signature sigAttr = null;
}
return sigAttr;
}
-
+
public static void checkOneSignatureAttribute(Ajc ajc,String classname) {
JavaClass clazz = getClass(ajc,classname);
Attribute[] attrs = clazz.getAttributes();
}
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();
public class AptTests extends XMLBasedAjcTestCase {
public void testAptWithSpecifiedProcessor() {
- if (LangUtil.is19VMOrGreater()) {
+ if (LangUtil.is9VMOrGreater()) {
return;
}
runTest("annotation processing with specified processor");
* 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");
/********************************************************************
- * 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;
+ "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;
}
this.outjar = outjar;
this.changed |= ICompilerConfiguration.OUTJAR_CHANGED;
}
-
+
public void setProcessor(String processor) {
this.processor = processor;
this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED;
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());
}
@Deprecated
- public static boolean isOnePointThreeVMOrGreater() {
+ public static boolean is1dot3VMOrGreater() {
return 1.3 <= vmVersion;
}
}
@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;
}
return 14 <= vmVersion;
}
+ public static boolean is15VMOrGreater() {
+ return 15 <= vmVersion;
+ }
+
/**
* Shorthand for "if null, throw IllegalArgumentException"
*
// }
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());
}
}
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);
}
// 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--) {
public void setActiveProtectionDomain(ProtectionDomain protectionDomain) {
activeProtectionDomain = protectionDomain;
}
-}
\ No newline at end of file
+}
/* *******************************************************************
* 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;
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);
suite.addTestSuite(WorldTestCase.class);
suite.addTestSuite(ZipTestCase.class);
suite.addTestSuite(TypeXTestCase.class);
-
+
suite.addTestSuite(AnnotationPatternMatchingTestCase.class);
suite.addTestSuite(AnnotationPatternTestCase.class);
suite.addTestSuite(ConcretizationTestCase.class);
/* *******************************************************************
* 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;
/**
* Exercise the JImage handling in @link {@link org.aspectj.weaver.bcel.ClassPathManager}.
- *
+ *
* @author Andy Clement
*/
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());
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
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 {
@Override
public void ignore(Kind kind) {
}
-
+
}
// ---
-
+
private JImageEntry getJImageEntry() {
return (JImageEntry) cpm.getEntries().get(0);
}