< prev index next >

test/hotspot/jtreg/serviceability/dcmd/vm/ShowReflectionTargetTest.java

Print this page
rev 50565 : [mq]: 8203343-VM.metaspace-show-reflection-invocation-targets
rev 50566 : [mq]: 8203343-VM.metaspace-show-reflection-invocation-targets-delta

*** 35,45 **** /* * @test * @summary Test that various diagnostic commands which can show core reflection * invocation targets do so correctly (See: JDK-8203343). * @library /test/lib ! * @run testng ShowReflectionTargetTest * @author stuefe */ public class ShowReflectionTargetTest { --- 35,45 ---- /* * @test * @summary Test that various diagnostic commands which can show core reflection * invocation targets do so correctly (See: JDK-8203343). * @library /test/lib ! * @run testng/othervm -Dsun.reflect.noInflation=true ShowReflectionTargetTest * @author stuefe */ public class ShowReflectionTargetTest {
*** 49,68 **** public Dummy(int i) { _i = i; } public int get_i() { return _i; } } public void run(CommandExecutor executor) throws Exception { ! // Do some reflection, enough times to hit the sun.reflect.inflationThreshold and force ! // generation of reflection accessor classes. Class<?> c = Class.forName("ShowReflectionTargetTest$Dummy"); Constructor<?> ctor = c.getConstructor(int.class); Method m = c.getMethod("get_i"); ! for (int i = 0; i < 100; i ++) { ! Object o = ctor.newInstance(i); int j = ((Integer)m.invoke(o)).intValue(); ! Assert.assertEquals(j, i); ! } // Now invoke VM.class_hierarchy and check its output. // Should show reflection targets, e.g.: // .... // |--jdk.internal.reflect.MagicAccessorImpl/null --- 49,67 ---- public Dummy(int i) { _i = i; } public int get_i() { return _i; } } public void run(CommandExecutor executor) throws Exception { ! // Do some reflection; since we set -Dsun.reflect.noInflation=true, this should ! // immediately generate Generated{Method|Constructor}Accessor objects. Class<?> c = Class.forName("ShowReflectionTargetTest$Dummy"); Constructor<?> ctor = c.getConstructor(int.class); Method m = c.getMethod("get_i"); ! ! Object o = ctor.newInstance(17); int j = ((Integer)m.invoke(o)).intValue(); ! Assert.assertEquals(j, 17); // Now invoke VM.class_hierarchy and check its output. // Should show reflection targets, e.g.: // .... // |--jdk.internal.reflect.MagicAccessorImpl/null
< prev index next >