Record Class ClassLoadTrace
java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.diagnostic.ClassLoadTrace
- Record Components:
className- the fully qualified class name | 完全限定类名delegationChain- the ordered list of ClassLoader names consulted during loading | 加载期间按顺序咨询的 ClassLoader 名称列表definingLoader- the name of the ClassLoader that defines the class, or "bootstrap" | 定义该类的 ClassLoader 名称,或 "bootstrap"location- the resource URL where the class was found, or null if not found | 发现该类的资源 URL,如果未找到则为 null
public record ClassLoadTrace(String className, List<String> delegationChain, String definingLoader, String location)
extends Record
Immutable trace of a class loading delegation chain
类加载委托链的不可变跟踪记录
Captures the full delegation path traversed when loading a class, showing which ClassLoaders were consulted and which one ultimately defined the class. This is invaluable for debugging ClassNotFoundException or unexpected class versions.
捕获加载类时遍历的完整委托路径,显示咨询了哪些 ClassLoader 以及最终由哪个定义了该类。 这对于调试 ClassNotFoundException 或意外的类版本非常有价值。
Features | 主要功能:
- Records full delegation chain - 记录完整的委托链
- Identifies the defining loader - 标识定义加载器
- Captures resource location (URL) - 捕获资源位置 (URL)
Usage Examples | 使用示例:
ClassLoadTrace trace = ClassLoaderDiagnostics.traceClassLoading(
"com.example.Foo", myClassLoader
);
System.out.println("Defined by: " + trace.definingLoader());
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是 (不可变记录)
- Since:
- JDK 25, opencode-base-classloader V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theclassNamerecord component.Returns the value of thedefiningLoaderrecord component.Returns the value of thedelegationChainrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.location()Returns the value of thelocationrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ClassLoadTrace
public ClassLoadTrace(String className, List<String> delegationChain, String definingLoader, String location) Compact constructor with validation and defensive copies 带验证和防御性拷贝的紧凑构造器- Throws:
NullPointerException- if className, delegationChain, or definingLoader is null | 当 className、delegationChain 或 definingLoader 为 null 时
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
className
-
delegationChain
Returns the value of thedelegationChainrecord component.- Returns:
- the value of the
delegationChainrecord component
-
definingLoader
Returns the value of thedefiningLoaderrecord component.- Returns:
- the value of the
definingLoaderrecord component
-
location
-