/[classpath]/classpath/java/io/ObjectInputStream.java
ViewVC logotype

Diff of /classpath/java/io/ObjectInputStream.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.43.2.14 by gnu_andrew, Sun Aug 7 18:34:10 2005 UTC revision 1.43.2.15 by gnu_andrew, Tue Aug 16 16:22:37 2005 UTC
# Line 508  public class ObjectInputStream extends I Line 508  public class ObjectInputStream extends I
508                                                    flags, fields);                                                    flags, fields);
509      assignNewHandle(osc);      assignNewHandle(osc);
510    
511      if (callersClassLoader == null)      ClassLoader callersClassLoader = currentLoader();
       callersClassLoader = currentLoader();  
512                                
513      for (int i = 0; i < field_count; i++)      for (int i = 0; i < field_count; i++)
514        {        {
# Line 535  public class ObjectInputStream extends I Line 534  public class ObjectInputStream extends I
534                                
535      /* Now that fields have been read we may resolve the class      /* Now that fields have been read we may resolve the class
536       * (and read annotation if needed). */       * (and read annotation if needed). */
537      Class clazz;      Class clazz = resolveClass(osc);
     try  
       {  
         clazz = resolveClass(osc);  
       }  
     catch (ClassNotFoundException cnfe)  
       {  
         // Maybe it was an primitive class?  
         if (name.equals("void"))  
           clazz = Void.TYPE;  
         else if (name.equals("boolean"))  
           clazz = Boolean.TYPE;  
         else if (name.equals("byte"))  
           clazz = Byte.TYPE;  
         else if (name.equals("short"))  
           clazz = Short.TYPE;  
         else if (name.equals("char"))  
           clazz = Character.TYPE;  
         else if (name.equals("int"))  
           clazz = Integer.TYPE;  
         else if (name.equals("long"))  
           clazz = Long.TYPE;  
         else if (name.equals("float"))  
           clazz = Float.TYPE;  
         else if (name.equals("double"))  
           clazz = Double.TYPE;  
         else  
           throw cnfe;  
       }  
   
538      boolean oldmode = setBlockDataMode(true);      boolean oldmode = setBlockDataMode(true);
539      osc.setClass(clazz, lookupClass(clazz.getSuperclass()));      osc.setClass(clazz, lookupClass(clazz.getSuperclass()));
540      classLookupTable.put(clazz, osc);      classLookupTable.put(clazz, osc);
# Line 777  public class ObjectInputStream extends I Line 747  public class ObjectInputStream extends I
747    protected Class resolveClass(ObjectStreamClass osc)    protected Class resolveClass(ObjectStreamClass osc)
748      throws ClassNotFoundException, IOException      throws ClassNotFoundException, IOException
749    {    {
750      if (callersClassLoader == null)      String name = osc.getName();
751        try
752        {        {
753          callersClassLoader = currentLoader ();          return Class.forName(name, true, currentLoader());
754          if (DEBUG && dump)        }
755            {      catch(ClassNotFoundException x)
756              dumpElementln ("CallersClassLoader = " + callersClassLoader);        {
757            }          if (name.equals("void"))
758              return Void.TYPE;
759            else if (name.equals("boolean"))
760              return Boolean.TYPE;
761            else if (name.equals("byte"))
762              return Byte.TYPE;
763            else if (name.equals("char"))
764              return Character.TYPE;
765            else if (name.equals("short"))
766              return Short.TYPE;
767            else if (name.equals("int"))
768              return Integer.TYPE;
769            else if (name.equals("long"))
770              return Long.TYPE;
771            else if (name.equals("float"))
772              return Float.TYPE;
773            else if (name.equals("double"))
774              return Double.TYPE;
775            else
776              throw x;
777        }        }
   
     return Class.forName(osc.getName(), true, callersClassLoader);  
778    }    }
779    
780    /**    /**
# Line 1282  public class ObjectInputStream extends I Line 1270  public class ObjectInputStream extends I
1270              }              }
1271            catch (NoSuchFieldException e)            catch (NoSuchFieldException e)
1272              {              {
1273                throw new IllegalArgumentException(e.getMessage());                throw new IllegalArgumentException(e);
1274              }              }
1275          }          }
1276    
# Line 1427  public class ObjectInputStream extends I Line 1415  public class ObjectInputStream extends I
1415            ObjectStreamField field = clazz.getField(name);            ObjectStreamField field = clazz.getField(name);
1416            boolean illegal = false;            boolean illegal = false;
1417    
1418              // XXX This code is horrible and needs to be rewritten!
1419            try            try
1420              {              {
1421                try                try
# Line 1486  public class ObjectInputStream extends I Line 1475  public class ObjectInputStream extends I
1475                catch (NoSuchFieldException e)                catch (NoSuchFieldException e)
1476                  {                  {
1477                    if (field == null)                    if (field == null)
1478                      throw new IllegalArgumentException(e.getMessage());                      throw new IllegalArgumentException(e);
1479                  }                  }
1480                                
1481              }              }
# Line 1830  public class ObjectInputStream extends I Line 1819  public class ObjectInputStream extends I
1819        }        }
1820      catch (InstantiationException e)      catch (InstantiationException e)
1821        {        {
1822          throw new ClassNotFoundException          throw (ClassNotFoundException) new ClassNotFoundException
1823                  ("Instance of " + real_class + " could not be created");            ("Instance of " + real_class + " could not be created").initCause(e);
1824        }        }
1825    }    }
1826    
# Line 1872  public class ObjectInputStream extends I Line 1861  public class ObjectInputStream extends I
1861          if (exception instanceof ClassNotFoundException)          if (exception instanceof ClassNotFoundException)
1862            throw (ClassNotFoundException) exception;            throw (ClassNotFoundException) exception;
1863    
1864          throw new IOException("Exception thrown from readObject() on " +          throw (IOException) new IOException(
1865                                 klass + ": " + exception.getClass().getName());            "Exception thrown from readObject() on " + klass).initCause(x);
1866        }        }
1867      catch (Exception x)      catch (Exception x)
1868        {        {
1869          throw new IOException("Failure invoking readObject() on " +          throw (IOException) new IOException(
1870                                 klass + ": " + x.getClass().getName());            "Failure invoking readObject() on " + klass).initCause(x);
1871        }        }
1872    
1873      // Invalidate fields which has been read through readFields.      // Invalidate fields which has been read through readFields.
# Line 1906  public class ObjectInputStream extends I Line 1895  public class ObjectInputStream extends I
1895    private Hashtable<Class,ObjectStreamClass> classLookupTable;    private Hashtable<Class,ObjectStreamClass> classLookupTable;
1896    private GetField prereadFields;    private GetField prereadFields;
1897    
   private ClassLoader callersClassLoader;  
1898    private static boolean dump;    private static boolean dump;
1899    
1900    // The nesting depth for debugging output    // The nesting depth for debugging output

Legend:
Removed from v.1.43.2.14  
changed lines
  Added in v.1.43.2.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26