5

I was wondering about when you call the newProxyInstance method when creating a dynamic proxy instance, what exactly is the ClassLoader argument for?

public static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) throws IllegalArgumentException

Many thanks!

P.S. I'm not sure how to use the code formatting tags correctly.

1

1 Answer 1

3

The documentation for newProxyInstance defines its use to be equivalent to:

Proxy.getProxyClass(loader, interfaces).
    getConstructor(new Class[] { InvocationHandler.class }).
    newInstance(new Object[] { handler });

So, if you want a bit more detail about loader, you can look at the documentation for getProxyClass. Basically, it just serves as the class loader that defines the generated proxy class.

Sign up to request clarification or add additional context in comments.

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.