mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
6653858: dynamic languages need to be able to load anonymous classes
Low-level privileged sun.misc.Unsafe.defineAnonymousClass Reviewed-by: kvn
This commit is contained in:
parent
015a08b3e8
commit
849e0ffb04
19 changed files with 607 additions and 37 deletions
|
@ -937,6 +937,8 @@ klassOop SystemDictionary::parse_stream(symbolHandle class_name,
|
|||
Handle class_loader,
|
||||
Handle protection_domain,
|
||||
ClassFileStream* st,
|
||||
KlassHandle host_klass,
|
||||
GrowableArray<Handle>* cp_patches,
|
||||
TRAPS) {
|
||||
symbolHandle parsed_name;
|
||||
|
||||
|
@ -953,10 +955,10 @@ klassOop SystemDictionary::parse_stream(symbolHandle class_name,
|
|||
instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name,
|
||||
class_loader,
|
||||
protection_domain,
|
||||
cp_patches,
|
||||
parsed_name,
|
||||
THREAD);
|
||||
|
||||
|
||||
// We don't redefine the class, so we just need to clean up whether there
|
||||
// was an error or not (don't want to modify any system dictionary
|
||||
// data structures).
|
||||
|
@ -973,6 +975,30 @@ klassOop SystemDictionary::parse_stream(symbolHandle class_name,
|
|||
}
|
||||
}
|
||||
|
||||
if (host_klass.not_null() && k.not_null()) {
|
||||
assert(AnonymousClasses, "");
|
||||
// If it's anonymous, initialize it now, since nobody else will.
|
||||
k->set_host_klass(host_klass());
|
||||
|
||||
{
|
||||
MutexLocker mu_r(Compile_lock, THREAD);
|
||||
|
||||
// Add to class hierarchy, initialize vtables, and do possible
|
||||
// deoptimizations.
|
||||
add_to_hierarchy(k, CHECK_NULL); // No exception, but can block
|
||||
|
||||
// But, do not add to system dictionary.
|
||||
}
|
||||
|
||||
k->eager_initialize(THREAD);
|
||||
|
||||
// notify jvmti
|
||||
if (JvmtiExport::should_post_class_load()) {
|
||||
assert(THREAD->is_Java_thread(), "thread->is_Java_thread()");
|
||||
JvmtiExport::post_class_load((JavaThread *) THREAD, k());
|
||||
}
|
||||
}
|
||||
|
||||
return k();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue