Solved

Find loaded classes derived from X

Posted on 2007-12-05
3
330 Views
Last Modified: 2010-04-21
Is there a way to enumerate classes which have been loaded, which are derived from X or which implement interface Y?

My best shot is to do something like:

(1) Assume it is Sun J2 and enumerate all classes using the approach shown at http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725-classsrc2.html where you snoop the ClassLoader private Vector of classes.

(2) Use the instanceof operator on each to find the classes.

Is there something less brutal and more efficient? I can live without portability, but that would be nice too.
0
Comment
Question by:rstaveley
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
that would seem the way to go
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
may break though if sun changes underlying class loader implementation
0
 
LVL 17

Author Closing Comment

by:rstaveley
Comment Utility
Thanks for verifying.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
matchUp  challenge 9 70
Fibonacci challenge 11 81
get weblogic logged in user in java 2 38
Java / Linux and Regular Expressions 11 41
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now