]> source.dussan.org Git - aspectj.git/commitdiff
Further 451966: privileged aspect and ITDs
authorAndy Clement <aclement@gopivotal.com>
Tue, 18 Nov 2014 02:32:25 +0000 (18:32 -0800)
committerAndy Clement <aclement@gopivotal.com>
Tue, 18 Nov 2014 02:32:25 +0000 (18:32 -0800)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMethodBinding.java
tests/bugs185/451966/Code2.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java
tests/src/org/aspectj/systemtest/ajc185/ajc185.xml

index 94637ffc6e29e5af2e123c3e18d42bd21c8155f2..94dd63e2766914f4ff93cebaef93a5f8d3b9bf70 100644 (file)
@@ -4,7 +4,7 @@
      The -Xlintfile:lint.properties allows fine-grained control. In tools.jar, see
      org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. 
 ### AspectJ-specific messages 
-compiler.name = AspectJ Compiler 1.8.4
+compiler.name = AspectJ Compiler 1.8.5
 compiler.version = Eclipse Compiler BETA_JAVA8_2b07958, 3.11
 compiler.copyright = 
 
index 5d17dd3578b5099aae5c318c0bc46dab6418568a..953e7d9ee5fecae2176efce10fed13ac270b2844 100644 (file)
@@ -104,13 +104,25 @@ public class InterTypeMethodBinding extends MethodBinding {
                        // it is a privileged aspect
                        return true;
                }
-
+               
                if (isProtected()) {
                        throw new RuntimeException("unimplemented");
                }
 
                // XXX make sure this walks correctly
                if (isPrivate()) {
+                       // Possibly the call is made from an inner type within the privileged aspect
+                       // TODO should check the first outer aspect we come across and stop at that point?
+                       if (invocationType.isNestedType()) {
+                               TypeBinding enclosingType = invocationType.enclosingType();
+                               while (enclosingType != null) {
+                                       if ((enclosingType instanceof SourceTypeBinding) && ((SourceTypeBinding)enclosingType).privilegedHandler != null) {
+                                               return true;
+                                       }
+                                       enclosingType = enclosingType.enclosingType();
+                               }
+                       }
+
                        // answer true if the receiverType is the declaringClass
                        // AND the invocationType and the declaringClass have a common enclosingType
                        // if (receiverType != declaringClass) return false;
diff --git a/tests/bugs185/451966/Code2.java b/tests/bugs185/451966/Code2.java
new file mode 100644 (file)
index 0000000..d402117
--- /dev/null
@@ -0,0 +1,31 @@
+
+public class Code2 {
+  public static void main(String []argv) {
+    new Bar().foo();
+  }
+}
+interface Common { }
+
+interface Allergies extends Common { 
+  default public void foo() {
+  }
+}
+
+class Bar implements Allergies { }
+
+aspect Y {
+  private boolean Common.instancesInvariant() {
+    return false;
+  }
+}
+
+privileged aspect AspectJMLRac_allergies_Allergies {
+  before(final Allergies object$rac): execution(* Allergies+.*(..)) && this(object$rac) {
+    Runnable r = new Runnable() {
+      public void run() {
+        boolean b = object$rac.instancesInvariant();
+      }
+    };
+    boolean b = object$rac.instancesInvariant();
+  }
+}
index 9fefaa5eb6f520f6d190d1d061b3ce27b07a8fc9..135eb84643f23bcfc80ed5e252efac72a39106c6 100644 (file)
@@ -24,7 +24,12 @@ public class Ajc185Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testITDInterface_451966() throws Exception {
                runTest("itd interface");
        }
-       
+
+       public void testITDInterface_451966_2() throws Exception {
+               // call made from inner type
+               runTest("itd interface - 2");
+       }
+
        // ---
 
        public static Test suite() {
index 5e8f8dc8a19f7279e82bff3e2a146e468fe918b9..7c30d7bf4a01ad80ddd0d85331dd258bd5a013b5 100644 (file)
@@ -2,11 +2,16 @@
 
 <suite>
 
-
 <ajc-test dir="bugs185/451966" title="itd interface">
 <compile files="Code.java" options="-1.8"/>
 <run class="Code">
 </run>
 </ajc-test>
 
+<ajc-test dir="bugs185/451966" title="itd interface - 2">
+<compile files="Code2.java" options="-1.8"/>
+<run class="Code2">
+</run>
+</ajc-test>
+
 </suite>