Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2004

Tip: Looking for answers? Try searching our database.

Extenders

Thread view: 
_Mario_ - 05 Dec 2004 16:39 GMT
Hi all,

I've got a class Figure in my project.

Figure is an Abstract class.

I need to know all the names of the classes present in the package that
extends/implement Figure.

How can I do to do this from my MainClass (that is not Figure)????

Thanks a lot.

Mario
Stefan Schulz - 05 Dec 2004 19:49 GMT
> Hi all,
>
[quoted text clipped - 6 lines]
>
> How can I do to do this from my MainClass (that is not Figure)????

Not at all.

What if you call the hypothetical "getChildren" method, and two  
milliseconds
later some other thread calls defineClass() for yet another child class?

Signature

Whom the gods wish to destroy they first call promising.

_Mario_ - 05 Dec 2004 20:59 GMT
>> Hi all,
>>
[quoted text clipped - 12 lines]
> milliseconds
> later some other thread calls defineClass() for yet another child class?

No thread can do this....

anyway: how can I find all the class that extends my class Figure?

Mario
Ryan Stewart - 05 Dec 2004 21:51 GMT
[...]
>>> I need to know all the names of the classes present in the package that
>>> extends/implement Figure.
>>>
>>> How can I do to do this from my MainClass (that is not Figure)????
>>
>> Not at all.

[...]
> anyway: how can I find all the class that extends my class Figure?

Try reading Stefan's post again (important part above). You can't. ... But
then, theoretically, I supposed you could run javadoc on your project, parse
the output for that class and try to get subclasses from that.
_Mario_ - 06 Dec 2004 00:31 GMT
> [...]
>>>> I need to know all the names of the classes present in the package that
[quoted text clipped - 10 lines]
> then, theoretically, I supposed you could run javadoc on your project,
> parse the output for that class and try to get subclasses from that.
OK thanks

Mario
Iain Robinson - 06 Dec 2004 00:41 GMT
> Hi all,
>
[quoted text clipped - 8 lines]
>
>...

Hi,

I dont want to go against what everyone else has said on this - since
i'm no Java expert -  but if you meant "implements" (not - i think -
extends - but then again..) wouldn't this be possible to do using the
Class.getInterfaces() method?

The way i'm thinking is this... if you know each class will be in the
same package then it must be in the same directory...you could create an
instance of each class in that directory and call this method for each one.

I'm not saying that this would be safe in all circumstances but it might
be suitable in some (although a bit of a work-around for possibly little
benefit...i don't know).

comments please

P@
Chris Smith - 09 Dec 2004 20:02 GMT
> I dont want to go against what everyone else has said on this - since
> i'm no Java expert -  but if you meant "implements" (not - i think -
[quoted text clipped - 8 lines]
> be suitable in some (although a bit of a work-around for possibly little
> benefit...i don't know).

If you could get a list of all classes that *might* extend or implement
a given type, then yes it would become possible.  However, you can't do
that.  There is no way to get a list of all the classes in the system,
or in a package, or anything.

If you only want classes from the system classloader, though, then you
could walk through all the paths in the "java.class.path" system
property and look for classes; but you'll get some that didn't exist
(i.e., weren't loaded into the VM) until you looked for them.  If all
these limitations are okay, then you have a kludgy answer.

Alternatively, if you're attempting to write a development tool, look
into the JVMTI (or pre 1.5, the JVMPI or JVMDI).

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.