From d373429ee98f689574fb2657ef0739c58ed4e0b8 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 25 Jul 2006 08:38:09 +0000 Subject: [PATCH] test and fixes for Bug 145963: add injar aspects to the model --- .../core/builder/AsmElementFormatter.java | 70 +++------------ tests/bugs152/pr145963/AbstractAspect.aj | 10 +++ .../pr145963/AspectInDefaultPackage.aj | 18 ++++ tests/bugs152/pr145963/C.java | 12 +++ tests/bugs152/pr145963/ConcreteAspect.aj | 17 ++++ tests/bugs152/pr145963/README.txt | 16 ++++ tests/bugs152/pr145963/SrcAspect.aj | 10 +++ tests/bugs152/pr145963/adviceLabels.jar | Bin 0 -> 1445 bytes .../pr145963/aspectInDefaultPackage.jar | Bin 0 -> 1473 bytes .../ajc152/CreatingModelForInjarTests.java | 43 ++++++++- .../org/aspectj/systemtest/ajc152/injar.xml | 7 ++ .../weaver/AsmRelationshipProvider.java | 3 + .../aspectj/weaver/AsmRelationshipUtils.java | 84 ++++++++++++++++++ .../src/org/aspectj/weaver/ShadowMunger.java | 54 ++++++----- 14 files changed, 267 insertions(+), 77 deletions(-) create mode 100644 tests/bugs152/pr145963/AbstractAspect.aj create mode 100644 tests/bugs152/pr145963/AspectInDefaultPackage.aj create mode 100644 tests/bugs152/pr145963/C.java create mode 100644 tests/bugs152/pr145963/ConcreteAspect.aj create mode 100644 tests/bugs152/pr145963/README.txt create mode 100644 tests/bugs152/pr145963/SrcAspect.aj create mode 100644 tests/bugs152/pr145963/adviceLabels.jar create mode 100644 tests/bugs152/pr145963/aspectInDefaultPackage.jar create mode 100644 weaver/src/org/aspectj/weaver/AsmRelationshipUtils.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index 4f86ad97c..661aaaa28 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -34,16 +34,14 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.weaver.AdviceKind; +import org.aspectj.weaver.AsmRelationshipUtils; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.patterns.AndPointcut; import org.aspectj.weaver.patterns.DeclareAnnotation; import org.aspectj.weaver.patterns.DeclareErrorOrWarning; import org.aspectj.weaver.patterns.DeclareParents; import org.aspectj.weaver.patterns.DeclarePrecedence; import org.aspectj.weaver.patterns.DeclareSoft; -import org.aspectj.weaver.patterns.OrPointcut; -import org.aspectj.weaver.patterns.ReferencePointcut; import org.aspectj.weaver.patterns.TypePattern; import org.aspectj.weaver.patterns.TypePatternList; @@ -52,19 +50,6 @@ import org.aspectj.weaver.patterns.TypePatternList; */ public class AsmElementFormatter { - public static final String UNDEFINED=""; - public static final String DECLARE_PRECEDENCE = "precedence"; - public static final String DECLARE_SOFT = "soft"; - public static final String DECLARE_PARENTS = "parents"; - public static final String DECLARE_WARNING = "warning"; - public static final String DECLARE_ERROR = "error"; - public static final String DECLARE_UNKNONWN = ""; - public static final String POINTCUT_ABSTRACT = ""; - public static final String POINTCUT_ANONYMOUS = ""; - public static final String DOUBLE_DOTS = ".."; - public static final int MAX_MESSAGE_LENGTH = 18; - public static final String DEC_LABEL = "declare"; - public void genLabelAndKind(MethodDeclaration methodDeclaration, IProgramElement node) { if (methodDeclaration instanceof AdviceDeclaration) { @@ -77,28 +62,9 @@ public class AsmElementFormatter { StringBuffer details = new StringBuffer(); if (ad.pointcutDesignator != null) { - if (ad.pointcutDesignator.getPointcut() instanceof ReferencePointcut) { - ReferencePointcut rp = (ReferencePointcut)ad.pointcutDesignator.getPointcut(); - details.append(rp.name).append(".."); - } else if (ad.pointcutDesignator.getPointcut() instanceof AndPointcut) { - AndPointcut ap = (AndPointcut)ad.pointcutDesignator.getPointcut(); - if (ap.getLeft() instanceof ReferencePointcut) { - details.append(ap.getLeft().toString()).append(DOUBLE_DOTS); - } else { - details.append(POINTCUT_ANONYMOUS).append(DOUBLE_DOTS); - } - } else if (ad.pointcutDesignator.getPointcut() instanceof OrPointcut) { - OrPointcut op = (OrPointcut)ad.pointcutDesignator.getPointcut(); - if (op.getLeft() instanceof ReferencePointcut) { - details.append(op.getLeft().toString()).append(DOUBLE_DOTS); - } else { - details.append(POINTCUT_ANONYMOUS).append(DOUBLE_DOTS); - } - } else { - details.append(POINTCUT_ANONYMOUS); - } + details.append(AsmRelationshipUtils.genPointcutDetails(ad.pointcutDesignator.getPointcut())); } else { - details.append(POINTCUT_ABSTRACT); + details.append(AsmRelationshipUtils.POINTCUT_ABSTRACT); } node.setName(ad.kind.toString()); //if (details.length()!=0) @@ -113,25 +79,25 @@ public class AsmElementFormatter { } else if (methodDeclaration instanceof DeclareDeclaration) { DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration; - String name = DEC_LABEL + " "; + String name = AsmRelationshipUtils.DEC_LABEL + " "; if (declare.declareDecl instanceof DeclareErrorOrWarning) { DeclareErrorOrWarning deow = (DeclareErrorOrWarning)declare.declareDecl; if (deow.isError()) { node.setKind( IProgramElement.Kind.DECLARE_ERROR); - name += DECLARE_ERROR; + name += AsmRelationshipUtils.DECLARE_ERROR; } else { node.setKind( IProgramElement.Kind.DECLARE_WARNING); - name += DECLARE_WARNING; + name += AsmRelationshipUtils.DECLARE_WARNING; } node.setName(name) ; - node.setDetails("\"" + genDeclareMessage(deow.getMessage()) + "\""); + node.setDetails("\"" + AsmRelationshipUtils.genDeclareMessage(deow.getMessage()) + "\""); } else if (declare.declareDecl instanceof DeclareParents) { node.setKind( IProgramElement.Kind.DECLARE_PARENTS); DeclareParents dp = (DeclareParents)declare.declareDecl; - node.setName(name + DECLARE_PARENTS); + node.setName(name + AsmRelationshipUtils.DECLARE_PARENTS); String kindOfDP = null; StringBuffer details = new StringBuffer(""); @@ -161,13 +127,13 @@ public class AsmElementFormatter { } else if (declare.declareDecl instanceof DeclareSoft) { node.setKind( IProgramElement.Kind.DECLARE_SOFT); DeclareSoft ds = (DeclareSoft)declare.declareDecl; - node.setName(name + DECLARE_SOFT); + node.setName(name + AsmRelationshipUtils.DECLARE_SOFT); node.setDetails(genTypePatternLabel(ds.getException())); } else if (declare.declareDecl instanceof DeclarePrecedence) { node.setKind( IProgramElement.Kind.DECLARE_PRECEDENCE); DeclarePrecedence ds = (DeclarePrecedence)declare.declareDecl; - node.setName(name + DECLARE_PRECEDENCE); + node.setName(name + AsmRelationshipUtils.DECLARE_PRECEDENCE); node.setDetails(genPrecedenceListLabel(ds.getPatterns())); } else if (declare.declareDecl instanceof DeclareAnnotation) { @@ -188,7 +154,7 @@ public class AsmElementFormatter { } else { node.setKind(IProgramElement.Kind.ERROR); - node.setName(DECLARE_UNKNONWN); + node.setName(AsmRelationshipUtils.DECLARE_UNKNONWN); } } else if (methodDeclaration instanceof InterTypeDeclaration) { @@ -247,7 +213,7 @@ public class AsmElementFormatter { || "Lorg/aspectj/lang/annotation/Around;".equals(annotationSig)) { node.setKind(IProgramElement.Kind.ADVICE); //TODO AV - all are considered anonymous - is that ok? - node.setDetails(POINTCUT_ANONYMOUS); + node.setDetails(AsmRelationshipUtils.POINTCUT_ANONYMOUS); break; } } @@ -348,15 +314,6 @@ public class AsmElementFormatter { return label; } - - public String genDeclareMessage(String message) { - int length = message.length(); - if (length < MAX_MESSAGE_LENGTH) { - return message; - } else { - return message.substring(0, MAX_MESSAGE_LENGTH-1) + ".."; - } - } // // TODO: // private String translateAdviceName(String label) { @@ -387,7 +344,8 @@ public class AsmElementFormatter { // } // } - // !!! move or replace + + // !!! move or replace private String translatePointcutName(String name) { int index = name.indexOf("$$")+2; int endIndex = name.lastIndexOf('$'); diff --git a/tests/bugs152/pr145963/AbstractAspect.aj b/tests/bugs152/pr145963/AbstractAspect.aj new file mode 100644 index 000000000..ed2b12170 --- /dev/null +++ b/tests/bugs152/pr145963/AbstractAspect.aj @@ -0,0 +1,10 @@ +package pkg; + +public abstract aspect AbstractAspect { + + public abstract pointcut abstractPCD(); + + before() : abstractPCD() { + } + +} diff --git a/tests/bugs152/pr145963/AspectInDefaultPackage.aj b/tests/bugs152/pr145963/AspectInDefaultPackage.aj new file mode 100644 index 000000000..88d2e00a8 --- /dev/null +++ b/tests/bugs152/pr145963/AspectInDefaultPackage.aj @@ -0,0 +1,18 @@ + +public aspect AspectInDefaultPackage { + + public pointcut execM1() : execution(* pack.C.method1(..)); + public pointcut execM2() : execution(* pack.C.method2(..)); + + before() : execM1() && this(pack.C) { + } + + before() : execM2() || execM1() { + } + + before() : execution(* pack.C.method1()) { + } + + + +} diff --git a/tests/bugs152/pr145963/C.java b/tests/bugs152/pr145963/C.java new file mode 100644 index 000000000..b255175c9 --- /dev/null +++ b/tests/bugs152/pr145963/C.java @@ -0,0 +1,12 @@ +package pack; + +public class C { + + public void method1() { + new C().method2(); + } + + public void method2() { + } + +} diff --git a/tests/bugs152/pr145963/ConcreteAspect.aj b/tests/bugs152/pr145963/ConcreteAspect.aj new file mode 100644 index 000000000..4052180d3 --- /dev/null +++ b/tests/bugs152/pr145963/ConcreteAspect.aj @@ -0,0 +1,17 @@ +package pkg; + +public aspect ConcreteAspect { + + public pointcut execM1() : execution(* pack.C.method1(..)); + public pointcut execM2() : execution(* pack.C.method2(..)); + + before() : execM1() && this(pack.C) { + } + + before() : execM2() || execM1() { + } + + before() : execution(* pack.C.method1()) { + } + +} diff --git a/tests/bugs152/pr145963/README.txt b/tests/bugs152/pr145963/README.txt new file mode 100644 index 000000000..b039752bc --- /dev/null +++ b/tests/bugs152/pr145963/README.txt @@ -0,0 +1,16 @@ +To recreate the jar files create AspectJ projects within Eclipse containing the +required files, right click and select 'Export > Java > JAR file with AspectJ Support' + +jar file files contained in the jar file +-------- ------------------------------- +adviceAndDeow.jar A.aj, Deow.aj, Itd.aj, NewClass.java +adviceLabels.jar ConcreteAspect.aj +aspectInDefaultPackage.jar AspectInDefaultPackage.aj + + + +may need classpath entries on some of these: ? + +ajc A.aj Deow.aj Itd.aj NewClass.java -outjar adviceAndDeow.jar +ajc ConcreteAspect.aj -outjar adviceLabels.jar +ajc AspectInDefaultPackage.aj -outjar aspectInDefaultPackage.jar \ No newline at end of file diff --git a/tests/bugs152/pr145963/SrcAspect.aj b/tests/bugs152/pr145963/SrcAspect.aj new file mode 100644 index 000000000..c10ed2698 --- /dev/null +++ b/tests/bugs152/pr145963/SrcAspect.aj @@ -0,0 +1,10 @@ +package pkg; + +public aspect SrcAspect { + + pointcut p() : execution(* *.*(..)) && !within(pkg.*); + + before() : p() { + } + +} diff --git a/tests/bugs152/pr145963/adviceLabels.jar b/tests/bugs152/pr145963/adviceLabels.jar new file mode 100644 index 0000000000000000000000000000000000000000..054c0da2cd8408f97feb567b6f0455c3feed8997 GIT binary patch literal 1445 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"); + assertNotNull("expected to find ipe with label 'before(): '" + + " but didn't", node); + } + + // ensure that filled in hierarchy only has one entry for + // aspect + public void testOnlyOneAspectEntry() { + runTest("ensure advice label is correct"); + + IProgramElement pkgNode = getPkgNode(); + assertEquals("expected one child node but found " + + pkgNode.getChildren().size(), 1, pkgNode.getChildren().size()); + + } + + public void testOnlyOneAspectEntry_inDefaultPackage() { + runTest("aspect in default package"); + // expect there to be two children - 'pack' and + // 'AspectInDefaultPackage.aj (binary)' + IProgramElement defaultPkg = AsmManager.getDefault().getHierarchy().getRoot(); + assertEquals("expected two child node but found " + + defaultPkg.getChildren().size(), 2, defaultPkg.getChildren().size()); + + } + // --------------------- Helper methods --------------------- private IProgramElement getPkgNode() { diff --git a/tests/src/org/aspectj/systemtest/ajc152/injar.xml b/tests/src/org/aspectj/systemtest/ajc152/injar.xml index 955069a3e..f53dbbaac 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/injar.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/injar.xml @@ -9,5 +9,12 @@ + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java index 04725f894..a353a845a 100644 --- a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java +++ b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java @@ -176,6 +176,9 @@ public class AsmRelationshipProvider { return; } + if (World.createInjarHierarchy) { + munger.createHierarchy(); + } IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap(); IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(), shadow); diff --git a/weaver/src/org/aspectj/weaver/AsmRelationshipUtils.java b/weaver/src/org/aspectj/weaver/AsmRelationshipUtils.java new file mode 100644 index 000000000..e9a1bdbf6 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/AsmRelationshipUtils.java @@ -0,0 +1,84 @@ +/******************************************************************** + * 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 - initial version + *******************************************************************/ +package org.aspectj.weaver; + +import org.aspectj.weaver.patterns.AndPointcut; +import org.aspectj.weaver.patterns.OrPointcut; +import org.aspectj.weaver.patterns.Pointcut; +import org.aspectj.weaver.patterns.ReferencePointcut; + +/** + * Provides utility methods for generating details for IProgramElements + * used when creating the model both from source (via AsmElementFormatter.visit(..)) + * and when filling in the model for binary aspects (via AsmRelationshipProvider + * bug 145963) + */ +public class AsmRelationshipUtils { + + public static final String UNDEFINED=""; + public static final String DECLARE_PRECEDENCE = "precedence"; + public static final String DECLARE_SOFT = "soft"; + public static final String DECLARE_PARENTS = "parents"; + public static final String DECLARE_WARNING = "warning"; + public static final String DECLARE_ERROR = "error"; + public static final String DECLARE_UNKNONWN = ""; + public static final String POINTCUT_ABSTRACT = ""; + public static final String POINTCUT_ANONYMOUS = ""; + public static final String DOUBLE_DOTS = ".."; + public static final int MAX_MESSAGE_LENGTH = 18; + public static final String DEC_LABEL = "declare"; + + /** + * Generates the declare message used in the details, for example if + * the declare warning statement has message "There should be no printlns" + * will return 'declare warning: "There should be n.."' + */ + public static String genDeclareMessage(String message) { + int length = message.length(); + if (length < MAX_MESSAGE_LENGTH) { + return message; + } else { + return message.substring(0, MAX_MESSAGE_LENGTH-1) + DOUBLE_DOTS; + } + } + + /** + * Generates the pointcut details for the given pointcut, for example + * an anonymous pointcut will return '' and + * a named pointcut called p() will return 'p()..' + */ + public static String genPointcutDetails(Pointcut pcd) { + StringBuffer details = new StringBuffer(); + if (pcd instanceof ReferencePointcut) { + ReferencePointcut rp = (ReferencePointcut)pcd; + details.append(rp.name).append(DOUBLE_DOTS); + } else if (pcd instanceof AndPointcut) { + AndPointcut ap = (AndPointcut)pcd; + if (ap.getLeft() instanceof ReferencePointcut) { + details.append(ap.getLeft().toString()).append(DOUBLE_DOTS); + } else { + details.append(POINTCUT_ANONYMOUS).append(DOUBLE_DOTS); + } + } else if (pcd instanceof OrPointcut) { + OrPointcut op = (OrPointcut)pcd; + if (op.getLeft() instanceof ReferencePointcut) { + details.append(op.getLeft().toString()).append(DOUBLE_DOTS); + } else { + details.append(POINTCUT_ANONYMOUS).append(DOUBLE_DOTS); + } + } else { + details.append(POINTCUT_ANONYMOUS); + } + return details.toString(); + } + + +} diff --git a/weaver/src/org/aspectj/weaver/ShadowMunger.java b/weaver/src/org/aspectj/weaver/ShadowMunger.java index df21a4a82..e5e5d0574 100644 --- a/weaver/src/org/aspectj/weaver/ShadowMunger.java +++ b/weaver/src/org/aspectj/weaver/ShadowMunger.java @@ -98,9 +98,6 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH if (null == handle) { ISourceLocation sl = getSourceLocation(); if (sl != null) { - if (World.createInjarHierarchy) { - createHierarchy(); - } IProgramElement ipe = AsmManager.getDefault().getHierarchy().findElementForSourceLine(sl); handle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(ipe); } @@ -155,6 +152,9 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH */ public abstract ResolvedType getResolvedDeclaringAspect(); + /** + * Creates the hierarchy for binary aspects + */ public void createHierarchy() { IProgramElement sourceFileNode = AsmManager.getDefault().getHierarchy().findElementForSourceLine(getSourceLocation()); if (!sourceFileNode.getKind().equals(IProgramElement.Kind.FILE_JAVA)) { @@ -162,6 +162,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH } String name = sourceFileNode.getName(); sourceFileNode.setName(name + " (binary)"); + AsmManager.getDefault().getHandleProvider().createHandleIdentifier(sourceFileNode); ResolvedType aspect = getResolvedDeclaringAspect(); @@ -178,9 +179,29 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH IProgramElement.Kind.PACKAGE, new ArrayList()); root.addChild(pkgNode); + pkgNode.addChild(sourceFileNode); + } else { + for (Iterator iter = pkgNode.getChildren().iterator(); iter.hasNext();) { + IProgramElement element = (IProgramElement) iter.next(); + if (element.getHandleIdentifier().equals( + sourceFileNode.getHandleIdentifier())) { + // already added the sourcefile so have already + // added the structure for this aspect + return; + } + } + pkgNode.addChild(sourceFileNode); } - pkgNode.addChild(sourceFileNode); } else { + for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) { + IProgramElement element = (IProgramElement) iter.next(); + if (element.getHandleIdentifier().equals( + sourceFileNode.getHandleIdentifier())) { + // already added the sourcefile so have already + // added the structure for this aspect + return; + } + } root.addChild(sourceFileNode); } @@ -240,26 +261,19 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH getSourceLocation(), this.getDeclaringType().getModifiers(), null,null); - deowNode.setDetails("\"" + genDeclareMessage(decl.getMessage()) + "\""); + deowNode.setDetails("\"" + AsmRelationshipUtils.genDeclareMessage(decl.getMessage()) + "\""); parent.addChild(deowNode); } else if (element instanceof BcelAdvice) { BcelAdvice advice = (BcelAdvice)element; - parent.addChild(new ProgramElement( - advice.kind.getName(), - IProgramElement.Kind.ADVICE, - getSourceLocation(), - advice.signature.getModifiers(),null,Collections.EMPTY_LIST)); + IProgramElement adviceNode = new ProgramElement( + advice.kind.getName(), + IProgramElement.Kind.ADVICE, + getSourceLocation(), + advice.signature.getModifiers(),null,Collections.EMPTY_LIST); + adviceNode.setDetails(AsmRelationshipUtils.genPointcutDetails(advice.getPointcut())); + parent.addChild(adviceNode); } } } - - // taken from AsmElementFormatter - private String genDeclareMessage(String message) { - int length = message.length(); - if (length < 18) { - return message; - } else { - return message.substring(0, 17) + ".."; - } - } + } -- 2.39.5