Skip to content

CGLIB Enhancer enhances classes with java prefix which causes IllegalArgumentException in JDK 17 #29960

Closed as not planned
@liujunlou

Description

@liujunlou

Affects:

  • Spring Framework: 2.7.8
  • openjdk: 17.0.5
  • GraalVM CE: 22.3.0

Spring Framework's Enhancer enhances the classes beginning with "java" which causes IllegalArgumentException in JDK 17 for not in same package as lookup classes.

Exception:

not-same-package

Cause by DefaultNamingPolicy#getClassName:

public String getClassName(String prefix, String source, Object key, Predicate names) {
    if (prefix == null) {
        prefix = "org.springframework.cglib.empty.Object";
    } else if (prefix.startsWith("java")) {
        prefix = "$" + prefix;
    }

    String base = prefix + "$$" + source.substring(source.lastIndexOf(46) + 1) + this.getTag() + "$$" + Integer.toHexString(STRESS_HASH_CODE ? 0 : key.hashCode());
    String attempt = base;

    for(int var7 = 2; names.evaluate(attempt); attempt = base + "_" + var7++) {
    }

    return attempt;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions