< 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,11 +35,11 @@
 /*
  * @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
+ * @run testng/othervm -Dsun.reflect.noInflation=true ShowReflectionTargetTest
  * @author stuefe
  */
 
 public class ShowReflectionTargetTest {
 

@@ -49,20 +49,19 @@
         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.
+        // 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");
-        for (int i = 0; i < 100; i ++) {
-            Object o = ctor.newInstance(i);
+
+        Object o = ctor.newInstance(17);
             int j = ((Integer)m.invoke(o)).intValue();
-            Assert.assertEquals(j, i);
-        }
+        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 >