Mercurial > hg > heapstats
view agent/test/race-condition/ClassPrepare/MonitorWaited/testcase/Test.java @ 227:f421a4c6e7ea
Bug 3357: [TEST][RaceCondition]Add some events with ClassPrepare
Reviewed-by: yasuenag
https://github.com/HeapStats/heapstats/pull/92
author | KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> |
---|---|
date | Tue, 11 Apr 2017 18:05:01 +0900 |
parents | |
children | 84f67233da38 |
line wrap: on
line source
import java.net.*; import java.nio.file.*; import java.lang.reflect.*; public class Test implements Runnable{ public void run(){ try{ synchronized(Test.class){ Test.class.wait(1000); } } catch(IllegalArgumentException | IllegalMonitorStateException | InterruptedException e){ e.printStackTrace(); } } public static void main(String[] args) throws Exception{ (new Thread(new Test())).start(); ClassLoader loader = new URLClassLoader(new URL[]{ Paths.get(System.getProperty("java.class.path"), "dynload") .toUri() .toURL()}); Class<?> target = loader.loadClass("DynLoad"); Method targetMethod = target.getMethod("call"); Object targetObj = target.newInstance(); targetMethod.invoke(targetObj); } }