JDK-4295718 : (reflect) No method to scan for classes under a package
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 1.2.0,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-12-01
  • Updated: 2012-09-28
  • Resolved: 2001-11-02
Related Reports
Duplicate :  
Duplicate :  
Description

Name: mc57594			Date: 11/30/99


java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)

The reflection capability in Java is missing one important element, the ability
for an object to list out all the classes that it can access during runtime.
Currently, if you don't know the name of the class, you can't access the
class.  What would be nice is that the Package class have a method that lists
out the name of all its classes (in String format).

This is my situation...
I made an abstract CreditCard class upder a package called Payment that is the
super class of all credit card types (eg.. Visa, Mastercard, etc) What I want
to do is for the CreditCardClass to scan the Payment Package, and tell me all
the classes in that package.  Then armed with a list of class names then I can
test each class to see if they are subclassed from CreditCard.  This is done so
that the class CreditCard won't have to be modified when a new credit card is
written and placed in the Package.
(Review ID: 98462) 
======================================================================

Comments
WORK AROUND Name: mc57594 Date: 11/30/99 Right now, I manually scan through the classpath and then using the File class to manually change directories and then scan for *.class files. This work around does not work for jar classes. ======================================================================
11-06-2004

EVALUATION It does appear that reflection is incomplete in this respect. william.maddox@Eng 1999-12-15 Duplicate 4061452. -- iag@sfbay 2001-11-01
15-12-1999