java.io

Class InvalidClassException

Implemented Interfaces:
Serializable

public class InvalidClassException
extends ObjectStreamException

Thrown when the Serialization runtime detects one of the following problems with a Class.
Since:
JDK1.1
See Also:
Serialized Form

Field Summary

String
classname
Name of the invalid class.

Constructor Summary

InvalidClassException(String reason)
Report a InvalidClassException for the reason specified.
InvalidClassException(String cname, String reason)
Constructs an InvalidClassException object.

Method Summary

String
getMessage()
Produce the message and include the classname, if present.

Methods inherited from class java.lang.Throwable

fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

classname

public String classname
Name of the invalid class.

Constructor Details

InvalidClassException

public InvalidClassException(String reason)
Report a InvalidClassException for the reason specified.
Parameters:
reason - String describing the reason for the exception.
Usages and Demos :

View More Examples of InvalidClassException(String reason)
   1: 
   2:         throw new java.io.InvalidClassException(clazz.getName(), "Does not implement " + Importer.class.getName() );
   3:     }
   4:     public static ImporterFactory getInstance(){
   5:         if( reference == null )

View Full Code Here
   1: 
   2:         if (field == null) throw new InvalidClassException(classDesc.forClass().getName(), "Nonexistent field " + name);
   3:         try {
   4:         ...
   5:             case 'L': out.writeObject(field.get(o));          break;
   6:             default: throw new InvalidClassException(classDesc.forClass().getName());
   7:         }
   8:         ...
   9:         catch (IllegalAccessException e) {
  10:         throw new InvalidClassException(classDesc.forClass().getName(), e.getMessage());
  11:         }

View Full Code Here
   1:         } catch (ClassNotFoundException e) {
   2:             throw new InvalidClassException(GenericServiceEndpoint.class.getName(), "this is impossible");
   3:         }
   4:     }

View Full Code Here
   1:         if (factory==null || event==null) return;
   2:         if (!((BaseEvent.class).isAssignableFrom(event))) throw new InvalidClassException("Class "+event.getName()+" is not a BaseEvent");
   3:         if (logger.isInfoEnabled()) logger.info("Adding listener:"+factory+" for class:"+event);
   4:         ...
   5:         if (factory==null || event==null) return;
   6:         if (!((BaseEvent.class).isAssignableFrom(event))) throw new InvalidClassException("Class "+event.getName()+" is not a BaseEvent");
   7:         if (logger.isInfoEnabled()) logger.info("Removing listener:"+factory+" for class:"+event);
   8:         ...
   9:         if (event==null) return null;
  10:         if (!((BaseEvent.class).isAssignableFrom(event))) throw new InvalidClassException("Class "+event.getName()+" is not a BaseEvent");
  11:         if (logger.isInfoEnabled()) logger.info("Getting listeners for Class:"+event);

View Full Code Here
   1:                     } else {
   2:                         throw new InvalidClassException(clazz.getName());
   3:                     }
   4:         ...
   5:                                 field = fields[i].getField();
   6:                                 if ( field == null ) throw new InvalidClassException(clazz.getName(), "Nonexistent field " + fields[i].getName());
   7:                                 try {
   8:         ...
   9:                                             break;
  10:                                         default: throw new InvalidClassException(clazz.getName());
  11:                                     }

View Full Code Here

InvalidClassException

public InvalidClassException(String cname,
                             String reason)
Constructs an InvalidClassException object.
Parameters:
cname - a String naming the invalid class.
reason - a String describing the reason for the exception.

Method Details

getMessage

public String getMessage()
Produce the message and include the classname, if present.
Overrides:
getMessage in interface Throwable
Usages and Demos :

View More Examples of getMessage()
   1:         System.out.println("SimpleLogFile: write: " + rec);    
   2:     } catch (InvalidClassException ice) {
   3:         ...
   4:         System.out.println("SimpleLogFile: write: " + ice.getMessage());
   5:         ice.printStackTrace();
   6:         ...
   7:     } catch (NotSerializableException nse) {
   8:         System.out.println("SimpleLogFile: write: " + nse.getMessage());
   9:         nse.printStackTrace();
  10:         ...
  11:     } catch (IOException ioe) {
  12:         System.out.println("SimpleLogFile: write: " + ioe.getMessage());

View Full Code Here