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;
}

Comment From: sbrannen

This is related to #27622 which was addressed in Spring Framework 6.0.

Comment From: snicoll

@liujunlou I am trying to see if that's still a problem and the lack of reproducer is not helping me. If you're still affected, can you share a small sample we can run ourselves?

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.