Jyothi Babu Araja Jyothi Babu Araja - 1 year ago 129
Java Question

cglib: Java dynamic proxy for class without constructor (HttpUrlConnection)

I'm unable to create dynamic proxy for HttpURLConnection class, since it don't have public constructor to create Enhancer. Coming to requirement, I want to create a dynamic proxy to get details of current connection at run time.

I tried using this tutorial, but failed to do so.

Answer Source

You can use a library like Objenesis to create instances of classes that do not offer a suitable constructor. You can use cglib for creating the subclass but without creating the instance in this case.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download