• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class loader determination

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)Is it possible to determine by which class loader was loaded some class(name of classloader)?
2)Is it possible to load some class in runtime when the class with the same name/path(but with another content) already loaded and run.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out Class.getClassLoader()
The default behaviour for ClassLoaders is to inherit a parent ClassLoader, and not re-load any Class already loaded by that ClassLoader. They also allow the parent to load it first to allow other ClassLOaders with tah same parent to share the same Class instance.
BUT, you can always write your own ClassLoader that breaks either rule (not recommended for the inexperienced), and if B and C inherit from A, then B and C can both load a Class that is not loaded by A.
...but with another content...
I assume you're referring to static content in the Class? If the Class is one you've written, it may be easier to rewrite the Class to remove this restriction. It's much easier than introducing ClassLoaders into code that doesn't need it.
dave
 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give me any coding example, which is working. This will help me to define my own classloader.
 
Peter Kovgan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an example
forum's topic
 
It runs on an internal combustion engine. This ad does not:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic