• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

classloaders

 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an easy way to determine where a class is first getting loaded by either an app or ext class loader?
 
author
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "where"?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean a Class is getting loaded, and you want to know where (physically) that Class comes from? I've had to do this when I was accidentally loading the wrong Class from having multiple definitions of the same class on the classpath.
What I did was convert the fully-qualified Class name into a relative file location (not a java.io.File, just a String that describes the location of the Class). It will be relative to the classpath, so to find com.javaranch.davo.MyClass, convert it to /com/javaranch/davo/MyClass.class, then use the ClassLoader.getResource to find it as a URL. If you don't use a URL you won't be able to print the location of classes loaded from JARs.
Dave
 
Jeff Langr
author
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. It's been a long day. I mean where is the first spot in code that the class is referenced and thus loaded.
-Jeff-
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic