aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs192
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2018-10-10 13:27:17 -0700
committerAndy Clement <aclement@pivotal.io>2018-10-10 13:27:17 -0700
commitf92ea896c1978011c827ed0a2ab0fd658fa23bb2 (patch)
treeea9aca6d17ad934c44b7249027859d7e17c942d9 /tests/bugs192
parent46a1172aac0b24ccbcb38083ff66d8e8e4ff2d17 (diff)
downloadaspectj-f92ea896c1978011c827ed0a2ab0fd658fa23bb2.tar.gz
aspectj-f92ea896c1978011c827ed0a2ab0fd658fa23bb2.zip
513528: Fix use of lambda in ITD
Diffstat (limited to 'tests/bugs192')
-rw-r--r--tests/bugs192/513528/Apple.java20
-rw-r--r--tests/bugs192/513528/AppleController.java16
-rw-r--r--tests/bugs192/513528/AppleControllerITDAspect.java30
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/bugs192/513528/Apple.java b/tests/bugs192/513528/Apple.java
new file mode 100644
index 000000000..658616ae8
--- /dev/null
+++ b/tests/bugs192/513528/Apple.java
@@ -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
index 000000000..6a8d93f88
--- /dev/null
+++ b/tests/bugs192/513528/AppleController.java
@@ -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
index 000000000..76773d479
--- /dev/null
+++ b/tests/bugs192/513528/AppleControllerITDAspect.java
@@ -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());
+ }
+}