]> source.dussan.org Git - aspectj.git/commitdiff
513528: Fix use of lambda in ITD
authorAndy Clement <aclement@pivotal.io>
Wed, 10 Oct 2018 20:27:17 +0000 (13:27 -0700)
committerAndy Clement <aclement@pivotal.io>
Wed, 10 Oct 2018 20:27:17 +0000 (13:27 -0700)
org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
org.eclipse.jdt.core/jdtcore-for-aspectj.jar
tests/bugs192/513528/Apple.java [new file with mode: 0644]
tests/bugs192/513528/AppleController.java [new file with mode: 0644]
tests/bugs192/513528/AppleControllerITDAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc190/ajc190.xml
tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java
tests/src/org/aspectj/systemtest/ajc192/ajc192.xml

index 0e70dcd2050fc637dc79552644b442ceca874e5c..c4b27ad4c0083d12c06339380d554ea4200447a3 100644 (file)
Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip and b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip differ
index 3d73f19d960e5050cf4a9afcc0cbd569e7b27ab2..d48584d2e685c537f8e160e42548f88a7aab9684 100644 (file)
Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar and b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar differ
diff --git a/tests/bugs192/513528/Apple.java b/tests/bugs192/513528/Apple.java
new file mode 100644 (file)
index 0000000..658616a
--- /dev/null
@@ -0,0 +1,20 @@
+package de.scrum_master.app;
+
+public class Apple {
+  private String type;
+  private boolean sweet;
+
+  public Apple(String type, boolean sweet) {
+    this.type = type;
+    this.sweet = sweet;
+  }
+
+  public String getType() {
+    return type;
+  }
+
+  public boolean isSweet() {
+    return sweet;
+  }
+}
+
diff --git a/tests/bugs192/513528/AppleController.java b/tests/bugs192/513528/AppleController.java
new file mode 100644 (file)
index 0000000..6a8d93f
--- /dev/null
@@ -0,0 +1,16 @@
+package de.scrum_master.app;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class AppleController {
+  private static final List<Apple> APPLES =
+    Arrays.asList(new Apple("Granny Smith", false), new Apple("Golden Delicious", true));
+
+  public static void main(String[] args) {
+    AppleController appleController = new AppleController();
+    System.out.println("Named: " + appleController.namedApples(APPLES, "Smith"));
+    System.out.println("Sweet: " + appleController.sweetApples(APPLES));
+    System.out.println("Sour:  " + appleController.sourApples(APPLES));
+  }
+}
diff --git a/tests/bugs192/513528/AppleControllerITDAspect.java b/tests/bugs192/513528/AppleControllerITDAspect.java
new file mode 100644 (file)
index 0000000..76773d4
--- /dev/null
@@ -0,0 +1,30 @@
+package de.scrum_master.aspect;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import java.util.function.Predicate;
+import de.scrum_master.app.Apple;
+import de.scrum_master.app.AppleController;
+
+public privileged aspect AppleControllerITDAspect {
+  public List<Apple> AppleController.namedApples(List<Apple> apples, String subString) {
+    // Anonymous subclass works
+    return apples.stream().filter(new Predicate<Apple>() {
+      @Override
+      public boolean test(Apple a) {
+        return a.getType().contains(subString);
+      }
+    }).collect(Collectors.toList());
+  }
+
+  public List<Apple> AppleController.sweetApples(List<Apple> apples) {
+    // Method reference works
+    return apples.stream().filter(Apple::isSweet).collect(Collectors.toList());
+  }
+
+  public List<Apple> AppleController.sourApples(List<Apple> apples) {
+    // Lambda causes IllegalAccessError
+    return apples.stream().filter(a -> !a.isSweet()).collect(Collectors.toList());
+  }
+}
index dc311f63fcc8fa7e1b9171c30a59073b3427381d..d6507daceae1c89a17fe9421ba1d590c67ae2127 100644 (file)
@@ -90,7 +90,7 @@
     <compile files="module-info.java aaa/bbb/A.java" options="-1.9" outjar="my.module.jar"/>
     <file deletefile="module-info.java"/>
     <file deletefile="aaa"/>
-    <compile files="Azpect.java" outjar="azpects.jar"/>
+    <compile files="Azpect.java" outjar="azpects.jar" options="-1.4"/>
     <compile options="-showWeaveInfo" inpath="my.module.jar" aspectpath="azpects.jar" outjar="my.module.woven.jar">
                <message kind="weave" text="Join point 'method-execution(void aaa.bbb.A.main(java.lang.String[]))' in Type 'aaa.bbb.A' (A.java:4) advised by before advice from 'aspects.Azpect' (azpects.jar!Azpect.class:4(from Azpect.java))"/>    
     </compile>
index 148e3030d5e11874275f033a358d783bf4966d19..ea1215b2d514ea6de14cba79346e19e18763021e 100644 (file)
@@ -24,6 +24,10 @@ import junit.framework.Test;
  */
 public class Ajc192Tests extends XMLBasedAjcTestCase {
 
+       public void testITDLambdas() throws Exception {
+               runTest("itd lambdas");
+       }
+       
        public void test11Flags() throws Exception {
                runTest("11flags");
        }
index 304d522aa810872ad310732fac24a8ad35eb510c..095c3978a991b5d950a6ccebde0ca5ab5e6586ef 100644 (file)
@@ -2,6 +2,13 @@
 
 <suite>
 
+  <ajc-test dir="bugs192/513528" title="itd lambdas">
+    <compile files="Apple.java AppleController.java AppleControllerITDAspect.java" options="-11">
+       </compile>
+       <run class="de.scrum_master.app.AppleController">
+       </run>
+  </ajc-test>
+  
   <ajc-test dir="bugs192/11flags" title="11flags">
     <compile files="A.java" options="-11 -showWeaveInfo">
     <message kind="weave" text="Join point 'method-execution(void A.foo())' in Type 'A' (A.java:8) advised by before advice from 'X' (A.java:12)"/>