]> source.dussan.org Git - aspectj.git/commitdiff
expanded coverage and fix for bug involving around advice with either
authorjhugunin <jhugunin>
Thu, 1 May 2003 03:25:43 +0000 (03:25 +0000)
committerjhugunin <jhugunin>
Thu, 1 May 2003 03:25:43 +0000 (03:25 +0000)
assert or <name>.class in the body

the fix for now is just to not inline such advice, but in the future these
should be transformed to inlinable constructs

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
tests/bugs/interSpecials/p1/C.java
tests/bugs/interSpecials/p2/A1.java
tests/bugs/interSpecials/p2/A2.java
tests/jimTests.xml

index 637ab0bd1418e41440a847d06e305cf66c29352f..aa195135e145ab64eb75d39bca6afacc7693dbd2 100644 (file)
@@ -23,6 +23,8 @@ import org.aspectj.weaver.AjcMemberMaker;
 import org.aspectj.weaver.ResolvedMember;
 import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
 import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
+import org.eclipse.jdt.internal.compiler.ast.AssertStatement;
+import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
 import org.eclipse.jdt.internal.compiler.ast.FieldReference;
 import org.eclipse.jdt.internal.compiler.ast.MessageSend;
 import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
@@ -57,6 +59,10 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
        AspectDeclaration inAspect;
        EclipseFactory world; // alias for inAspect.world
        
+       //      set to true for ClassLiteralAccess and AssertStatement
+       // ??? A better answer would be to transform these into inlinable forms
+       public boolean isInlinable = true;  
+       
        public AccessForInlineVisitor(AspectDeclaration inAspect, PrivilegedHandler handler) {
                this.inAspect = inAspect;
                this.world = inAspect.factory;
@@ -187,4 +193,18 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
                        return;
                }
        }
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor#endVisit(org.eclipse.jdt.internal.compiler.ast.AssertStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
+        */
+       public void endVisit(AssertStatement assertStatement, BlockScope scope) {
+               isInlinable = false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor#endVisit(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
+        */
+       public void endVisit(ClassLiteralAccess classLiteral, BlockScope scope) {
+               isInlinable = false;
+       }
+
 }
index f23502f75dd7339bac33f8b730b90534eed1bce7..aabc84624d9890df0c257efc2642d89f6ba81c5c 100644 (file)
@@ -163,6 +163,10 @@ public class AdviceDeclaration extends MethodDeclaration {
                                
                                AccessForInlineVisitor v = new AccessForInlineVisitor((AspectDeclaration)upperScope.referenceContext, handler);
                                this.traverse(v, (ClassScope) null);
+                               
+                               // ??? if we found a construct that we can't inline, set
+                               //     proceedInInners so that we won't try to inline this body
+                               if (!v.isInlinable) proceedInInners = true;
                        }
                }
        }
index 472afd808b7fab65a27c5b4262ba6d2e5a696cbd..160bb847c62cb5dc18c99d4389f0737c7ac60c5c 100644 (file)
@@ -1,4 +1,5 @@
 package p1;
 
 public class C {
+       public void bar() {}
 }
\ No newline at end of file
index 4a84e592d90932d5de031c30c918750c06c4391e..9b75428bbf47632b60b6643131368072b6daa25b 100644 (file)
@@ -5,6 +5,7 @@ import p1.C;
 public class A1 {
        public static void main(String[] args) {
                new C().foo();
+               new C().bar();
        }
 }
 
@@ -12,4 +13,9 @@ aspect InterClass {
        void C.foo() {
                System.out.println("class: " + C.class);
        }
+       
+       void around(): execution(void C.bar()) {
+               System.out.println("class: " + C.class);
+               proceed();
+       }
 }
\ No newline at end of file
index a29f3d5b954d6409ba401ce07eac52069dca2b07..003e35486bdb0463591af2196bb33284cef56045 100644 (file)
@@ -4,6 +4,7 @@ import p1.C;
 public class A2 {
        public static void main(String[] args) {
                new C().foo();
+               new C().bar();
        }
 }
 
@@ -11,4 +12,9 @@ aspect InterClass {
        void C.foo() {
                assert(C.class != null);
        }
+       
+       void around(): execution(void C.bar()) {
+               assert(C.class != null);
+               proceed();
+       }
 }
index 0ebd8cd50c8f256d6c78a065f057f2107e3fbe3c..a7b32080d8ebdff70c95b3884b228f7d92dbc240 100644 (file)
@@ -1,7 +1,17 @@
 <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
 <suite> 
 
-
+    <ajc-test dir="bugs/interSpecials" title="IllegalAccessError while accessing introduced variable / 1.1rc1"
+      pr="36110">
+        <compile files="p1/C.java,p2/A1.java"/>
+        <run class="p2.A1"/>
+    </ajc-test>
+    
+    <ajc-test dir="bugs/interSpecials" title="testing that assert works like .class"
+      pr="36110">
+        <compile files="p1/C.java,p2/A2.java" options="-source14"/>
+        <run class="p2.A2" vm="1.4"/>
+    </ajc-test>
 
     <!--