Piotr Klimczak created ARIES-2051:
-------------------------------------

             Summary: Blueprint Spring SpringApplicationContext ClassLoader 
implementation not working for loadClass(name, resolve) operation
                 Key: ARIES-2051
                 URL: https://issues.apache.org/jira/browse/ARIES-2051
             Project: Aries
          Issue Type: Bug
          Components: Blueprint
    Affects Versions: blueprint-spring-1.0.0
            Reporter: Piotr Klimczak


Blueprint Spring SpringApplicationContext uses its own ClassLoader.

This class loader implementation however is not handling calls to 
loadClass(String name, boolean resolve), which is used by other class loaders.
Therefore if we obtain class loader for app context and use it for example with 
Groovy, it will fail asĀ 
{code:java}
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException...{code}
Will not be called at all.

Proper implementation should be:
{code:java}
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
    return loadClass(name, false);
}

@Override
public Class<?> loadClass(String name, boolean resolve) throws 
ClassNotFoundException {
    for (ClassLoader cl : parentClassLoaders) {
        try {
            Class<?> c = cl.loadClass(name);
            if (resolve) {
                resolveClass(c);
            }
            return c;
        } catch (ClassNotFoundException e) {
            // Ignore
        }
    }
    throw new ClassNotFoundException(name);
} {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to