You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Noam Mor (JIRA)" <ji...@apache.org> on 2013/12/05 19:51:35 UTC

[jira] [Created] (FELIX-4344) Behavior of dependency manager broken for java.lang.reflect.Proxy objects

Noam Mor created FELIX-4344:
-------------------------------

             Summary: Behavior of dependency manager broken for java.lang.reflect.Proxy objects
                 Key: FELIX-4344
                 URL: https://issues.apache.org/jira/browse/FELIX-4344
             Project: Felix
          Issue Type: Bug
          Components: Dependency Manager
            Reporter: Noam Mor


https://svn.apache.org/repos/asf/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java

The object on which a method should be called is explicitly checked to be a proxy, and if it is, the method is called on the proxy object's InvocationHandler. This assumes that the InvocationHandler's invoke() method delegates calls to the InvocationHandler. If this is not the case (as it can easily be - you can do whatever in the invoke() method, such as write to a queue for later execution, in which case the method is not in the InvocationHandler), then the method calls on the Proxy would not be called. So despite you being able to call proxyObject.someFunction(), you can't use the InvocationUtil to run the function someFunction on the proxyObject.

This is screwing me over in a project of mine, where I try to register a proxy object with a rather sophisticated InvocationHandler to OSGi with a dependency on an other service, and the dependency manager cannot execute the setOtherService() methods on my proxy because the InvocationHandler does not have a setOtherService method.

I am not a reflection expert but it sounds to me that removing those 3 lines of  direct handling of proxy objects should "just work" - there is no reason not to just call the method on the proxy object and let the InvocationHandler's invoke() do what it is supposed to do.



--
This message was sent by Atlassian JIRA
(v6.1#6144)