Jyothi Babu Araja Jyothi Babu Araja - 4 months ago 43
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.


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.