< prev index next >

src/share/vm/classfile/systemDictionary.cpp

Print this page
rev 10979 : 8140594: Various minor code improvements (compiler)


1143                                          NULL, // cp_patches
1144                                          &parsed_name,
1145                                          THREAD);
1146   }
1147 
1148   const char* pkg = "java/";
1149   if (!HAS_PENDING_EXCEPTION &&
1150       !class_loader.is_null() &&
1151       !SystemDictionary::is_platform_class_loader(class_loader) &&
1152       parsed_name != NULL &&
1153       !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) {
1154     // It is illegal to define classes in the "java." package from
1155     // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader
1156     ResourceMark rm(THREAD);
1157     char* name = parsed_name->as_C_string();
1158     char* index = strrchr(name, '/');
1159     *index = '\0'; // chop to just the package name
1160     while ((index = strchr(name, '/')) != NULL) {
1161       *index = '.'; // replace '/' with '.' in package name
1162     }
1163     const char* fmt = "Prohibited package name: %s";
1164     size_t len = strlen(fmt) + strlen(name);
1165     char* message = NEW_RESOURCE_ARRAY(char, len);
1166     jio_snprintf(message, len, fmt, name);
1167     Exceptions::_throw_msg(THREAD_AND_LOCATION,
1168       vmSymbols::java_lang_SecurityException(), message);
1169   }
1170 
1171   if (!HAS_PENDING_EXCEPTION) {
1172     assert(parsed_name != NULL, "Sanity");
1173     assert(class_name == NULL || class_name == parsed_name, "name mismatch");
1174     // Verification prevents us from creating names with dots in them, this
1175     // asserts that that's the case.
1176     assert(is_internal_format(parsed_name),
1177            "external class name format used internally");
1178 
1179     // Add class just loaded
1180     // If a class loader supports parallel classloading handle parallel define requests
1181     // find_or_define_instance_class may return a different InstanceKlass
1182     if (is_parallelCapable(class_loader)) {
1183       k = find_or_define_instance_class(class_name, class_loader, k, THREAD);
1184     } else {
1185       define_instance_class(k, THREAD);
1186     }




1143                                          NULL, // cp_patches
1144                                          &parsed_name,
1145                                          THREAD);
1146   }
1147 
1148   const char* pkg = "java/";
1149   if (!HAS_PENDING_EXCEPTION &&
1150       !class_loader.is_null() &&
1151       !SystemDictionary::is_platform_class_loader(class_loader) &&
1152       parsed_name != NULL &&
1153       !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) {
1154     // It is illegal to define classes in the "java." package from
1155     // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader
1156     ResourceMark rm(THREAD);
1157     char* name = parsed_name->as_C_string();
1158     char* index = strrchr(name, '/');
1159     *index = '\0'; // chop to just the package name
1160     while ((index = strchr(name, '/')) != NULL) {
1161       *index = '.'; // replace '/' with '.' in package name
1162     }
1163     const char* msg_text = "Prohibited package name: ";
1164     size_t len = strlen(msg_text) + strlen(name) + 1;
1165     char* message = NEW_RESOURCE_ARRAY(char, len);
1166     jio_snprintf(message, len, "%s%s", msg_text, name);
1167     Exceptions::_throw_msg(THREAD_AND_LOCATION,
1168       vmSymbols::java_lang_SecurityException(), message);
1169   }
1170 
1171   if (!HAS_PENDING_EXCEPTION) {
1172     assert(parsed_name != NULL, "Sanity");
1173     assert(class_name == NULL || class_name == parsed_name, "name mismatch");
1174     // Verification prevents us from creating names with dots in them, this
1175     // asserts that that's the case.
1176     assert(is_internal_format(parsed_name),
1177            "external class name format used internally");
1178 
1179     // Add class just loaded
1180     // If a class loader supports parallel classloading handle parallel define requests
1181     // find_or_define_instance_class may return a different InstanceKlass
1182     if (is_parallelCapable(class_loader)) {
1183       k = find_or_define_instance_class(class_name, class_loader, k, THREAD);
1184     } else {
1185       define_instance_class(k, THREAD);
1186     }


< prev index next >