test/java/util/logging/ClassLoaderLeakTest.java

Print this page
rev 3186 : 6880112: Project Coin: Port JDK core library code to use diamond operator


  72                 } catch (Throwable e) {
  73                     launchFailure = e;
  74                 } finally {
  75                     launchSignal.countDown();
  76                 }
  77             }
  78         };
  79 
  80         /* prepare test  class loader */
  81         URL pwd = null;
  82         try {
  83 
  84             pwd = new File(System.getProperty("test.classes",".")).toURL();
  85         } catch (MalformedURLException e) {
  86             throw new RuntimeException("Test failed.", e);
  87         }
  88         URL[] urls = new URL[] { pwd };
  89 
  90          MyClassLoader appClassLoader = new MyClassLoader(urls, "test0");
  91          WeakReference<MyClassLoader> ref =
  92                  new WeakReference<MyClassLoader>(appClassLoader);
  93 
  94 
  95          Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0");
  96          appThread.setContextClassLoader(appClassLoader);
  97 
  98          appThread.start();
  99          appClassLoader = null;
 100          launcher = null;
 101          appThread = null;
 102 
 103          /* wait for laucnh completion */
 104          try {
 105              launchSignal.await();
 106          } catch (InterruptedException e) {
 107          }
 108 
 109          /* check if launch failed */
 110          if (launchFailure != null) {
 111              throw new RuntimeException("Test failed.", launchFailure);
 112          }




  72                 } catch (Throwable e) {
  73                     launchFailure = e;
  74                 } finally {
  75                     launchSignal.countDown();
  76                 }
  77             }
  78         };
  79 
  80         /* prepare test  class loader */
  81         URL pwd = null;
  82         try {
  83 
  84             pwd = new File(System.getProperty("test.classes",".")).toURL();
  85         } catch (MalformedURLException e) {
  86             throw new RuntimeException("Test failed.", e);
  87         }
  88         URL[] urls = new URL[] { pwd };
  89 
  90          MyClassLoader appClassLoader = new MyClassLoader(urls, "test0");
  91          WeakReference<MyClassLoader> ref =
  92                  new WeakReference<>(appClassLoader);
  93 
  94 
  95          Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0");
  96          appThread.setContextClassLoader(appClassLoader);
  97 
  98          appThread.start();
  99          appClassLoader = null;
 100          launcher = null;
 101          appThread = null;
 102 
 103          /* wait for laucnh completion */
 104          try {
 105              launchSignal.await();
 106          } catch (InterruptedException e) {
 107          }
 108 
 109          /* check if launch failed */
 110          if (launchFailure != null) {
 111              throw new RuntimeException("Test failed.", launchFailure);
 112          }