0

Lets say i have a Proxy to an object, can I somehow get access to the object via reflection or other technique ?

2
  • when you say a Proxy, you mean the pattern or some java class? Commented Sep 10, 2010 at 12:38
  • By proxy i mean the java class(technology) when you have a remote object and you can use it remotely via a proxy class Commented Sep 10, 2010 at 12:43

3 Answers 3

1

No, as a Proxy is not even itself a "true" object. From the javadoc, you can see that the only object you can easily access is the invocation handler. Once this handler is reached, it's a matter of implementation :

  • you may encounter n invocation handler that keeps a reference to proxied object (as an example for kind of a decorator)
  • but you can also have no other reference (as an example, when implementing the Null object pattern using proxy).
Sign up to request clarification or add additional context in comments.

Comments

1

What do you mean by "Proxy to an object"? If you mean the invocation handler of a java.lang.reflect.Proxy instance:

InvocationHandler handler = Proxy.getInvocationHandler(proxy);

Comments

0

If you have a proxy to an object you can use the proxy to access the object.

proxy - An interface for a service, especially for one that is remote, resource-intensive, or otherwise difficult to use directly. (wiktionary)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.