diff options
36 files changed, 909 insertions, 648 deletions
diff --git a/ajdoc/pom.xml b/ajdoc/pom.xml index cd749215a..226f92fb9 100644 --- a/ajdoc/pom.xml +++ b/ajdoc/pom.xml @@ -48,7 +48,7 @@ <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> diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java index ec492fce9..7dd50b4ef 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -1,14 +1,14 @@ /* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, + * Copyright (c) 1999-2001 Xerox Corporation, * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Xerox/PARC initial implementation * Mik Kersten port to AspectJ 1.1+ code base * ******************************************************************/ @@ -77,7 +77,7 @@ class HtmlDecorator { /** * 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 */ @@ -229,6 +229,11 @@ class HtmlDecorator { // <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); @@ -307,7 +312,7 @@ class HtmlDecorator { 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)) { @@ -737,7 +742,7 @@ class HtmlDecorator { /** * 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>. */ @@ -758,7 +763,7 @@ class HtmlDecorator { * 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 = ""; @@ -828,7 +833,7 @@ class HtmlDecorator { * 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) { @@ -883,11 +888,11 @@ class HtmlDecorator { 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); } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java index c92e96d2e..61172346c 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -1,13 +1,13 @@ /* ******************************************************************* * Copyright (c) 2003 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * 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; @@ -18,21 +18,21 @@ import org.aspectj.util.LangUtil; /** * 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", @@ -42,21 +42,21 @@ public class CoverageTestCase extends AjdocTestCase { "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 @@ -69,7 +69,7 @@ public class CoverageTestCase extends AjdocTestCase { 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. @@ -81,7 +81,7 @@ public class CoverageTestCase extends AjdocTestCase { 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" */ @@ -91,13 +91,13 @@ public class CoverageTestCase extends AjdocTestCase { 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")}; @@ -105,29 +105,29 @@ public class CoverageTestCase extends AjdocTestCase { 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[] { @@ -160,26 +160,31 @@ public class CoverageTestCase extends AjdocTestCase { 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>", @@ -191,29 +196,29 @@ public class CoverageTestCase extends AjdocTestCase { 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..", @@ -231,19 +236,19 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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)\"", @@ -264,39 +269,39 @@ public class CoverageTestCase extends AjdocTestCase { "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..\""}; @@ -306,7 +311,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -314,20 +319,20 @@ public class CoverageTestCase extends AjdocTestCase { 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..\""}; @@ -351,20 +356,20 @@ public class CoverageTestCase extends AjdocTestCase { 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..\""}; @@ -374,7 +379,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -384,18 +389,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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..\""}; @@ -405,7 +410,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -415,18 +420,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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..\""}; @@ -436,7 +441,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -446,18 +451,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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", @@ -465,7 +470,7 @@ public class CoverageTestCase extends AjdocTestCase { 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)"), @@ -479,7 +484,7 @@ public class CoverageTestCase extends AjdocTestCase { 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()"), @@ -495,18 +500,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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..\""}; @@ -527,18 +532,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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, @@ -548,18 +553,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * 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..\""}; @@ -569,7 +574,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -587,17 +592,17 @@ public class CoverageTestCase extends AjdocTestCase { } /** * 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..\"", @@ -608,21 +613,21 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -630,7 +635,7 @@ public class CoverageTestCase extends AjdocTestCase { 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 @@ -638,12 +643,12 @@ public class CoverageTestCase extends AjdocTestCase { 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, @@ -652,40 +657,40 @@ public class CoverageTestCase extends AjdocTestCase { 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", @@ -708,10 +713,17 @@ public class CoverageTestCase extends AjdocTestCase { 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>", @@ -742,20 +754,20 @@ public class CoverageTestCase extends AjdocTestCase { /** * 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()) { @@ -770,7 +782,7 @@ public class CoverageTestCase extends AjdocTestCase { "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()); @@ -782,26 +794,33 @@ public class CoverageTestCase extends AjdocTestCase { 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>", @@ -822,7 +841,7 @@ public class CoverageTestCase extends AjdocTestCase { 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 @@ -830,13 +849,13 @@ public class CoverageTestCase extends AjdocTestCase { 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..", @@ -853,7 +872,7 @@ public class CoverageTestCase extends AjdocTestCase { "' 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 @@ -861,13 +880,13 @@ public class CoverageTestCase extends AjdocTestCase { 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 "); @@ -876,7 +895,7 @@ public class CoverageTestCase extends AjdocTestCase { 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()"), @@ -914,7 +933,7 @@ public class CoverageTestCase extends AjdocTestCase { " in the Method Summary section", b); } - + private void createFiles() { file0 = new File(getAbsoluteProjectDir() + "/InDefaultPackage.java"); file1 = new File(getAbsoluteProjectDir() + "/foo/ClassA.java"); @@ -929,12 +948,12 @@ public class CoverageTestCase extends AjdocTestCase { 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); // } - + } diff --git a/aspectjtools/pom.xml b/aspectjtools/pom.xml index ac665f78a..c0acbfcbd 100644 --- a/aspectjtools/pom.xml +++ b/aspectjtools/pom.xml @@ -50,7 +50,7 @@ <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> diff --git a/aspectjweaver/pom.xml b/aspectjweaver/pom.xml index fe50f5ed8..38049d78f 100644 --- a/aspectjweaver/pom.xml +++ b/aspectjweaver/pom.xml @@ -50,7 +50,7 @@ <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> diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java index c0c0930b0..f80cc0f82 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java @@ -58,7 +58,7 @@ import org.aspectj.apache.bcel.generic.Type; /** * Constants for the project, mostly defined in the JVM specification. - * + * * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author Andy Clement */ @@ -88,9 +88,11 @@ public interface Constants { 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; @@ -138,7 +140,7 @@ public interface Constants { // 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; @@ -159,15 +161,15 @@ public interface Constants { 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", @@ -651,7 +653,7 @@ public interface Constants { 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; @@ -663,11 +665,11 @@ public interface Constants { 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" }; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java index 9d15e81f4..2797df3cc 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java @@ -137,7 +137,7 @@ public class ClassPath implements Serializable { /** * Search for classes in CLASSPATH. - * + * * @deprecated Use SYSTEM_CLASS_PATH constant */ @Deprecated @@ -225,11 +225,13 @@ public class ClassPath implements Serializable { 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(); @@ -436,7 +438,7 @@ public class ClassPath implements Serializable { return dir; } } - + private static class JImage extends PathEntry { private static URI JRT_URI = URI.create("jrt:/"); //$NON-NLS-1$ @@ -444,8 +446,8 @@ public class ClassPath implements Serializable { 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(); @@ -476,7 +478,7 @@ public class ClassPath implements Serializable { } return fileMap; } - + private static class ByteBasedClassFile implements ClassFile { private byte[] bytes; @@ -485,15 +487,15 @@ public class ClassPath implements Serializable { 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? @@ -520,9 +522,9 @@ public class ClassPath implements Serializable { public long getSize() { return this.size; } - + } - + @Override ClassFile getClassFile(String name, String suffix) throws IOException { // Class files are in here under names like this: diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/core/dom/AjASTFactory.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/core/dom/AjASTFactory.java index 68084e7e4..5ee3cdbbf 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/core/dom/AjASTFactory.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/core/dom/AjASTFactory.java @@ -1,23 +1,23 @@ /******************************************************************** - * 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); } } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 8db8e6076..2d2dd999c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -1,13 +1,13 @@ /* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation * ******************************************************************/ package org.aspectj.ajdt.internal.compiler.ast; @@ -50,7 +50,7 @@ import org.aspectj.weaver.UnresolvedType; /** * 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 { @@ -61,7 +61,7 @@ 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 @@ -146,7 +146,7 @@ public class AdviceDeclaration extends AjMethodDeclaration { 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; @@ -183,7 +183,13 @@ public class AdviceDeclaration extends AjMethodDeclaration { // 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); } @@ -240,7 +246,7 @@ public class AdviceDeclaration extends AjMethodDeclaration { } AstUtil.generateReturn(returnType, codeStream); codeStream.recordPositionsFrom(0, 1); - classFile.completeCodeAttribute(codeAttributeOffset); + classFile.completeCodeAttribute(codeAttributeOffset,scope); attributeNumber++; classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index 31a1549ee..deea7f3f4 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -425,6 +425,8 @@ public class AspectDeclaration extends TypeDeclaration { 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 @@ -464,15 +466,23 @@ public class AspectDeclaration extends TypeDeclaration { 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); } @@ -713,14 +723,16 @@ public class AspectDeclaration extends TypeDeclaration { 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); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java index 3f8e99494..9b6d7ddcc 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java @@ -1,13 +1,13 @@ /* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation * ******************************************************************/ package org.aspectj.ajdt.internal.compiler.ast; @@ -53,10 +53,10 @@ import org.aspectj.weaver.UnresolvedType; /** * 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 { @@ -134,16 +134,16 @@ 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() && @@ -203,7 +203,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { /* * 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 = @@ -230,7 +230,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { * (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) { @@ -378,7 +378,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { } AstUtil.generateReturn(binding.returnType, codeStream); - classFile.completeCodeAttribute(codeAttributeOffset); + classFile.completeCodeAttribute(codeAttributeOffset,scope); attributeNumber++; classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java index fc0d42154..01e975a63 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java @@ -1,13 +1,13 @@ /* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation * ******************************************************************/ package org.aspectj.ajdt.internal.compiler.ast; @@ -52,12 +52,12 @@ import org.aspectj.weaver.UnresolvedType; /** * 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 @@ -103,7 +103,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { 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(); @@ -338,7 +338,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { } } } - classFile.completeCodeAttribute(codeAttributeOffset); + classFile.completeCodeAttribute(codeAttributeOffset,scope); attributeNumber++; classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java index bcb2a4c97..0f131c62e 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java @@ -1,13 +1,13 @@ /* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation * ******************************************************************/ package org.aspectj.ajdt.internal.compiler.lookup; @@ -18,8 +18,8 @@ import java.util.Map; 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; @@ -48,7 +48,7 @@ public class InterTypeScope extends ClassScope { 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 @@ -89,7 +89,7 @@ public class InterTypeScope extends ClassScope { 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! } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java index e48c6cd0f..2e4001e07 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java @@ -1,12 +1,12 @@ /* ******************************************************************* * 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; @@ -41,9 +41,9 @@ public class CompactTypeStructureRepresentation implements IBinaryType { char[] genericSignature; char[] superclassName; char[][] interfaces; - + char[] enclosingMethod; - + char[][][] missingTypeNames; // this is the extra state that enables us to be an IBinaryType @@ -59,7 +59,7 @@ public class CompactTypeStructureRepresentation implements IBinaryType { IBinaryNestedType[] memberTypes; IBinaryAnnotation[] annotations; IBinaryTypeAnnotation[] typeAnnotations; - + public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) { @@ -103,7 +103,7 @@ public class CompactTypeStructureRepresentation implements IBinaryType { public char[][][] getMissingTypeNames() { return missingTypeNames; } - + public char[] getEnclosingTypeName() { return enclosingTypeName; } @@ -115,7 +115,7 @@ public class CompactTypeStructureRepresentation implements IBinaryType { public char[] getGenericSignature() { return genericSignature; } - + public char[] getEnclosingMethod() { return enclosingMethod; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/StatefulNameEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/StatefulNameEnvironment.java index b3cb0e2d1..97284639a 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/StatefulNameEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/StatefulNameEnvironment.java @@ -1,12 +1,12 @@ /* ******************************************************************* * 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 * ******************************************************************/ @@ -63,9 +63,9 @@ public class StatefulNameEnvironment implements IModuleAwareNameEnvironment { 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; @@ -91,7 +91,7 @@ public class StatefulNameEnvironment implements IModuleAwareNameEnvironment { this.classesFromName = Collections.emptyMap(); this.packageNames.clear(); } - + @Override public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) { NameEnvironmentAnswer ret = findType(new String(CharOperation.concatWith(packageName, typeName, '.'))); @@ -140,10 +140,6 @@ public class StatefulNameEnvironment implements IModuleAwareNameEnvironment { 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) { @@ -160,4 +156,14 @@ public class StatefulNameEnvironment implements IModuleAwareNameEnvironment { 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); + } + } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java index 99580a8a6..627922205 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java @@ -1,11 +1,11 @@ /******************************************************************** - * 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; @@ -13,31 +13,28 @@ 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: @@ -46,21 +43,21 @@ public class AjAST extends AST { * </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 @@ -79,12 +76,12 @@ public class AjAST extends AST { 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; @@ -96,17 +93,17 @@ public class AjAST extends AST { } 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> @@ -117,24 +114,24 @@ public class AjAST extends AST { * 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() { @@ -144,47 +141,47 @@ public class AjAST extends AST { /** * 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() { @@ -194,21 +191,21 @@ public class AjAST extends AST { /** * 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 @@ -217,12 +214,12 @@ public class AjAST extends 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 @@ -231,12 +228,12 @@ public class AjAST extends 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 @@ -245,12 +242,12 @@ public class AjAST extends 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 @@ -259,102 +256,102 @@ public class AjAST extends 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() { @@ -366,138 +363,138 @@ public class AjAST extends AST { * 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() { diff --git a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/ajdt/ajc/messages.properties b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/ajdt/ajc/messages.properties index daf511f9d..24b95f854 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/ajdt/ajc/messages.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/ajdt/ajc/messages.properties @@ -5,7 +5,7 @@ org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. ### AspectJ-specific messages compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler #a9ab0710a01b2b(28-Mar-2019), 3.18 +compiler.version = Eclipse Compiler 3106c52cb89aa (29Oct2019) - Java13 compiler.copyright = diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java index ced2ecd8f..96e71cb7e 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java @@ -1,11 +1,11 @@ /******************************************************************** - * 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; @@ -15,6 +15,7 @@ import java.util.Collections; 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; @@ -74,15 +75,14 @@ import org.aspectj.org.eclipse.jdt.core.dom.Type; import org.aspectj.org.eclipse.jdt.core.dom.TypeCategoryTypePattern; import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration; import org.aspectj.org.eclipse.jdt.core.dom.TypePattern; -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. */ @@ -1660,24 +1660,24 @@ public class AjASTTest extends AjASTTestCase { 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( @@ -1690,7 +1690,7 @@ public class AjASTTest extends AjASTTestCase { { 84, 1 } // E }); } - + public void testDeclareParentsNotSource() { checkTypePatternSourceRangesJLS3( @@ -1702,7 +1702,7 @@ public class AjASTTest extends AjASTTestCase { { 80, 1 } // E }); } - + public void testDeclareParentsOrSource() { checkTypePatternSourceRangesJLS3( "class A{}class B{}class D{}class E{}aspect C {declare parents : A || B || D extends E;}", @@ -1714,16 +1714,16 @@ public class AjASTTest extends AjASTTestCase { { 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;}", @@ -1789,16 +1789,16 @@ public class AjASTTest extends AjASTTestCase { "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); } @@ -1820,21 +1820,22 @@ public class AjASTTest extends AjASTTestCase { 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)); } @@ -1843,14 +1844,14 @@ public class AjASTTest extends AjASTTestCase { class TypeCategoryTypeVisitor extends AjASTVisitor { - + private TypeCategoryTypePattern typeCategory = null; - + public boolean visit(TypeCategoryTypePattern node) { typeCategory = node; return false; } - + public TypeCategoryTypePattern getTypeCategoryNode() { return typeCategory; } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index 8d15cdf8f..45d2f1ad1 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -1,12 +1,12 @@ /* ******************************************************************* * 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; @@ -47,7 +47,7 @@ import junit.framework.TestCase; * 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 @@ -64,7 +64,7 @@ public abstract class AjcTestCase extends TestCase { 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 + ".." @@ -93,8 +93,8 @@ public abstract class AjcTestCase extends TestCase { + "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: @@ -128,7 +128,7 @@ public abstract class AjcTestCase extends TestCase { * <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 { @@ -324,14 +324,14 @@ public abstract class AjcTestCase extends TestCase { /** * 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; @@ -532,7 +532,7 @@ public abstract class AjcTestCase extends TestCase { /** * 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. @@ -555,7 +555,7 @@ public abstract class AjcTestCase extends TestCase { /** * 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) { @@ -582,11 +582,11 @@ public abstract class AjcTestCase extends TestCase { /** * 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) { @@ -615,7 +615,7 @@ public abstract class AjcTestCase extends TestCase { URLClassLoader sandboxLoader; ClassLoader parentLoader = getClass().getClassLoader().getParent(); - + /* Sandbox -> AspectJ -> Extension -> Bootstrap */ if ( !useFullLTW && useLTW) { // URLClassLoader testLoader = (URLClassLoader) getClass().getClassLoader(); @@ -633,17 +633,17 @@ public abstract class AjcTestCase extends TestCase { 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())); @@ -651,7 +651,7 @@ public abstract class AjcTestCase extends TestCase { 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(); @@ -681,7 +681,7 @@ public abstract class AjcTestCase extends TestCase { 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(); @@ -705,7 +705,7 @@ public abstract class AjcTestCase extends TestCase { 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(); @@ -718,7 +718,7 @@ public abstract class AjcTestCase extends TestCase { } ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); ByteArrayOutputStream baosErr = new ByteArrayOutputStream(); - + StringBuffer command = new StringBuffer(); command.append("java -classpath "); @@ -790,7 +790,7 @@ public abstract class AjcTestCase extends TestCase { String nextToken =st.nextToken(); arguments.add(nextToken); } - + return arguments; } @@ -799,7 +799,7 @@ public abstract class AjcTestCase extends TestCase { String line = ""; ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); ByteArrayOutputStream baosErr = new ByteArrayOutputStream(); - + PrintWriter stdOutWriter = new PrintWriter(baosOut); PrintWriter stdErrWriter = new PrintWriter(baosErr); @@ -814,10 +814,10 @@ public abstract class AjcTestCase extends TestCase { } stdErrWriter.flush(); - + baosOut.close(); baosErr.close(); - + return new RunResult(command.toString(), new String(baosOut.toByteArray()), new String(baosErr.toByteArray())); } @@ -902,7 +902,7 @@ public abstract class AjcTestCase extends TestCase { /** * 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 */ @@ -969,7 +969,7 @@ public abstract class AjcTestCase extends TestCase { /** * 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 @@ -1055,7 +1055,7 @@ public abstract class AjcTestCase extends TestCase { /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#setUp() */ @Override @@ -1066,7 +1066,7 @@ public abstract class AjcTestCase extends TestCase { /* * (non-Javadoc) - * + * * @see junit.framework.TestCase#tearDown() */ @Override diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip Binary files differindex ec0d8feeb..d8fd64ce5 100644 --- a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip +++ b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar Binary files differindex 24e4ee699..96ba5d026 100644 --- a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar +++ b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar diff --git a/run-all-junit-tests/pom.xml b/run-all-junit-tests/pom.xml index cd3f7e285..e8306d787 100644 --- a/run-all-junit-tests/pom.xml +++ b/run-all-junit-tests/pom.xml @@ -240,7 +240,13 @@ <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> diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index c64855928..de7a708cd 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -1,15 +1,15 @@ /* ******************************************************************* - * 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 * ******************************************************************/ @@ -40,7 +40,6 @@ import org.apache.tools.ant.taskdefs.MatchingTask; 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; @@ -66,7 +65,7 @@ import org.aspectj.util.LangUtil; * 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 { @@ -76,9 +75,9 @@ 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. @@ -89,23 +88,23 @@ public class AjcTask extends MatchingTask { * 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; @@ -114,7 +113,7 @@ public class AjcTask extends MatchingTask { * 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) @@ -166,7 +165,7 @@ public class AjcTask extends MatchingTask { * 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() { @@ -247,16 +246,16 @@ public class AjcTask extends MatchingTask { /** * -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; @@ -328,7 +327,7 @@ public class AjcTask extends MatchingTask { private String xdoneSignal; private List<CompilerArg> compilerArgs; - + // ----- added by adapter - integrate better? private List /* File */adapterFiles; private String[] adapterArguments; @@ -485,7 +484,7 @@ public class AjcTask extends MatchingTask { 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. @@ -611,7 +610,7 @@ public class AjcTask extends MatchingTask { /** * -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) { @@ -622,7 +621,7 @@ public class AjcTask extends MatchingTask { /** * -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) { @@ -698,19 +697,19 @@ public class AjcTask extends MatchingTask { 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; @@ -772,7 +771,7 @@ public class AjcTask extends MatchingTask { /** * Language compliance level. If not set explicitly, eclipse default holds. - * + * * @param input a String in COMPLIANCE_INPUTS */ public void setCompliance(String input) { @@ -784,7 +783,7 @@ public class AjcTask extends MatchingTask { /** * Source compliance level. If not set explicitly, eclipse default holds. - * + * * @param input a String in SOURCE_INPUTS */ public void setSource(String input) { @@ -793,14 +792,14 @@ public class AjcTask extends MatchingTask { 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) { @@ -812,7 +811,7 @@ public class AjcTask extends MatchingTask { /** * 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) { @@ -823,7 +822,7 @@ public class AjcTask extends MatchingTask { * 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) { @@ -861,7 +860,7 @@ public class AjcTask extends MatchingTask { /** * 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 @@ -885,7 +884,7 @@ public class AjcTask extends MatchingTask { /** * 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 @@ -904,7 +903,7 @@ public class AjcTask extends MatchingTask { /** * 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 @@ -1104,7 +1103,7 @@ public class AjcTask extends MatchingTask { /** * Compile using ajc per settings. - * + * * @exception BuildException if the compilation has problems or if there were compiler errors and failonerror is true. */ @Override @@ -1144,7 +1143,7 @@ public class AjcTask extends MatchingTask { /** * 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() { @@ -1197,7 +1196,7 @@ public class AjcTask extends MatchingTask { /** * Create any pseudo-options required to implement some of the macro options - * + * * @throws BuildException if options conflict */ protected void setupOptions() { @@ -1281,9 +1280,9 @@ public class AjcTask extends MatchingTask { /** * 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) { @@ -1376,9 +1375,9 @@ public class AjcTask extends MatchingTask { * <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. */ @@ -1531,7 +1530,7 @@ public class AjcTask extends MatchingTask { addFlaggedPath("-injars", injars, list); addFlaggedPath("-inpath", inpath, list); addFlaggedPath("-sourceroots", sourceRoots, list); - + if (this.compilerArgs != null) { for (CompilerArg compilerArg:compilerArgs) { list.add(compilerArg.toString()); @@ -1590,7 +1589,7 @@ public class AjcTask extends MatchingTask { /** * 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 @@ -1797,7 +1796,7 @@ public class AjcTask extends MatchingTask { /** * 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 @@ -2049,7 +2048,7 @@ public class AjcTask extends MatchingTask { /** * 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 @@ -2106,7 +2105,7 @@ public class AjcTask extends MatchingTask { /* * (non-Javadoc) - * + * * @see org.aspectj.bridge.IMessageHandler#handleMessage(org.aspectj.bridge.IMessage) */ @Override @@ -2141,7 +2140,7 @@ public class AjcTask extends MatchingTask { /* * (non-Javadoc) - * + * * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) */ @Override @@ -2151,7 +2150,7 @@ public class AjcTask extends MatchingTask { /* * (non-Javadoc) - * + * * @see org.aspectj.bridge.IMessageHandler#dontIgnore(org.aspectj.bridge.IMessage.Kind) */ @Override @@ -2160,7 +2159,7 @@ public class AjcTask extends MatchingTask { /* * (non-Javadoc) - * + * * @see org.aspectj.bridge.IMessageHandler#ignore(org.aspectj.bridge.IMessage.Kind) */ @Override diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java index b12dc4fe8..c149ad79b 100644 --- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java +++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java @@ -1,17 +1,17 @@ /* ******************************************************************* - * 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; @@ -47,7 +47,7 @@ import junit.framework.TestCase; /** * 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 @@ -98,10 +98,10 @@ public class AjcTaskTest extends TestCase { }; } - /** + /** * 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, @@ -111,7 +111,7 @@ public class AjcTaskTest extends TestCase { * 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 */ @@ -274,7 +274,7 @@ public class AjcTaskTest extends TestCase { // ------------------------------------------------------ // ------------------------------------------------------ // Start of test cases - + public void testNullDestDir() { AjcTask task = getTask(NOFILE, null); String[] cmd = task.makeCommand(); @@ -283,7 +283,7 @@ public class AjcTaskTest extends TestCase { assertTrue(!"-d".equals(cmd[i])); } } - + public void testOutputRequirement() { AjcTask task = getTask("default.lst"); checkRun(task, null); @@ -333,7 +333,7 @@ public class AjcTaskTest extends TestCase { 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(); @@ -341,7 +341,7 @@ public class AjcTaskTest extends TestCase { 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); @@ -365,7 +365,7 @@ public class AjcTaskTest extends TestCase { file = new File(destDir, "skipTxtFiles.txt"); assertTrue(file + ".canRead() passed", !file.canRead()); } - + public void testInpathDirCopyFilterWithJar() throws IOException { checkInpathCopy("testInpathDirCopyFilterWithJar-out.jar"); } @@ -374,14 +374,14 @@ public class AjcTaskTest extends TestCase { 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(); @@ -391,11 +391,11 @@ public class AjcTaskTest extends TestCase { 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++) { @@ -410,7 +410,7 @@ public class AjcTaskTest extends TestCase { 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(); @@ -514,7 +514,7 @@ public class AjcTaskTest extends TestCase { } // 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(..) } @@ -631,7 +631,7 @@ public class AjcTaskTest extends TestCase { // 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); @@ -681,7 +681,7 @@ public class AjcTaskTest extends TestCase { checkContains(cmd, inputs[i], true); } } - + public void testClasspath() { AjcTask task = getTask(NOFILE); String[] cmd = task.makeCommand(); @@ -697,13 +697,13 @@ public class AjcTaskTest extends TestCase { "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"); @@ -714,7 +714,7 @@ public class AjcTaskTest extends TestCase { 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)) { @@ -776,9 +776,9 @@ public class AjcTaskTest extends TestCase { 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); @@ -813,7 +813,7 @@ public class AjcTaskTest extends TestCase { String[] cmd = task.makeCommand(); checkContains(cmd,"-X" + xopts[i],true); } - + } public void testAptProc() { @@ -844,7 +844,7 @@ public class AjcTaskTest extends TestCase { checkContains(task.makeCommand(), "-s", true); checkContains(task.makeCommand(), "some/path", true); } - + public void testOutxml () { File destDir = getTempDir(); assertTrue( @@ -856,9 +856,9 @@ public class AjcTaskTest extends TestCase { 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, @@ -907,7 +907,7 @@ public class AjcTaskTest extends TestCase { && (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) { @@ -975,7 +975,7 @@ public class AjcTaskTest extends TestCase { 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; @@ -1027,7 +1027,7 @@ public class AjcTaskTest extends TestCase { 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); diff --git a/testing/src/test/java/org/aspectj/testing/AjcTest.java b/testing/src/test/java/org/aspectj/testing/AjcTest.java index 0384e775d..14eda67b5 100644 --- a/testing/src/test/java/org/aspectj/testing/AjcTest.java +++ b/testing/src/test/java/org/aspectj/testing/AjcTest.java @@ -1,10 +1,10 @@ /* ******************************************************************* * 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; @@ -19,7 +19,7 @@ import org.aspectj.util.LangUtil; * @author Andy Clement */ public class AjcTest { - + // private static boolean is13VMOrGreater = true; private static boolean is14VMOrGreater = true; private static boolean is15VMOrGreater = false; @@ -30,7 +30,8 @@ public class AjcTest { 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(); @@ -41,10 +42,11 @@ public class AjcTest { 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; @@ -54,16 +56,16 @@ public class AjcTest { 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("."); @@ -74,8 +76,8 @@ public class AjcTest { } 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; @@ -87,13 +89,14 @@ public class AjcTest { 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. */ @@ -162,7 +165,7 @@ public class AjcTest { public void setVm(String vmLevel) { this.vmLevel = vmLevel; } - + /** * @return Returns the vmLevel. */ diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java new file mode 100644 index 000000000..92193f540 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java @@ -0,0 +1,31 @@ +/* ******************************************************************* + * 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); + } + +} diff --git a/tests/pom.xml b/tests/pom.xml index 7e65f2f0f..c91ffffe0 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -55,7 +55,7 @@ <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> diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java index 72388ba68..9a36d3daf 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc193/Java12Tests.java @@ -5,7 +5,7 @@ * 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; @@ -15,22 +15,22 @@ import junit.framework.Test; /** * @author Andy Clement - */ + */ public class Java12Tests extends XMLBasedAjcTestCaseForJava12OrLater { public void testSwitch1() { runTest("switch 1"); - checkVersion("Switch1", Constants.MAJOR_12, Constants.PREVIEW_MINOR_VERSION); + 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); } // --- diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc195/AllTestsAspectJ195.java b/tests/src/test/java/org/aspectj/systemtest/ajc195/AllTestsAspectJ195.java index a7eb6604e..8a714a606 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc195/AllTestsAspectJ195.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc195/AllTestsAspectJ195.java @@ -18,6 +18,7 @@ public class AllTestsAspectJ195 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ 1.9.4 tests"); suite.addTest(Ajc195Tests.suite()); + suite.addTest(SanityTestsJava13.suite()); return suite; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java new file mode 100644 index 000000000..89ac25e07 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * 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"); + } + +} diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml index c13159c30..cea315f82 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc193/ajc193.xml @@ -51,8 +51,9 @@ Method call </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> @@ -64,8 +65,8 @@ Method call </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> @@ -77,8 +78,8 @@ Method call </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> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc195/sanity-tests-13.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc195/sanity-tests-13.xml new file mode 100644 index 000000000..3a83e1108 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc195/sanity-tests-13.xml @@ -0,0 +1,69 @@ +<!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> diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index ee77556c8..50c5a78c0 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -1,15 +1,15 @@ /* ******************************************************************* - * 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; @@ -33,7 +33,7 @@ import java.util.Map; import java.util.StringTokenizer; /** - * + * */ public class LangUtil { @@ -49,11 +49,11 @@ 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); @@ -87,7 +87,7 @@ public class LangUtil { .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); @@ -111,7 +111,7 @@ public class LangUtil { vmVersion = 1.5; } } - + private static List<Integer> getFirstNumbers(String vm) { List<Integer> result = new ArrayList<Integer>(); StringTokenizer st = new StringTokenizer(vm,".-_"); @@ -125,7 +125,7 @@ public class LangUtil { return result; } - public static boolean is13VMOrGreater() { + public static boolean isOnePointThreeVMOrGreater() { return 1.3 <= vmVersion; } @@ -144,15 +144,15 @@ public class LangUtil { 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; } @@ -165,9 +165,14 @@ public class LangUtil { 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) { @@ -179,7 +184,7 @@ public class LangUtil { /** * 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 */ @@ -202,7 +207,7 @@ public class LangUtil { /** * 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) { @@ -228,13 +233,13 @@ public class LangUtil { // 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) { @@ -276,7 +281,7 @@ public class LangUtil { /** * Splits <code>text</code> at whitespace. - * + * * @param text <code>String</code> to split. */ public static String[] split(String text) { @@ -285,7 +290,7 @@ public class LangUtil { /** * Splits <code>input</code> at commas, trimming any white space. - * + * * @param input <code>String</code> to split. * @return List of String of elements. */ @@ -295,7 +300,7 @@ public class LangUtil { /** * 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 */ @@ -316,7 +321,7 @@ public class LangUtil { /** * 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) { @@ -337,7 +342,7 @@ public class LangUtil { * 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. @@ -361,7 +366,7 @@ public class LangUtil { /** * 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) { @@ -423,7 +428,7 @@ public class LangUtil { // } // return (String[]) result.toArray(new String[0]); // } - // + // // /** // * Select from input String[] if readable directories // * @param inputs String[] of input - null ignored @@ -450,7 +455,7 @@ public class LangUtil { /** * copy non-null two-dimensional String[][] - * + * * @see extractOptions(String[], String[][]) */ public static String[][] copyStrings(String[][] in) { @@ -465,14 +470,14 @@ public class LangUtil { /** * 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. @@ -528,7 +533,7 @@ public class LangUtil { return args; } - // + // // /** // * Extract options and arguments to input parameter list, returning // remainder. @@ -661,7 +666,7 @@ public class LangUtil { // 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)) { @@ -689,7 +694,7 @@ public class LangUtil { // } // return result; // } - // + // // private static int exp(int base, int power) { // not in Math? // if (0 > power) { // throw new IllegalArgumentException("negative power: " + power); @@ -718,7 +723,7 @@ public class LangUtil { /** * 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 */ @@ -850,7 +855,7 @@ public class LangUtil { /** * Renders exception <code>t</code> after unwrapping and eliding any test packages. - * + * * @param t <code>Throwable</code> to print. * @see #maxStackTrace */ @@ -860,7 +865,7 @@ public class LangUtil { /** * 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 @@ -880,7 +885,7 @@ public class LangUtil { /** * 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 @@ -979,7 +984,7 @@ public class LangUtil { /** * 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) */ @@ -1019,7 +1024,7 @@ public class LangUtil { /** * Gen classpath. - * + * * @param bootclasspath * @param classpath * @param classesDir @@ -1056,7 +1061,7 @@ public class LangUtil { /** * 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 @@ -1100,7 +1105,7 @@ public class LangUtil { /** * 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() { @@ -1146,7 +1151,7 @@ public class LangUtil { /** * 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 */ @@ -1176,11 +1181,11 @@ public class LangUtil { * 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"); @@ -1193,7 +1198,7 @@ public class LangUtil { * 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 { @@ -1298,7 +1303,7 @@ public class LangUtil { /** * 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() { @@ -1388,7 +1393,7 @@ public class LangUtil { /** * 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 @@ -1405,7 +1410,7 @@ public class LangUtil { * 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() @@ -1417,7 +1422,7 @@ public class LangUtil { /** * 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 */ @@ -1453,7 +1458,7 @@ public class LangUtil { /** * 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) { @@ -1503,11 +1508,11 @@ public class LangUtil { } } // class Thrown } - + public static String getJrtFsFilePath() { return getJavaHome() + File.separator + "lib" + File.separator + JRT_FS; } - + public static String getJavaHome() { return System.getProperty("java.home"); } diff --git a/util/src/test/java/org/aspectj/util/LangUtilTest.java b/util/src/test/java/org/aspectj/util/LangUtilTest.java index 4cb44795d..f06103fec 100644 --- a/util/src/test/java/org/aspectj/util/LangUtilTest.java +++ b/util/src/test/java/org/aspectj/util/LangUtilTest.java @@ -101,7 +101,7 @@ public class LangUtilTest extends TestCase { // } 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()); } diff --git a/weaver/pom.xml b/weaver/pom.xml index 91870a62d..98cb5acdf 100644 --- a/weaver/pom.xml +++ b/weaver/pom.xml @@ -79,7 +79,7 @@ <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> diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java index b81f7ffb1..8d2709966 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java @@ -1,11 +1,11 @@ /******************************************************************************* * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * + * 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 *******************************************************************************/ @@ -47,7 +47,7 @@ import org.aspectj.weaver.UnresolvedType; * <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 */ @@ -150,12 +150,19 @@ public class BcelAccessForInlineMunger extends BcelTypeMunger { 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()); |