| 7 | // This class must be in a separate file or the invokedynamic |
| 8 | // bootstrap procedure fails. |
| 9 | public class A { |
| 10 | public static Integer staticMeth() { |
| 11 | System.out.println("staticMeth() called."); |
| 12 | return new Integer(10); |
| 13 | } |
| 14 | |
| 15 | public void methI(Integer i) { |
| 16 | System.out.println("this.methI(" + i + ") called, this = " + this.hashCode()); |
| 17 | } |
| 18 | |
| 19 | public Double doubleIdentity(Double d) { |
| 20 | System.out.println("doubleIdentity(" + d + ") called."); |
| 21 | return d; |
| 22 | } |
| 23 | |
| 24 | public Double add3(Integer a, Float b, Short c) { |
| 25 | Double sum = a.doubleValue() + b.doubleValue() + c.doubleValue(); |
| 26 | System.out.println("add3: " + a + " + " + " + " + b + " + " + c + " = " + sum); |
| 27 | return sum; |
| 28 | } |
| 29 | |
| 30 | public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType type) |
| 31 | throws NoSuchMethodException, IllegalAccessException { |
| 32 | MethodType mt = MethodType.methodType(Void.TYPE, A.class); |
| 33 | MethodHandle handle = MethodHandles.lookup().findStatic(A.class, name, mt); |
| 34 | return new ConstantCallSite(handle); |
| 35 | } |
| 36 | |
| 37 | public static CallSite bootstrap2(MethodHandles.Lookup caller, String name, MethodType type) |
| 38 | throws NoSuchMethodException, IllegalAccessException { |
| 39 | MethodHandle handle = MethodHandles.lookup().findStatic(A.class, name, type); |
| 40 | return new ConstantCallSite(handle); |
| 41 | } |
| 42 | |
| 43 | public static CallSite bootstrap3(MethodHandles.Lookup caller, String name, MethodType type) |
| 44 | throws NoSuchMethodException, IllegalAccessException { |
| 45 | Class<?> c; |
| 46 | try { |
| 47 | c = Class.forName("Unknown"); |
| 48 | } catch (ClassNotFoundException ex) { |
| 49 | c = A.class; |
| 50 | } |
| 51 | MethodHandle handle = MethodHandles.lookup().findStatic(c, name, type); |
| 52 | return new ConstantCallSite(handle); |
| 53 | } |
| 54 | |
| 55 | public static CallSite bootstrap4(MethodHandles.Lookup caller, String name, MethodType type) |
| 56 | throws NoSuchMethodException, IllegalAccessException { |
| 57 | MethodType mt = MethodType.methodType(Void.TYPE, A.class); |
| 58 | MethodHandle handle = MethodHandles.lookup().findVirtual(A.class, name, mt); |
| 59 | return new ConstantCallSite(handle); |
| 60 | } |
| 61 | |
| 62 | public static void print(A a) { |
| 63 | Integer i = a.staticMeth(); |
| 64 | } |
| 65 | |
| 66 | public void print2(A a) { |
nothing calls this directly
no outgoing calls
no test coverage detected