wood burning stoves*
The moose likes Java in General and the fly likes Classloading issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Classloading issue" Watch "Classloading issue" New topic
Author

Classloading issue

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

I have this fragment of code which always returns false.



Class Hierarchy..



The above a is an Object of SymRegIsland

Thanks in advance.



My Blog SCJP 5 SCWCD 5
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326



returns the Object that the JVM uses to find and load classes. That is of the type java.lang.ClassLoader. You are not extending that class.
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Is there any way I can make it return the JobClassLoader...

Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Himanshu Gupta wrote:Is there any way I can make it return the JobClassLoader...



Wait a minute now... you don't have to "return the JobClassLoader". Your class a IS A JobClassLoader.

Try:



Or are you doing something really cool with the JVM and ClassLoading?
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

This is some pre-written code and I am trying to make it run. I think I have to look deeper in this to get it resolved.
If I dont extend the Agent class by JobClassLoader is there any way I can make the following code return the JobClassLoader?


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Himanshu Gupta wrote:This is some pre-written code and I am trying to make it run. I think I have to look deeper in this to get it resolved.
If I dont extend the Agent class by JobClassLoader is there any way I can make the following code return the JobClassLoader?




You forgot to post the "following" code.

As for looking deeper into it, I would definitely agree. To me a class hierarchy of what appears to be business objects descending from a ClassLoader is quite bizarre and quite possibly a candidate for the Daily WTF. But all I have seen is the class hierarchy so there may be a good reason for having done that. Or at least a reason...
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Its a part of the software which runs genetic algorithms in a distributed Environment. The classes must be loaded using the URLClassLoader as the task is distributed among available peers.

And this is the code fragment I was talking about.

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598





This gives me output as



Is this correct. I expected it to be of JobClassLoader
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

a's class needs to be loaded by your own class loader. That means that, first of all, its parent class loader should not load it. And that in turn means that the class to be loaded cannot be on the class path. After all, everything on the class path will already be found by the system class loader. A class loader will only be asked to load a class if its parent can't find it.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Rob Spoor wrote:a's class needs to be loaded by your own class loader. That means that, first of all, its parent class loader should not load it. And that in turn means that the class to be loaded cannot be on the class path. After all, everything on the class path will already be found by the system class loader. A class loader will only be asked to load a class if its parent can't find it.


That was the real issue.
Thanks Rob.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classloading issue
 
Similar Threads
need help about generics
super class implemnts the sub class method ??
Collections
Generic wildcards
Abstract Inner Class