Record Class DuplicateClassReport

java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.diagnostic.DuplicateClassReport
Record Components:
className - the fully qualified class name | 完全限定类名
classLoaderNames - the names of ClassLoaders containing this class | 包含此类的 ClassLoader 名称列表
locations - the resource URL locations where the class was found | 发现此类的资源 URL 位置列表

public record DuplicateClassReport(String className, List<String> classLoaderNames, List<String> locations) extends Record
Immutable report of a class found in multiple ClassLoaders 在多个 ClassLoader 中发现的重复类的不可变报告

Represents a single class that was found to exist in two or more ClassLoaders, which may lead to classpath conflicts, ClassCastException, or unexpected behavior at runtime.

表示在两个或多个 ClassLoader 中发现存在的单个类, 这可能导致类路径冲突、ClassCastException 或运行时意外行为。

Features | 主要功能:

  • Records class name, loader names, and resource locations - 记录类名、加载器名称和资源位置
  • Defensive copies for immutability - 防御性拷贝以保证不可变性

Usage Examples | 使用示例:

DuplicateClassReport report = new DuplicateClassReport(
    "com.example.Foo",
    List.of("loader1", "loader2"),
    List.of("file:/path/a.jar", "file:/path/b.jar")
);

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是 (不可变记录)
Since:
JDK 25, opencode-base-classloader V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • DuplicateClassReport

      public DuplicateClassReport(String className, List<String> classLoaderNames, List<String> locations)
      Compact constructor with validation and defensive copies 带验证和防御性拷贝的紧凑构造器
      Throws:
      NullPointerException - if any parameter is null | 当任何参数为 null 时
      IllegalArgumentException - if classLoaderNames has fewer than 2 entries | 当 classLoaderNames 少于 2 个条目时
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • className

      public String className()
      Returns the value of the className record component.
      Returns:
      the value of the className record component
    • classLoaderNames

      public List<String> classLoaderNames()
      Returns the value of the classLoaderNames record component.
      Returns:
      the value of the classLoaderNames record component
    • locations

      public List<String> locations()
      Returns the value of the locations record component.
      Returns:
      the value of the locations record component