Overriding classes in Java -
can use classloader's definepackage override packages inside jar?
for example, application contains "javax.xml.bind" abc.jar. if call classloader.definepackage(def.jar), in def.jar contains version of javax.xml.bind, can replace classpath entire application point of def.jar? thanks.
no, can not use classloader.definepackage
"override" packages inside jar.
if understand correctly, want make jvm load class under javax.xml.bind def.jar while other ones abc.jar. in case can (in personal order of preference):
1) put def.jar before abc.jar in classpath. requires no class want loaded abc.jar present in def.jar.
2) unzip def.jar, abc.jar, or both, , remove conflicting classes irrelevant jar comes first in classpath. re-zip them. or can on 1 jar , put before other.
3) use configurable classloader (sorry, no public domain 1 know of; let me know if find one). interesting topic os project, except several initiatives similar (but broader) objectives ongoing, @ core of language.
4) create classloader purpose, extending default one.
Comments
Post a Comment