aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs192/513528/AppleControllerITDAspect.java
blob: 76773d4790d79437e940ee79c6cde7f23e2e92a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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());
  }
}