< prev index next >

src/hotspot/share/jvmci/jvmciEnv.cpp

Print this page




  81   if (resolved_klass->is_objArray_klass()) {
  82     // Find the element klass, if this is an array.
  83     resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass();
  84   }
  85   if (resolved_klass->is_instance_klass()) {
  86     Reflection::VerifyClassAccessResults result =
  87       Reflection::verify_class_access(accessing_klass, InstanceKlass::cast(resolved_klass), true);
  88     return result == Reflection::ACCESS_OK;
  89   }
  90   return true;
  91 }
  92 
  93 // ------------------------------------------------------------------
  94 Klass* JVMCIEnv::get_klass_by_name_impl(Klass* accessing_klass,
  95                                         const constantPoolHandle& cpool,
  96                                         Symbol* sym,
  97                                         bool require_local) {
  98   JVMCI_EXCEPTION_CONTEXT;
  99 
 100   // Now we need to check the SystemDictionary
 101   if (sym->byte_at(0) == 'L' &&
 102     sym->byte_at(sym->utf8_length()-1) == ';') {
 103     // This is a name from a signature.  Strip off the trimmings.
 104     // Call recursive to keep scope of strippedsym.
 105     TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
 106                     sym->utf8_length()-2,
 107                     CHECK_NULL);
 108     return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
 109   }
 110 
 111   Handle loader(THREAD, (oop)NULL);
 112   Handle domain(THREAD, (oop)NULL);
 113   if (accessing_klass != NULL) {
 114     loader = Handle(THREAD, accessing_klass->class_loader());
 115     domain = Handle(THREAD, accessing_klass->protection_domain());
 116   }
 117 
 118   Klass* found_klass = NULL;
 119   {
 120     ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
 121     MutexLocker ml(Compile_lock);
 122     if (!require_local) {
 123       found_klass = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_NULL);
 124     } else {
 125       found_klass = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_NULL);
 126     }
 127   }
 128 
 129   // If we fail to find an array klass, look again for its element type.
 130   // The element type may be available either locally or via constraints.
 131   // In either case, if we can find the element type in the system dictionary,
 132   // we must build an array type around it.  The CI requires array klasses
 133   // to be loaded if their element klasses are loaded, except when memory
 134   // is exhausted.
 135   if (sym->byte_at(0) == '[' &&
 136       (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
 137     // We have an unloaded array.
 138     // Build it on the fly if the element class exists.
 139     TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
 140                                                  sym->utf8_length()-1,
 141                                                  CHECK_NULL);
 142 
 143     // Get element Klass recursively.
 144     Klass* elem_klass =
 145       get_klass_by_name_impl(accessing_klass,
 146                              cpool,
 147                              elem_sym,
 148                              require_local);
 149     if (elem_klass != NULL) {
 150       // Now make an array for it
 151       return elem_klass->array_klass(CHECK_NULL);
 152     }
 153   }
 154 
 155   if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) {
 156     // Look inside the constant pool for pre-resolved class entries.




  81   if (resolved_klass->is_objArray_klass()) {
  82     // Find the element klass, if this is an array.
  83     resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass();
  84   }
  85   if (resolved_klass->is_instance_klass()) {
  86     Reflection::VerifyClassAccessResults result =
  87       Reflection::verify_class_access(accessing_klass, InstanceKlass::cast(resolved_klass), true);
  88     return result == Reflection::ACCESS_OK;
  89   }
  90   return true;
  91 }
  92 
  93 // ------------------------------------------------------------------
  94 Klass* JVMCIEnv::get_klass_by_name_impl(Klass* accessing_klass,
  95                                         const constantPoolHandle& cpool,
  96                                         Symbol* sym,
  97                                         bool require_local) {
  98   JVMCI_EXCEPTION_CONTEXT;
  99 
 100   // Now we need to check the SystemDictionary
 101   if (sym->char_at(0) == 'L' &&
 102     sym->char_at(sym->utf8_length()-1) == ';') {
 103     // This is a name from a signature.  Strip off the trimmings.
 104     // Call recursive to keep scope of strippedsym.
 105     TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
 106                     sym->utf8_length()-2,
 107                     CHECK_NULL);
 108     return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
 109   }
 110 
 111   Handle loader(THREAD, (oop)NULL);
 112   Handle domain(THREAD, (oop)NULL);
 113   if (accessing_klass != NULL) {
 114     loader = Handle(THREAD, accessing_klass->class_loader());
 115     domain = Handle(THREAD, accessing_klass->protection_domain());
 116   }
 117 
 118   Klass* found_klass = NULL;
 119   {
 120     ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
 121     MutexLocker ml(Compile_lock);
 122     if (!require_local) {
 123       found_klass = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_NULL);
 124     } else {
 125       found_klass = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_NULL);
 126     }
 127   }
 128 
 129   // If we fail to find an array klass, look again for its element type.
 130   // The element type may be available either locally or via constraints.
 131   // In either case, if we can find the element type in the system dictionary,
 132   // we must build an array type around it.  The CI requires array klasses
 133   // to be loaded if their element klasses are loaded, except when memory
 134   // is exhausted.
 135   if (sym->char_at(0) == '[' &&
 136       (sym->char_at(1) == '[' || sym->char_at(1) == 'L')) {
 137     // We have an unloaded array.
 138     // Build it on the fly if the element class exists.
 139     TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
 140                                                  sym->utf8_length()-1,
 141                                                  CHECK_NULL);
 142 
 143     // Get element Klass recursively.
 144     Klass* elem_klass =
 145       get_klass_by_name_impl(accessing_klass,
 146                              cpool,
 147                              elem_sym,
 148                              require_local);
 149     if (elem_klass != NULL) {
 150       // Now make an array for it
 151       return elem_klass->array_klass(CHECK_NULL);
 152     }
 153   }
 154 
 155   if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) {
 156     // Look inside the constant pool for pre-resolved class entries.


< prev index next >