Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (22 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/java/io/ObjectStreamClass.java

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* ObjectStreamClass.java -- Class used to write class information
    22   about serialized objects.
    3    Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation, Inc.
     3   Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation, Inc.
    44
    55This file is part of GNU Classpath.
     
    4545import java.lang.reflect.Method;
    4646import java.lang.reflect.Modifier;
     47
    4748import java.security.DigestOutputStream;
    4849import java.security.MessageDigest;
     
    7778      return null;
    7879
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
    7993    ObjectStreamClass osc = (ObjectStreamClass)classLookupTable.get (cl);
    8094
     
    181195
    182196  // Returns true iff the class that this ObjectStreamClass represents
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
    183219  // implements Serializable but does *not* implement Externalizable.
    184220  boolean isSerializable ()
     
    261297  {
    262298    this.clazz = cl;
     299
    263300    long class_uid = getClassUID (cl);
    264301    if (uid == 0)
    265       {
    266        uid = class_uid;
    267        return;
    268       }
    269    
    270     // Check that the actual UID of the resolved class matches the UID from
    271     // the stream.   
    272     if (uid != class_uid)
    273       {
    274        String msg = cl +
    275          ": Local class not compatible: stream serialVersionUID="
    276          + uid + ", local serialVersionUID=" + class_uid;
    277        throw new InvalidClassException (msg);
    278       }
     302      uid = class_uid;
     303    else
     304      {
     305        // Check that the actual UID of the resolved class matches the UID from
     306        // the stream.   
     307        if (uid != class_uid)
     308          {
     309            String msg = cl +
     310              ": Local class not compatible: stream serialVersionUID="
     311              + uid + ", local serialVersionUID=" + class_uid;
     312            throw new InvalidClassException (msg);
     313          }
     314      }
     315
     316    isProxyClass = clazz != null && Proxy.isProxyClass (clazz);
     317    ObjectStreamClass osc = (ObjectStreamClass)classLookupTable.get (clazz);
     318    if (osc == null)
     319      classLookupTable.put (clazz, this);
     320    superClass = lookupForClassObject (clazz.getSuperclass ());
     321    calculateOffsets ();
    279322  }
    280323
     
    329372    uid = 0;
    330373    flags = 0;
     374
    331375
    332376    clazz = cl;
     
    334378    setFlags (cl);
    335379    setFields (cl);
    336     uid = getClassUID (cl);
     380    // to those class nonserializable, its uid field is 0
     381    if ( (Serializable.class).isAssignableFrom (cl) && !isProxyClass)
     382      uid = getClassUID (cl);
    337383    superClass = lookup (cl.getSuperclass ());
    338384  }
     
    378424      Field serialPersistentFields
    379425        = cl.getDeclaredField ("serialPersistentFields");
     426
    380427      int modifiers = serialPersistentFields.getModifiers ();
    381428
     
    428475    try
    429476    {
     477
     478
     479
    430480      Field suid = cl.getDeclaredField ("serialVersionUID");
     481
    431482      int modifiers = suid.getModifiers ();
    432483
    433       if (Modifier.isStatic (modifiers) && Modifier.isFinal (modifiers))
    434         return suid.getLong (null);       
     484      if (Modifier.isStatic (modifiers)
     485          && Modifier.isFinal (modifiers)
     486          && suid.getType() == Long.TYPE)
     487        return suid.getLong (null);
    435488    }
    436489    catch (NoSuchFieldException ignore)
    437     {
    438     }
     490    {}
    439491    catch (IllegalAccessException ignore)
    440     {
    441     }
     492    {}
    442493
    443494    // cl didn't define serialVersionUID, so we have to compute it
    444495    try
    445496    {
    446       MessageDigest md = null;
    447       DigestOutputStream digest_out = null;
    448       DataOutputStream data_out = null;
    449 
     497      MessageDigest md;
    450498      try
    451499        {
     
    460508        }
    461509
    462       digest_out = new DigestOutputStream (nullOutputStream, md);
    463       data_out = new DataOutputStream (digest_out);
     510      DigestOutputStream digest_out =
     511        new DigestOutputStream (nullOutputStream, md);
     512      DataOutputStream data_out = new DataOutputStream (digest_out);
     513
    464514      data_out.writeUTF (cl.getName ());
    465515
     
    498548
    499549      // write class initializer method if present
    500       boolean has_init;
    501       try
    502       {
    503         has_init = hasClassInitializer (cl);
    504       }
    505       catch (NoSuchMethodError e)
    506       {
    507         has_init = false;
    508       }
    509 
    510       if (has_init)
     550      if (VMObjectStreamClass.hasClassInitializer (cl))
    511551      {
    512552        data_out.writeUTF ("<clinit>");
     
    565605    {
    566606      throw new RuntimeException ("The SHA algorithm was not found to use in computing the Serial Version UID for class "
    567                                   + cl.getName ());
     607                                  + cl.getName ());
    568608    }
    569609    catch (IOException ioe)
    570610    {
    571       throw new RuntimeException (ioe.getMessage ());
     611      throw new RuntimeException (ioe);
    572612    }
    573613  }
     
    583623        // as above in getDefinedSUID.
    584624        Field f = clazz.getDeclaredField ("getSerialPersistentFields");
     625
    585626        o = (ObjectStreamField[])f.get (null);
    586627      }
     
    593634
    594635    return o;
    595   }
    596 
    597 
    598   // Returns true if CLAZZ has a static class initializer
    599   // (a.k.a. <clinit>).
    600   //
    601   // A NoSuchMethodError is raised if CLAZZ has no such method.
    602   private static boolean hasClassInitializer (Class clazz)
    603     throws java.lang.NoSuchMethodError
    604   {
    605     Method m = null;
    606 
    607     try
    608       {
    609         Class classArgs[] = {};
    610         m = clazz.getDeclaredMethod ("<clinit>", classArgs);
    611       }
    612     catch (java.lang.NoSuchMethodException e)
    613       {
    614         throw new java.lang.NoSuchMethodError ();
    615       }
    616 
    617     return m != null;
    618636  }
    619637
     
    641659  int objectFieldCount;
    642660
     661
     662
    643663  // This is probably not necessary because this class is special cased already
    644664  // but it will avoid showing up as a discrepancy when comparing SUIDs.
    645665  private static final long serialVersionUID = -6120832682080437368L;
     666
    646667}
    647668
Note: See TracChangeset for help on using the changeset viewer.