- Timestamp:
- Apr 27, 2004, 8:39:34 PM (22 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
libjava/java/io/ObjectStreamClass.java (modified) (15 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libjava/java/io/ObjectStreamClass.java
-
Property cvs2svn:cvs-rev
changed from
1.1to1.1.1.2
r1390 r1391 1 1 /* ObjectStreamClass.java -- Class used to write class information 2 2 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. 4 4 5 5 This file is part of GNU Classpath. … … 45 45 import java.lang.reflect.Method; 46 46 import java.lang.reflect.Modifier; 47 47 48 import java.security.DigestOutputStream; 48 49 import java.security.MessageDigest; … … 77 78 return null; 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 79 93 ObjectStreamClass osc = (ObjectStreamClass)classLookupTable.get (cl); 80 94 … … 181 195 182 196 // 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 183 219 // implements Serializable but does *not* implement Externalizable. 184 220 boolean isSerializable () … … 261 297 { 262 298 this.clazz = cl; 299 263 300 long class_uid = getClassUID (cl); 264 301 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 (); 279 322 } 280 323 … … 329 372 uid = 0; 330 373 flags = 0; 374 331 375 332 376 clazz = cl; … … 334 378 setFlags (cl); 335 379 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); 337 383 superClass = lookup (cl.getSuperclass ()); 338 384 } … … 378 424 Field serialPersistentFields 379 425 = cl.getDeclaredField ("serialPersistentFields"); 426 380 427 int modifiers = serialPersistentFields.getModifiers (); 381 428 … … 428 475 try 429 476 { 477 478 479 430 480 Field suid = cl.getDeclaredField ("serialVersionUID"); 481 431 482 int modifiers = suid.getModifiers (); 432 483 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); 435 488 } 436 489 catch (NoSuchFieldException ignore) 437 { 438 } 490 {} 439 491 catch (IllegalAccessException ignore) 440 { 441 } 492 {} 442 493 443 494 // cl didn't define serialVersionUID, so we have to compute it 444 495 try 445 496 { 446 MessageDigest md = null; 447 DigestOutputStream digest_out = null; 448 DataOutputStream data_out = null; 449 497 MessageDigest md; 450 498 try 451 499 { … … 460 508 } 461 509 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 464 514 data_out.writeUTF (cl.getName ()); 465 515 … … 498 548 499 549 // 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)) 511 551 { 512 552 data_out.writeUTF ("<clinit>"); … … 565 605 { 566 606 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 ()); 568 608 } 569 609 catch (IOException ioe) 570 610 { 571 throw new RuntimeException (ioe .getMessage ());611 throw new RuntimeException (ioe); 572 612 } 573 613 } … … 583 623 // as above in getDefinedSUID. 584 624 Field f = clazz.getDeclaredField ("getSerialPersistentFields"); 625 585 626 o = (ObjectStreamField[])f.get (null); 586 627 } … … 593 634 594 635 return o; 595 }596 597 598 // Returns true if CLAZZ has a static class initializer599 // (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.NoSuchMethodError604 {605 Method m = null;606 607 try608 {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;618 636 } 619 637 … … 641 659 int objectFieldCount; 642 660 661 662 643 663 // This is probably not necessary because this class is special cased already 644 664 // but it will avoid showing up as a discrepancy when comparing SUIDs. 645 665 private static final long serialVersionUID = -6120832682080437368L; 666 646 667 } 647 668 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
