<artifactId>asm</artifactId>
<version>1.0</version>
<scope>system</scope>
- <systemPath>${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar</systemPath>
+ <systemPath>${project.basedir}/../lib/asm/asm-7.2.renamed.jar</systemPath>
</dependency>
</dependencies>
</project>
/* *******************************************************************
- * 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
* Mik Kersten port to AspectJ 1.1+ code base
* ******************************************************************/
/**
* Before attempting to decorate the HTML file we have to verify that it exists, which depends on the documentation visibility
* specified to c.
- *
+ *
* Depending on docModifier, can document - public: only public - protected: protected and public (default) - package: package
* protected and public - private: everything
*/
// <h2 title="Class A" class="title">Class A</h2>
classStartIndex = fileContents.toString().indexOf("<h2 title=\"Class ");
int classEndIndex = fileContents.toString().indexOf("</h2>", classStartIndex);
+ if (classStartIndex == -1) {
+ // Java 13 - replaced h2 with h1 here
+ classStartIndex = fileContents.toString().indexOf("<h1 title=\"Class ");
+ classEndIndex = fileContents.toString().indexOf("</h1>", classStartIndex);
+ }
if (classEndIndex != -1) {
// Convert it to "<h2 title="Aspect A" class="title">Aspect A</h2>"
String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
insertDeclarationsSummary(fileBuffer, constDeclaredOn, ITD_CONSTRUCTOR_SUMMARY, index);
}
for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) {
- IProgramElement member = (IProgramElement) it.next();
+ IProgramElement member = it.next();
if (member.getKind().equals(IProgramElement.Kind.POINTCUT)) {
pointcuts.add(member);
} else if (member.getKind().equals(IProgramElement.Kind.ADVICE)) {
/**
* Generates a relative directory path fragment that can be used to navigate "upwards" from the directory location implied by
* the argument.
- *
+ *
* @param packagePath
* @return String consisting of multiple "../" parts, one for each component part of the input <code>packagePath</code>.
*/
* Generate the "public int"-type information about the given IProgramElement. Used when dealing with ITDs. To mirror the
* behaviour of methods and fields in classes, if we're generating the summary information we don't want to include "public" if
* the accessibility of the IProgramElement is public.
- *
+ *
*/
private static String generateModifierInformation(IProgramElement decl, boolean isDetails) {
String intro = "";
* the characters between the /** that begins the comment and the 'star-slash' that ends it. The text is devided into one or
* more lines. On each of these lines, the leading * characters are ignored; for lines other than the first, blanks and tabs
* preceding the initial * characters are also discarded.</I>
- *
+ *
* TODO: implement formatting or linking for tags.
*/
static String getFormattedComment(IProgramElement decl) {
static public IProgramElement[] getProgramElements(AsmManager model, String filename) {
- IProgramElement file = (IProgramElement) model.getHierarchy().findElementForSourceFile(filename);
+ IProgramElement file = model.getHierarchy().findElementForSourceFile(filename);
final List nodes = new ArrayList();
HierarchyWalker walker = new HierarchyWalker() {
public void preProcess(IProgramElement node) {
- IProgramElement p = (IProgramElement) node;
+ IProgramElement p = node;
if (accept(node))
nodes.add(p);
}
/* *******************************************************************
* 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:
- * Mik Kersten 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:
+ * Mik Kersten initial implementation
* ******************************************************************/
package org.aspectj.tools.ajdoc;
/**
* A long way to go until full coverage, but this is the place to add more.
- *
+ *
* @author Mik Kersten
*/
public class CoverageTestCase extends AjdocTestCase {
protected File file0,file1,aspect1,file2,file3,file4,file5,file6,file7,file8,file9,file10;
-
+
protected void setUp() throws Exception {
super.setUp();
initialiseProject("coverage");
createFiles();
}
-
+
public void testOptions() {
- String[] args = {
+ String[] args = {
"-private",
"-encoding",
"EUCJIS",
"UTF-8",
"-classpath",
AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
+ "-d",
getAbsolutePathOutdir(),
- file0.getAbsolutePath(),
+ file0.getAbsolutePath(),
};
org.aspectj.tools.ajdoc.Main.main(args);
assertTrue(true);
}
-
+
/**
- * Test the "-public" argument
+ * Test the "-public" argument
*/
public void testCoveragePublicMode() throws Exception {
File[] files = {file3,file9};
runAjdoc("public","9",files);
-
+
// have passed the "public" modifier as well as
// one public and one package visible class. There
// should only be ajdoc for the public class
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
// check there's no private fields within the file, that
// the file contains the getI() method but doesn't contain
// the private ClassBar, Bazz and Jazz classes.
assertTrue(htmlFile.getName() + " should not contain the private Bazz class",missing.contains("Bazz"));
assertTrue(htmlFile.getName() + " should not contain the private Jazz class",missing.contains("Jazz"));
}
-
+
/**
* Test that the ajdoc for an aspect has the title "Aspect"
*/
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/A.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
- }
+ }
assertTrue(htmlFile.getAbsolutePath() + " should have Aspect A as it's title",
AjdocOutputChecker.containsString(htmlFile,"Aspect A"));
}
-
+
/**
- * Test that the ajdoc for a class has the title "Class"
+ * Test that the ajdoc for a class has the title "Class"
*/
public void testAJdocHasClassTitle() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/C.java")};
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?");
- }
+ }
assertTrue(htmlFile.getAbsolutePath() + " should have Class C as it's title",
AjdocOutputChecker.containsString(htmlFile,"Class C"));
-
+
}
-
+
/**
* Test that the ajdoc for an inner aspect is entitled "Aspect" rather
- * than "Class", but that the enclosing class is still "Class"
+ * than "Class", but that the enclosing class is still "Class"
*/
public void testInnerAspect() throws Exception {
File[] files = {file1, file2};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/ClassA.InnerAspect.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
// ensure that the file is entitled "Aspect ClassA.InnerAspect" rather
// than "Class ClassA.InnerAspect"
-
+
String[] strings = null;
if (LangUtil.is18VMOrGreater()) {
strings = new String[] {
assertTrue(htmlFile.getName() + " should not have class in its subtitle",
missingStrings.contains("<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"));
}
-
+
// get the html file for the enclosing class
File htmlFileClass = new File(getAbsolutePathOutdir() + "/foo/ClassA.html");
if (!htmlFileClass.exists()) {
fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
// ensure that the file is entitled "Class ClassA" and
// has not been changed to "Aspect ClassA"
String[] classStrings = null;
-
- if (LangUtil.is18VMOrGreater()) {
+
+ if (LangUtil.is13VMOrGreater()) {
+ classStrings = new String[] {
+ "Class ClassA</h1>",
+ "public abstract class <span class=\"typeNameLabel\">ClassA</span>",
+ "Aspect ClassA</H2>",
+ "public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"};
+ } else if (LangUtil.is18VMOrGreater()) {
classStrings = new String[] {
"Class ClassA</h2>",
"public abstract class <span class=\"typeNameLabel\">ClassA</span>",
"Aspect ClassA</H2>",
"public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"};
- }
- else {
+ } else {
classStrings = new String[] {
"Class ClassA</H2>",
"public abstract class <B>ClassA</B><DT>extends java.lang.Object<DT>",
assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>"));
if (LangUtil.is18VMOrGreater()) {
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=\"typeNameLabel\">ClassA</span>"));
}
else {
assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
classMissing.contains("public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"));
}
}
-
+
/**
* Test that all the different types of advice appear
- * with the named pointcut in it's description
+ * with the named pointcut in it's description
*/
public void testAdviceNamingCoverage() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
-
- String[] strings = {
+
+ String[] strings = {
"after(): named..",
"afterReturning(int,int): namedWithArgs..",
"afterThrowing(): named..",
}
/**
- * Test that all the advises relationships appear in the
+ * Test that all the advises relationships appear in the
* Advice Detail and Advice Summary sections and that
- * the links are correct
+ * the links are correct
*/
public void testAdvisesRelationshipCoverage() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
"before(): methodExecutionP..",
"HREF=\"../foo/Point.html#setX(int)\"",
"before(): handlerP..",
"HREF=\"../foo/Point.html#doIt()\""
};
-
+
for (int i = 0; i < strings.length - 1; i = i+2) {
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"ADVICE DETAIL SUMMARY",strings[i],
HtmlDecorator.HtmlRelationshipKind.ADVISES,
strings[i+1]);
- assertTrue(strings[i] + " should advise " + strings[i+1] +
+ assertTrue(strings[i] + " should advise " + strings[i+1] +
" in the Advice Detail section", b);
}
-
+
for (int i = 0; i < strings.length - 1; i = i+2) {
boolean b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"ADVICE SUMMARY",strings[i],
HtmlDecorator.HtmlRelationshipKind.ADVISES,
strings[i+1]);
- assertTrue(strings[i] + " should advise " + strings[i+1] +
+ assertTrue(strings[i] + " should advise " + strings[i+1] +
" in the Advice Summary section", b);
}
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a method execution pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a method execution pointcut
*/
public void testAdvisedByMethodExecution() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
toName("setX(int)"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): methodExecutionP..\""};
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
strings[1]);
assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
}
-
+
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a constructor execution pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a constructor execution pointcut
*/
public void testAdvisedByConstructorExecution() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""};
strings[1]);
assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b);
}
-
+
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a method call pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a method call pointcut
*/
public void testAdvisedByMethodCall() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
toName("changeX(int)"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callMethodP..\""};
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a constructor call pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a constructor call pointcut
*/
public void testAdvisedByConstructorCall() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
toName("doIt()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callConstructorP..\""};
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a get pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a get pointcut
*/
public void testAdvisedByGet() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
toName("getX()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): getP..\""};
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a set pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a set pointcut
*/
public void testAdvisedBySet() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): setP..\"";
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== METHOD DETAIL",
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
href);
assertTrue("the Method Detail should have setX(int) advised by " + href,b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
toName("setX(int)"),
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
href);
assertTrue("the Constructor Detail should have advised by " + href,b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== CONSTRUCTOR SUMMARY",
LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"),
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with an initialization pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with an initialization pointcut
*/
public void testAdvisedByInitialization() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""};
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a staticinitialization pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a staticinitialization pointcut
*/
public void testAdvisedByStaticInitialization() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): staticinitializationP..\"";
boolean b = AjdocOutputChecker.classDataSectionContainsRel(
htmlFile,
}
/**
- * Test that the advised by relationship appears in the ajdoc when the
- * advice is associated with a handler pointcut
+ * Test that the advised by relationship appears in the ajdoc when the
+ * advice is associated with a handler pointcut
*/
public void testAdvisedByHandler() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
toName("doIt()"),
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): handlerP..\""};
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
}
/**
* Test that if have two before advice blocks from the same
- * aspect affect the same method, then both appear in the ajdoc
+ * aspect affect the same method, then both appear in the ajdoc
*/
public void testTwoBeforeAdvice() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A2.aj")};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C2.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String[] strings = {
toName("amethod()"),
"HREF=\"../pkg/A2.html#before(): p..\"",
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[1]);
assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b);
-
+
b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== METHOD DETAIL",
strings[0],
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY,
strings[2]);
assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[2],b);
-
+
b = AjdocOutputChecker.summarySectionContainsRel(
htmlFile,"=== METHOD SUMMARY",
strings[0],
strings[2]);
assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[2],b);
}
-
+
/**
* Test that there are no spurious "advised by" entries
* against the aspect in the ajdoc
public void testNoSpuriousAdvisedByRels() throws Exception {
File[] files = {file4};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
}
-
+
String href = "foo.Point.setX(int)";
boolean b = AjdocOutputChecker.classDataSectionContainsRel(
htmlFile,
assertFalse("The class data section should not have 'advised by " + href + "'",b);
}
-
+
public void testCoverage() {
File[] files = {aspect1,file0,file1,file2,file3,file4,file5,file6,
file7,file8,file9,file10};
runAjdoc("private","1.6",files);
}
-
+
/**
* Test that nested aspects appear with "aspect" in their title
- * when the ajdoc file is written slightly differently (when it's
- * written for this apsect, it's different than for testInnerAspect())
+ * when the ajdoc file is written slightly differently (when it's
+ * written for this apsect, it's different than for testInnerAspect())
*/
public void testNestedAspect() throws Exception {
File[] files = {file9};
- runAjdoc("private",AJDocConstants.VERSION,files);
-
+ runAjdoc("private",AJDocConstants.VERSION,files);
+
File htmlFile = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.NestedAspect.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
// ensure that the file is entitled "Aspect PkgVisibleClass.NestedAspect" rather
// than "Class PkgVisibleClass.NestedAspect"
String[] strings = null;
if (LangUtil.is18VMOrGreater()) {
- strings = new String[] {
+ strings = new String[] {
"Aspect PkgVisibleClass.NestedAspect",
"<pre>static aspect <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>",
"Class PkgVisibleClass.NestedAspect",
"<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"};
}
else {
- strings = new String[] {
+ strings = new String[] {
"Aspect PkgVisibleClass.NestedAspect",
"<PRE>static aspect <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>",
"Class PkgVisibleClass.NestedAspect",
fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
// ensure that the file is entitled "Class PkgVisibleClass" and
// has not been changed to "Aspect PkgVisibleClass"
String[] classStrings = null;
+ if (LangUtil.is13VMOrGreater()) {
+ classStrings = new String[] {
+ "Class PkgVisibleClass</h1>",
+ "<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>",
+ "Aspect PkgVisibleClass</h2>",
+ "<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"};
+ } else
if (LangUtil.is18VMOrGreater()) {
classStrings = new String[] {
"Class PkgVisibleClass</h2>",
/**
* Test that in the case when you have a nested aspect whose
- * name is part of the enclosing class, for example a class called
+ * name is part of the enclosing class, for example a class called
* ClassWithNestedAspect has nested aspect called NestedAspect,
* that the titles for the ajdoc are correct.
*/
public void testNestedAspectWithSimilarName() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
- // ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect"
+ // ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect"
// rather than "Class ClassWithNestedAspect.NestedAspect"
String[] strings = null;
if (LangUtil.is18VMOrGreater()) {
"Aspect ClassWithNestedAspect.NestedAspect",
"<PRE>static a;spect <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>",
"Class ClassWithNestedAspect.NestedAspect",
- "<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"};
+ "<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"};
}
List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
assertEquals("There should be 2 missing strings",2,missing.size());
else {
assertTrue(htmlFile.getName() + " should not have class in its subtitle",missing.contains("<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"));
}
-
+
// get the html file for the enclosing class
File htmlFileClass = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
if (htmlFileClass == null || !htmlFileClass.exists()) {
fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
// ensure that the file is entitled "Class ClassWithNestedAspect" and
// has not been changed to "Aspect ClassWithNestedAspect"
String[] classStrings = null;
+ if (LangUtil.is13VMOrGreater()) {
+ classStrings = new String[] {
+ "Class ClassWithNestedAspect</h1>",
+ "public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>",
+ "Aspect ClassWithNestedAspect</h2>",
+ "public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"};
+ } else
if (LangUtil.is18VMOrGreater()) {
- classStrings = new String[] {
+ classStrings = new String[] {
"Class ClassWithNestedAspect</h2>",
"public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>",
"Aspect ClassWithNestedAspect</h2>",
"public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"};
}
else {
- classStrings = new String[] {
+ classStrings = new String[] {
"Class ClassWithNestedAspect</H2>",
"public class <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>",
"Aspect ClassWithNestedAspect</H2>",
classMissing.contains("public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>"));
}
}
-
+
/**
* Test that everythings being decorated correctly within the ajdoc
* for the aspect when the aspect is a nested aspect
public void testAdviceInNestedAspect() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
boolean b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"ADVICE DETAIL SUMMARY",
"before(): p..",
"' in the Advice Summary section", b);
}
-
+
/**
* Test that everythings being decorated correctly within the ajdoc
* for the advised class when the aspect is a nested aspect
public void testAdvisedByInNestedAspect() throws Exception {
File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")};
runAjdoc("private",AJDocConstants.VERSION,files);
-
+
File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
if (!htmlFile.exists()) {
fail("couldn't find " + htmlFile.getAbsolutePath()
+ " - were there compilation errors?");
}
-
+
boolean b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT SUMMARY ");
assertFalse(htmlFile.getName() + " should not contain a pointcut summary section",b);
b = AjdocOutputChecker.containsString(htmlFile,"ADVICE SUMMARY ");
assertFalse(htmlFile.getName() + " should not contain a pointcut detail section",b);
b = AjdocOutputChecker.containsString(htmlFile,"ADVICE DETAIL ");
assertFalse(htmlFile.getName() + " should not contain an advice detail section",b);
-
+
b = AjdocOutputChecker.detailSectionContainsRel(
htmlFile,"=== METHOD DETAIL",
toName("amethod()"),
" in the Method Summary section", b);
}
-
+
private void createFiles() {
file0 = new File(getAbsoluteProjectDir() + "/InDefaultPackage.java");
file1 = new File(getAbsoluteProjectDir() + "/foo/ClassA.java");
file9 = new File(getAbsoluteProjectDir() + "/foo/PkgVisibleClass.java");
file10 = new File(getAbsoluteProjectDir() + "/foo/NoMembers.java");
}
-
+
// public void testPlainJava() {
-// String[] args = { "-d",
+// String[] args = { "-d",
// getAbsolutePathOutdir(),
// file3.getAbsolutePath() };
// org.aspectj.tools.ajdoc.Main.main(args);
// }
-
+
}
<tasks>
<echo message="unzip jarjar'd asm" />
<unzip
- src="${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar"
+ src="${project.basedir}/../lib/asm/asm-7.2.renamed.jar"
dest="target/asm-unzipped" />
</tasks>
</configuration>
<tasks>
<echo message="unzip jarjar'd asm" />
<unzip
- src="${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar"
+ src="${project.basedir}/../lib/asm/asm-7.2.renamed.jar"
dest="target/asm-unzipped" />
</tasks>
</configuration>
/**
* Constants for the project, mostly defined in the JVM specification.
- *
+ *
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @author Andy Clement
*/
public final static short MINOR_11 = 0;
public final static short MAJOR_12 = 56;
public final static short MINOR_12 = 0;
-
+ public final static short MAJOR_13 = 57;
+ public final static short MINOR_13 = 0;
+
public final static int PREVIEW_MINOR_VERSION = 65535;
-
+
// Defaults
public final static short MAJOR = MAJOR_1_1;
public final static short MINOR = MINOR_1_1;
// Indicates that this dependence was implicitly declared in the source of
// the module declaration
public final static int MODULE_ACC_MANDATED = 0x8000;
-
+
// Applies to classes compiled by new compilers only
public final static short ACC_SUPER = 0x0020;
public final static byte CONSTANT_Methodref = 10;
public final static byte CONSTANT_InterfaceMethodref = 11;
public final static byte CONSTANT_NameAndType = 12;
-
+
public final static byte CONSTANT_MethodHandle = 15;
public final static byte CONSTANT_MethodType = 16;
public final static byte CONSTANT_Dynamic = 17;
public final static byte CONSTANT_InvokeDynamic = 18;
-
+
public final static byte CONSTANT_Module = 19;
public final static byte CONSTANT_Package = 20;
-
+
public final static String[] CONSTANT_NAMES = { "", "CONSTANT_Utf8", "", "CONSTANT_Integer", "CONSTANT_Float", "CONSTANT_Long",
"CONSTANT_Double", "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref", "CONSTANT_Methodref",
public static final byte ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS = 20;
public static final byte ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = 21;
public static final byte ATTR_METHOD_PARAMETERS = 22;
-
+
// J9:
public static final byte ATTR_MODULE = 23;
public static final byte ATTR_MODULE_PACKAGES = 24;
public static final short KNOWN_ATTRIBUTES = 28;
- public static final String[] ATTRIBUTE_NAMES = {
+ public static final String[] ATTRIBUTE_NAMES = {
"SourceFile", "ConstantValue", "Code", "Exceptions", "LineNumberTable", "LocalVariableTable",
"InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap",
"RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations", "RuntimeVisibleParameterAnnotations",
- "RuntimeInvisibleParameterAnnotations", "LocalVariableTypeTable", "EnclosingMethod",
+ "RuntimeInvisibleParameterAnnotations", "LocalVariableTypeTable", "EnclosingMethod",
"AnnotationDefault","BootstrapMethods", "RuntimeVisibleTypeAnnotations", "RuntimeInvisibleTypeAnnotations",
"MethodParameters", "Module", "ModulePackages", "ModuleMainClass", "NestHost", "NestMembers"
};
/**
* Search for classes in CLASSPATH.
- *
+ *
* @deprecated Use SYSTEM_CLASS_PATH constant
*/
@Deprecated
buf.append(File.pathSeparatorChar);
}
- // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem
+ // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem
if (vm_version.startsWith("9") || vm_version.startsWith("10")
- || vm_version.startsWith("11") || vm_version.startsWith("12")) {
+ || vm_version.startsWith("11")
+ || vm_version.startsWith("12")
+ || vm_version.startsWith("13")) {
buf.insert(0, File.pathSeparatorChar);
- buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS);
+ buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS);
}
return buf.toString().intern();
return dir;
}
}
-
+
private static class JImage extends PathEntry {
private static URI JRT_URI = URI.create("jrt:/"); //$NON-NLS-1$
private static String JAVA_BASE_PATH = "java.base"; //$NON-NLS-1$
private java.nio.file.FileSystem fs;
- private final Map<String, Path> fileMap;
-
+ private final Map<String, Path> fileMap;
+
JImage() {
fs = FileSystems.getFileSystem(JRT_URI);
fileMap = buildFileMap();
}
return fileMap;
}
-
+
private static class ByteBasedClassFile implements ClassFile {
private byte[] bytes;
private String base;
private long time;
private long size;
-
+
public ByteBasedClassFile(byte[] bytes, String path, String base, long time, long size) {
- this.bytes = bytes;
+ this.bytes = bytes;
this.path = path;
this.base = base;
this.time = time;
this.size = size;
}
-
+
@Override
public InputStream getInputStream() throws IOException {
// TODO too costly to keep these in inflated form in memory?
public long getSize() {
return this.size;
}
-
+
}
-
+
@Override
ClassFile getClassFile(String name, String suffix) throws IOException {
// Class files are in here under names like this:
/********************************************************************
- * Copyright (c) 2006 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) 2006 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.ajdt.core.dom;
import org.aspectj.org.eclipse.jdt.core.dom.AST;
-import org.aspectj.org.eclipse.jdt.core.dom.AjAST;
import org.aspectj.org.eclipse.jdt.core.dom.ASTParser.IASTFactory;
+import org.aspectj.org.eclipse.jdt.core.dom.AjAST;
public class AjASTFactory implements IASTFactory {
- public AST getAST(int level) {
- return AjAST.newAjAST(level);
+ public AST getAST(int level, boolean previewEnabled) {
+ return AjAST.newAjAST(level,previewEnabled);
}
}
/* *******************************************************************
* 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.ast;
/**
* Represents before, after and around advice in an aspect. Will generate a method corresponding to the body of the advice with an
* attribute including additional information.
- *
+ *
* @author Jim Hugunin
*/
public class AdviceDeclaration extends AjMethodDeclaration {
public AdviceKind kind; // set during parsing, referenced by Proceed and AsmElementFormatter
private int extraArgumentFlags = 0;
-
+
public int adviceSequenceNumberInType;
public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed
declaredExceptions = new UnresolvedType[0];
for (int i = 0; i < n; i++) {
- Proceed call = (Proceed) proceedCalls.get(i);
+ Proceed call = proceedCalls.get(i);
if (call.inInner) {
// System.err.println("proceed in inner: " + call);
proceedInInners = true;
// called by Proceed.resolveType
public int getDeclaredParameterCount() {
// this only works before code generation
- return this.arguments.length - 3 - ((extraArgument == null) ? 0 : 1);
+ if (this.arguments == null) {
+ // Indicates something seriously wrong and a separate error should show the real problem.
+ // (for example duplicate .aj file: https://bugs.eclipse.org/bugs/show_bug.cgi?id=549583)
+ return 0;
+ } else {
+ return this.arguments.length - 3 - ((extraArgument == null) ? 0 : 1);
+ }
// Advice.countOnes(extraArgumentFlags);
}
}
AstUtil.generateReturn(returnType, codeStream);
codeStream.recordPositionsFrom(0, 1);
- classFile.completeCodeAttribute(codeAttributeOffset);
+ classFile.completeCodeAttribute(codeAttributeOffset,scope);
attributeNumber++;
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber);
}
return l;
}
+ public static final char[] HAS_ASPECT = "hasAspect".toCharArray();
+
/*
* additionalAttributes allows us to pass some optional attributes we want to attach to the method we generate. Currently this
* is used for inline accessor methods that have been generated to allow private field references or private method calls to be
if (codeStream.pcToSourceMapSize == 0) {
codeStream.recordPositionsFrom(0, 1);
}
+ // Seems a dirty hack around some underlying issue...?
+ boolean b2 = CharOperation.equals(methodBinding.selector,HAS_ASPECT) &&
+ ((classFile.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0 ? true : false);
+ if (b2) {
+ classFile.produceAttributes &= ~ClassFileConstants.ATTR_STACK_MAP_TABLE;
+ }
boolean b = ((codeStream.generateAttributes & ClassFileConstants.ATTR_VARS) != 0 ? true : false); // pr148693
if (codeStream.maxLocals == 0) {
codeStream.generateAttributes &= ~ClassFileConstants.ATTR_VARS;
}
- classFile.completeCodeAttribute(codeAttributeOffset);
+ classFile.completeCodeAttribute(codeAttributeOffset, md.scope);
if (b) {
codeStream.generateAttributes |= ClassFileConstants.ATTR_VARS;
}
-
+ if (b2) {
+ classFile.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
+ }
attributeNumber++;
classFile.completeMethodInfo(methodBinding, methodAttributeOffset, attributeNumber);
}
world.makeMethodBinding(AjcMemberMaker.perTypeWithinGetInstance(typeX)), null);
codeStream.ifnull(noInstanceExists);
codeStream.iconst_1();
- codeStream.goto_(leave);
+ codeStream.ireturn();
+ // codeStream.goto_(leave);
noInstanceExists.place();
codeStream.iconst_0();
leave.place();
goneBang.placeEnd();
codeStream.ireturn();
goneBang.place();
- codeStream.astore_1();
+ //codeStream.astore_1();
+ codeStream.pop();
codeStream.iconst_0();
codeStream.ireturn();
codeStream.locals[0].recordInitializationEndPC(codeStream.position);
/* *******************************************************************
* 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.ast;
/**
* An inter-type field declaration.
- *
+ *
* returnType encodes the type of the field selector encodes the name statements is null until resolution when it is filled in from
* the initializer
- *
+ *
* @author Jim Hugunin
*/
public class InterTypeFieldDeclaration extends InterTypeDeclaration {
* else if (initialization!=null) { MethodScope initializationScope = this.scope; TypeBinding fieldType = realFieldType;
* TypeBinding initializationType; this.initialization.setExpectedType(fieldType); // needed in case of generic method
* invocation if (this.initialization instanceof ArrayInitializer) {
- *
+ *
* if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) {
* ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType;
* this.initialization.computeConversion(initializationScope, fieldType, initializationType); } } //
* System.err.println("i=>"+initialization); // System.err.println("sasuages=>"+initialization.resolvedType); //
* //initializationType = initialization.resolveType(initializationScope); //
* System.err.println("scope=>"+initializationScope);
- *
+ *
* else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) {
- *
+ *
* if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError()
* initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); if
* (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) || (fieldType.isBaseType() &&
/*
* public void resolveStatements() { super.resolveStatements();
- *
+ *
* // if (initialization!=null) { // MethodScope initializationScope = this.scope; // TypeBinding fieldType = realFieldType; //
* TypeBinding initializationType; // this.initialization.setExpectedType(fieldType); // needed in case of generic method
* invocation // if (this.initialization instanceof ArrayInitializer) { // // if ((initializationType =
* (this.binding.isFinal()){ // cast from constant actual type to variable type // //
* this.binding.setConstant(this.initialization.constant.castTo((this.binding.returnType.id << 4) +
* this.initialization.constant.typeID())); // // } // // } else { // // this.binding.setConstant(NotAConstant); // }}
- *
+ *
* }
*/
public EclipseTypeMunger build(ClassScope classScope) {
}
AstUtil.generateReturn(binding.returnType, codeStream);
- classFile.completeCodeAttribute(codeAttributeOffset);
+ classFile.completeCodeAttribute(codeAttributeOffset,scope);
attributeNumber++;
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber);
}
/* *******************************************************************
* 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.ast;
/**
* An inter-type method declaration.
- *
+ *
* @author Jim Hugunin
*/
public class InterTypeMethodDeclaration extends InterTypeDeclaration {
public InterTypeMethodDeclaration(CompilationResult result, TypeReference onType) {
- super(result, onType);
+ super(result, onType);
}
@Override
if (!Modifier.isStatic(declaredModifiers)) {
this.arguments = AstUtil.insert(AstUtil.makeFinalArgument("ajc$this_".toCharArray(), onTypeBinding), this.arguments);
binding.parameters = AstUtil.insert(onTypeBinding, binding.parameters);
-
+
// If the inserted argument is a generic type, we should include the associated type variables to ensure
// the generated signature is correct (it will be checked by eclipse when this type is consumed in binary form).
TypeVariableBinding onTypeTVBs[] = onTypeBinding.typeVariables();
}
}
}
- classFile.completeCodeAttribute(codeAttributeOffset);
+ classFile.completeCodeAttribute(codeAttributeOffset,scope);
attributeNumber++;
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber);
}
/* *******************************************************************
* 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.lookup;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PlainPackageBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
public String getAnyAliasForTypeVariableBinding(TypeVariableBinding tvb) {
if (usedAliases == null)
return null;
- return (String) usedAliases.get(tvb);
+ return usedAliases.get(tvb);
}
// this method depends on the fact that BinaryTypeBinding extends SourceTypeBinding
if (aliased > sourceType.typeVariables.length || sourceType.typeVariables.length == 0) {
TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(), null, 0,this.environment());
tvb.superclass = getJavaLangObject();
- tvb.fPackage = new PackageBinding(environment());
+ tvb.fPackage = new PlainPackageBinding(environment());
return tvb;
// error is going to be reported by someone else!
}
/* *******************************************************************
* 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://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 promoted member type from AjState
* ******************************************************************/
package org.aspectj.ajdt.internal.core.builder;
char[] genericSignature;
char[] superclassName;
char[][] interfaces;
-
+
char[] enclosingMethod;
-
+
char[][][] missingTypeNames;
// this is the extra state that enables us to be an IBinaryType
IBinaryNestedType[] memberTypes;
IBinaryAnnotation[] annotations;
IBinaryTypeAnnotation[] typeAnnotations;
-
+
public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) {
public char[][][] getMissingTypeNames() {
return missingTypeNames;
}
-
+
public char[] getEnclosingTypeName() {
return enclosingTypeName;
}
public char[] getGenericSignature() {
return genericSignature;
}
-
+
public char[] getEnclosingMethod() {
return enclosingMethod;
}
/* *******************************************************************
* Copyright (c) 2002 IBM and other 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:
* Palo Alto Research Center, Incorporated (PARC)
* Andy Clement
* ******************************************************************/
return new NameEnvironmentAnswer(seenOnPreviousBuild, null);
}
if (this.inflatedClassFilesCache.containsKey(name)) {
- return (NameEnvironmentAnswer) this.inflatedClassFilesCache.get(name);
+ return this.inflatedClassFilesCache.get(name);
} else {
- File fileOnDisk = (File) classesFromName.get(name);
+ File fileOnDisk = classesFromName.get(name);
// System.err.println("find: " + name + " found: " + cf);
if (fileOnDisk == null) {
return null;
this.classesFromName = Collections.emptyMap();
this.packageNames.clear();
}
-
+
@Override
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
NameEnvironmentAnswer ret = findType(new String(CharOperation.concatWith(packageName, typeName, '.')));
return baseEnvironment.findType(typeName, packageName, moduleName);
}
- @Override
- public char[][] getModulesDeclaringPackage(char[][] parentPackageName, char[] name, char[] moduleName) {
- return baseEnvironment.getModulesDeclaringPackage(parentPackageName, name, moduleName);
- }
@Override
public boolean hasCompilationUnit(char[][] qualifiedPackageName, char[] moduleName, boolean checkCUs) {
return baseEnvironment.getAllAutomaticModules();
}
+ @Override
+ public char[][] getModulesDeclaringPackage(char[][] arg0, char[] arg1) {
+ return baseEnvironment.getModulesDeclaringPackage(arg0, arg1);
+ }
+
+ @Override
+ public char[][] listPackages(char[] arg0) {
+ return baseEnvironment.listPackages(arg0);
+ }
+
}
/********************************************************************
- * Copyright (c) 2006 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) 2006 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.org.eclipse.jdt.core.dom;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.aspectj.org.eclipse.jdt.core.dom.AST;
-import org.aspectj.org.eclipse.jdt.core.dom.BindingResolver;
-import org.aspectj.org.eclipse.jdt.core.dom.DefaultBindingResolver;
public class AjAST extends AST {
/**
* Creates a new AspectJ abstract syntax tree
- * (AST) following the specified set of API rules.
- *
+ * (AST) following the specified set of API rules.
+ *
* @param level the API level; one of the LEVEL constants
* @since 3.0
*/
- private AjAST(int level) {
- super(level);
+ private AjAST(int level,boolean previewEnabled) {
+ super(level,previewEnabled);
}
-
+
/**
* Creates a new AspectJ abstract syntax tree
- * (AST) following the specified set of API rules.
+ * (AST) following the specified set of API rules.
* <p>
* Clients should use this method specifing {@link #JLS3} as the
* AST level in all cases, even when dealing with JDK 1.3 or 1.4..
* </p>
- *
+ *
* @param level the API level; one of the LEVEL constants
* @return new AST instance following the specified set of API rules.
* @exception IllegalArgumentException if:
* </ul>
* @since 3.0
*/
- public static AjAST newAjAST(int level) {
+ public static AjAST newAjAST(int level,boolean previewEnabled) {
if ((level != AST.JLS2)
&& (level != AST.JLS3)) {
throw new IllegalArgumentException();
}
- return new AjAST(level);
+ return new AjAST(level,previewEnabled);
}
-
+
/**
* Internal method.
* <p>
* This method converts the given internal compiler AST for the given source string
* into a compilation unit. This method is not intended to be called by clients.
* </p>
- *
+ *
* @param level the API level; one of the LEVEL constants
* @param compilationUnitDeclaration an internal AST node for a compilation unit declaration
* @param source the string of the Java compilation unit
boolean isResolved,
org.aspectj.org.eclipse.jdt.internal.core.CompilationUnit workingCopy,
IProgressMonitor monitor) {
-
- ASTConverter converter =
+
+ ASTConverter converter =
// AspectJ extension - use the factory
- ASTConverter.getASTConverter(options,isResolved,monitor);
+ ASTConverter.getASTConverter(options,isResolved,monitor);
// create a new AjAst - difference between this method in AjAST and AST
- AjAST ast = AjAST.newAjAST(level);
+ AjAST ast = AjAST.newAjAST(level,false);
int savedDefaultNodeFlag = ast.getDefaultNodeFlag();
ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
BindingResolver resolver = null;
}
ast.setBindingResolver(resolver);
converter.setAST(ast);
-
+
CompilationUnit unit = converter.convert(compilationUnitDeclaration, source);
unit.setLineEndTable(compilationUnitDeclaration.compilationResult.lineSeparatorPositions);
unit.setTypeRoot(workingCopy);
ast.setDefaultNodeFlag(savedDefaultNodeFlag);
return unit;
}
-
+
/**
* Creates an unparented aspect declaration node owned by this AST.
- * The name of the aspect is an unspecified, but legal, name;
+ * The name of the aspect is an unspecified, but legal, name;
* no modifiers; no doc comment; no superclass or superinterfaces;
* an empty body; a null perclause; and is not privileged
* <p>
* To create a privileged aspect, use this method and then call
* <code>AspectDeclaration.setPrivileged(true)</code>.
* </p>
- *
+ *
* @return a new unparented aspect declaration node
*/
public AspectDeclaration newAspectDeclaration() {
AspectDeclaration result = new AspectDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented ajtype declaration node owned by this AST.
- * The name of the class is an unspecified, but legal, name;
+ * The name of the class is an unspecified, but legal, name;
* no modifiers; no doc comment; no superclass or superinterfaces;
* and an empty body.
* <p>
* To create an aspect, use this method and then call
* <code>AjTypeDeclaration.setAspect(true)</code>.
* </p>
- *
+ *
* @return a new unparented ajtype declaration node
*/
public AjTypeDeclaration newAjTypeDeclaration() {
/**
* Creates an unparented after advice declaration node owned by this AST.
- * By default, the declaration is for an after advice with no pointcut;
+ * By default, the declaration is for an after advice with no pointcut;
* no doc comment; and no body (as opposed to an empty body).
- *
+ *
* @return a new unparented after advice declaration node
*/
public AfterAdviceDeclaration newAfterAdviceDeclaration() {
AfterAdviceDeclaration result = new AfterAdviceDeclaration(this);
return result;
}
-
+
/**
- * Creates an unparented after returning advice declaration node owned
- * by this AST. By default, the declaration is for an after returning
- * advice with no pointcut; no doc comment; no return value and no
+ * Creates an unparented after returning advice declaration node owned
+ * by this AST. By default, the declaration is for an after returning
+ * advice with no pointcut; no doc comment; no return value and no
* body (as opposed to an empty body).
- *
+ *
* @return a new unparented after returning advice declaration node
*/
public AfterReturningAdviceDeclaration newAfterReturningAdviceDeclaration() {
AfterReturningAdviceDeclaration result = new AfterReturningAdviceDeclaration(this);
return result;
}
-
+
/**
- * Creates an unparented after throwing advice declaration node owned
- * by this AST. By default, the declaration is for an after throwing
- * advice with no pointcut; no doc comment; no throwing value and no
+ * Creates an unparented after throwing advice declaration node owned
+ * by this AST. By default, the declaration is for an after throwing
+ * advice with no pointcut; no doc comment; no throwing value and no
* body (as opposed to an empty body).
- *
+ *
* @return a new unparented after throwing advice declaration node
*/
public AfterThrowingAdviceDeclaration newAfterThrowingAdviceDeclaration() {
AfterThrowingAdviceDeclaration result = new AfterThrowingAdviceDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented before advice declaration node owned by this AST.
- * By default, the declaration is for a before advice with no pointcut;
+ * By default, the declaration is for a before advice with no pointcut;
* no doc comment; and no body (as opposed to an empty body).
- *
+ *
* @return a new unparented before advice declaration node
*/
public BeforeAdviceDeclaration newBeforeAdviceDeclaration() {
/**
* Creates an unparented around advice declaration node owned by this AST.
- * By default, the declaration is for an around advice with no pointcut;
+ * By default, the declaration is for an around advice with no pointcut;
* no doc comment; no return type; and no body (as opposed to an empty body).
- *
+ *
* @return a new unparented around advice declaration node
*/
public AroundAdviceDeclaration newAroundAdviceDeclaration() {
AroundAdviceDeclaration result = new AroundAdviceDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare at constructor declaration node owned by this AST.
- * By default, the declaration is for a declare annotation with no doc comment;
+ * By default, the declaration is for a declare annotation with no doc comment;
* no pattern node; no annotation name; and no declare kind.
- *
+ *
* @return a new unparented declare at constructor declaration node
* @exception UnsupportedOperationException if this operation is used in
* a JLS2 AST
DeclareAtConstructorDeclaration result = new DeclareAtConstructorDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare at field declaration node owned by this AST.
- * By default, the declaration is for a declare annotation with no doc comment;
+ * By default, the declaration is for a declare annotation with no doc comment;
* no pattern node; no annotation name; and no declare kind.
- *
+ *
* @return a new unparented declare at field declaration node
* @exception UnsupportedOperationException if this operation is used in
* a JLS2 AST
DeclareAtFieldDeclaration result = new DeclareAtFieldDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare at method declaration node owned by this AST.
- * By default, the declaration is for a declare annotation with no doc comment;
+ * By default, the declaration is for a declare annotation with no doc comment;
* no pattern node; no annotation name; and no declare kind.
- *
+ *
* @return a new unparented declare at method declaration node
* @exception UnsupportedOperationException if this operation is used in
* a JLS2 AST
DeclareAtMethodDeclaration result = new DeclareAtMethodDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare at type declaration node owned by this AST.
- * By default, the declaration is for a declare annotation with no doc comment;
+ * By default, the declaration is for a declare annotation with no doc comment;
* no pattern node; no annotation name; and no declare kind.
- *
+ *
* @return a new unparented declare at type declaration node
* @exception UnsupportedOperationException if this operation is used in
* a JLS2 AST
DeclareAtTypeDeclaration result = new DeclareAtTypeDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare error declaration node owned by this AST.
- * By default, the declaration is for a declare error with no doc comment;
+ * By default, the declaration is for a declare error with no doc comment;
* no pointcut; and no message.
- *
+ *
* @return a new unparented declare error declaration node
*/
public DeclareErrorDeclaration newDeclareErrorDeclaration() {
DeclareErrorDeclaration result = new DeclareErrorDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare parents declaration node owned by this AST.
- * By default, the declaration is for a declare parents which is implements;
+ * By default, the declaration is for a declare parents which is implements;
* with no doc comment; no child type pattern; and no parent type pattern
* <p>
* To create an extends declare parents, use this method and then call
* <code>DeclareParentsDeclaration.setExtends(true)</code>.
* </p>
- *
+ *
* @return a new unparented declare parents declaration node
*/
public DeclareParentsDeclaration newDeclareParentsDeclaration() {
DeclareParentsDeclaration result = new DeclareParentsDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare precedence declaration node owned by this AST.
- * By default, the declaration is for a declare precedence with no doc comment;
+ * By default, the declaration is for a declare precedence with no doc comment;
* and no type pattern list.
- *
+ *
* @return a new unparented declare precedence declaration node
*/
public DeclarePrecedenceDeclaration newDeclarePrecedenceDeclaration() {
DeclarePrecedenceDeclaration result = new DeclarePrecedenceDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare soft declaration node owned by this AST.
- * By default, the declaration is for a declare soft with no doc comment;
+ * By default, the declaration is for a declare soft with no doc comment;
* no pointcut; and no type pattern.
- *
+ *
* @return a new unparented declare soft declaration node
*/
public DeclareSoftDeclaration newDeclareSoftDeclaration() {
DeclareSoftDeclaration result = new DeclareSoftDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented declare warning declaration node owned by this AST.
- * By default, the declaration is for a declare warning with no doc comment;
+ * By default, the declaration is for a declare warning with no doc comment;
* no pointcut; and no message.
- *
+ *
* @return a new unparented declare warning declaration node
*/
public DeclareWarningDeclaration newDeclareWarningDeclaration() {
DeclareWarningDeclaration result = new DeclareWarningDeclaration(this);
return result;
}
-
+
/**
- * Creates a new unparented intertype field declaration node owned by this
- * AST. By default, there are no modifiers, no doc comment, and the base
+ * Creates a new unparented intertype field declaration node owned by this
+ * AST. By default, there are no modifiers, no doc comment, and the base
* type is unspecified (but legal).
- *
+ *
* @return a new unparented intertype field declaration node
*/
public InterTypeFieldDeclaration newInterTypeFieldDeclaration() {
InterTypeFieldDeclaration result = new InterTypeFieldDeclaration(this);
return result;
}
-
+
/**
- * Creates an unparented intertype method declaration node owned by
- * this AST. By default, the declaration is for a method of an
- * unspecified, but legal, name; no modifiers; no doc comment; no
- * parameters; return type void; no extra array dimensions; no
+ * Creates an unparented intertype method declaration node owned by
+ * this AST. By default, the declaration is for a method of an
+ * unspecified, but legal, name; no modifiers; no doc comment; no
+ * parameters; return type void; no extra array dimensions; no
* thrown exceptions; and no body (as opposed to an empty body).
- *
+ *
* @return a new unparented inter type method declaration node
*/
public InterTypeMethodDeclaration newInterTypeMethodDeclaration() {
InterTypeMethodDeclaration result = new InterTypeMethodDeclaration(this);
return result;
}
-
+
/**
* Creates an unparented pointcut declaration node owned by this AST.
- * By default, the declaration is for a pointcut of an unspecified, but
+ * By default, the declaration is for a pointcut of an unspecified, but
* legal, name; no modifiers; no doc comment; and no pointcut designator
- *
+ *
* @return a new unparented pointcut declaration node
*/
public PointcutDeclaration newPointcutDeclaration() {
* Creates an unparented AndPointcut node owned by this AST.
* By default, the declaration is for an and pointcut with no left
* or right pointcut designators
- *
+ *
* @return a new unparented AndPointcut node
*/
public AndPointcut newAndPointcut() {
AndPointcut result = new AndPointcut(this);
return result;
}
-
+
/**
* Creates an unparented CflowPointcut node owned by this AST.
* By default, the declaration is for a cflow pointcut with no body
* pointcut designator
- *
+ *
* @return a new unparented CflowPointcut node
*/
public CflowPointcut newCflowPointcut() {
CflowPointcut result = new CflowPointcut(this);
return result;
}
-
+
/**
* Creates an unparented NotPointcut node owned by this AST.
* By default, the declaration is for a not pointcut with no body
* pointcut designator
- *
+ *
* @return a new unparented NotPointcut node
*/
public NotPointcut newNotPointcut() {
NotPointcut result = new NotPointcut(this);
return result;
}
-
+
/**
* Creates an unparented OrPointcut node owned by this AST.
* By default, the declaration is for an or pointcut with no left
* or right pointcut designators
- *
+ *
* @return a new unparented OrPointcut node
*/
public OrPointcut newOrPointcut() {
OrPointcut result = new OrPointcut(this);
return result;
}
-
+
/**
* Creates an unparented PerCflow node owned by this AST.
* By default, the declaration is for a percflow with no body
* pointcut designator
- *
+ *
* @return a new unparented percflow node
*/
public PerCflow newPerCflow() {
PerCflow result = new PerCflow(this);
return result;
}
-
+
/**
* Creates an unparented perobject node owned by this AST.
* By default, the declaration is for a perobject with no body
* pointcut designator
- *
+ *
* @return a new unparented perobject node
*/
public PerObject newPerObject() {
PerObject result = new PerObject(this);
return result;
}
-
+
/**
* Creates an unparented pertypewithin node owned by this AST.
* By default, the declaration is for a pertypewithin
- *
+ *
* @return a new unparented pertypewithin node
*/
public PerTypeWithin newPerTypeWithin() {
PerTypeWithin result = new PerTypeWithin(this);
return result;
}
-
+
/**
* Creates an unparented reference pointcut node owned by this AST.
- * By default, the declaration is for a reference pointcut with no
+ * By default, the declaration is for a reference pointcut with no
* name
- *
+ *
* @return a new unparented reference pointcut node
*/
public ReferencePointcut newReferencePointcut() {
ReferencePointcut result = new ReferencePointcut(this);
return result;
}
-
+
/**
* Creates an unparented default pointcut node owned by this AST.
- * By default, the declaration is for a default pointcut with an
+ * By default, the declaration is for a default pointcut with an
* empty detail string.
* <p>
* To edit the detail string, use this method and then call
* <code>DefaultPointcut.setDetail("newString")</code>.
* </p>
- *
+ *
* @return a new unparented default pointcut node
*/
public DefaultPointcut newDefaultPointcut() {
DefaultPointcut result = new DefaultPointcut(this,"");
return result;
}
-
+
/**
* Creates an unparented default type pattern node owned by this AST.
- * By default, the declaration is for a default type pattern with an
+ * By default, the declaration is for a default type pattern with an
* empty detail string.
* <p>
* To edit the detail string, use this method and then call
* <code>DefaultTypePattern.setDetail("newString")</code>.
* </p>
- *
+ *
* @return a new unparented default type pattern node
*/
public DefaultTypePattern newDefaultTypePattern() {
DefaultTypePattern result = new DefaultTypePattern(this,"");
return result;
}
-
+
/**
* Creates an unparented default signature pattern node owned by this AST.
- * By default, the declaration is for a default signature pattern with an
+ * By default, the declaration is for a default signature pattern with an
* empty detail string.
* <p>
* To edit the detail string, use this method and then call
* <code>SignaturePattern.setDetail("newString")</code>.
* </p>
- *
+ *
* @return a new unparented default signature pattern node
*/
public SignaturePattern newSignaturePattern() {
org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy.
### AspectJ-specific messages
compiler.name = AspectJ Compiler
-compiler.version = Eclipse Compiler #a9ab0710a01b2b(28-Mar-2019), 3.18
+compiler.version = Eclipse Compiler 3106c52cb89aa (29Oct2019) - Java13
compiler.copyright =
/********************************************************************
- * Copyright (c) 2006, 2010 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) 2006, 2010 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.tools.ajc;
import java.util.Iterator;
import java.util.List;
+import org.aspectj.org.eclipse.jdt.core.SourceRange;
import org.aspectj.org.eclipse.jdt.core.dom.AST;
import org.aspectj.org.eclipse.jdt.core.dom.ASTNode;
import org.aspectj.org.eclipse.jdt.core.dom.ASTParser;
import org.aspectj.org.eclipse.jdt.core.dom.TypeCategoryTypePattern;
import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration;
import org.aspectj.org.eclipse.jdt.core.dom.TypePattern;
-import org.aspectj.org.eclipse.jdt.core.SourceRange;
/**
* For each AspectJ ASTNode there is a test for:
- *
+ *
* - that a new instance can be created via ajast.newXXX() - that the property descriptors have been set correctly - that the
* get/set methods for the different properties work as expected - that the clone0 method sets the correct properties - that the
* internalStructuralPropertiesForType(int) and internalGetSetXXXProperty(..) methods have been implemented correctly
- *
+ *
* These are all that is required for an ASTNode, except an implementation of the accept0() method which is tested in
* ASTVisitorTest.
*/
public void testDeclareParents() {
checkJLS3("class A{}class B{}aspect C {declare parents : A extends B;}", 28, 29);
}
-
-
+
+
/*
- *
- *
+ *
+ *
* START: Test TypePattern nodes introduced in Bugzilla 329268.
- *
- *
+ *
+ *
*/
-
+
public void testDeclareParentsTypePatternNodeSource() {
checkTypePatternSourceRangesJLS3("class A{}class B{}aspect C {declare parents : A extends B;}", new int[][] {{46, 1} , {56, 1 }});
}
-
+
public void testDeclareParentsAnySource() {
checkTypePatternSourceRangesJLS3("class A{}class B{}aspect C {declare parents : * extends B;}", new int[][] {{46, 1} , {56, 1 }});
}
-
+
public void testDeclareParentsAndSource() {
checkTypePatternSourceRangesJLS3(
{ 84, 1 } // E
});
}
-
+
public void testDeclareParentsNotSource() {
checkTypePatternSourceRangesJLS3(
{ 80, 1 } // E
});
}
-
+
public void testDeclareParentsOrSource() {
checkTypePatternSourceRangesJLS3(
"class A{}class B{}class D{}class E{}aspect C {declare parents : A || B || D extends E;}",
{ 84, 1 } // E
});
}
-
+
public void testDeclareParentsAnyWithAnnotationSource() {
checkTypePatternSourceRangesJLS3(
"@interface AnnotationT {}class E{}aspect C {declare parents : (@AnnotationT *) extends E;}",
new int[][] { { 62, 16 },// (@AnnotationT *)
{ 87, 1 } // E
});
-
+
}
-
+
public void testDeclareParentsTypeCategorySource() {
checkTypePatternSourceRangesJLS3(
"class A{}class E{}aspect C {declare parents : A && is(ClassType) extends E;}",
"class B{}class E{}aspect C {declare parents : B && !is(EnumType) extends E;}",
TypeCategoryTypePattern.ENUM, "is(EnumType)");
}
-
+
/*
- *
- *
+ *
+ *
* END: Test TypePattern nodes introduced in Bugzilla 329268.
- *
- *
+ *
+ *
*/
-
-
+
+
public void testDeclareWarning() {
checkJLS3("aspect A {pointcut a();declare warning: a(): \"error\";}", 23, 30);
}
public void testJavadocCommentForDeclareExists_pr150467() {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource("aspect X {/** I have a doc comment */declare parents : Y implements Z;}".toCharArray());
- parser.setCompilerOptions(Collections.EMPTY_MAP);
+ //parser.setSource("aspect X {/** I have a doc comment */public void foo() {}}".toCharArray());
+ parser.setCompilerOptions(Collections.emptyMap());
parser.setKind(ASTParser.K_COMPILATION_UNIT);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
- Javadoc javadoc = ((DeclareParentsDeclaration) ((TypeDeclaration) cu.types().get(0)).bodyDeclarations().get(0))
- .getJavadoc();
+ //Javadoc javadoc = ((MethodDeclaration) ((TypeDeclaration) cu.types().get(0)).bodyDeclarations().get(0)).getJavadoc();
+ Javadoc javadoc = ((DeclareParentsDeclaration) ((TypeDeclaration) cu.types().get(0)).bodyDeclarations().get(0)).getJavadoc();
assertNull("expected the doc comment node to be null but it wasn't", javadoc);
assertEquals("expected there to be one comment but found " + cu.getCommentList().size(), 1, cu.getCommentList().size());
}
-
+
protected void assertExpression(String expectedExpression, TypePattern node) {
assertTrue("Expected: " + expectedExpression + ". Actual: " + node.getTypePatternExpression(), node.getTypePatternExpression().equals(expectedExpression));
-
+
}
-
+
protected void assertNodeType(Class<?> expected, TypePattern node) {
assertTrue("Expected " + expected.toString() + ". Actual: " + node.getClass().toString(), node.getClass().equals(expected));
}
class TypeCategoryTypeVisitor extends AjASTVisitor {
-
+
private TypeCategoryTypePattern typeCategory = null;
-
+
public boolean visit(TypeCategoryTypePattern node) {
typeCategory = node;
return false;
}
-
+
public TypeCategoryTypePattern getTypeCategoryNode() {
return typeCategory;
}
/* *******************************************************************
* Copyright (c) 2004 IBM Corporation
- * 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:
* Adrian Colyer, Abraham Nevado (lucierna)
* ******************************************************************/
package org.aspectj.tools.ajc;
* See the XMLBasedAjcTestCase subclass for TestCase class that can be used to drive compiler tests based on an ajcTests.xml format
* test specification file.
* </p>
- *
+ *
* @see org.aspectj.tools.ajc.AjcTestCase.Message
* @see org.aspectj.tools.ajc.AjcTestCase.MessageSpec
* @see org.aspectj.tools.ajc.AjcTestCase.RunResult
protected Ajc ajc;
// see Ajc and AntSpec
- public static final String DEFAULT_CLASSPATH_ENTRIES =
+ public static final String DEFAULT_CLASSPATH_ENTRIES =
Ajc.outputFolders("bridge","util","loadtime","weaver","asm","testing-client","runtime","org.aspectj.matcher")
// File.pathSeparator + ".." + File.separator + "bridge" + File.separator
// + "bin" + File.pathSeparator + ".." + File.separator + "util" + File.separator + "bin" + File.pathSeparator + ".."
+ "bcel"
+ File.separator
+ "bcel-verifier.jar"
-
- + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "asm" + File.separator + "asm-7.0-beta.renamed.jar"
+
+ + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "asm" + File.separator + "asm-7.2.renamed.jar"
// When the build machine executes the tests, it is using code built into jars rather than code build into
// bin directories. This means for the necessary types to be found we have to put these jars on the classpath:
* <p>
* Message objects are combined in a MessageSpec which can then be passed to the various assertMessage methods.
* </p>
- *
+ *
* @see org.aspectj.tools.ajc.AjcTestCase.MessageSpec
*/
public static class Message {
/**
* Create a message specification to test a CompilationResult for a given set of info, warning, error, and fail messages.
- *
+ *
* @param infos The set of info messages to test for. Specifying a non-null value for this parameter enables info message
* comparison.
* @param warnings The set of warning messages to test for - can pass null to indicate empty set.
* @param errors The set of error messages to test for - can pass null to indicate empty set.
* @param fails The set of fail or abort messages to test for - can pass null to indicate empty set.
*/
- public MessageSpec(List<AjcTestCase.Message> infos, List<AjcTestCase.Message> warnings,
+ public MessageSpec(List<AjcTestCase.Message> infos, List<AjcTestCase.Message> warnings,
List<AjcTestCase.Message> errors, List<AjcTestCase.Message> fails, List<AjcTestCase.Message> weaves) {
if (infos != null) {
this.infos = infos;
/**
* Perform a compilation and return the result.
- *
+ *
* @param baseDir the base directory relative to which all relative paths and directories in the arguments will be interpreted.
* @param args the compiler arguments, as you would specify on the command-line. See the Ajc class for a description of the
* argument processing done in order to run the compilation in a sandbox.
/**
* Indicate whether or not the sandbox should be emptied before the next compile.
- *
+ *
* @see org.aspectj.tools.ajc.Ajc#setShouldEmptySandbox(boolean)
*/
public void setShouldEmptySandbox(boolean empty) {
/**
* Run the given class, and return the result in a RunResult. The program runs with a classpath containing the sandbox
* directory, runtime, testing-client, bridge, and util projects (all used by the Tester class), and any jars in the sandbox.
- *
+ *
* @param args the arguments to pass to the program.
* @param classpath the execution classpath, the sandbox directory, runtime, testing-client, bridge, and util projects will all
* be appended to the classpath, as will any jars in the sandbox.
- * @param runSpec
+ * @param runSpec
*/
public RunResult run(String className, String moduleName, String[] args, String vmargs, final String classpath, String modulepath, boolean useLTW, boolean useFullLTW) {
URLClassLoader sandboxLoader;
ClassLoader parentLoader = getClass().getClassLoader().getParent();
-
+
/* Sandbox -> AspectJ -> Extension -> Bootstrap */
if ( !useFullLTW && useLTW) {
// URLClassLoader testLoader = (URLClassLoader) getClass().getClassLoader();
URL[] sandboxUrls = getURLs(cp.toString());
sandboxLoader = createWeavingClassLoader(sandboxUrls, aspectjLoader);
// sandboxLoader = createWeavingClassLoader(sandboxUrls,testLoader);
- } else if(useFullLTW && useLTW) {
+ } else if(useFullLTW && useLTW) {
if(vmargs == null){
vmargs ="";
}
-
+
File directory = new File (".");
String absPath = directory.getAbsolutePath();
String javaagent= absPath+File.separator+".."+File.separator+"aj-build"+File.separator+"dist"+File.separator+"tools"+File.separator+"lib"+File.separator+"aspectjweaver.jar";
try {
String command ="java " +vmargs+ " -classpath " + cp +" -javaagent:"+javaagent + " " + className ;
-
+
// Command is executed using ProcessBuilder to allow setting CWD for ajc sandbox compliance
ProcessBuilder pb = new ProcessBuilder(tokenizeCommand(command));
pb.directory( new File(ajc.getSandboxDirectory().getAbsolutePath()));
BufferedReader stdInput = new BufferedReader(new InputStreamReader(exec.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(exec.getErrorStream()));
exec.waitFor();
- lastRunResult = createResultFromBufferReaders(command,stdInput, stdError);
+ lastRunResult = createResultFromBufferReaders(command,stdInput, stdError);
} catch (Exception e) {
System.out.println("Error executing full LTW test: " + e);
e.printStackTrace();
BufferedReader stdInput = new BufferedReader(new InputStreamReader(exec.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(exec.getErrorStream()));
exec.waitFor();
- lastRunResult = createResultFromBufferReaders(command,stdInput, stdError);
+ lastRunResult = createResultFromBufferReaders(command,stdInput, stdError);
} catch (Exception e) {
System.out.println("Error executing module test: " + e);
e.printStackTrace();
BufferedReader stdInput = new BufferedReader(new InputStreamReader(exec.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(exec.getErrorStream()));
exec.waitFor();
- lastRunResult = createResultFromBufferReaders(command,stdInput, stdError);
+ lastRunResult = createResultFromBufferReaders(command,stdInput, stdError);
} catch (Exception e) {
System.out.println("Error executing module test: " + e);
e.printStackTrace();
}
ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
-
+
StringBuffer command = new StringBuffer();
command.append("java -classpath ");
String nextToken =st.nextToken();
arguments.add(nextToken);
}
-
+
return arguments;
}
String line = "";
ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
-
+
PrintWriter stdOutWriter = new PrintWriter(baosOut);
PrintWriter stdErrWriter = new PrintWriter(baosErr);
}
stdErrWriter.flush();
-
+
baosOut.close();
baosErr.close();
-
+
return new RunResult(command.toString(), new String(baosOut.toByteArray()), new String(baosErr.toByteArray()));
}
/**
* Any central pre-processing of args. This supplies aspectjrt.jar if available and classpath not set.
- *
+ *
* @param args the String[] args to fix up
* @return the String[] args to use
*/
/**
* Compare the set of expected messages against the set of actual messages, leaving in missingElements the set of messages that
* were expected but did not occur, and in extraElements the set of messages that occured but were not excpected
- *
+ *
* @param expected the expected messages
* @param actual the actual messages
* @param missingElements the missing messages, when passed in must contain all of the expected messages
/*
* (non-Javadoc)
- *
+ *
* @see junit.framework.TestCase#setUp()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see junit.framework.TestCase#tearDown()
*/
@Override
<scope>system</scope>
<systemPath>${project.basedir}/../lib/ant/lib/ant.jar</systemPath>
</dependency>
-
+ <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>jrockit</groupId>
<artifactId>jrockit</artifactId>
/* *******************************************************************
- * Copyright (c) 2001-2001 Xerox Corporation,
+ * Copyright (c) 2001-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC)
* 2003-2004 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:
- * 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
* Wes Isberg 2003-2004 changes
* ******************************************************************/
import org.apache.tools.ant.taskdefs.Mkdir;
import org.apache.tools.ant.taskdefs.PumpStreamHandler;
import org.apache.tools.ant.taskdefs.Zip;
-import org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.FileSet;
* for each iterative compile, but when forking things are only copied at the completion of a successful compile.
* <p>
* See the development environment guide for usage documentation.
- *
+ *
* @since AspectJ 1.1, Ant 1.5
*/
public class AjcTask extends MatchingTask {
* <code>readArguments(String[])</code>; (2) testing is supported by (a) permitting the same specification to be re-run with
* added flags (settings once made cannot be removed); and (b) permitting recycling the task with <code>reset()</code>
* (untested).
- *
+ *
* The parts that do more than convert ant specs are (a) code for forking; (b) code for copying resources.
- *
+ *
* If you maintain/upgrade this task, keep in mind: (1) changes to the semantics of ajc (new options, new values permitted,
* etc.) will have to be reflected here. (2) the clients: the iajc ant script, Javac compiler adapter, maven clients of iajc,
* and testing code.
* This method extracts javac arguments to ajc, and add arguments to make ajc behave more like javac in copying resources.
* <p>
* Pass ajc-specific options using compilerarg sub-element:
- *
+ *
* <pre>
* <javac srcdir="src">
* <compilerarg compiler="..." line="-argfile src/args.lst"/>
* <javac>
* </pre>
- *
+ *
* Some javac arguments are not supported in this component (yet):
- *
+ *
* <pre>
* String memoryInitialSize;
* boolean includeAntRuntime = true;
* boolean includeJavaRuntime = false;
* </pre>
- *
+ *
* Other javac arguments are not supported in ajc 1.1:
- *
+ *
* <pre>
* boolean optimize;
* String forkedExecutable;
* String debugLevel;
* Path compileSourcepath;
* </pre>
- *
+ *
* @param javac the Javac command to implement (not null)
* @param ajc the AjcTask to adapt (not null)
* @param destDir the File class destination directory (may be null)
* Find aspectjtools.jar on the task or system classpath. Accept <code>aspectj{-}tools{...}.jar</code> mainly to support build
* systems using maven-style re-naming (e.g., <code>aspectj-tools-1.1.0.jar</code>. Note that we search the task classpath
* first, though an entry on the system classpath would be loaded first, because it seems more correct as the more specific one.
- *
+ *
* @return readable File for aspectjtools.jar, or null if not found.
*/
public static File findAspectjtoolsJar() {
/**
* -Xlint variants (error, warning, ignore)
- *
+ *
* @see org.aspectj.weaver.Lint
*/
private static final List VALID_XLINT;
public static final String COMMAND_EDITOR_NAME = AjcTask.class.getName() + ".COMMAND_EDITOR";
- static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11", "12" };
- static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11", "12" };
- static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", "-10", "-11", "-12" };
+ static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11", "12", "13" };
+ static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11", "12", "13" };
+ static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", "-10", "-11", "-12", "-13" };
private static final ICommandEditor COMMAND_EDITOR;
private String xdoneSignal;
private List<CompilerArg> compilerArgs;
-
+
// ----- added by adapter - integrate better?
private List /* File */adapterFiles;
private String[] adapterArguments;
public void setProcessor(String processors) {
cmd.addFlagged("-processor", processors);
}
-
+
/**
* -processorpath path
* Specify where to find annotation processors; if this option is not used, the class path will be searched for processors.
/**
* -Xlint:{error|warning|info} - set default level for -Xlint messages
- *
+ *
* @param xlint the String with one of error, warning, ignored
*/
public void setXlint(String xlint) {
/**
* -Xlintfile {lint.properties} - enable or disable specific forms of -Xlint messages based on a lint properties file (default
* is <code>org/aspectj/weaver/XLintDefault.properties</code>)
- *
+ *
* @param xlintFile the File with lint properties
*/
public void setXlintfile(File xlintFile) {
public Commandline.Argument createJvmarg() {
return this.javaCmd.createVmArgument();
}
-
+
public static class CompilerArg {
private String value;
-
+
public String getValue() {
return value;
}
-
+
public void setValue(String value) {
this.value = value;
}
-
+
@Override
public String toString() {
return value;
/**
* Language compliance level. If not set explicitly, eclipse default holds.
- *
+ *
* @param input a String in COMPLIANCE_INPUTS
*/
public void setCompliance(String input) {
/**
* Source compliance level. If not set explicitly, eclipse default holds.
- *
+ *
* @param input a String in SOURCE_INPUTS
*/
public void setSource(String input) {
ignore(ignore);
}
}
-
+
public void setParameters(boolean b) {
cmd.addFlag("-parameters",b);
}
/**
* Flag to copy all non-.class contents of injars to outjar after compile completes. Requires both injars and outjar.
- *
+ *
* @param doCopy
*/
public void setCopyInjars(boolean doCopy) {
/**
* Option to copy all files from all source root directories except those specified here. If this is specified and sourceroots
* are specified, then this will copy all files except those specified in the filter pattern. Requires sourceroots.
- *
+ *
* @param filter a String acceptable as an excludes filter for an Ant Zip fileset.
*/
public void setSourceRootCopyFilter(String filter) {
* Option to copy all files from all inpath directories except the files specified here. If this is specified and inpath
* directories are specified, then this will copy all files except those specified in the filter pattern. Requires inpath. If
* the input does not contain "**\/*.class", then this prepends it, to avoid overwriting woven classes with unwoven input.
- *
+ *
* @param filter a String acceptable as an excludes filter for an Ant Zip fileset.
*/
public void setInpathDirCopyFilter(String filter) {
/**
* Setup custom message handling.
- *
+ *
* @param className the String fully-qualified-name of a class reachable from this object's class loader, implementing
* IMessageHolder, and having a public no-argument constructor.
* @throws BuildException if unable to create instance of className
/**
* Setup command-line filter. To do this staticly, define the environment variable
* <code>org.aspectj.tools.ant.taskdefs.AjcTask.COMMAND_EDITOR</code> with the <code>className</code> parameter.
- *
+ *
* @param className the String fully-qualified-name of a class reachable from this object's class loader, implementing
* ICommandEditor, and having a public no-argument constructor.
* @throws BuildException if unable to create instance of className
/**
* Add path elements to source path and return result. Elements are added even if they do not exist.
- *
+ *
* @param source the Path to add to - may be null
* @param toAdd the Path to add - may be null
* @return the (never-null) Path that results
/**
* Compile using ajc per settings.
- *
+ *
* @exception BuildException if the compilation has problems or if there were compiler errors and failonerror is true.
*/
@Override
/**
* Halt processing. This tells main in the same vm to quit. It fails when running in forked mode.
- *
+ *
* @return true if not in forked mode and main has quit or been told to quit
*/
public boolean quit() {
/**
* Create any pseudo-options required to implement some of the macro options
- *
+ *
* @throws BuildException if options conflict
*/
protected void setupOptions() {
/**
* Run the compile in the same VM by loading the compiler (Main), setting up any message holders, doing the compile, and
* converting abort/failure and error messages to BuildException, as appropriate.
- *
+ *
* @throws BuildException if abort or failure messages or if errors and failonerror.
- *
+ *
*/
protected void executeInSameVM(String[] args) {
if (null != maxMem) {
* <li>No resource-copying between interative runs</li>
* <li>failonerror fails when process interface fails to return negative values</li>
* </ul>
- *
+ *
* @param args String[] of the complete compiler command to execute
- *
+ *
* @see DefaultCompilerAdapter#executeExternalCompile(String[], int)
* @throws BuildException if ajc aborts (negative value) or if failonerror and there were compile errors.
*/
addFlaggedPath("-injars", injars, list);
addFlaggedPath("-inpath", inpath, list);
addFlaggedPath("-sourceroots", sourceRoots, list);
-
+
if (this.compilerArgs != null) {
for (CompilerArg compilerArg:compilerArgs) {
list.add(compilerArg.toString());
/**
* Throw BuildException unless file is valid.
- *
+ *
* @param file the File to check
* @param name the symbolic name to print on error
* @param isDir if true, verify file is a directory
/**
* Read arguments in as if from a command line, mainly to support compiler adapter compilerarg subelement.
- *
+ *
* @param args the String[] of arguments to read
*/
public void readArguments(String[] args) { // XXX slow, stupid, unmaintainable
/**
* Adjust args for size if necessary by creating an argument file, which should be deleted by the client after the compiler
* run has completed.
- *
+ *
* @param max the int maximum length of the command line (in char)
* @return the temp File for the arguments (if generated), for deletion when done.
* @throws IllegalArgumentException if max is negative
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.bridge.IMessageHandler#handleMessage(org.aspectj.bridge.IMessage)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.bridge.IMessageHandler#dontIgnore(org.aspectj.bridge.IMessage.Kind)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.bridge.IMessageHandler#ignore(org.aspectj.bridge.IMessage.Kind)
*/
@Override
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC)
* 2003 Contributors.
* 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://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:
* Xerox/PARC initial implementation
- * IBM ongoing maintenance
+ * IBM ongoing maintenance
* ******************************************************************/
package org.aspectj.tools.ant.taskdefs;
/**
* AjcTask test cases.
* Please put new ones with others between ------- comments.
- *
+ *
* Some API tests, but mostly functional tests driving
* the task execute using data in ../taskdefs/testdata.
* This will re-run in forked mode for any nonfailing
};
}
- /**
+ /**
* Check that aspectjtools are found on the classpath,
* reporting any errors to System.err.
- *
+ *
* Run multiple times with different classpaths.
* This should find variants
* aspectjtools.jar,
* but not
* aspectjrt.jar or
* aspectj/tools.jar.
- * XXX use testing aspect to stub out
+ * XXX use testing aspect to stub out
* <code>System.getProperty("java.class.path")</code>
* @param args a String[], first is expected path, if any
*/
// ------------------------------------------------------
// ------------------------------------------------------
// Start of test cases
-
+
public void testNullDestDir() {
AjcTask task = getTask(NOFILE, null);
String[] cmd = task.makeCommand();
assertTrue(!"-d".equals(cmd[i]));
}
}
-
+
public void testOutputRequirement() {
AjcTask task = getTask("default.lst");
checkRun(task, null);
assertTrue(
"unable to create " + destDir,
destDir.canRead() || destDir.mkdirs());
- AjcTask task = getTask(NOFILE, destDir);
+ AjcTask task = getTask(NOFILE, destDir);
Project p = task.getProject();
Path indirs = new Path(p);
File dir = new File(testdataDir, "inpathDirs").getAbsoluteFile();
indirs.addExisting(new Path(p, new File(dir, "inpathDirTwo").getAbsolutePath()));
task.setInpath(indirs);
task.setInpathDirCopyFilter("doNotCopy,**/*.txt");
-
+
File file = new File(destDir, "Default.java").getAbsoluteFile();
assertTrue(file + ".canRead() prematurely", !file.canRead());
checkRun(task, null);
file = new File(destDir, "skipTxtFiles.txt");
assertTrue(file + ".canRead() passed", !file.canRead());
}
-
+
public void testInpathDirCopyFilterWithJar() throws IOException {
checkInpathCopy("testInpathDirCopyFilterWithJar-out.jar");
}
public void testInpathDirCopyFilterWithOddjar() throws IOException {
checkInpathCopy("testInpathDirCopyFilterWithJar-outJarFile");
}
-
+
private void checkInpathCopy(String outjarFileStr) throws IOException {
// inpathDirCopyFilter works with output jar
File destDir = getTempDir();
assertTrue(
"unable to create " + destDir,
destDir.canRead() || destDir.mkdirs());
- AjcTask task = getTask(NOFILE, null);
+ AjcTask task = getTask(NOFILE, null);
File destJar = new File(destDir, outjarFileStr);
task.setOutjar(destJar);
Project p = task.getProject();
indirs.addExisting(new Path(p, new File(dir, "inpathDirTwo").getAbsolutePath()));
task.setInpath(indirs);
task.setInpathDirCopyFilter("doNotCopy,**/*.txt,**/*.class");
-
+
checkRun(task, null);
JarFile jarFile = new JarFile(destJar);
- String[] expected = {"copyMe.htm", "pack/includeme",
+ String[] expected = {"copyMe.htm", "pack/includeme",
"pack/Pack.class", "Default.class"};
String[] unexpected = {"doNotCopy", "skipTxtFiles.txt", "pack/something.txt"};
for (int i = 0; i < expected.length; i++) {
public void testInpathDirCopyFilterError() {
// inpathDirCopyFilter fails with no output directory or jar iff specified
- AjcTask task = getTask(NOFILE, null);
+ AjcTask task = getTask(NOFILE, null);
Project p = task.getProject();
Path indirs = new Path(p);
File dir = new File(testdataDir, "inpathDirs").getAbsoluteFile();
}
// not found when unit testing b/c not on system classpath
// so just checking for exceptions.
- // XXX need aspect to stub out System.getProperty(..)
+ // XXX need aspect to stub out System.getProperty(..)
}
// change by 1.8 final... this might need reverting back to ONE_ERROR
runTest(task, NO_EXCEPTION, MessageHolderChecker.THREE_ERRORS);
}
-
+
public void testShowWeaveInfo() {
AjcTask task = getTask("showweaveinfo.lst");
task.setShowWeaveInfo(true);
checkContains(cmd, inputs[i], true);
}
}
-
+
public void testClasspath() {
AjcTask task = getTask(NOFILE);
String[] cmd = task.makeCommand();
"expecting aspectj in classpath",
(-1 != classpath.indexOf("aspectjrt.jar")));
}
-
+
CompilerArg createCompilerArg(String value) {
CompilerArg c = new CompilerArg();
c.setValue(value);
return c;
}
-
+
public void testAddModulesJ9() {
AjcTask task = getTask(NOFILE);
task.createCompilerarg().setValue("--add-modules");
assertNotSame(-1, addModulesPos);
assertEquals("java.xml.bind,java.io",cmd[addModulesPos+1]);
}
-
+
private int findOptionPosition(String[] cmd, String optionString) {
for (int i=0;i<cmd.length;i++) {
if (cmd[i].equals(optionString)) {
task.setTarget("1.1");
task.setTime(true);
task.setVerbose(true);
- task.setXlint("info");
+ task.setXlint("info");
}
-
+
public void testLogCommand() {
final String DEFAULT = "default.lst";
AjcTask task = getTask(DEFAULT);
String[] cmd = task.makeCommand();
checkContains(cmd,"-X" + xopts[i],true);
}
-
+
}
public void testAptProc() {
checkContains(task.makeCommand(), "-s", true);
checkContains(task.makeCommand(), "some/path", true);
}
-
+
public void testOutxml () {
File destDir = getTempDir();
assertTrue(
File outxmlFile = new File(destDir,"META-INF/aop-ajc.xml");
assertTrue("META-INF/aop-ajc.xml missing",outxmlFile.exists());
}
-
+
public void testOutxmlFile () {
- String customName = "custom/aop.xml";
+ String customName = "custom/aop.xml";
File destDir = getTempDir();
assertTrue(
"unable to create " + destDir,
&& (null == exceptionType)
&& ((null == checker) || !checker.expectFail()));
String label = "same-vm ";
- while (true) { // same vm, then perhaps forked
+ while (true) { // same vm, then perhaps forked
try {
task.execute();
} catch (Throwable t) {
new MessageHolderChecker(0, 0, 0, 1, IGNORE);
static MessageHolderChecker THREE_ERRORS =
new MessageHolderChecker(0, 0, 3, 0, IGNORE);
-
+
int aborts, fails, errors, warnings, infos;
int weaveinfos;
holder,
kind + " expected " + num + " got " + actual);
}
- if (num != actual){
+ if (num != actual){
System.out.println("===\n"+Arrays.toString(holder.getMessages(kind, false))+"\n===\n");
}
assertEquals(kind.toString(), num, actual);
/* *******************************************************************
* Copyright (c) 2004,2019 IBM Corporation, contributors
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * 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.testing;
* @author Andy Clement
*/
public class AjcTest {
-
+
// private static boolean is13VMOrGreater = true;
private static boolean is14VMOrGreater = true;
private static boolean is15VMOrGreater = false;
private static boolean is10VMOrGreater = false;
private static boolean is11VMOrGreater = false;
private static boolean is12VMOrGreater = false;
-
+ private static boolean is13VMOrGreater = false;
+
static { // matching logic is also in org.aspectj.util.LangUtil
is14VMOrGreater = LangUtil.is14VMOrGreater();
is15VMOrGreater = LangUtil.is15VMOrGreater();
is10VMOrGreater = LangUtil.is10VMOrGreater();
is11VMOrGreater = LangUtil.is11VMOrGreater();
is12VMOrGreater = LangUtil.is12VMOrGreater();
+ is13VMOrGreater = LangUtil.is13VMOrGreater();
}
private List<ITestStep> testSteps = new ArrayList<ITestStep>();
-
+
private String dir;
private String pr;
private String title;
public AjcTest() {
}
-
+
public void addTestStep(ITestStep step) {
testSteps.add(step);
step.setTest(this);
}
-
+
public boolean runTest(AjcTestCase testCase) {
if (!canRunOnThisVM()) return false;
try {
- System.out.print("TEST: " + getTitle() + "\t");
+ System.out.print("TEST: " + getTitle() + "\t");
for (ITestStep step: testSteps) {
step.setBaseDir(getDir());
System.out.print(".");
}
return true;
}
-
- public boolean canRunOnThisVM() {
+
+ public boolean canRunOnThisVM() {
if (vmLevel.equals("1.3")) return true;
boolean canRun = true;
if (vmLevel.equals("1.4")) canRun = is14VMOrGreater;
if (vmLevel.equals("10")) canRun = is10VMOrGreater;
if (vmLevel.equals("11")) canRun = is11VMOrGreater;
if (vmLevel.equals("12")) canRun = is12VMOrGreater;
+ if (vmLevel.equals("13")) canRun = is13VMOrGreater;
if (!canRun) {
- System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
+ System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
+ ", currently running on " + System.getProperty("java.vm.version"));
}
return canRun;
}
-
+
/**
* @return Returns the comment.
*/
public void setVm(String vmLevel) {
this.vmLevel = vmLevel;
}
-
+
/**
* @return Returns the vmLevel.
*/
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2019 Contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement
+ * ******************************************************************/
+package org.aspectj.testing;
+
+import org.aspectj.util.LangUtil;
+
+/**
+ * Makes sure tests are running on the right level of JDK.
+ *
+ * @author Andy Clement
+ */
+public abstract class XMLBasedAjcTestCaseForJava13OrLater extends XMLBasedAjcTestCase {
+
+ @Override
+ public void runTest(String title) {
+ if (!LangUtil.is13VMOrGreater()) {
+ throw new IllegalStateException("These tests should be run on Java 13 or later");
+ }
+ super.runTest(title);
+ }
+
+}
<artifactId>asm</artifactId>
<version>1.0</version>
<scope>system</scope>
- <systemPath>${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar</systemPath>
+ <systemPath>${project.basedir}/../lib/asm/asm-7.2.renamed.jar</systemPath>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.aspectj.systemtest.ajc193;
+package org.aspectj.systemtest.ajc193;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.testing.XMLBasedAjcTestCase;
/**
* @author Andy Clement
- */
+ */
public class Java12Tests extends XMLBasedAjcTestCaseForJava12OrLater {
public void testSwitch1() {
runTest("switch 1");
- checkVersion("Switch1", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ checkVersion("Switch1", Constants.MAJOR_13, Constants.PREVIEW_MINOR_VERSION);
}
public void testSwitch2() {
runTest("switch 2");
- checkVersion("Switch2", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ checkVersion("Switch2", Constants.MAJOR_13, Constants.PREVIEW_MINOR_VERSION);
}
public void testSwitch3() {
runTest("switch 3");
- checkVersion("Switch3", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION);
+ checkVersion("Switch3", Constants.MAJOR_13, Constants.PREVIEW_MINOR_VERSION);
}
// ---
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.9.4 tests");
suite.addTest(Ajc195Tests.suite());
+ suite.addTest(SanityTestsJava13.suite());
return suite;
}
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2006, 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
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc195;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava13OrLater;
+
+import junit.framework.Test;
+
+/*
+ * Some very trivial tests that help verify things are OK.
+ * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option
+ * to check code generation and modification with that version specified.
+ *
+ * @author Andy Clement
+ */
+public class SanityTestsJava13 extends XMLBasedAjcTestCaseForJava13OrLater {
+
+ public static final int bytecode_version_for_JDK_level = 57;
+
+ // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
+ public void testSimpleJava_A() {
+ runTest("simple - a");
+ }
+
+ public void testSimpleJava_B() {
+ runTest("simple - b");
+ }
+
+ public void testSimpleCode_C() {
+ runTest("simple - c");
+ }
+
+ public void testSimpleCode_D() {
+ runTest("simple - d");
+ }
+
+ public void testSimpleCode_E() {
+ runTest("simple - e");
+ }
+
+ public void testSimpleCode_F() {
+ runTest("simple - f");
+ }
+
+ public void testSimpleCode_G() {
+ runTest("simple - g");
+ }
+
+ public void testSimpleCode_H() {
+ runTest("simple - h", true);
+ }
+
+ public void testSimpleCode_I() {
+ runTest("simple - i");
+ }
+
+ public void testVersionCorrect1() throws ClassNotFoundException {
+ runTest("simple - j");
+ checkVersion("A", bytecode_version_for_JDK_level, 0);
+ }
+
+ public void testVersionCorrect2() throws ClassNotFoundException {
+ runTest("simple - k");
+ checkVersion("A", bytecode_version_for_JDK_level, 0);
+ }
+
+ public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
+ runTest("simple - m");
+ checkVersion("A", 49, 0);
+ }
+
+
+ // ///////////////////////////////////////
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(SanityTestsJava13.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("sanity-tests-13.xml");
+ }
+
+}
</run>
</ajc-test>
- <ajc-test dir="features193" vm="12" title="switch 1">
- <compile files="Switch1.java" options="-12 --enable-preview">
+ <!-- with the release of 13 this behaviour seems to have moved from 12 to 13?? -->
+ <ajc-test dir="features193" vm="13" title="switch 1">
+ <compile files="Switch1.java" options="-13 --enable-preview">
</compile>
<run class="Switch1" vmargs="--enable-preview">
<stdout>
</run>
</ajc-test>
- <ajc-test dir="features193" vm="12" title="switch 2">
- <compile files="Switch2.java" options="--enable-preview -source 12">
+ <ajc-test dir="features193" vm="13" title="switch 2">
+ <compile files="Switch2.java" options="--enable-preview -source 13">
</compile>
<run class="Switch2" vmargs="--enable-preview">
<stdout>
</run>
</ajc-test>
- <ajc-test dir="features193" vm="12" title="switch 3">
- <compile files="Switch3.java" options="--enable-preview -source 12">
+ <ajc-test dir="features193" vm="13" title="switch 3">
+ <compile files="Switch3.java" options="--enable-preview -source 13">
</compile>
<run class="Switch3" vmargs="--enable-preview">
<stdout>
--- /dev/null
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <!-- empty class -->
+ <ajc-test dir="bugs160/simplejava" title="simple - a">
+ <compile files="SimpleA.java" options="-13"/>
+ </ajc-test>
+
+ <!-- class with one method -->
+ <ajc-test dir="bugs160/simplejava" title="simple - b">
+ <compile files="SimpleB.java" options="-13"/>
+ <run class="SimpleB"/>
+ </ajc-test>
+
+ <!-- empty aspect -->
+ <ajc-test dir="bugs160/simplejava" title="simple - c">
+ <compile files="SimpleC.java" options="-13"/>
+ </ajc-test>
+
+ <!-- simple before -->
+ <ajc-test dir="bugs160/simplejava" title="simple - d">
+ <compile files="SimpleD.java" options="-13"/>
+ </ajc-test>
+
+ <!-- simple itd field -->
+ <ajc-test dir="bugs160/simplejava" title="simple - e">
+ <compile files="SimpleE.java" options="-13"/>
+ </ajc-test>
+
+ <!-- aspect with main calling a static method -->
+ <ajc-test dir="bugs160/simplejava" title="simple - f">
+ <compile files="SimpleF.java" options="-13"/>
+ </ajc-test>
+
+ <!-- pertarget -->
+ <ajc-test dir="bugs160/simplejava" title="simple - g">
+ <compile files="SimpleG.java" options="-13"/>
+ </ajc-test>
+
+ <!-- generic ctor itds -->
+ <ajc-test dir="bugs160/simplejava" title="simple - h">
+ <compile files="SimpleH.java" options="-13"/>
+ </ajc-test>
+
+ <!-- overriding generic itd methods -->
+ <ajc-test dir="bugs160/simplejava" title="simple - i">
+ <compile files="SimpleI.java" options="-13"/>
+ </ajc-test>
+
+ <!-- check class file version is 57.0 -->
+ <ajc-test dir="bugs160/simplejava" title="simple - j">
+ <compile files="SimpleJ.java" options="-13"/>
+ </ajc-test>
+
+ <!-- check class file version is 57.0 -->
+ <ajc-test dir="bugs160/simplejava" title="simple - k">
+ <compile files="SimpleJ.java" options="-source 13"/>
+ </ajc-test>
+
+ <!-- check class file version is 49.0 -->
+ <ajc-test dir="bugs160/simplejava" title="simple - m">
+ <compile files="SimpleJ.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs160/simplejava" title="simple - n">
+ <compile files="SimpleN.java" options="-13"/>
+ </ajc-test>
+</suite>
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* 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:
- * 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.util;
import java.util.StringTokenizer;
/**
- *
+ *
*/
public class LangUtil {
public static String getVmVersionString() {
return Double.toString(vmVersion);
}
-
+
public static double getVmVersion() {
return vmVersion;
}
-
+
static {
StringWriter buf = new StringWriter();
PrintWriter writer = new PrintWriter(buf);
.printStackTrace(System.err);
vmVersion = 1.5;
} else {
- // Version: [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
+ // Version: [1-9][0-9]*((\.0)*\.[1-9][0-9]*)*
// Care about the first set of digits and second set if first digit is 1
try {
List<Integer> numbers = getFirstNumbers(vm);
vmVersion = 1.5;
}
}
-
+
private static List<Integer> getFirstNumbers(String vm) {
List<Integer> result = new ArrayList<Integer>();
StringTokenizer st = new StringTokenizer(vm,".-_");
return result;
}
- public static boolean is13VMOrGreater() {
+ public static boolean isOnePointThreeVMOrGreater() {
return 1.3 <= vmVersion;
}
public static boolean is17VMOrGreater() {
return 1.7 <= vmVersion;
}
-
+
public static boolean is18VMOrGreater() {
return 1.8 <= vmVersion;
}
-
+
public static boolean is19VMOrGreater() {
return 9 <= vmVersion;
}
-
+
public static boolean is10VMOrGreater() {
return 10 <= vmVersion;
}
return 12 <= vmVersion;
}
+ public static boolean is13VMOrGreater() {
+ return 13 <= vmVersion;
+ }
+
+
/**
* Shorthand for "if null, throw IllegalArgumentException"
- *
+ *
* @throws IllegalArgumentException "null {name}" if o is null
*/
public static final void throwIaxIfNull(final Object o, final String name) {
/**
* Shorthand for "if not null or not assignable, throw IllegalArgumentException"
- *
+ *
* @param c the Class to check - use null to ignore type check
* @throws IllegalArgumentException "null {name}" if o is null
*/
/**
* Shorthand for "if not null or not assignable, throw IllegalArgumentException"
- *
+ *
* @throws IllegalArgumentException "null {name}" if o is null
*/
public static final void throwIaxIfNotAssignable(final Object o, final Class<?> c, final String name) {
// if (null != c) {
// for (Iterator iter = collection.iterator(); iter.hasNext();) {
// throwIaxIfNotAssignable(iter.next(), c, name);
- //
+ //
// }
// }
// }
/**
* Shorthand for "if false, throw IllegalArgumentException"
- *
+ *
* @throws IllegalArgumentException "{message}" if test is false
*/
public static final void throwIaxIfFalse(final boolean test, final String message) {
/**
* Splits <code>text</code> at whitespace.
- *
+ *
* @param text <code>String</code> to split.
*/
public static String[] split(String text) {
/**
* Splits <code>input</code> at commas, trimming any white space.
- *
+ *
* @param input <code>String</code> to split.
* @return List of String of elements.
*/
/**
* Split string as classpath, delimited at File.pathSeparator. Entries are not trimmed, but empty entries are ignored.
- *
+ *
* @param classpath the String to split - may be null or empty
* @return String[] of classpath entries
*/
/**
* Get System property as boolean, but use default value where the system property is not set.
- *
+ *
* @return true if value is set to true, false otherwise
*/
public static boolean getBoolean(String propertyName, boolean defaultValue) {
* Splits <code>input</code>, removing delimiter and trimming any white space. Returns an empty collection if the input is null.
* If delimiter is null or empty or if the input contains no delimiters, the input itself is returned after trimming white
* space.
- *
+ *
* @param input <code>String</code> to split.
* @param delim <code>String</code> separators for input.
* @return List of String of elements.
/**
* Splits strings into a <code>List</code> using a <code>StringTokenizer</code>.
- *
+ *
* @param text <code>String</code> to split.
*/
public static List<String> strings(String text) {
// }
// return (String[]) result.toArray(new String[0]);
// }
- //
+ //
// /**
// * Select from input String[] if readable directories
// * @param inputs String[] of input - null ignored
/**
* copy non-null two-dimensional String[][]
- *
+ *
* @see extractOptions(String[], String[][])
*/
public static String[][] copyStrings(String[][] in) {
/**
* Extract options and arguments to input option list, returning remainder. The input options will be nullified if not found.
* e.g.,
- *
+ *
* <pre>
* String[] options = new String[][] { new String[] { "-verbose" }, new String[] { "-classpath", null } };
* String[] args = extractOptions(args, options);
* boolean verbose = null != options[0][0];
* boolean classpath = options[1][1];
* </pre>
- *
+ *
* @param args the String[] input options
* @param options the String[][]options to find in the input args - not null for each String[] component the first subcomponent
* is the option itself, and there is one String subcomponent for each additional argument.
return args;
}
- //
+ //
// /**
// * Extract options and arguments to input parameter list, returning
// remainder.
// options = temp;
// boolean[] dup = new boolean[options.length];
// int numDups = 0;
- //
+ //
// for (int i = 0; i < options.length; i++) {
// String option = options[i];
// if (LangUtil.isEmpty(option)) {
// }
// return result;
// }
- //
+ //
// private static int exp(int base, int power) { // not in Math?
// if (0 > power) {
// throw new IllegalArgumentException("negative power: " + power);
/**
* Convert arrays safely. The number of elements in the result will be 1 smaller for each element that is null or not
* assignable. This will use sink if it has exactly the right size. The result will always have the same component type as sink.
- *
+ *
* @return an array with the same component type as sink containing any assignable elements in source (in the same order).
* @throws IllegalArgumentException if either is null
*/
/**
* Renders exception <code>t</code> after unwrapping and eliding any test packages.
- *
+ *
* @param t <code>Throwable</code> to print.
* @see #maxStackTrace
*/
/**
* Renders exception <code>t</code>, unwrapping, optionally eliding and limiting total number of lines.
- *
+ *
* @param t <code>Throwable</code> to print.
* @param elide true to limit to 100 lines and elide test packages
* @see StringChecker#TEST_PACKAGES
/**
* Trim ending lines from a StringBuffer, clipping to maxLines and further removing any number of trailing lines accepted by
* checker.
- *
+ *
* @param checker returns true if trailing line should be elided.
* @param stack StringBuffer with lines to elide
* @param maxLines int for maximum number of resulting lines
/**
* Replacement for Arrays.asList(..) which gacks on null and returns a List in which remove is an unsupported operation.
- *
+ *
* @param array the Object[] to convert (may be null)
* @return the List corresponding to array (never null)
*/
/**
* Gen classpath.
- *
+ *
* @param bootclasspath
* @param classpath
* @param classesDir
/**
* Create or initialize a process controller to run a process in another VM asynchronously.
- *
+ *
* @param controller the ProcessController to initialize, if not null
* @param classpath
* @param mainClass
/**
* Find java executable File path from java.home system property.
- *
+ *
* @return File associated with the java command, or null if not found.
*/
public static File getJavaExecutable() {
/**
* Sleep until a particular time.
- *
+ *
* @param time the long time in milliseconds to sleep until
* @return true if delay succeeded, false if interrupted 100 times
*/
* when the process completes.
* <p>
* The following sample code creates a process with a completion callback starts it, and some time later retries the process.
- *
+ *
* <pre>
* LangUtil.ProcessController controller = new LangUtil.ProcessController() {
* protected void doCompleting(LangUtil.ProcessController.Thrown thrown, int result) {
- * // signal result
+ * // signal result
* }
* };
* controller.init(new String[] { "java", "-version" }, "java version");
* controller.start();
* }
* </pre>
- *
+ *
* <u>warning</u>: Currently this does not close the input or output streams, since doing so prevents their use later.
*/
public static class ProcessController {
/**
* Start running the process and pipes asynchronously.
- *
+ *
* @return Thread started or null if unable to start thread (results available via <code>getThrown()</code>, etc.)
*/
public final Thread start() {
/**
* Get any Throwable thrown. Note that the process can complete normally (with a valid return value), at the same time the
* pipes throw exceptions, and that this may return some exceptions even if the process is not complete.
- *
+ *
* @return null if not complete or Thrown containing exceptions thrown by the process and streams.
*/
public final Thrown getThrown() { // cache this
* completed abruptly (including side-effects of the user halting the process). If <code>userStopped()</code> is true, then
* some client asked that the process be destroyed using <code>stop()</code>. Otherwise, the result code should be the
* result value returned by the process.
- *
+ *
* @param thrown same as <code>getThrown().fromProcess</code>.
* @param result same as <code>getResult()</code>
* @see getThrown()
/**
* Handle termination (on-demand, abrupt, or normal) by destroying and/or halting process and pipes.
- *
+ *
* @param thrown ignored if null
* @param result ignored if Integer.MIN_VALUE
*/
/**
* Create snapshot of Throwable's thrown.
- *
+ *
* @param thrown ignored if null or if this.thrown is not null
*/
private final synchronized Thrown makeThrown(Throwable processThrown) {
}
} // class Thrown
}
-
+
public static String getJrtFsFilePath() {
return getJavaHome() + File.separator + "lib" + File.separator + JRT_FS;
}
-
+
public static String getJavaHome() {
return System.getProperty("java.home");
}
// }
public void testVersion() {
- assertTrue(LangUtil.is13VMOrGreater()); // min vm now - floor may change
+ assertTrue(LangUtil.isOnePointThreeVMOrGreater()); // min vm now - floor may change
if (LangUtil.is15VMOrGreater()) {
assertTrue(LangUtil.is14VMOrGreater());
}
<artifactId>asm</artifactId>
<version>1.0</version>
<scope>system</scope>
- <systemPath>${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar</systemPath>
+ <systemPath>${project.basedir}/../lib/asm/asm-7.2.renamed.jar</systemPath>
</dependency>
</dependencies>
</project>
/*******************************************************************************
* 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
- *
+ * 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:
* Alexandre Vasseur initial implementation
*******************************************************************************/
* <p/>
* Specific state and logic is kept in the munger ala ITD so that call/get/set pointcuts can still be matched on the wrapped member
* thanks to the EffectiveSignature attribute.
- *
+ *
* @author Alexandre Vasseur
* @author Andy Clement
*/
for (ResolvedMember resolvedMember : methods) {
if (invoke.getName(cpg).equals(resolvedMember.getName())
&& invoke.getSignature(cpg).equals(resolvedMember.getSignature()) && !resolvedMember.isPublic()) {
- if ("<init>".equals(invoke.getName(cpg))) {
- // skipping open up for private constructor
- // can occur when aspect new a private inner type
- // too complex to handle new + dup + .. + invokespecial here.
- aroundAdvice.setCanInline(false);
- realizedCannotInline = true;
+ if ("<init>".equals(invoke.getName(cpg))
+ ) {
+ // If ctor invocation, we care about whether it is targeting exactly the same type
+ // (ignore non public ctors in supertype of the target) (J13 - AbstractStringBuilder has something
+ // that trips this up in one testcase)
+ if (invoke.getClassName(cpg).equals(resolvedMember.getDeclaringType().getPackageName()+
+ "."+resolvedMember.getDeclaringType().getClassName())) {
+ // skipping open up for private constructor
+ // can occur when aspect new a private inner type
+ // too complex to handle new + dup + .. + invokespecial here.
+ aroundAdvice.setCanInline(false);
+ realizedCannotInline = true;
+ }
} else {
// specific handling for super.foo() calls, where foo is non public
ResolvedType memberType = aspectGen.getWorld().resolve(resolvedMember.getDeclaringType());