< prev index next >

test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
  27  * @library ../../../../../
  28  * @modules jdk.vm.ci/jdk.vm.ci.meta
  29  *          jdk.vm.ci/jdk.vm.ci.runtime
  30  *          java.base/jdk.internal.misc
  31  * @build jdk.vm.ci.runtime.test.RedefineClassTest
  32  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.RedefineClassTest
  33  */
  34 
  35 package jdk.vm.ci.runtime.test;
  36 
  37 import static org.junit.Assume.assumeTrue;


  38 

  39 import java.io.FileOutputStream;
  40 import java.io.IOException;
  41 import java.io.InputStream;
  42 import java.lang.instrument.ClassFileTransformer;
  43 import java.lang.instrument.IllegalClassFormatException;
  44 import java.lang.instrument.Instrumentation;
  45 import java.lang.management.ManagementFactory;
  46 import java.lang.reflect.Method;
  47 import java.nio.file.Files;
  48 import java.nio.file.Path;
  49 import java.security.ProtectionDomain;
  50 import java.util.Arrays;
  51 import java.util.jar.Attributes;
  52 import java.util.jar.JarEntry;
  53 import java.util.jar.JarOutputStream;
  54 import java.util.jar.Manifest;
  55 
  56 import javax.tools.ToolProvider;
  57 
  58 import jdk.vm.ci.meta.ResolvedJavaMethod;
  59 
  60 import org.junit.Assert;
  61 import org.junit.Test;
  62 
  63 /**
  64  * Tests that {@link ResolvedJavaMethod}s are safe in the context of class redefinition being used
  65  * to redefine the method to which they refer.
  66  */
  67 public class RedefineClassTest extends TypeUniverse {
  68 
  69     static class Foo {
  70         public static Object getName() {
  71             return "foo";
  72         }
  73     }
  74 
  75     @Test
  76     public void test() throws Throwable {
  77 
  78         Method fooMethod = Foo.class.getDeclaredMethod("getName");
  79 
  80         ResolvedJavaMethod foo1 = metaAccess.lookupJavaMethod(fooMethod);
  81         ResolvedJavaMethod foo2 = metaAccess.lookupJavaMethod(fooMethod);
  82 




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
  27  * @library ../../../../../
  28  * @modules jdk.vm.ci/jdk.vm.ci.meta
  29  *          jdk.vm.ci/jdk.vm.ci.runtime
  30  *          java.base/jdk.internal.misc
  31  * @build jdk.vm.ci.runtime.test.RedefineClassTest
  32  * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.RedefineClassTest
  33  */
  34 
  35 package jdk.vm.ci.runtime.test;
  36 
  37 import jdk.vm.ci.meta.ResolvedJavaMethod;
  38 import org.junit.Assert;
  39 import org.junit.Test;
  40 
  41 import javax.tools.ToolProvider;
  42 import java.io.FileOutputStream;
  43 import java.io.IOException;
  44 import java.io.InputStream;
  45 import java.lang.instrument.ClassFileTransformer;
  46 import java.lang.instrument.IllegalClassFormatException;
  47 import java.lang.instrument.Instrumentation;
  48 import java.lang.management.ManagementFactory;
  49 import java.lang.reflect.Method;
  50 import java.nio.file.Files;
  51 import java.nio.file.Path;
  52 import java.security.ProtectionDomain;
  53 import java.util.Arrays;
  54 import java.util.jar.Attributes;
  55 import java.util.jar.JarEntry;
  56 import java.util.jar.JarOutputStream;
  57 import java.util.jar.Manifest;
  58 
  59 import static org.junit.Assume.assumeTrue;
  60 





  61 /**
  62  * Tests that {@link ResolvedJavaMethod}s are safe in the context of class redefinition being used
  63  * to redefine the method to which they refer.
  64  */
  65 public class RedefineClassTest extends TypeUniverse {
  66 
  67     static class Foo {
  68         public static Object getName() {
  69             return "foo";
  70         }
  71     }
  72 
  73     @Test
  74     public void test() throws Throwable {
  75 
  76         Method fooMethod = Foo.class.getDeclaredMethod("getName");
  77 
  78         ResolvedJavaMethod foo1 = metaAccess.lookupJavaMethod(fooMethod);
  79         ResolvedJavaMethod foo2 = metaAccess.lookupJavaMethod(fooMethod);
  80 


< prev index next >