Tue, 28 Jul 2015 23:01:47 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions | |
make/hotspot_version | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Thu Jul 23 10:56:10 2015 -0700 1.2 +++ b/.hgtags Tue Jul 28 23:01:47 2015 -0700 1.3 @@ -713,6 +713,7 @@ 1.4 e0d75c284bd1c09fd7d9ef09627d8a99b88d468d jdk8u60-b21 1.5 ff8fdeb2fb6d6f3348597339c53412f8f6202c3f hs25.60-b22 1.6 878cb0df27c22c6b1e9f4add1eb3da3edc8ab51d jdk8u60-b22 1.7 +ad04e0ef0f85625b68ed18e949c75399b8d9b99b hs25.66-b01 1.8 0e4094950cd312c8f95c7f37336606323fe049fe jdk8u60-b23 1.9 d89ceecf1bad55e1aee2932b8895d60fc64c15db hs25.60-b23 1.10 fb157d537278cda4150740e27bb57cd8694e15bf jdk8u60-b24 1.11 @@ -728,3 +729,6 @@ 1.12 3070e116da4cfebc2ceb0df8f40faeefd38a6d4a jdk8u65-b06 1.13 878cb0df27c22c6b1e9f4add1eb3da3edc8ab51d jdk8u66-b00 1.14 777a354cada52b831a32bfc5362ad7cedfde4450 jdk8u66-b01 1.15 +0366ad2644f58ec88af9cb2ea8c23a02559fb2d1 hs25.66-b02 1.16 +47110b037994f9006c22abcb12569fcafad84edb hs25.66-b03 1.17 +ae5624088d86abe8e7981dbb893c1b6da5140a1c jdk8u66-b02
2.1 --- a/make/defs.make Thu Jul 23 10:56:10 2015 -0700 2.2 +++ b/make/defs.make Tue Jul 28 23:01:47 2015 -0700 2.3 @@ -116,6 +116,18 @@ 2.4 # hotspot version definitions 2.5 include $(GAMMADIR)/make/hotspot_version 2.6 2.7 +# When config parameter --with-update-version is defined, 2.8 +# Hotspot minor version should be set to that 2.9 +ifneq ($(JDK_UPDATE_VERSION),) 2.10 + HS_MINOR_VER=$(JDK_UPDATE_VERSION) 2.11 +endif 2.12 + 2.13 +# When config parameter --with-build-number is defined, 2.14 +# Hotspot build number should be set to that 2.15 +ifneq ($(JDK_BUILD_NUMBER),) 2.16 + HS_BUILD_NUMBER=$(subst b,,$(JDK_BUILD_NUMBER)) 2.17 +endif 2.18 + 2.19 # Java versions needed 2.20 ifeq ($(PREVIOUS_JDK_VERSION),) 2.21 PREVIOUS_JDK_VERSION=$(JDK_PREVIOUS_VERSION)
3.1 --- a/make/hotspot_version Thu Jul 23 10:56:10 2015 -0700 3.2 +++ b/make/hotspot_version Tue Jul 28 23:01:47 2015 -0700 3.3 @@ -35,7 +35,7 @@ 3.4 3.5 HS_MAJOR_VER=25 3.6 HS_MINOR_VER=66 3.7 -HS_BUILD_NUMBER=01 3.8 +HS_BUILD_NUMBER=00 3.9 3.10 JDK_MAJOR_VER=1 3.11 JDK_MINOR_VER=8
4.1 --- a/src/share/vm/classfile/classFileParser.cpp Thu Jul 23 10:56:10 2015 -0700 4.2 +++ b/src/share/vm/classfile/classFileParser.cpp Tue Jul 28 23:01:47 2015 -0700 4.3 @@ -4421,9 +4421,15 @@ 4.4 Method* m = k->lookup_method(vmSymbols::finalize_method_name(), 4.5 vmSymbols::void_method_signature()); 4.6 if (m != NULL && !m->is_empty_method()) { 4.7 - f = true; 4.8 + f = true; 4.9 } 4.10 - assert(f == k->has_finalizer(), "inconsistent has_finalizer"); 4.11 + 4.12 + // Spec doesn't prevent agent from redefinition of empty finalizer. 4.13 + // Despite the fact that it's generally bad idea and redefined finalizer 4.14 + // will not work as expected we shouldn't abort vm in this case 4.15 + if (!k->has_redefined_this_or_super()) { 4.16 + assert(f == k->has_finalizer(), "inconsistent has_finalizer"); 4.17 + } 4.18 #endif 4.19 4.20 // Check if this klass supports the java.lang.Cloneable interface
5.1 --- a/src/share/vm/oops/instanceKlass.cpp Thu Jul 23 10:56:10 2015 -0700 5.2 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Jul 28 23:01:47 2015 -0700 5.3 @@ -439,6 +439,9 @@ 5.4 if (!constants()->is_shared()) { 5.5 MetadataFactory::free_metadata(loader_data, constants()); 5.6 } 5.7 + // Delete any cached resolution errors for the constant pool 5.8 + SystemDictionary::delete_resolution_error(constants()); 5.9 + 5.10 set_constants(NULL); 5.11 } 5.12 5.13 @@ -1569,6 +1572,21 @@ 5.14 return NULL; 5.15 } 5.16 5.17 +#ifdef ASSERT 5.18 +// search through class hierarchy and return true if this class or 5.19 +// one of the superclasses was redefined 5.20 +bool InstanceKlass::has_redefined_this_or_super() const { 5.21 + const InstanceKlass* klass = this; 5.22 + while (klass != NULL) { 5.23 + if (klass->has_been_redefined()) { 5.24 + return true; 5.25 + } 5.26 + klass = InstanceKlass::cast(klass->super()); 5.27 + } 5.28 + return false; 5.29 +} 5.30 +#endif 5.31 + 5.32 // lookup a method in the default methods list then in all transitive interfaces 5.33 // Do NOT return private or static methods 5.34 Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
6.1 --- a/src/share/vm/oops/instanceKlass.hpp Thu Jul 23 10:56:10 2015 -0700 6.2 +++ b/src/share/vm/oops/instanceKlass.hpp Tue Jul 28 23:01:47 2015 -0700 6.3 @@ -808,6 +808,11 @@ 6.4 bool implements_interface(Klass* k) const; 6.5 bool is_same_or_direct_interface(Klass* k) const; 6.6 6.7 +#ifdef ASSERT 6.8 + // check whether this class or one of its superclasses was redefined 6.9 + bool has_redefined_this_or_super() const; 6.10 +#endif 6.11 + 6.12 // Access to the implementor of an interface. 6.13 Klass* implementor() const 6.14 { 6.15 @@ -865,8 +870,8 @@ 6.16 6.17 // Casting from Klass* 6.18 static InstanceKlass* cast(Klass* k) { 6.19 - assert(k->is_klass(), "must be"); 6.20 - assert(k->oop_is_instance(), "cast to InstanceKlass"); 6.21 + assert(k == NULL || k->is_klass(), "must be"); 6.22 + assert(k == NULL || k->oop_is_instance(), "cast to InstanceKlass"); 6.23 return (InstanceKlass*) k; 6.24 } 6.25
7.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp Thu Jul 23 10:56:10 2015 -0700 7.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp Tue Jul 28 23:01:47 2015 -0700 7.3 @@ -4071,9 +4071,6 @@ 7.4 mnt->adjust_method_entries(the_class(), &trace_name_printed); 7.5 } 7.6 7.7 - // Fix Resolution Error table also to remove old constant pools 7.8 - SystemDictionary::delete_resolution_error(old_constants); 7.9 - 7.10 if (the_class->oop_map_cache() != NULL) { 7.11 // Flush references to any obsolete methods from the oop map cache 7.12 // so that obsolete methods are not pinned.
8.1 --- a/src/share/vm/runtime/thread.cpp Thu Jul 23 10:56:10 2015 -0700 8.2 +++ b/src/share/vm/runtime/thread.cpp Tue Jul 28 23:01:47 2015 -0700 8.3 @@ -3307,6 +3307,9 @@ 8.4 8.5 extern void JDK_Version_init(); 8.6 8.7 + // Preinitialize version info. 8.8 + VM_Version::early_initialize(); 8.9 + 8.10 // Check version 8.11 if (!is_supported_jni_version(args->version)) return JNI_EVERSION; 8.12
9.1 --- a/src/share/vm/runtime/vm_version.hpp Thu Jul 23 10:56:10 2015 -0700 9.2 +++ b/src/share/vm/runtime/vm_version.hpp Tue Jul 28 23:01:47 2015 -0700 9.3 @@ -56,6 +56,13 @@ 9.4 public: 9.5 static void initialize(); 9.6 9.7 + // This allows for early initialization of VM_Version information 9.8 + // that may be needed later in the initialization sequence but before 9.9 + // full VM_Version initialization is possible. It can not depend on any 9.10 + // other part of the VM being initialized when called. Platforms that 9.11 + // need to specialize this define VM_Version::early_initialize(). 9.12 + static void early_initialize() { } 9.13 + 9.14 // Name 9.15 static const char* vm_name(); 9.16 // Vendor
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/runtime/RedefineFinalizer/RedefineFinalizer.java Tue Jul 28 23:01:47 2015 -0700 10.3 @@ -0,0 +1,64 @@ 10.4 +/* 10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 6904403 10.30 + * @summary Don't assert if we redefine finalize method 10.31 + * @library /testlibrary 10.32 + * @build RedefineClassHelper 10.33 + * @run main RedefineClassHelper 10.34 + * @run main/othervm -javaagent:redefineagent.jar RedefineFinalizer 10.35 + */ 10.36 + 10.37 +/* 10.38 + * Regression test for hitting: 10.39 + * 10.40 + * assert(f == k->has_finalizer()) failed: inconsistent has_finalizer 10.41 + * 10.42 + * when redefining finalizer method 10.43 + */ 10.44 +public class RedefineFinalizer { 10.45 + 10.46 + public static String newB = 10.47 + "class RedefineFinalizer$B {" + 10.48 + " protected void finalize() { " + 10.49 + " System.out.println(\"Finalizer called\");" + 10.50 + " }" + 10.51 + "}"; 10.52 + 10.53 + public static void main(String[] args) throws Exception { 10.54 + RedefineClassHelper.redefineClass(B.class, newB); 10.55 + 10.56 + A a = new A(); 10.57 + } 10.58 + 10.59 + static class A extends B { 10.60 + } 10.61 + 10.62 + static class B { 10.63 + protected void finalize() { 10.64 + // should be empty 10.65 + } 10.66 + } 10.67 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java Tue Jul 28 23:01:47 2015 -0700 11.3 @@ -0,0 +1,143 @@ 11.4 +/* 11.5 + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +/* 11.28 + * @test 11.29 + * @bug 8076110 11.30 + * @summary Redefine running methods that have cached resolution errors 11.31 + * @library /testlibrary 11.32 + * @modules java.instrument 11.33 + * java.base/jdk.internal.org.objectweb.asm 11.34 + * @build RedefineClassHelper 11.35 + * @run main RedefineClassHelper 11.36 + * @run main/othervm -javaagent:redefineagent.jar RedefineRunningMethodsWithResolutionErrors 11.37 + */ 11.38 + 11.39 +import jdk.internal.org.objectweb.asm.ClassWriter; 11.40 +import jdk.internal.org.objectweb.asm.Label; 11.41 +import jdk.internal.org.objectweb.asm.MethodVisitor; 11.42 +import jdk.internal.org.objectweb.asm.Opcodes; 11.43 + 11.44 +import java.lang.reflect.InvocationTargetException; 11.45 + 11.46 +public class RedefineRunningMethodsWithResolutionErrors extends ClassLoader implements Opcodes { 11.47 + 11.48 + @Override 11.49 + protected Class<?> findClass(String name) throws ClassNotFoundException { 11.50 + if (name.equals("C")) { 11.51 + byte[] b = loadC(false); 11.52 + return defineClass(name, b, 0, b.length); 11.53 + } else { 11.54 + return super.findClass(name); 11.55 + } 11.56 + } 11.57 + 11.58 + private static byte[] loadC(boolean redefine) { 11.59 + ClassWriter cw = new ClassWriter(0); 11.60 + 11.61 + cw.visit(52, ACC_SUPER | ACC_PUBLIC, "C", null, "java/lang/Object", null); 11.62 + { 11.63 + MethodVisitor mv; 11.64 + 11.65 + mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "m", "()V", null, null); 11.66 + mv.visitCode(); 11.67 + 11.68 + // First time we run we will: 11.69 + // 1) Cache resolution errors 11.70 + // 2) Redefine the class / method 11.71 + // 3) Try to read the resolution errors that were cached 11.72 + // 11.73 + // The redefined method will never run, throw error to be sure 11.74 + if (redefine) { 11.75 + createThrowRuntimeExceptionCode(mv, "The redefined method was called"); 11.76 + } else { 11.77 + createMethodBody(mv); 11.78 + } 11.79 + mv.visitMaxs(3, 0); 11.80 + mv.visitEnd(); 11.81 + } 11.82 + cw.visitEnd(); 11.83 + return cw.toByteArray(); 11.84 + } 11.85 + 11.86 + private static void createMethodBody(MethodVisitor mv) { 11.87 + Label classExists = new Label(); 11.88 + 11.89 + // Cache resolution errors 11.90 + createLoadNonExistentClassCode(mv, classExists); 11.91 + 11.92 + // Redefine our own class and method 11.93 + mv.visitMethodInsn(INVOKESTATIC, "RedefineRunningMethodsWithResolutionErrors", "redefine", "()V"); 11.94 + 11.95 + // Provoke the same error again to make sure the resolution error cache works 11.96 + createLoadNonExistentClassCode(mv, classExists); 11.97 + 11.98 + // Test passed 11.99 + mv.visitInsn(RETURN); 11.100 + 11.101 + mv.visitFrame(F_SAME, 0, new Object[0], 0, new Object[0]); 11.102 + mv.visitLabel(classExists); 11.103 + 11.104 + createThrowRuntimeExceptionCode(mv, "Loaded class that shouldn't exist (\"NonExistentClass\")"); 11.105 + } 11.106 + 11.107 + private static void createLoadNonExistentClassCode(MethodVisitor mv, Label classExists) { 11.108 + Label tryLoadBegin = new Label(); 11.109 + Label tryLoadEnd = new Label(); 11.110 + Label catchLoadBlock = new Label(); 11.111 + mv.visitTryCatchBlock(tryLoadBegin, tryLoadEnd, catchLoadBlock, "java/lang/NoClassDefFoundError"); 11.112 + 11.113 + // Try to load a class that does not exist to provoke resolution errors 11.114 + mv.visitLabel(tryLoadBegin); 11.115 + mv.visitMethodInsn(INVOKESTATIC, "NonExistentClass", "nonExistentMethod", "()V"); 11.116 + mv.visitLabel(tryLoadEnd); 11.117 + 11.118 + // No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen 11.119 + mv.visitJumpInsn(GOTO, classExists); 11.120 + 11.121 + mv.visitFrame(F_SAME1, 0, new Object[0], 1, new Object[] { "java/lang/NoClassDefFoundError" }); 11.122 + mv.visitLabel(catchLoadBlock); 11.123 + 11.124 + // Ignore the expected NoClassDefFoundError 11.125 + mv.visitInsn(POP); 11.126 + } 11.127 + 11.128 + private static void createThrowRuntimeExceptionCode(MethodVisitor mv, String msg) { 11.129 + mv.visitTypeInsn(NEW, "java/lang/RuntimeException"); 11.130 + mv.visitInsn(DUP); 11.131 + mv.visitLdcInsn(msg); 11.132 + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/RuntimeException", "<init>", "(Ljava/lang/String;)V"); 11.133 + mv.visitInsn(ATHROW); 11.134 + } 11.135 + 11.136 + private static Class<?> c; 11.137 + 11.138 + public static void redefine() throws Exception { 11.139 + RedefineClassHelper.redefineClass(c, loadC(true)); 11.140 + } 11.141 + 11.142 + public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { 11.143 + c = Class.forName("C", true, new RedefineRunningMethodsWithResolutionErrors()); 11.144 + c.getMethod("m").invoke(null); 11.145 + } 11.146 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/testlibrary/RedefineClassHelper.java Tue Jul 28 23:01:47 2015 -0700 12.3 @@ -0,0 +1,79 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +import java.io.PrintWriter; 12.28 +import java.lang.instrument.*; 12.29 +import com.oracle.java.testlibrary.*; 12.30 + 12.31 +/* 12.32 + * Helper class to write tests that redefine classes. 12.33 + * When main method is run, it will create a redefineagent.jar that can be used 12.34 + * with the -javaagent option to support redefining classes in jtreg tests. 12.35 + * 12.36 + * See sample test in test/testlibrary_tests/RedefineClassTest.java 12.37 + */ 12.38 +public class RedefineClassHelper { 12.39 + 12.40 + public static Instrumentation instrumentation; 12.41 + public static void premain(String agentArgs, Instrumentation inst) { 12.42 + instrumentation = inst; 12.43 + } 12.44 + 12.45 + /** 12.46 + * Redefine a class 12.47 + * 12.48 + * @param clazz Class to redefine 12.49 + * @param javacode String with the new java code for the class to be redefined 12.50 + */ 12.51 + public static void redefineClass(Class clazz, String javacode) throws Exception { 12.52 + byte[] bytecode = InMemoryJavaCompiler.compile(clazz.getName(), javacode); 12.53 + redefineClass(clazz, bytecode); 12.54 + } 12.55 + 12.56 + /** 12.57 + * Redefine a class 12.58 + * 12.59 + * @param clazz Class to redefine 12.60 + * @param bytecode byte[] with the new class 12.61 + */ 12.62 + public static void redefineClass(Class clazz, byte[] bytecode) throws Exception { 12.63 + instrumentation.redefineClasses(new ClassDefinition(clazz, bytecode)); 12.64 + } 12.65 + 12.66 + /** 12.67 + * Main method to be invoked before test to create the redefineagent.jar 12.68 + */ 12.69 + public static void main(String[] args) throws Exception { 12.70 + ClassFileInstaller.main("RedefineClassHelper"); 12.71 + 12.72 + PrintWriter pw = new PrintWriter("MANIFEST.MF"); 12.73 + pw.println("Premain-Class: RedefineClassHelper"); 12.74 + pw.println("Can-Redefine-Classes: true"); 12.75 + pw.close(); 12.76 + 12.77 + sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); 12.78 + if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineClassHelper.class" })) { 12.79 + throw new Exception("jar operation failed"); 12.80 + } 12.81 + } 12.82 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/testlibrary_tests/RedefineClassTest.java Tue Jul 28 23:01:47 2015 -0700 13.3 @@ -0,0 +1,54 @@ 13.4 +/* 13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + */ 13.26 + 13.27 +/* 13.28 + * @test 13.29 + * @library /testlibrary 13.30 + * @summary Proof of concept test for RedefineClassHelper 13.31 + * @build RedefineClassHelper 13.32 + * @run main RedefineClassHelper 13.33 + * @run main/othervm -javaagent:redefineagent.jar RedefineClassTest 13.34 + */ 13.35 + 13.36 +import static com.oracle.java.testlibrary.Asserts.*; 13.37 +import com.oracle.java.testlibrary.*; 13.38 + 13.39 +/* 13.40 + * Proof of concept test for the test utility class RedefineClassHelper 13.41 + */ 13.42 +public class RedefineClassTest { 13.43 + 13.44 + public static String newClass = "class RedefineClassTest$A { public int Method() { return 2; } }"; 13.45 + public static void main(String[] args) throws Exception { 13.46 + A a = new A(); 13.47 + assertTrue(a.Method() == 1); 13.48 + RedefineClassHelper.redefineClass(A.class, newClass); 13.49 + assertTrue(a.Method() == 2); 13.50 + } 13.51 + 13.52 + static class A { 13.53 + public int Method() { 13.54 + return 1; 13.55 + } 13.56 + } 13.57 +}