Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
liujunlou opened this issue Feb 13, 2023 · 4 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression)

Comments

@liujunlou
Copy link

liujunlou commented Feb 13, 2023

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;
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 13, 2023
@rstoyanchev rstoyanchev added the in: core Issues in core modules (aop, beans, core, context, expression) label Feb 14, 2023
@sbrannen sbrannen changed the title Enhancer enhance the classes beginning with java. which cause IllegalArgumentException in JDK 17 for not in same package as lookup classes CGLIB Enhancer enhances classes java prefix which causes IllegalArgumentException in JDK 17 Feb 28, 2023
@sbrannen sbrannen changed the title CGLIB Enhancer enhances classes java prefix which causes IllegalArgumentException in JDK 17 CGLIB Enhancer enhances classes with java prefix which causes IllegalArgumentException in JDK 17 Feb 28, 2023
@sbrannen
Copy link
Member

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

@snicoll
Copy link
Member

snicoll commented Oct 4, 2023

@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?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Oct 4, 2023
@spring-projects-issues
Copy link
Collaborator

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.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Oct 11, 2023
@spring-projects-issues
Copy link
Collaborator

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.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression)
Projects
None yet
Development

No branches or pull requests

5 participants