< prev index next >

src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java

Print this page

 42     private ThreadGroup execThreadGroup;
 43 
 44     /**
 45      * Creates an instance, delegating loader operations to the specified
 46      * delegate.
 47      *
 48      * @param loaderDelegate the delegate to handle loading classes
 49      */
 50     public LocalExecutionControl(LoaderDelegate loaderDelegate) {
 51         super(loaderDelegate);
 52     }
 53 
 54     /**
 55      * Create an instance using the default class loading.
 56      */
 57     public LocalExecutionControl() {
 58     }
 59 
 60     @Override
 61     protected String invoke(Method doitMethod) throws Exception {
 62         execThreadGroup = new ThreadGroup("JShell process local execution");


 63 
 64         AtomicReference<InvocationTargetException> iteEx = new AtomicReference<>();
 65         AtomicReference<IllegalAccessException> iaeEx = new AtomicReference<>();
 66         AtomicReference<NoSuchMethodException> nmeEx = new AtomicReference<>();
 67         AtomicReference<Boolean> stopped = new AtomicReference<>(false);
 68 
 69         Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
 70             if (e instanceof InvocationTargetException) {
 71                 if (e.getCause() instanceof ThreadDeath) {
 72                     stopped.set(true);
 73                 } else {
 74                     iteEx.set((InvocationTargetException) e);
 75                 }
 76             } else if (e instanceof IllegalAccessException) {
 77                 iaeEx.set((IllegalAccessException) e);
 78             } else if (e instanceof NoSuchMethodException) {
 79                 nmeEx.set((NoSuchMethodException) e);
 80             } else if (e instanceof ThreadDeath) {
 81                 stopped.set(true);
 82             }

 42     private ThreadGroup execThreadGroup;
 43 
 44     /**
 45      * Creates an instance, delegating loader operations to the specified
 46      * delegate.
 47      *
 48      * @param loaderDelegate the delegate to handle loading classes
 49      */
 50     public LocalExecutionControl(LoaderDelegate loaderDelegate) {
 51         super(loaderDelegate);
 52     }
 53 
 54     /**
 55      * Create an instance using the default class loading.
 56      */
 57     public LocalExecutionControl() {
 58     }
 59 
 60     @Override
 61     protected String invoke(Method doitMethod) throws Exception {
 62         @SuppressWarnings("deprecation")
 63         ThreadGroup group = new ThreadGroup("JShell process local execution");
 64         execThreadGroup = group;
 65 
 66         AtomicReference<InvocationTargetException> iteEx = new AtomicReference<>();
 67         AtomicReference<IllegalAccessException> iaeEx = new AtomicReference<>();
 68         AtomicReference<NoSuchMethodException> nmeEx = new AtomicReference<>();
 69         AtomicReference<Boolean> stopped = new AtomicReference<>(false);
 70 
 71         Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
 72             if (e instanceof InvocationTargetException) {
 73                 if (e.getCause() instanceof ThreadDeath) {
 74                     stopped.set(true);
 75                 } else {
 76                     iteEx.set((InvocationTargetException) e);
 77                 }
 78             } else if (e instanceof IllegalAccessException) {
 79                 iaeEx.set((IllegalAccessException) e);
 80             } else if (e instanceof NoSuchMethodException) {
 81                 nmeEx.set((NoSuchMethodException) e);
 82             } else if (e instanceof ThreadDeath) {
 83                 stopped.set(true);
 84             }
< prev index next >