< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java

Print this page




 235         private static Class<?> layerClass = null;
 236         private static Method bootMethod;
 237         private static Method defineModulesWithOneLoaderMethod;
 238         private static Method configurationMethod;
 239 
 240         private static void init() {
 241             if (layerClass == null) {
 242                 try {
 243                     layerClass = Class.forName("java.lang.reflect.Layer", false, null);
 244                     bootMethod = layerClass.getDeclaredMethod("boot");
 245                     defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
 246                                 Configuration.getConfigurationClass(),
 247                                 ClassLoader.class);
 248                     configurationMethod = layerClass.getDeclaredMethod("configuration");
 249                 } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
 250                     throw new Abort(ex);
 251                 }
 252             }
 253         }
 254     }




































 255 }


 235         private static Class<?> layerClass = null;
 236         private static Method bootMethod;
 237         private static Method defineModulesWithOneLoaderMethod;
 238         private static Method configurationMethod;
 239 
 240         private static void init() {
 241             if (layerClass == null) {
 242                 try {
 243                     layerClass = Class.forName("java.lang.reflect.Layer", false, null);
 244                     bootMethod = layerClass.getDeclaredMethod("boot");
 245                     defineModulesWithOneLoaderMethod = layerClass.getDeclaredMethod("defineModulesWithOneLoader",
 246                                 Configuration.getConfigurationClass(),
 247                                 ClassLoader.class);
 248                     configurationMethod = layerClass.getDeclaredMethod("configuration");
 249                 } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
 250                     throw new Abort(ex);
 251                 }
 252             }
 253         }
 254     }
 255 
 256 
 257     /**
 258      * Helper class for new method in jdk.internal.misc.VM.
 259      */
 260     public static final class VMHelper {
 261         public static final String VM_CLASSNAME = "jdk.internal.misc.VM";
 262 
 263         @SuppressWarnings("unchecked")
 264         public static String[] getRuntimeArguments() {
 265             try {
 266                 init();
 267                 Object result = getRuntimeArgumentsMethod.invoke(null);
 268                 return (String[])result;
 269             } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
 270                     | SecurityException ex) {
 271                 throw new Abort(ex);
 272             }
 273         }
 274 
 275         // -----------------------------------------------------------------------------------------
 276 
 277         private static Class<?> vmClass = null;
 278         private static Method getRuntimeArgumentsMethod = null;
 279 
 280         private static void init() {
 281             if (vmClass == null) {
 282                 try {
 283                     vmClass = Class.forName(VM_CLASSNAME, false, null);
 284                     getRuntimeArgumentsMethod = vmClass.getDeclaredMethod("getRuntimeArguments");
 285                 } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
 286                     throw new Abort(ex);
 287                 }
 288             }
 289         }
 290     }
 291 }
< prev index next >