58 oop SystemDictionary::java_system_loader() { |
58 oop SystemDictionary::java_system_loader() { |
59 return _java_system_loader; |
59 return _java_system_loader; |
60 } |
60 } |
61 |
61 |
62 void SystemDictionary::compute_java_system_loader(TRAPS) { |
62 void SystemDictionary::compute_java_system_loader(TRAPS) { |
63 KlassHandle system_klass(THREAD, WK_KLASS(classloader_klass)); |
63 KlassHandle system_klass(THREAD, WK_KLASS(ClassLoader_klass)); |
64 JavaValue result(T_OBJECT); |
64 JavaValue result(T_OBJECT); |
65 JavaCalls::call_static(&result, |
65 JavaCalls::call_static(&result, |
66 KlassHandle(THREAD, WK_KLASS(classloader_klass)), |
66 KlassHandle(THREAD, WK_KLASS(ClassLoader_klass)), |
67 vmSymbolHandles::getSystemClassLoader_name(), |
67 vmSymbolHandles::getSystemClassLoader_name(), |
68 vmSymbolHandles::void_classloader_signature(), |
68 vmSymbolHandles::void_classloader_signature(), |
69 CHECK); |
69 CHECK); |
70 |
70 |
71 _java_system_loader = (oop)result.get_jobject(); |
71 _java_system_loader = (oop)result.get_jobject(); |
126 if (HAS_PENDING_EXCEPTION) { |
126 if (HAS_PENDING_EXCEPTION) { |
127 // If we have a pending exception we forward it to the caller, unless throw_error is true, |
127 // If we have a pending exception we forward it to the caller, unless throw_error is true, |
128 // in which case we have to check whether the pending exception is a ClassNotFoundException, |
128 // in which case we have to check whether the pending exception is a ClassNotFoundException, |
129 // and if so convert it to a NoClassDefFoundError |
129 // and if so convert it to a NoClassDefFoundError |
130 // And chain the original ClassNotFoundException |
130 // And chain the original ClassNotFoundException |
131 if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass())) { |
131 if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) { |
132 ResourceMark rm(THREAD); |
132 ResourceMark rm(THREAD); |
133 assert(klass_h() == NULL, "Should not have result with exception pending"); |
133 assert(klass_h() == NULL, "Should not have result with exception pending"); |
134 Handle e(THREAD, PENDING_EXCEPTION); |
134 Handle e(THREAD, PENDING_EXCEPTION); |
135 CLEAR_PENDING_EXCEPTION; |
135 CLEAR_PENDING_EXCEPTION; |
136 THROW_MSG_CAUSE_0(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); |
136 THROW_MSG_CAUSE_0(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); |
357 tty->print(" - loading: "); klass()->print_value_on(tty); tty->cr(); |
357 tty->print(" - loading: "); klass()->print_value_on(tty); tty->cr(); |
358 } |
358 } |
359 |
359 |
360 assert(class_loader() != NULL, "should not have non-null protection domain for null classloader"); |
360 assert(class_loader() != NULL, "should not have non-null protection domain for null classloader"); |
361 |
361 |
362 KlassHandle system_loader(THREAD, SystemDictionary::classloader_klass()); |
362 KlassHandle system_loader(THREAD, SystemDictionary::ClassLoader_klass()); |
363 JavaCalls::call_special(&result, |
363 JavaCalls::call_special(&result, |
364 class_loader, |
364 class_loader, |
365 system_loader, |
365 system_loader, |
366 vmSymbolHandles::checkPackageAccess_name(), |
366 vmSymbolHandles::checkPackageAccess_name(), |
367 vmSymbolHandles::class_protectiondomain_signature(), |
367 vmSymbolHandles::class_protectiondomain_signature(), |
741 // Should not get here for classloaders that support parallelism |
741 // Should not get here for classloaders that support parallelism |
742 // with the new cleaner mechanism, even with AllowParallelDefineClass |
742 // with the new cleaner mechanism, even with AllowParallelDefineClass |
743 // Bootstrap goes through here to allow for an extra guarantee check |
743 // Bootstrap goes through here to allow for an extra guarantee check |
744 if (UnsyncloadClass || (class_loader.is_null())) { |
744 if (UnsyncloadClass || (class_loader.is_null())) { |
745 if (k.is_null() && HAS_PENDING_EXCEPTION |
745 if (k.is_null() && HAS_PENDING_EXCEPTION |
746 && PENDING_EXCEPTION->is_a(SystemDictionary::linkageError_klass())) { |
746 && PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { |
747 MutexLocker mu(SystemDictionary_lock, THREAD); |
747 MutexLocker mu(SystemDictionary_lock, THREAD); |
748 klassOop check = find_class(d_index, d_hash, name, class_loader); |
748 klassOop check = find_class(d_index, d_hash, name, class_loader); |
749 if (check != NULL) { |
749 if (check != NULL) { |
750 // Klass is already loaded, so just use it |
750 // Klass is already loaded, so just use it |
751 k = instanceKlassHandle(THREAD, check); |
751 k = instanceKlassHandle(THREAD, check); |
1365 // Translate to external class name format, i.e., convert '/' chars to '.' |
1365 // Translate to external class name format, i.e., convert '/' chars to '.' |
1366 Handle string = java_lang_String::externalize_classname(s, CHECK_(nh)); |
1366 Handle string = java_lang_String::externalize_classname(s, CHECK_(nh)); |
1367 |
1367 |
1368 JavaValue result(T_OBJECT); |
1368 JavaValue result(T_OBJECT); |
1369 |
1369 |
1370 KlassHandle spec_klass (THREAD, SystemDictionary::classloader_klass()); |
1370 KlassHandle spec_klass (THREAD, SystemDictionary::ClassLoader_klass()); |
1371 |
1371 |
1372 // Call public unsynchronized loadClass(String) directly for all class loaders |
1372 // Call public unsynchronized loadClass(String) directly for all class loaders |
1373 // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will |
1373 // for parallelCapable class loaders. JDK >=7, loadClass(String, boolean) will |
1374 // acquire a class-name based lock rather than the class loader object lock. |
1374 // acquire a class-name based lock rather than the class loader object lock. |
1375 // JDK < 7 already acquire the class loader lock in loadClass(String, boolean), |
1375 // JDK < 7 already acquire the class loader lock in loadClass(String, boolean), |
1942 start_id = limit_id; |
1942 start_id = limit_id; |
1943 } |
1943 } |
1944 |
1944 |
1945 |
1945 |
1946 void SystemDictionary::initialize_preloaded_classes(TRAPS) { |
1946 void SystemDictionary::initialize_preloaded_classes(TRAPS) { |
1947 assert(WK_KLASS(object_klass) == NULL, "preloaded classes should only be initialized once"); |
1947 assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once"); |
1948 // Preload commonly used klasses |
1948 // Preload commonly used klasses |
1949 WKID scan = FIRST_WKID; |
1949 WKID scan = FIRST_WKID; |
1950 // first do Object, String, Class |
1950 // first do Object, String, Class |
1951 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(class_klass), scan, CHECK); |
1951 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK); |
1952 |
1952 |
1953 debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(class_klass))); |
1953 debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(Class_klass))); |
1954 |
1954 |
1955 // Fixup mirrors for classes loaded before java.lang.Class. |
1955 // Fixup mirrors for classes loaded before java.lang.Class. |
1956 // These calls iterate over the objects currently in the perm gen |
1956 // These calls iterate over the objects currently in the perm gen |
1957 // so calling them at this point is matters (not before when there |
1957 // so calling them at this point is matters (not before when there |
1958 // are fewer objects and not later after there are more objects |
1958 // are fewer objects and not later after there are more objects |
1959 // in the perm gen. |
1959 // in the perm gen. |
1960 Universe::initialize_basic_type_mirrors(CHECK); |
1960 Universe::initialize_basic_type_mirrors(CHECK); |
1961 Universe::fixup_mirrors(CHECK); |
1961 Universe::fixup_mirrors(CHECK); |
1962 |
1962 |
1963 // do a bunch more: |
1963 // do a bunch more: |
1964 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(reference_klass), scan, CHECK); |
1964 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK); |
1965 |
1965 |
1966 // Preload ref klasses and set reference types |
1966 // Preload ref klasses and set reference types |
1967 instanceKlass::cast(WK_KLASS(reference_klass))->set_reference_type(REF_OTHER); |
1967 instanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER); |
1968 instanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(reference_klass)); |
1968 instanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass)); |
1969 |
1969 |
1970 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(phantom_reference_klass), scan, CHECK); |
1970 initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK); |
1971 instanceKlass::cast(WK_KLASS(soft_reference_klass))->set_reference_type(REF_SOFT); |
1971 instanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT); |
1972 instanceKlass::cast(WK_KLASS(weak_reference_klass))->set_reference_type(REF_WEAK); |
1972 instanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK); |
1973 instanceKlass::cast(WK_KLASS(final_reference_klass))->set_reference_type(REF_FINAL); |
1973 instanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL); |
1974 instanceKlass::cast(WK_KLASS(phantom_reference_klass))->set_reference_type(REF_PHANTOM); |
1974 instanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM); |
1975 |
1975 |
1976 WKID meth_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); |
1976 WKID meth_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass); |
1977 WKID meth_group_end = WK_KLASS_ENUM_NAME(WrongMethodTypeException_klass); |
1977 WKID meth_group_end = WK_KLASS_ENUM_NAME(WrongMethodTypeException_klass); |
1978 initialize_wk_klasses_until(meth_group_start, scan, CHECK); |
1978 initialize_wk_klasses_until(meth_group_start, scan, CHECK); |
1979 if (EnableMethodHandles) { |
1979 if (EnableMethodHandles) { |
1994 scan = WKID(indy_group_end+1); |
1994 scan = WKID(indy_group_end+1); |
1995 } |
1995 } |
1996 |
1996 |
1997 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK); |
1997 initialize_wk_klasses_until(WKID_LIMIT, scan, CHECK); |
1998 |
1998 |
1999 _box_klasses[T_BOOLEAN] = WK_KLASS(boolean_klass); |
1999 _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass); |
2000 _box_klasses[T_CHAR] = WK_KLASS(char_klass); |
2000 _box_klasses[T_CHAR] = WK_KLASS(Character_klass); |
2001 _box_klasses[T_FLOAT] = WK_KLASS(float_klass); |
2001 _box_klasses[T_FLOAT] = WK_KLASS(Float_klass); |
2002 _box_klasses[T_DOUBLE] = WK_KLASS(double_klass); |
2002 _box_klasses[T_DOUBLE] = WK_KLASS(Double_klass); |
2003 _box_klasses[T_BYTE] = WK_KLASS(byte_klass); |
2003 _box_klasses[T_BYTE] = WK_KLASS(Byte_klass); |
2004 _box_klasses[T_SHORT] = WK_KLASS(short_klass); |
2004 _box_klasses[T_SHORT] = WK_KLASS(Short_klass); |
2005 _box_klasses[T_INT] = WK_KLASS(int_klass); |
2005 _box_klasses[T_INT] = WK_KLASS(Integer_klass); |
2006 _box_klasses[T_LONG] = WK_KLASS(long_klass); |
2006 _box_klasses[T_LONG] = WK_KLASS(Long_klass); |
2007 //_box_klasses[T_OBJECT] = WK_KLASS(object_klass); |
2007 //_box_klasses[T_OBJECT] = WK_KLASS(object_klass); |
2008 //_box_klasses[T_ARRAY] = WK_KLASS(object_klass); |
2008 //_box_klasses[T_ARRAY] = WK_KLASS(object_klass); |
2009 |
2009 |
2010 #ifdef KERNEL |
2010 #ifdef KERNEL |
2011 if (sun_jkernel_DownloadManager_klass() == NULL) { |
2011 if (sun_jkernel_DownloadManager_klass() == NULL) { |
2012 warning("Cannot find sun/jkernel/DownloadManager"); |
2012 warning("Cannot find sun/jkernel/DownloadManager"); |
2013 } |
2013 } |
2014 #endif // KERNEL |
2014 #endif // KERNEL |
2015 |
2015 |
2016 { // Compute whether we should use loadClass or loadClassInternal when loading classes. |
2016 { // Compute whether we should use loadClass or loadClassInternal when loading classes. |
2017 methodOop method = instanceKlass::cast(classloader_klass())->find_method(vmSymbols::loadClassInternal_name(), vmSymbols::string_class_signature()); |
2017 methodOop method = instanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::loadClassInternal_name(), vmSymbols::string_class_signature()); |
2018 _has_loadClassInternal = (method != NULL); |
2018 _has_loadClassInternal = (method != NULL); |
2019 } |
2019 } |
2020 { // Compute whether we should use checkPackageAccess or NOT |
2020 { // Compute whether we should use checkPackageAccess or NOT |
2021 methodOop method = instanceKlass::cast(classloader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature()); |
2021 methodOop method = instanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature()); |
2022 _has_checkPackageAccess = (method != NULL); |
2022 _has_checkPackageAccess = (method != NULL); |
2023 } |
2023 } |
2024 } |
2024 } |
2025 |
2025 |
2026 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer). |
2026 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer). |
2372 Handle class_loader, |
2372 Handle class_loader, |
2373 Handle protection_domain, |
2373 Handle protection_domain, |
2374 TRAPS) { |
2374 TRAPS) { |
2375 Handle empty; |
2375 Handle empty; |
2376 int npts = ArgumentCount(signature()).size(); |
2376 int npts = ArgumentCount(signature()).size(); |
2377 objArrayHandle pts = oopFactory::new_objArray(SystemDictionary::class_klass(), npts, CHECK_(empty)); |
2377 objArrayHandle pts = oopFactory::new_objArray(SystemDictionary::Class_klass(), npts, CHECK_(empty)); |
2378 int arg = 0; |
2378 int arg = 0; |
2379 Handle rt; // the return type from the signature |
2379 Handle rt; // the return type from the signature |
2380 for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) { |
2380 for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) { |
2381 oop mirror; |
2381 oop mirror; |
2382 if (!ss.is_object()) { |
2382 if (!ss.is_object()) { |