< prev index next >

test/langtools/tools/javac/lambda/methodReference/BridgeMethod.java

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com


  58     }
  59 
  60     static void bar(String s) {
  61         System.out.println("BridgeMethod.bar(String) " + s);
  62     }
  63 
  64     String moo() {
  65         return "moo";
  66     }
  67 
  68     private static Set<String> setOfStringObject() {
  69         Set<String> s = new HashSet<>();
  70         s.add("java.lang.String");
  71         s.add("java.lang.Object");
  72         return s;
  73     }
  74 
  75     private static Set<String> allowedMethods() {
  76         Set<String> s = new HashSet<>();
  77         s.add("m");
  78         if (Boolean.getBoolean("jdk.internal.lambda.disableEagerInitialization")) {
  79             s.add("get$Lambda");
  80         }
  81         return s;
  82     }
  83 
  84     private static boolean matchingMethodNames(Method[] methods) {
  85         Set<String> methodNames = new HashSet<>();
  86         for (Method m : methods) {
  87             methodNames.add(m.getName());
  88         }
  89         return methodNames.equals(allowedMethods());
  90     }
  91 
  92     public static void main(String[] args) {
  93         L la = BridgeMethod::bar; //static reference
  94         la.m("hi");
  95         Class<? extends L> c1 = la.getClass();
  96         Method[] methods = c1.getDeclaredMethods();
  97         assertTrue(matchingMethodNames(methods));
  98         Set<String> types = setOfStringObject();
  99         System.out.println("methods in SAM conversion of L:");
 100         for(Method m : methods) {




  58     }
  59 
  60     static void bar(String s) {
  61         System.out.println("BridgeMethod.bar(String) " + s);
  62     }
  63 
  64     String moo() {
  65         return "moo";
  66     }
  67 
  68     private static Set<String> setOfStringObject() {
  69         Set<String> s = new HashSet<>();
  70         s.add("java.lang.String");
  71         s.add("java.lang.Object");
  72         return s;
  73     }
  74 
  75     private static Set<String> allowedMethods() {
  76         Set<String> s = new HashSet<>();
  77         s.add("m");



  78         return s;
  79     }
  80 
  81     private static boolean matchingMethodNames(Method[] methods) {
  82         Set<String> methodNames = new HashSet<>();
  83         for (Method m : methods) {
  84             methodNames.add(m.getName());
  85         }
  86         return methodNames.equals(allowedMethods());
  87     }
  88 
  89     public static void main(String[] args) {
  90         L la = BridgeMethod::bar; //static reference
  91         la.m("hi");
  92         Class<? extends L> c1 = la.getClass();
  93         Method[] methods = c1.getDeclaredMethods();
  94         assertTrue(matchingMethodNames(methods));
  95         Set<String> types = setOfStringObject();
  96         System.out.println("methods in SAM conversion of L:");
  97         for(Method m : methods) {


< prev index next >