Skip to content
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

Auto-proxying does not recursively search for all interfaces #53

Open
Aklakan opened this issue Nov 23, 2016 · 1 comment
Open

Auto-proxying does not recursively search for all interfaces #53

Aklakan opened this issue Nov 23, 2016 · 1 comment

Comments

@Aklakan
Copy link

Aklakan commented Nov 23, 2016

Auto-proxying does not recursively search for interfaces, so this small example unexpectedly does not work:

interface I {}
class A implements I{}
class B extends A {}
JarClassLoader jcl = new JarClassLoader();
JclObjectFactory factory = JclObjectFactory.getInstance(true);
Object o = factory.create(jcl, "B");

Results in:

Exception in thread "main" org.xeustechnologies.jcl.exception.JclException: org.xeustechnologies.jcl.exception.JclException: Neither the class [B] nor all the implemented interfaces found in the current classloader
	at org.xeustechnologies.jcl.JclObjectFactory.create(JclObjectFactory.java:93)

The fix would be to change JclObjectFactory.java with:

//            Class[] interfaces = object.getClass().getInterfaces(); // Remove this line
            List<Class> il = new ArrayList<Class>();


// Use this util e.g. from org.apache.commons:commons-lang3 instead
            List<Class<?>> interfaces = ClassUtils.getAllInterfaces(object.getClass());
@jtnelson
Copy link

@kamranzafar would you be open to a PR that implements this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants