< prev index next >

src/hotspot/share/prims/unsafe.cpp

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com


 833   if (cp_patches_h.not_null()) {
 834     int alen = cp_patches_h->length();
 835 
 836     for (int i = alen-1; i >= 0; i--) {
 837       oop p = cp_patches_h->obj_at(i);
 838       if (p != NULL) {
 839         Handle patch(THREAD, p);
 840 
 841         if (cp_patches == NULL) {
 842           cp_patches = new GrowableArray<Handle>(i+1, i+1, Handle());
 843         }
 844 
 845         cp_patches->at_put(i, patch);
 846       }
 847     }
 848   }
 849 
 850   ClassFileStream st(class_bytes, class_bytes_length, host_source, ClassFileStream::verify);
 851 
 852   Symbol* no_class_name = NULL;









 853   Klass* anonk = SystemDictionary::parse_stream(no_class_name,
 854                                                 host_loader,
 855                                                 host_domain,
 856                                                 &st,
 857                                                 InstanceKlass::cast(host_klass),
 858                                                 cp_patches,
 859                                                 CHECK_NULL);
 860   if (anonk == NULL) {
 861     return NULL;
 862   }
 863 
 864   return InstanceKlass::cast(anonk);
 865 }
 866 
 867 UNSAFE_ENTRY(jclass, Unsafe_DefineAnonymousClass0(JNIEnv *env, jobject unsafe, jclass host_class, jbyteArray data, jobjectArray cp_patches_jh)) {
 868   ResourceMark rm(THREAD);
 869 
 870   jobject res_jh = NULL;
 871   u1* temp_alloc = NULL;
 872 
 873   InstanceKlass* anon_klass = Unsafe_DefineAnonymousClass_impl(env, host_class, data, cp_patches_jh, &temp_alloc, THREAD);
 874   if (anon_klass != NULL) {
 875     res_jh = JNIHandles::make_local(env, anon_klass->java_mirror());
 876   }
 877 
 878   // try/finally clause:




 833   if (cp_patches_h.not_null()) {
 834     int alen = cp_patches_h->length();
 835 
 836     for (int i = alen-1; i >= 0; i--) {
 837       oop p = cp_patches_h->obj_at(i);
 838       if (p != NULL) {
 839         Handle patch(THREAD, p);
 840 
 841         if (cp_patches == NULL) {
 842           cp_patches = new GrowableArray<Handle>(i+1, i+1, Handle());
 843         }
 844 
 845         cp_patches->at_put(i, patch);
 846       }
 847     }
 848   }
 849 
 850   ClassFileStream st(class_bytes, class_bytes_length, host_source, ClassFileStream::verify);
 851 
 852   Symbol* no_class_name = NULL;
 853   ClassLoadInfo cl_info(host_domain,
 854                         InstanceKlass::cast(host_klass),
 855                         cp_patches,
 856                         NULL,     // dynamic_nest_host
 857                         Handle(), // classData
 858                         false,    // is_hidden
 859                         false,    // is_strong_hidden
 860                         true);    // can_access_vm_annotations
 861 
 862   Klass* anonk = SystemDictionary::parse_stream(no_class_name,
 863                                                 host_loader,

 864                                                 &st,
 865                                                 cl_info,

 866                                                 CHECK_NULL);
 867   if (anonk == NULL) {
 868     return NULL;
 869   }
 870 
 871   return InstanceKlass::cast(anonk);
 872 }
 873 
 874 UNSAFE_ENTRY(jclass, Unsafe_DefineAnonymousClass0(JNIEnv *env, jobject unsafe, jclass host_class, jbyteArray data, jobjectArray cp_patches_jh)) {
 875   ResourceMark rm(THREAD);
 876 
 877   jobject res_jh = NULL;
 878   u1* temp_alloc = NULL;
 879 
 880   InstanceKlass* anon_klass = Unsafe_DefineAnonymousClass_impl(env, host_class, data, cp_patches_jh, &temp_alloc, THREAD);
 881   if (anon_klass != NULL) {
 882     res_jh = JNIHandles::make_local(env, anon_klass->java_mirror());
 883   }
 884 
 885   // try/finally clause:


< prev index next >