- Timestamp:
- Apr 27, 2004, 8:39:34 PM (22 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
libjava/java/rmi/MarshalledObject.java (modified) (1 diff, 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/rmi/MarshalledObject.java
-
Property cvs2svn:cvs-rev
changed from
1.1to1.1.1.2
r1390 r1391 39 39 40 40 import java.io.Serializable; 41 42 43 44 41 45 46 47 48 42 49 public final class MarshalledObject 43 extends Object implements Serializable { 50 extends Object implements Serializable 51 { 52 53 //The following fields are from Java API Documentation "Serialized form" 54 private static final long serialVersionUID = 8988374069173025854L; 55 byte[] objBytes; 56 byte[] locBytes; 57 int hash; 58 59 public MarshalledObject(Object obj) throws java.io.IOException 60 { 61 ByteArrayOutputStream objStream = new ByteArrayOutputStream(); 62 RMIMarshalledObjectOutputStream stream = new RMIMarshalledObjectOutputStream(objStream); 63 stream.writeObject(obj); 64 stream.flush(); 65 objBytes = objStream.toByteArray(); 66 locBytes = stream.getLocBytes(); 67 68 //The following algorithm of calculating hashCode is similar to String 69 hash = 0; 70 for (int i = 0; i < objBytes.length; i++) 71 hash = hash * 31 + objBytes[i]; 72 if(locBytes != null) 73 for (int i = 0; i < locBytes.length; i++) 74 hash = hash * 31 + locBytes[i]; 75 } 76 77 public boolean equals(Object obj) 78 { 79 if(obj == null || !(obj instanceof MarshalledObject) ) 80 return false; 44 81 45 public MarshalledObject(Object obj) { 46 throw new Error("Not implemented"); 82 // hashCode even differs, don't do the time-consuming comparisons 83 if (obj.hashCode() != hash) 84 return false; 85 86 MarshalledObject aobj = (MarshalledObject)obj; 87 if (objBytes == null || aobj.objBytes == null) 88 return objBytes == aobj.objBytes; 89 if (objBytes.length != aobj.objBytes.length) 90 return false; 91 for (int i = 0; i < objBytes.length; i++) 92 { 93 if (objBytes[i] != aobj.objBytes[i]) 94 return false; 95 } 96 // Ignore comparison of locBytes(annotation) 97 return true; 98 } 99 100 public Object get() 101 throws java.io.IOException, java.lang.ClassNotFoundException 102 { 103 if(objBytes == null) 104 return null; 105 RMIMarshalledObjectInputStream stream = 106 new RMIMarshalledObjectInputStream(objBytes, locBytes); 107 return stream.readObject(); 47 108 } 48 49 public boolean equals(Object obj) { 50 throw new Error("Not implemented"); 109 110 public int hashCode() { 111 return hash; 112 } 113 51 114 } 52 53 public Object get() {54 throw new Error("Not implemented");55 }56 57 public int hashCode() {58 throw new Error("Not implemented");59 }60 61 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
