Class ClassLoadingPolicy.Builder

java.lang.Object
cloud.opencode.base.classloader.security.ClassLoadingPolicy.Builder
Enclosing class:
ClassLoadingPolicy

public static final class ClassLoadingPolicy.Builder extends Object
Builder for ClassLoadingPolicy ClassLoadingPolicy 的构建器
Since:
JDK 25, opencode-base-classloader V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • allowedPackages

      public ClassLoadingPolicy.Builder allowedPackages(Set<String> packages)
      Set the allowed packages (whitelist) 设置允许的包(白名单)
      Parameters:
      packages - set of allowed package prefixes | 允许的包前缀集合
      Returns:
      this builder | 此构建器
      Throws:
      NullPointerException - if packages is null | 当 packages 为 null 时
    • addAllowedPackage

      public ClassLoadingPolicy.Builder addAllowedPackage(String packagePrefix)
      Add a single allowed package prefix 添加单个允许的包前缀
      Parameters:
      packagePrefix - the package prefix to allow | 要允许的包前缀
      Returns:
      this builder | 此构建器
      Throws:
      NullPointerException - if packagePrefix is null | 当 packagePrefix 为 null 时
    • deniedPackages

      public ClassLoadingPolicy.Builder deniedPackages(Set<String> packages)
      Set the denied packages (blacklist) 设置拒绝的包(黑名单)
      Parameters:
      packages - set of denied package prefixes | 拒绝的包前缀集合
      Returns:
      this builder | 此构建器
      Throws:
      NullPointerException - if packages is null | 当 packages 为 null 时
    • addDeniedPackage

      public ClassLoadingPolicy.Builder addDeniedPackage(String packagePrefix)
      Add a single denied package prefix 添加单个拒绝的包前缀
      Parameters:
      packagePrefix - the package prefix to deny | 要拒绝的包前缀
      Returns:
      this builder | 此构建器
      Throws:
      NullPointerException - if packagePrefix is null | 当 packagePrefix 为 null 时
    • maxLoadedClasses

      public ClassLoadingPolicy.Builder maxLoadedClasses(int maxLoadedClasses)
      Set the maximum number of loaded classes (0 for unlimited) 设置最大已加载类数量(0 表示无限制)
      Parameters:
      maxLoadedClasses - maximum class count | 最大类数量
      Returns:
      this builder | 此构建器
      Throws:
      IllegalArgumentException - if maxLoadedClasses is negative | 当 maxLoadedClasses 为负数时
    • maxBytecodeSize

      public ClassLoadingPolicy.Builder maxBytecodeSize(int maxBytecodeSize)
      Set the maximum bytecode size per class in bytes (0 for unlimited) 设置每个类的最大字节码大小(字节,0 表示无限制)
      Parameters:
      maxBytecodeSize - maximum bytecode size in bytes | 最大字节码大小(字节)
      Returns:
      this builder | 此构建器
      Throws:
      IllegalArgumentException - if maxBytecodeSize is negative | 当 maxBytecodeSize 为负数时
    • bytecodeVerifier

      public ClassLoadingPolicy.Builder bytecodeVerifier(BytecodeVerifier verifier)
      Set a custom bytecode verifier 设置自定义字节码验证器
      Parameters:
      verifier - the bytecode verifier | 字节码验证器
      Returns:
      this builder | 此构建器
    • build

      public ClassLoadingPolicy build()
      Build the immutable ClassLoadingPolicy 构建不可变的 ClassLoadingPolicy
      Returns:
      a new ClassLoadingPolicy instance | 新的 ClassLoadingPolicy 实例