- java.lang.ClassLoader.loadClass(String)
- java.net.URLClassLoader.findClass(String)
- java.lang.ClassLoader.defineClass(String, ByteBuffer, ProtectionDomain)
- jdk/src/share/native/java/lang/ClassLoader.c
jclass Java_java_lang_ClassLoader_defineClass1() {
jclass result = JVM_DefineClassWithSource(env, utfName, loader, body, length, pd, utfSource);
return result;
}
- hotspot/src/share/vm/prims/jvm.cpp
JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source))
JVMWrapper2("JVM_DefineClassWithSource %s", name);
return jvm_define_class_common(env, name, loader, buf, len, pd, source, true, THREAD);
JVM_END
static jclass jvm_define_class_common() {
ClassFileStream st((u1 *) buf, len, (char *) source);
klassOop k = SystemDictionary::resolve_from_stream(class_name, class_loader, protection_domain, &st, verify != 0, CHECK_NULL);
return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
}
- hotspot/src/share/vm/classfile/systemDictionary.cpp
klassOop SystemDictionary::parse_stream() {
instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name, class_loader, protection_domain, host_klass, cp_patches, parsed_name, true, THREAD);
return k();
}
- hotspot/src/share/vm/classfile/classFileParser.cpp
instanceKlassHandle ClassFileParser::parseClassFile() {
u4 magic = cfs->get_u4_fast();
guarantee_property(magic == JAVA_CLASSFILE_MAGIC, "Incompatible magic value %u in class file %s", magic,
CHECK_(nullHandle));
u2 minor_version = cfs->get_u2_fast();
u2 major_version = cfs->get_u2_fast();
if (!is_supported_version(major_version, minor_version)) {
Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_UnsupportedClassVersionError(),
"%s : Unsupported major.minor version %u.%u", name->as_C_string(), major_version,
minor_version);
return nullHandle;
}
constantPoolHandle cp = parse_constant_pool(class_loader, CHECK_(nullHandle));
int cp_size = cp->length();
jint flags = cfs->get_u2_fast() & JVM_RECOGNIZED_CLASS_MODIFIERS;
u2 this_class_index = cfs->get_u2_fast();
Symbol *class_name = cp->unresolved_klass_at(this_class_index);
u2 super_class_index = cfs->get_u2_fast();
u2 itfs_len = cfs->get_u2_fast();
if (itfs_len == 0) {
local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name,
CHECK_(nullHandle));
}
u2 java_fields_count = 0;
typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
&java_fields_count, CHECK_(nullHandle));
objArrayHandle methods = parse_methods(class_loader, cp, access_flags.is_interface(), &promoted_flags,
&has_final_method, &methods_annotations_oop,
&methods_parameter_annotations_oop, &methods_default_annotations_oop,
CHECK_(nullHandle));
parse_classfile_attributes(class_loader, cp, &parsed_annotations, CHECK_(nullHandle));
int vtable_size = 0;
int itable_size = 0;
klassVtable::compute_vtable_size_and_num_mirandas(vtable_size, num_miranda_methods, super_klass(), methods(),
access_flags, class_loader, class_name, local_interfaces(),
CHECK_(nullHandle));
itable_size = access_flags.is_interface() ? 0 : klassItable::compute_itable_size(transitive_interfaces);
int instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size, static_field_size, total_oop_map_count,
access_flags, rt, host_klass, CHECK_(nullHandle));
instanceKlassHandle this_klass(THREAD, ik);
this_klass->set_class_loader(class_loader());
this_klass->set_nonstatic_field_size(nonstatic_field_size);
java_lang_Class::create_mirror(this_klass, class_loader, CHECK_(nullHandle));
return this_klass;
}
- java.lang.ClassLoader.loadClass(String)
- java.net.URLClassLoader.findClass(String)
- java.lang.ClassLoader.defineClass(String, ByteBuffer, ProtectionDomain)
- jdk/src/share/native/java/lang/ClassLoader.c
jclass Java_java_lang_ClassLoader_defineClass1() {
jclass result = JVM_DefineClassWithSource(env, utfName, loader, body, length, pd, utfSource);
return result;
}
- hotspot/src/share/vm/prims/jvm.cpp
JVM_ENTRY(jclass, JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source))
JVMWrapper2("JVM_DefineClassWithSource %s", name);
return jvm_define_class_common(env, name, loader, buf, len, pd, source, true, THREAD);
JVM_END
static jclass jvm_define_class_common() {
ClassFileStream st((u1 *) buf, len, (char *) source);
klassOop k = SystemDictionary::resolve_from_stream(class_name, class_loader, protection_domain, &st, verify != 0, CHECK_NULL);
return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
}
- hotspot/src/share/vm/classfile/systemDictionary.cpp
klassOop SystemDictionary::parse_stream() {
instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name, class_loader, protection_domain, host_klass, cp_patches, parsed_name, true, THREAD);
return k();
}
- hotspot/src/share/vm/classfile/classFileParser.cpp
instanceKlassHandle ClassFileParser::parseClassFile() {
u4 magic = cfs->get_u4_fast();
guarantee_property(magic == JAVA_CLASSFILE_MAGIC, "Incompatible magic value %u in class file %s", magic,
CHECK_(nullHandle));
u2 minor_version = cfs->get_u2_fast();
u2 major_version = cfs->get_u2_fast();
if (!is_supported_version(major_version, minor_version)) {
Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_UnsupportedClassVersionError(),
"%s : Unsupported major.minor version %u.%u", name->as_C_string(), major_version,
minor_version);
return nullHandle;
}
constantPoolHandle cp = parse_constant_pool(class_loader, CHECK_(nullHandle));
int cp_size = cp->length();
jint flags = cfs->get_u2_fast() & JVM_RECOGNIZED_CLASS_MODIFIERS;
u2 this_class_index = cfs->get_u2_fast();
Symbol *class_name = cp->unresolved_klass_at(this_class_index);
u2 super_class_index = cfs->get_u2_fast();
u2 itfs_len = cfs->get_u2_fast();
if (itfs_len == 0) {
local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name,
CHECK_(nullHandle));
}
u2 java_fields_count = 0;
typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
&java_fields_count, CHECK_(nullHandle));
objArrayHandle methods = parse_methods(class_loader, cp, access_flags.is_interface(), &promoted_flags,
&has_final_method, &methods_annotations_oop,
&methods_parameter_annotations_oop, &methods_default_annotations_oop,
CHECK_(nullHandle));
parse_classfile_attributes(class_loader, cp, &parsed_annotations, CHECK_(nullHandle));
int vtable_size = 0;
int itable_size = 0;
klassVtable::compute_vtable_size_and_num_mirandas(vtable_size, num_miranda_methods, super_klass(), methods(),
access_flags, class_loader, class_name, local_interfaces(),
CHECK_(nullHandle));
itable_size = access_flags.is_interface() ? 0 : klassItable::compute_itable_size(transitive_interfaces);
int instance_size = align_object_size(next_nonstatic_type_offset / wordSize);
klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size, static_field_size, total_oop_map_count,
access_flags, rt, host_klass, CHECK_(nullHandle));
instanceKlassHandle this_klass(THREAD, ik);
this_klass->set_class_loader(class_loader());
this_klass->set_nonstatic_field_size(nonstatic_field_size);
java_lang_Class::create_mirror(this_klass, class_loader, CHECK_(nullHandle));
return this_klass;
}