File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes An error while loading class 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 "An error while loading class" Watch "An error while loading class" New topic
Author

An error while loading class

Anirban Chatterjee
Greenhorn

Joined: Feb 06, 2001
Posts: 18
Hi ,
I need to find out if a class implements the java.io.Serializable interface .

For that I am reading in the class through a bytestream and loading it using class.defineClass() method.
And getting the interfaces by
loadedClass.getInterfaces();

Everything goes fine if its a standalone class.

But if this class extends another class , or implements a not system interface , I am getting a class loader exception .
Can any one help me out with this?
Anirban
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Why don't you just try to Serialize it, and if it is not Serializable, handle the exception?


"JavaRanch, where the deer and the Certified play" - David O'Meara
Anirban Chatterjee
Greenhorn

Joined: Feb 06, 2001
Posts: 18
Originally posted by Cindy Glass:
Why don't you just try to Serialize it, and if it is not Serializable, handle the exception?

Hi,
Thanks for the suggestion .
But dont I have to load the class to try and serialize the same ?
Here is the use case for me >
I have a .class file which can be present in the file system , which I can basically read into an array of bytes .
I know the fully qualified name of the class as well .
How do I find out if it implements java.io.Serialisable in the easiest manner possible ?
Thanks in advance,
Anirban
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Duh - I get it now :roll: .
hmmm , the only isSerializable() that I know of is used in the Doclet stuff.
Nope - I am just not going to be able to help here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An error while loading class
 
Similar Threads
which class is implementing the RequestDispatcher interface
Why interface not need prior intialization??????
Problem in Java Class Loading process
meaning pf this code
which class is impementing the RequestDispatcher inteface