I am working on a large (many classes) java project, and I have its source code, but most classes are dynamically created or loaded via ClassLoaders. In any case, I would like to be able to "override" the java.net.URL class so that I can track calls to open the url. I can’t use sniffer because the content is SSL encrypted. I tried to extend java.net.URL, but this did not work because it is the last class. I also opened the source for java.net.URL and changed it and was able to create it successfully, now how can I force the java loader to load a modified copy of java.net.URL by default instead of the original one? Any suggestions are welcome! Thanks in advance.
The parameter would be to use AspectJ and embed your extension code in the URL class instead of its extension. This way, you don’t need to modify any of the source sources, and you can still “extend” the final class. Of course, the disadvantage is that you add another dependency to your project.
If you haven't worked with AOP yet, you can find a brief introduction to AOP on my blog: http://whatiscomingtomyhead.wordpress.com/2010/02/06/aspect-oriented-programming-an-introduction/
URL, . JVM , IMHO .
, URLStreamHandlerFactory URL.setURLStreamHandlerFactory(). , URL- , .
, ; URLStreamHandlerFactories - 1/. (, Tomcat), , , SOL.
AspectJ? pointcut URL , , URL.
API, ( ), VM , . Sun VM -Xbootclasspath/p: , .
, URL-, ProxySelector. URLConnection , URL- ProxySelector.select(URI uri) - . , . ProxySelector ProxySelector.getDefault(), URI, select.
Source: https://habr.com/ru/post/1731581/More articles:Should User Controls be supported by properties? - c #upload large files in a browser with a progress bar, do not use flash js and php - javascriptHow to make powershell wait for event log entries? - powershellGetting started with vim scripts with perl - vimhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1731580/connect-multiple-jcr-repositories-to-one-database-and-keep-updated&usg=ALkJrhi19_qaiEFnnoDRlHsEOze4sHEy4QMySQL Select Like - sqlSimple task scheduling inside a Rails application - ruby-on-railsTrojan debugging and analysis - analysisjQuery Sortable () with original place position? - jqueryEdited-MySQL. Large MyISAM table (40 million records) with an index that is very slow and huge in size on disk - optimizationAll Articles