Skip to content

Commit 9f60a53

Browse files
committed
8337547: Add LoadableDescriptors to comments for class loading
Reviewed-by: fparain
1 parent 7afbf29 commit 9f60a53

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6018,7 +6018,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
60186018
_super_klass = vmClasses::Object_klass();
60196019
} else {
60206020
_super_klass = (const InstanceKlass*)
6021-
SystemDictionary::resolve_with_circularity_detection_or_fail(_class_name,
6021+
SystemDictionary::resolve_super_or_fail(_class_name,
60226022
super_class_name,
60236023
loader,
60246024
true,
@@ -6090,7 +6090,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
60906090
"Bad interface name in class file %s", CHECK);
60916091

60926092
// Call resolve on the interface class name with class circularity checking
6093-
interf = SystemDictionary::resolve_with_circularity_detection_or_fail(
6093+
interf = SystemDictionary::resolve_super_or_fail(
60946094
_class_name,
60956095
unresolved_klass,
60966096
Handle(THREAD, _loader_data->class_loader()),
@@ -6169,10 +6169,10 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
61696169
log_info(class, preload)("Preloading of class %s during loading of class %s. "
61706170
"Cause: a null-free non-static field is declared with this type",
61716171
s->as_C_string(), _class_name->as_C_string());
6172-
InstanceKlass* klass = SystemDictionary::resolve_with_circularity_detection_or_fail(_class_name, s,
6173-
Handle(THREAD,
6174-
_loader_data->class_loader()),
6175-
false, THREAD);
6172+
InstanceKlass* klass = SystemDictionary::resolve_with_circularity_detection(_class_name, s,
6173+
Handle(THREAD,
6174+
_loader_data->class_loader()),
6175+
false, THREAD);
61766176
if (HAS_PENDING_EXCEPTION) {
61776177
log_warning(class, preload)("Preloading of class %s during loading of class %s "
61786178
"(cause: null-free non-static field) failed: %s",
@@ -6196,9 +6196,9 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st
61966196
"Cause: field type in LoadableDescriptors attribute",
61976197
name->as_C_string(), _class_name->as_C_string());
61986198
oop loader = loader_data()->class_loader();
6199-
Klass* klass = SystemDictionary::resolve_with_circularity_detection_or_fail(_class_name, name,
6200-
Handle(THREAD, loader),
6201-
false, THREAD);
6199+
Klass* klass = SystemDictionary::resolve_super_or_fail(_class_name, name,
6200+
Handle(THREAD, loader),
6201+
false, THREAD);
62026202
if (klass != nullptr) {
62036203
if (klass->is_inline_klass()) {
62046204
_inline_layout_info_array->adr_at(fieldinfo.index())->set_klass(InlineKlass::cast(klass));

src/hotspot/share/classfile/placeholders.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static InternalPlaceholderTable* _placeholders;
6161
// For DEFINE_CLASS, the head of the queue owns the
6262
// define token and the rest of the threads wait to return the
6363
// result the first thread gets.
64-
// For INLINE_FIELD, set when loading inline type fields for
65-
// class circularity checking.
64+
// For DETECT_CIRCULARITY, set when loading super class, interfaces, or inline type
65+
// fields for class circularity checking.
6666
class SeenThread: public CHeapObj<mtInternal> {
6767
private:
6868
JavaThread* _thread;

src/hotspot/share/classfile/placeholders.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,6 @@ class PlaceholderTable : public AllStatic {
4747
// on a class/classloader basis
4848
// so the head of that queue owns the token
4949
// and the rest of the threads return the result the first thread gets
50-
// VALUE_OBJECT_FIELD: needed to check for inline type fields circularity
5150
enum classloadAction {
5251
LOAD_INSTANCE = 1, // calling load_instance_class
5352
DETECT_CIRCULARITY = 2, // loading while detecting class circularity

src/hotspot/share/classfile/systemDictionary.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader
374374
assert(class_name != nullptr && !Signature::is_array(class_name), "must be");
375375
if (Signature::has_envelope(class_name)) {
376376
ResourceMark rm(THREAD);
377-
// Ignore wrapping L and ; (and Q and ; for value types).
377+
// Ignore wrapping L and ;.
378378
TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
379379
class_name->utf8_length() - 2);
380380
return resolve_instance_class_or_null(name, class_loader, THREAD);
@@ -422,7 +422,8 @@ static inline void log_circularity_error(Symbol* name, PlaceholderEntry* probe)
422422
}
423423

424424
// Must be called for any superclass or superinterface resolution
425-
// during class definition to allow class circularity checking
425+
// during class definition, or may be called for inline field layout processing
426+
// to detect class circularity errors.
426427
// superinterface callers:
427428
// parse_interfaces - from defineClass
428429
// superclass callers:
@@ -435,10 +436,12 @@ static inline void log_circularity_error(Symbol* name, PlaceholderEntry* probe)
435436
// If another thread is trying to resolve the class, it must do
436437
// superclass checks on its own thread to catch class circularity and
437438
// to avoid deadlock.
439+
// inline field layout callers:
440+
// The field's class must be loaded to determine layout.
438441
//
439442
// resolve_with_circularity_detection adds a DETECT_CIRCULARITY placeholder to the placeholder table before calling
440443
// resolve_instance_class_or_null. ClassCircularityError is detected when a DETECT_CIRCULARITY or LOAD_INSTANCE
441-
// placeholder for the same thread, class, classloader is found.
444+
// placeholder for the same thread, class, and classloader is found.
442445
// This can be seen with logging option: -Xlog:class+load+placeholders=debug.
443446
//
444447
InstanceKlass* SystemDictionary::resolve_with_circularity_detection(Symbol* class_name,
@@ -473,7 +476,7 @@ InstanceKlass* SystemDictionary::resolve_with_circularity_detection(Symbol* clas
473476
{
474477
MutexLocker mu(THREAD, SystemDictionary_lock);
475478

476-
// Must check ClassCircularity before resolving next_name (superclass or interface).
479+
// Must check ClassCircularity before resolving next_name (superclass, interface, field types or speculatively preloaded argument types).
477480
PlaceholderEntry* probe = PlaceholderTable::get_entry(class_name, loader_data);
478481
if (probe != nullptr && probe->check_seen_thread(THREAD, PlaceholderTable::DETECT_CIRCULARITY)) {
479482
log_circularity_error(class_name, probe);
@@ -497,7 +500,7 @@ InstanceKlass* SystemDictionary::resolve_with_circularity_detection(Symbol* clas
497500
THROW_MSG_NULL(vmSymbols::java_lang_ClassCircularityError(), class_name->as_C_string());
498501
}
499502

500-
// Resolve the superclass or superinterface, check results on return
503+
// Resolve the superclass, superinterface, field type or speculatively preloaded argument types and check results on return.
501504
InstanceKlass* superk =
502505
SystemDictionary::resolve_instance_class_or_null(next_name,
503506
class_loader,
@@ -1104,7 +1107,7 @@ bool SystemDictionary::preload_from_null_free_field(InstanceKlass* ik, Handle cl
11041107
log_info(class, preload)("Preloading of class %s during loading of shared class %s. "
11051108
"Cause: a null-free non-static field is declared with this type",
11061109
name->as_C_string(), ik->name()->as_C_string());
1107-
InstanceKlass* real_k = SystemDictionary::resolve_with_circularity_detection_or_fail(ik->name(), name,
1110+
InstanceKlass* real_k = SystemDictionary::resolve_with_circularity_detection(ik->name(), name,
11081111
class_loader, false, CHECK_false);
11091112
if (HAS_PENDING_EXCEPTION) {
11101113
log_warning(class, preload)("Preloading of class %s during loading of class %s "
@@ -1142,7 +1145,7 @@ void SystemDictionary::try_preload_from_loadable_descriptors(InstanceKlass* ik,
11421145
log_info(class, preload)("Preloading of class %s during loading of shared class %s. "
11431146
"Cause: field type in LoadableDescriptors attribute",
11441147
name->as_C_string(), ik->name()->as_C_string());
1145-
InstanceKlass* real_k = SystemDictionary::resolve_with_circularity_detection_or_fail(ik->name(), name,
1148+
InstanceKlass* real_k = SystemDictionary::resolve_with_circularity_detection(ik->name(), name,
11461149
class_loader, false, THREAD);
11471150
if (HAS_PENDING_EXCEPTION) {
11481151
CLEAR_PENDING_EXCEPTION;

src/hotspot/share/classfile/systemDictionary.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class BootstrapInfo;
6868
class ClassFileStream;
6969
class ClassLoadInfo;
7070
class Dictionary;
71-
class AllFieldStream;
7271
class PackageEntry;
7372
class GCTimer;
7473
class EventClassLoad;
@@ -113,8 +112,7 @@ class SystemDictionary : AllStatic {
113112
// Resolve a superclass or superinterface. Called from ClassFileParser,
114113
// parse_interfaces, resolve_instance_class_or_null, load_shared_class
115114
// "class_name" is the class whose super class or interface is being resolved.
116-
static InstanceKlass* resolve_with_circularity_detection_or_fail(Symbol* class_name,
117-
Symbol* super_name,
115+
static InstanceKlass* resolve_super_or_fail(Symbol* class_name, Symbol* super_name,
118116
Handle class_loader,
119117
bool is_superclass, TRAPS) {
120118
return resolve_with_circularity_detection(class_name, super_name, class_loader, is_superclass, THREAD);

0 commit comments

Comments
 (0)