From a1953b55458304e99b90124925c3b7c4aa88ebe3 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 15 Oct 2018 09:25:27 -0700 Subject: [PATCH] Merge changes for 536782 Changes contributed by Manfred under https://github.com/eclipse/org.aspectj/pull/5/commits --- .../ajdt/internal/core/builder/AsmElementFormatter.java | 7 +++++-- weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java | 8 +++++--- weaver/src/org/aspectj/weaver/bcel/BcelMethod.java | 5 ++++- weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 2 +- weaver/src/org/aspectj/weaver/bcel/Utility.java | 4 +++- weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | 7 +++++-- 6 files changed, 23 insertions(+), 10 deletions(-) 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 e43aea87c..450ffc40b 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 @@ -57,6 +57,9 @@ import org.aspectj.weaver.patterns.TypePatternList; */ public class AsmElementFormatter { + private final static String ASPECTJ_ANNOTATION_PACKAGE = "org.aspectj.lang.annotation"; + private final static char PACKAGE_INITIAL_CHAR = ASPECTJ_ANNOTATION_PACKAGE.charAt(0); + public void genLabelAndKind(MethodDeclaration methodDeclaration, IProgramElement node) { if (methodDeclaration instanceof AdviceDeclaration) { @@ -219,7 +222,7 @@ public class AsmElementFormatter { // Note: AV: implicit single advice type support here (should be enforced somewhere as well (APT etc)) Annotation annotation = methodDeclaration.annotations[i]; String annotationSig = new String(annotation.type.getTypeBindingPublic(methodDeclaration.scope).signature()); - if (annotationSig.charAt(1) == 'o') { + if (annotationSig.charAt(1) == PACKAGE_INITIAL_CHAR) { if ("Lorg/aspectj/lang/annotation/Pointcut;".equals(annotationSig)) { node.setKind(IProgramElement.Kind.POINTCUT); node.setAnnotationStyleDeclaration(true); // pointcuts don't seem to get handled quite right... @@ -459,7 +462,7 @@ public class AsmElementFormatter { // TODO: fix this way of determing ajc-added arguments, make subtype of Argument with extra info private boolean acceptArgument(String name, String type) { - if (name.charAt(0) != 'a' && type.charAt(0) != 'o') { + if (name.charAt(0) != 'a' && type.charAt(0) != PACKAGE_INITIAL_CHAR) { return true; } return !name.startsWith("ajc$this_") && !type.equals("org.aspectj.lang.JoinPoint.StaticPart") diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java index dbb81b53e..19170b547 100644 --- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -98,6 +98,8 @@ public class AtAjAttributes { private final static String THROWING = "throwing"; private final static String RETURNING = "returning"; private final static String STRING_DESC = "Ljava/lang/String;"; + private final static String ASPECTJ_ANNOTATION_PACKAGE = "org.aspectj.lang.annotation"; + private final static char PACKAGE_INITIAL_CHAR = ASPECTJ_ANNOTATION_PACKAGE.charAt(0); /** * A struct that allows to add extra arguments without always breaking the API @@ -193,8 +195,8 @@ public class AtAjAttributes { */ public static List readAj5ClassAttributes(AsmManager model, JavaClass javaClass, ReferenceType type, ISourceContext context, IMessageHandler msgHandler, boolean isCodeStyleAspect) { - boolean ignoreThisClass = javaClass.getClassName().charAt(0) == 'o' - && javaClass.getClassName().startsWith("org.aspectj.lang.annotation"); + boolean ignoreThisClass = javaClass.getClassName().charAt(0) == PACKAGE_INITIAL_CHAR + && javaClass.getClassName().startsWith(ASPECTJ_ANNOTATION_PACKAGE); if (ignoreThisClass) { return NO_ATTRIBUTES; } @@ -205,7 +207,7 @@ public class AtAjAttributes { Constant constant = cpool[i]; if (constant != null && constant.getTag() == Constants.CONSTANT_Utf8) { String constantValue = ((ConstantUtf8) constant).getValue(); - if (constantValue.length() > 28 && constantValue.charAt(1) == 'o') { + if (constantValue.length() > 28 && constantValue.charAt(1) == PACKAGE_INITIAL_CHAR) { if (constantValue.startsWith("Lorg/aspectj/lang/annotation")) { containsAnnotationClassReference = true; if ("Lorg/aspectj/lang/annotation/DeclareAnnotation;".equals(constantValue)) { diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java index 4d8114eaf..d1e60e1c7 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java @@ -51,6 +51,9 @@ import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.GenericSigna //public final class BcelMethod extends ResolvedMemberImpl { + private final static String ASPECTJ_ANNOTATION_PACKAGE = "org.aspectj.lang.annotation"; + private final static char PACKAGE_INITIAL_CHAR = ASPECTJ_ANNOTATION_PACKAGE.charAt(0); + private Method method; // these fields are not set for many BcelMethods... @@ -141,7 +144,7 @@ class BcelMethod extends ResolvedMemberImpl { for (int i = 0; i < axs.length; i++) { AnnotationAJ annotationX = axs[i]; String typename = annotationX.getTypeName(); - if (typename.charAt(0) == 'o') { + if (typename.charAt(0) == PACKAGE_INITIAL_CHAR) { if (typename.equals("org.aspectj.lang.annotation.Pointcut") || typename.equals("org.aspectj.lang.annotation.Before") || typename.equals("org.aspectj.lang.annotation.Around") diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 2e8d3ab6b..c93a0f26e 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2941,7 +2941,7 @@ public class BcelShadow extends Shadow { closureInstantiation.append(fact.createConstant(Integer.valueOf(bitflags))); closureInstantiation.append(Utility.createInvoke(getFactory(), getWorld(), new MemberImpl(Member.METHOD, UnresolvedType.forName("org.aspectj.runtime.internal.AroundClosure"), - Modifier.PUBLIC, "linkClosureAndJoinPoint", "(I)Lorg/aspectj/lang/ProceedingJoinPoint;"))); + Modifier.PUBLIC, "linkClosureAndJoinPoint", String.format("%s%s", "(I)", "Lorg/aspectj/lang/ProceedingJoinPoint;")))); } InstructionList advice = new InstructionList(); diff --git a/weaver/src/org/aspectj/weaver/bcel/Utility.java b/weaver/src/org/aspectj/weaver/bcel/Utility.java index cd1fd4ab8..4acf032fc 100644 --- a/weaver/src/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/org/aspectj/weaver/bcel/Utility.java @@ -65,6 +65,8 @@ import org.aspectj.weaver.World; public class Utility { + private final static char PACKAGE_INITIAL_CHAR = AjAttribute.AttributePrefix.charAt(0); + public static List readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w, AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor) { List attributes = new ArrayList(); @@ -76,7 +78,7 @@ public class Utility { if (a instanceof Unknown) { Unknown u = (Unknown) a; String name = u.getName(); - if (name.charAt(0) == 'o') { // 'o'rg.aspectj + if (name.charAt(0) == PACKAGE_INITIAL_CHAR) { // 'o'rg.aspectj if (name.startsWith(AjAttribute.AttributePrefix)) { if (name.endsWith(WeaverVersionInfo.AttributeName)) { version = (AjAttribute.WeaverVersionInfo) AjAttribute.read(version, name, u.getBytes(), context, w, diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index c372afc83..a02400fb0 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -80,6 +80,9 @@ public class WeavingAdaptor implements IMessageContext { public static final String SHOW_WEAVE_INFO_PROPERTY = "org.aspectj.weaver.showWeaveInfo"; public static final String TRACE_MESSAGES_PROPERTY = "org.aspectj.tracing.messages"; + private final static String ASPECTJ_BASE_PACKAGE = "org.aspectj."; + private final static String PACKAGE_INITIAL_CHARS = ASPECTJ_BASE_PACKAGE.charAt(0) + "sj"; + private boolean enabled = false; protected boolean verbose = getVerbose(); protected BcelWorld bcelWorld; @@ -447,7 +450,7 @@ public class WeavingAdaptor implements IMessageContext { } private boolean shouldWeaveName(String name) { - if ("osj".indexOf(name.charAt(0)) != -1) { + if (PACKAGE_INITIAL_CHARS.indexOf(name.charAt(0)) != -1) { if ((weavingSpecialTypes & INITIALIZED) == 0) { weavingSpecialTypes |= INITIALIZED; // initialize it @@ -463,7 +466,7 @@ public class WeavingAdaptor implements IMessageContext { } } } - if (name.startsWith("org.aspectj.")) { + if (name.startsWith(ASPECTJ_BASE_PACKAGE)) { return false; } if (name.startsWith("sun.reflect.")) {// JDK reflect -- 2.39.5