]> source.dussan.org Git - aspectj.git/commitdiff
Merge changes for 536782
authorAndy Clement <aclement@pivotal.io>
Mon, 15 Oct 2018 16:25:27 +0000 (09:25 -0700)
committerAndy Clement <aclement@pivotal.io>
Mon, 15 Oct 2018 16:25:27 +0000 (09:25 -0700)
Changes contributed by Manfred under https://github.com/eclipse/org.aspectj/pull/5/commits

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java
weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/Utility.java
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java

index e43aea87c3ca593f650fa22a34365a62477c9166..450ffc40b57faa023ed9041c6e3cededac027693 100644 (file)
@@ -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")
index dbb81b53e8aae5c1b9caac8cbc4e291bc9b4d5ea..19170b547d403bd59929ab2da079992d57c91c49 100644 (file)
@@ -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<AjAttribute> 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)) {
index 4d8114eaffd325b3ebe1950b3d79372bdbaaf2c2..d1e60e1c79ea451de9c353cfe336075e5ced8c96 100644 (file)
@@ -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")
index 2e8d3ab6b8865a508872c66faff397df6a9b8a0b..c93a0f26e1eee97cd02e77d200cbcf68a9e5e49c 100644 (file)
@@ -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();
index cd1fd4ab8ddd75116704dc1352a10c350f4faa15..4acf032fc91c15fef129a58a16ac4b9fc924c5da 100644 (file)
@@ -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<AjAttribute> readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w,
                        AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor) {
                List<AjAttribute> attributes = new ArrayList<AjAttribute>();
@@ -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,
index c372afc83b44dfe57b11e5ffb34c7b0662245c64..a02400fb0831ae8b7196c5d26c5dccc7464bca23 100644 (file)
@@ -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