]> source.dussan.org Git - aspectj.git/commitdiff
tests and fixes for two awful error message bugs:
authorjhugunin <jhugunin>
Wed, 2 Jul 2003 23:12:18 +0000 (23:12 +0000)
committerjhugunin <jhugunin>
Wed, 2 Jul 2003 23:12:18 +0000 (23:12 +0000)
[Bug 39458] New: Compiler crash in ajc 1.1
[Bug 39460] New: Missing import crashes compiler

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
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
tests/ajcTests.xml
tests/ajcTestsFailing.xml
tests/bugs/MissingImport.java [new file with mode: 0644]
tests/bugs/NewVoid.java [new file with mode: 0644]

index 76acd7306f6bb3f908fc9356d73c5699ead181ad..c692d1b4c04dc7dc422e0c6f0c0d08d8dd4044fd 100644 (file)
@@ -100,7 +100,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
        }
        public void endVisit(MessageSend send, BlockScope scope) {
                if (send instanceof Proceed) return;
-               if (send.binding == null) return;
+               if (send.binding == null || !send.binding.isValidBinding()) return;
                
                if (send.isSuperAccess() && !send.binding.isStatic()) {
                        send.receiver = new ThisReference(send.sourceStart, send.sourceEnd);
@@ -111,7 +111,7 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
                }
        }
        public void endVisit(AllocationExpression send, BlockScope scope) {
-               if (send.binding == null) return;
+               if (send.binding == null || !send.binding.isValidBinding()) return;
                //XXX TBD
                if (isPublic(send.binding)) return;
                makePublic(send.binding.declaringClass);
@@ -121,14 +121,14 @@ public class AccessForInlineVisitor extends AbstractSyntaxTreeVisitorAdapter {
                QualifiedTypeReference ref,
                BlockScope scope)
        {
-               makePublic(ref.getTypeBinding(scope));   //??? might be trouble
+               makePublic(ref.resolvedType); //getTypeBinding(scope));   //??? might be trouble
        }
        
        public void endVisit(
                SingleTypeReference ref,
                BlockScope scope)
        {
-               makePublic(ref.getTypeBinding(scope));  //??? might be trouble
+               makePublic(ref.resolvedType); //getTypeBinding(scope));  //??? might be trouble
        }
        
        private FieldBinding getAccessibleField(FieldBinding binding) {
@@ -208,16 +208,11 @@ 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 aabc84624d9890df0c257efc2642d89f6ba81c5c..122760fc2fdd099c05d0b28b6da573a104eca57b 100644 (file)
@@ -156,7 +156,7 @@ public class AdviceDeclaration extends MethodDeclaration {
                                PrivilegedHandler handler = (PrivilegedHandler)upperScope.referenceContext.binding.privilegedHandler;
                                if (handler == null) {
                                        handler = new PrivilegedHandler((AspectDeclaration)upperScope.referenceContext);
-                                       upperScope.referenceContext.binding.privilegedHandler = handler;
+                                       //upperScope.referenceContext.binding.privilegedHandler = handler;
                                }
                                
                                this.traverse(new MakeDeclsPublicVisitor(), (ClassScope)null);
index 3343e063458d7dc1be27aa4ce88889ebe44affb1..ac410b89654cc6823bdd35852a21f04949600f2d 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.AstUtil;
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.weaver.AjcMemberMaker;
 import org.aspectj.weaver.Lint;
@@ -55,19 +56,21 @@ public class PrivilegedHandler implements IPrivilegedHandler {
        public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod, AstNode location) {
                if (baseMethod.alwaysNeedsAccessMethod()) return baseMethod;
                
-               ResolvedMember key = inAspect.factory.makeResolvedMember(baseMethod);
+               ResolvedMember key = EclipseFactory.makeResolvedMember(baseMethod);
                if (accessors.containsKey(key)) return (MethodBinding)accessors.get(key);
                
                MethodBinding ret;
                if (baseMethod.isConstructor()) {
-                       ret = baseMethod;
+                       ret = new MethodBinding(baseMethod, baseMethod.declaringClass);
+                       ret.modifiers = AstUtil.makePublic(ret.modifiers); 
                } else {
                        ret = inAspect.factory.makeMethodBinding(
                        AjcMemberMaker.privilegedAccessMethodForMethod(inAspect.typeX, key)
                        );
                }
                checkWeaveAccess(key.getDeclaringType(), location);
-               //new PrivilegedMethodBinding(inAspect, baseMethod);
+               //System.err.println(ret);
+               //Thread.dumpStack();
                accessors.put(key, ret);
                return ret;
        }
index 1419fc198adec2efb6bdd764b2a788d48d366942..8cf4bbc767808ec038ecbe9d7f4c8a8048375fd7 100644 (file)
         <compile files="TrySwitch.java"/>
         <run class="TrySwitch"/>
     </ajc-test>
+    
+    <ajc-test dir="bugs" pr="39458"
+        title="Compiler crash in ajc 1.1 - terrible error for inaccessible constructor">
+        <compile files="NewVoid.java">
+            <message kind="error" line="17"/>        
+            <message kind="error" line="20"/>        
+            <message kind="error" line="21"/>
+                  
+            <message kind="error" line="28"/>        
+            <message kind="warning" line="29"/>        
+            <message kind="warning" line="30"/>            
+        </compile>
+    </ajc-test>
+    
+    <ajc-test dir="bugs" pr="39460"
+        title="Missing import crashes compiler">
+        <compile files="MissingImport.java">
+            <message kind="error" line="13"/>       
+        </compile>
+    </ajc-test>
 </suite>
index 50d4ab09007d7b625d36166b55e0027a3dc06c5f..cb741c1e06e224218dbbdf2f4da77f36dff43413 100644 (file)
@@ -4,4 +4,5 @@
 <!-- contains valid tests that the compiler has never passed -->
 <suite>
 
+
 </suite>
diff --git a/tests/bugs/MissingImport.java b/tests/bugs/MissingImport.java
new file mode 100644 (file)
index 0000000..c70129e
--- /dev/null
@@ -0,0 +1,22 @@
+import org.aspectj.lang.*;
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.Method;
+//import java.lang.reflect.InvocationTargetException; <- crash with this line commented out
+
+public aspect MissingImport {
+       Object around() : 
+                       call(* *(..)) &&  !within(ImposterProcessing+) {
+               MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
+               try {
+                       Method meth = ImposterProcessing.class.getMethod("dynamicThrow",  new Class[] { Throwable.class });
+                                meth.invoke(this, new Object[] { null });
+                       } catch (InvocationTargetException e) {  // expect CE
+                                throw new RuntimeException("framework error in throwing test exception ", e);
+                       } catch (IllegalAccessException e) {
+                                throw new RuntimeException("framework error in throwing test exception ", e);
+                       }
+               return null;
+       }
+}
+
+class ImposterProcessing { }
\ No newline at end of file
diff --git a/tests/bugs/NewVoid.java b/tests/bugs/NewVoid.java
new file mode 100644 (file)
index 0000000..0162b53
--- /dev/null
@@ -0,0 +1,33 @@
+import org.aspectj.lang.*;
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.Method;
+
+public aspect NewVoid {
+       Object around() : 
+                       call(new(..))  {
+               return proceed();
+       }
+
+    
+       Object around() : 
+                        call(* *(..)) {
+               MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
+               Class returnType = sig.getReturnType();
+               if (returnType == java.lang.Void.TYPE) {
+                       return new java.lang.Void(); // expect CE here
+               } else {
+                       String s = "hi";
+                       Xyz xyz = null;   // expect CE here
+                       int x = s.count;  // expect CE here
+                       return proceed();
+               }
+       }
+}
+privileged aspect PrivCheck {    
+       Object around() :  call(* *(..)) {
+               Xyz xyz = null;         // expect CE here
+               Object o = new Void(); // expect warning here
+               int x = "goo".count; // expect warning here
+               return null;
+       }
+}
\ No newline at end of file