• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Using classes loaded by custom classloader

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK so I recently ran into a bit of jar hell when using a vendor supplied library that had dependencies on a library i already use for my application. Unfortunantly the version required by the vendor is an outdated version and my app requires some of the new features. After reading around it sounded like the best option was to create a custom class loader to load this library. I have the class loader working and all is good, i can instantiate my classes, execute methods on them using the java.lang.reflect api's and thats all fine and dandy but what i want to do is be able to call


I don't have the library in the classpath because this is loaded from the custom loaders classpath. Am I stuck calling everything by the method name? Am I smashing a grape with a sledgehammer?

Thanks for any assistance!
--j
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on my extensive attempts in this area, the answer to:

Am I stuck calling everything by the method name?



the answer is yes. There appears to be no way around the security restrictions. The good news is working with the reflect apis is pretty fast.


Bill
 
J Holls
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Based on my extensive attempts in this area, the answer to:

Am I stuck calling everything by the method name?



the answer is yes. There appears to be no way around the security restrictions. The good news is working with the reflect apis is pretty fast.


Bill



Thanks for the quick reply, and thanks for reading my mind of what i meant by calling everything by method name. I meant to say Method.invoke.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't discount the use of a tool like jarjar when version conflicts like this happen.
 
J Holls
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Don't discount the use of a tool like jarjar when version conflicts like this happen.



Thanks, I never even knew this tool existed. Everything I found talked about writing custom class loaders for resolving dependency issues. This will be the path I am going to take. I prefer static typing over flexibility of reflect api's for something like this.
reply
    Bookmark Topic Watch Topic
  • New Topic