# HG changeset patch # User Tom Rodriguez # Date 1465242063 25200 # Node ID 480da86e95e95532908897c3b5cc21c8c68741de # Parent b2ca0db145463b6332c0096eaa68fa03e80ee5e8 Add local workaround for redefinition of anonymous classes bug JDK-8145964 diff -r b2ca0db14546 -r 480da86e95e9 src/share/vm/prims/jvmtiEnv.cpp --- a/src/share/vm/prims/jvmtiEnv.cpp Wed May 25 20:42:33 2016 +0200 +++ b/src/share/vm/prims/jvmtiEnv.cpp Mon Jun 06 12:41:03 2016 -0700 @@ -226,6 +226,7 @@ NEW_RESOURCE_ARRAY(jvmtiClassDefinition, class_count); NULL_CHECK(class_definitions, JVMTI_ERROR_OUT_OF_MEMORY); + int redef_index = 0; for (index = 0; index < class_count; index++) { HandleMark hm(current_thread); @@ -253,6 +254,11 @@ return JVMTI_ERROR_UNMODIFIABLE_CLASS; } + if (klass->oop_is_instance() && InstanceKlass::cast(klass())->is_anonymous()) { + // return JVMTI_ERROR_UNMODIFIABLE_CLASS; + continue; + } + instanceKlassHandle ikh(current_thread, k_oop); if (ikh->get_cached_class_file_bytes() == NULL) { // Not cached, we need to reconstitute the class file from the @@ -267,19 +273,24 @@ return reconstituter.get_error(); } - class_definitions[index].class_byte_count = (jint)reconstituter.class_file_size(); - class_definitions[index].class_bytes = (unsigned char*) + class_definitions[redef_index].class_byte_count = (jint)reconstituter.class_file_size(); + class_definitions[redef_index].class_bytes = (unsigned char*) reconstituter.class_file_bytes(); } else { // it is cached, get it from the cache - class_definitions[index].class_byte_count = ikh->get_cached_class_file_len(); - class_definitions[index].class_bytes = ikh->get_cached_class_file_bytes(); + class_definitions[redef_index].class_byte_count = ikh->get_cached_class_file_len(); + class_definitions[redef_index].class_bytes = ikh->get_cached_class_file_bytes(); } - class_definitions[index].klass = jcls; + class_definitions[redef_index].klass = jcls; + redef_index++; } - VM_RedefineClasses op(class_count, class_definitions, jvmti_class_load_kind_retransform); - VMThread::execute(&op); - return (op.check_error()); + if (redef_index > 0) { + VM_RedefineClasses op(redef_index, class_definitions, jvmti_class_load_kind_retransform); + VMThread::execute(&op); + return (op.check_error()); + } else { + return JVMTI_ERROR_NONE; + } } /* end RetransformClasses */