844 845 u1* class_bytes = NEW_C_HEAP_ARRAY(u1, length, mtInternal); 846 if (class_bytes == NULL) { 847 THROW_0(vmSymbols::java_lang_OutOfMemoryError()); 848 } 849 850 // caller responsible to free it: 851 *temp_alloc = class_bytes; 852 853 jbyte* array_base = typeArrayOop(JNIHandles::resolve_non_null(data))->byte_at_addr(0); 854 Copy::conjoint_jbytes(array_base, class_bytes, length); 855 856 objArrayHandle cp_patches_h; 857 if (cp_patches_jh != NULL) { 858 oop p = JNIHandles::resolve_non_null(cp_patches_jh); 859 assert(p->is_objArray(), "cp_patches must be an object[]"); 860 cp_patches_h = objArrayHandle(THREAD, (objArrayOop)p); 861 } 862 863 const Klass* host_klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(host_class)); 864 // Primitive types have NULL Klass* fields in their java.lang.Class instances. 865 if (host_klass == NULL) { 866 THROW_0(vmSymbols::java_lang_IllegalArgumentException()); 867 } 868 869 const char* host_source = host_klass->external_name(); 870 Handle host_loader(THREAD, host_klass->class_loader()); 871 Handle host_domain(THREAD, host_klass->protection_domain()); 872 873 GrowableArray<Handle>* cp_patches = NULL; 874 875 if (cp_patches_h.not_null()) { 876 int alen = cp_patches_h->length(); 877 878 for (int i = alen-1; i >= 0; i--) { 879 oop p = cp_patches_h->obj_at(i); 880 if (p != NULL) { 881 Handle patch(THREAD, p); 882 883 if (cp_patches == NULL) { | 844 845 u1* class_bytes = NEW_C_HEAP_ARRAY(u1, length, mtInternal); 846 if (class_bytes == NULL) { 847 THROW_0(vmSymbols::java_lang_OutOfMemoryError()); 848 } 849 850 // caller responsible to free it: 851 *temp_alloc = class_bytes; 852 853 jbyte* array_base = typeArrayOop(JNIHandles::resolve_non_null(data))->byte_at_addr(0); 854 Copy::conjoint_jbytes(array_base, class_bytes, length); 855 856 objArrayHandle cp_patches_h; 857 if (cp_patches_jh != NULL) { 858 oop p = JNIHandles::resolve_non_null(cp_patches_jh); 859 assert(p->is_objArray(), "cp_patches must be an object[]"); 860 cp_patches_h = objArrayHandle(THREAD, (objArrayOop)p); 861 } 862 863 const Klass* host_klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(host_class)); 864 865 // Make sure it's the real host class, not another anonymous class. 866 while (host_klass != NULL && host_klass->is_instance_klass() && 867 InstanceKlass::cast(host_klass)->is_anonymous()) { 868 host_klass = InstanceKlass::cast(host_klass)->host_klass(); 869 } 870 871 // Primitive types have NULL Klass* fields in their java.lang.Class instances. 872 if (host_klass == NULL) { 873 THROW_0(vmSymbols::java_lang_IllegalArgumentException()); 874 } 875 876 const char* host_source = host_klass->external_name(); 877 Handle host_loader(THREAD, host_klass->class_loader()); 878 Handle host_domain(THREAD, host_klass->protection_domain()); 879 880 GrowableArray<Handle>* cp_patches = NULL; 881 882 if (cp_patches_h.not_null()) { 883 int alen = cp_patches_h->length(); 884 885 for (int i = alen-1; i >= 0; i--) { 886 oop p = cp_patches_h->obj_at(i); 887 if (p != NULL) { 888 Handle patch(THREAD, p); 889 890 if (cp_patches == NULL) { |