Elis Edlund opened SPR-15473 and commented

In previous version I got a correct classname in my custom DefaultListableBeanFactory by fetching it from the RootBeanDefinition, Example doing something like this: private Class<?> figureOutClass(final RootBeanDefinition mbd) { String className = mbd.getBeanClassName(); return Class.forName(className); } This still works fine for regular classes but not internal ones like the following:

public class BeanTest {
    @Test
    public void someTest() {
      MyClass c = new MyClass() {
            public String getEscString() {
                return "\"'><&&";
            }
        };
    //some testing 
    }

        public class MyClass2() {
            public String getEscString() {
                return "\"'><&&";
            }
        };
}

both MyClass2 and MyClass will be resolved to the names: com.somepackage.BeanTest.MyClass1 com.somepackage.BeanTest.MyClass2 when using mbd.getBeanClassName(); instead of the expected (and how it worked before) com.somepackage.BeanTest$MyClass1 com.somepackage.BeanTest$MyClass2


Affects: 4.3.7

Comment From: spring-projects-issues

Juergen Hoeller commented

We use the Java source style representation of inner class names in quite a few places of the framework, and we never really gave guarantees about returning $-separated names there. Nevertheless, since this does seem to be a regression, I'll see what we can do; we might just leave this as-is though, depending on the circumstances.

Note that Spring's ClassUtils.forName can easily deal with such names; I'd recommend its use over Class.forName for any such purposes. Even better, you could check RootBeanDefinition.hasBeanClass and call getBeanClass or resolveBeanClass on it accordingly, never manually resolving bean class names.

Comment From: spring-projects-issues

Elis Edlund commented

Using ClassUtils.forName did actually solve my problem which enables me to remove my workaround. Thanks, "RootBeanDefinition.hasBeanClass and call getBeanClass or resolveBeanClass" are however unusable to me as I actually have my own resolver that enables me to configure classnames in the beanxml without package names and things like that.

Comment From: spring-projects-issues

Juergen Hoeller commented

How do you register those bean class names for your initial bean definitions, actually? I seem to be getting the '$' style syntax for any variant I'm trying... We support user-provided dot syntax but don't explicitly translate to that syntax ourselves.

Comment From: snicoll

I think this issue as run its course.