< prev index next >

make/jdk/src/classes/build/tools/classlist/HelloClasslist.java

Print this page
*** 114,22 ***
--- 114,34 ---
  
          String oldDate = String.format("%s%n",
                  DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.ROOT)
                          .format(new Date()));
  
+         // A selection of trivial and common reflection operations
+         var instance = HelloClasslist.class.getConstructor().newInstance();
+         HelloClasslist.class.getMethod("staticMethod_V").invoke(null);
+         var obj = HelloClasslist.class.getMethod("staticMethod_L_L", Object.class).invoke(null, instance);
+         HelloClasslist.class.getField("field").get(instance);
+ 
          // A selection of trivial and relatively common MH operations
          invoke(MethodHandles.identity(double.class), 1.0);
          invoke(MethodHandles.identity(int.class), 1);
          invoke(MethodHandles.identity(String.class), "x");
  
          invoke(handle("staticMethod_V", MethodType.methodType(void.class)));
  
          LOGGER.log(Level.FINE, "New Date: " + newDate + " - old: " + oldDate);
      }
  
+     public HelloClasslist() {}
+ 
+     public String field = "someValue";
+ 
      public static void staticMethod_V() {}
  
+     public static Object staticMethod_L_L(Object o) { return o; }
+ 
      private static MethodHandle handle(String name, MethodType type) throws Throwable {
          return MethodHandles.lookup().findStatic(HelloClasslist.class, name, type);
      }
  
      private static Object invoke(MethodHandle mh, Object ... args) throws Throwable {
< prev index next >