From 7c95fd0c4adf26f0cbb1d1527b4e86d0e25fcecf Mon Sep 17 00:00:00 2001 From: sspitsyn Date: Thu, 9 Apr 2015 17:04:24 -0700 Subject: [PATCH] 8066679: jvmtiRedefineClasses.cpp assert cache ptrs must match Summary: remove the assert and deallocate cashed class file bytes that are in collision Reviewed-by: coleenp, dcubed --- src/share/vm/prims/jvmtiRedefineClasses.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/share/vm/prims/jvmtiRedefineClasses.cpp b/src/share/vm/prims/jvmtiRedefineClasses.cpp index cad071f68..ba702135c 100644 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -3979,14 +3979,13 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, // the_class doesn't have a cache yet so copy it the_class->set_cached_class_file(scratch_class->get_cached_class_file()); } -#ifndef PRODUCT - else { - assert(the_class->get_cached_class_file_bytes() == - scratch_class->get_cached_class_file_bytes(), "cache ptrs must match"); - assert(the_class->get_cached_class_file_len() == - scratch_class->get_cached_class_file_len(), "cache lens must match"); + else if (scratch_class->get_cached_class_file_bytes() != + the_class->get_cached_class_file_bytes()) { + // The same class can be present twice in the scratch classes list or there + // are multiple concurrent RetransformClasses calls on different threads. + // In such cases we have to deallocate scratch_class cached_class_file_bytes. + os::free(scratch_class->get_cached_class_file_bytes()); } -#endif // NULL out in scratch class to not delete twice. The class to be redefined // always owns these bytes. -- GitLab