• 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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-
 
Hey cool! They got a blimp! But I have a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!