harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r568862 - in /harmony/enhanced/classlib/branches/java6/modules/rmi/src: main/java/java/rmi/MarshalledObject.java test/api/java/org/apache/harmony/rmi/MarshalledObjectTest.java
Date Thu, 23 Aug 2007 07:21:23 GMT
Author: tonywu
Date: Thu Aug 23 00:21:21 2007
New Revision: 568862

URL: http://svn.apache.org/viewvc?rev=568862&view=rev
Log:
Apply patch for HARMONY-4672([classlib][rmi][java6] Add generic type parameter <T> for
java.rmi.MarshalledObject)

Modified:
    harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/MarshalledObject.java
    harmony/enhanced/classlib/branches/java6/modules/rmi/src/test/api/java/org/apache/harmony/rmi/MarshalledObjectTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/MarshalledObject.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/MarshalledObject.java?rev=568862&r1=568861&r2=568862&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/MarshalledObject.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/MarshalledObject.java
Thu Aug 23 00:21:21 2007
@@ -26,7 +26,7 @@
 import org.apache.harmony.rmi.MarshalledObjectInputStream;
 import org.apache.harmony.rmi.MarshalledObjectOutputStream;
 
-public final class MarshalledObject implements Serializable {
+public final class MarshalledObject<T> implements Serializable {
     private static final long serialVersionUID = 8988374069173025854L;
 
     private final byte[] objBytes;
@@ -35,7 +35,7 @@
 
     private final int hash;
 
-    public MarshalledObject(Object obj) throws IOException {
+    public MarshalledObject(T obj) throws IOException {
         ByteArrayOutputStream objStream = new ByteArrayOutputStream();
         MarshalledObjectOutputStream moStream = new MarshalledObjectOutputStream(objStream);
         moStream.writeObject(obj);
@@ -61,12 +61,12 @@
         return (hash == anotherObj.hash) || (Arrays.equals(objBytes, anotherObj.objBytes));
     }
 
-    public Object get() throws IOException, ClassNotFoundException {
+    public T get() throws IOException, ClassNotFoundException {
         if (objBytes == null) {
             return null;
         }
         MarshalledObjectInputStream moin = new MarshalledObjectInputStream(objBytes, locBytes);
-        return moin.readObject();
+        return (T) moin.readObject();
     }
 
     @Override

Modified: harmony/enhanced/classlib/branches/java6/modules/rmi/src/test/api/java/org/apache/harmony/rmi/MarshalledObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/rmi/src/test/api/java/org/apache/harmony/rmi/MarshalledObjectTest.java?rev=568862&r1=568861&r2=568862&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/rmi/src/test/api/java/org/apache/harmony/rmi/MarshalledObjectTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/rmi/src/test/api/java/org/apache/harmony/rmi/MarshalledObjectTest.java
Thu Aug 23 00:21:21 2007
@@ -56,6 +56,36 @@
     public MarshalledObjectTest(String name) {
         super(name);
     }
+    
+    /**
+     * @tests java.rmi.MarshalledObject<T>#MarshalledObject(T)
+     */
+    public void test_Constructor() throws Exception {
+        MarshalledObject marObject = 
+            new MarshalledObject<Integer>(new Integer(100));
+        assertNotNull(marObject);
+
+        Object object = null;
+        marObject = new MarshalledObject<Object>(object);
+        assertNotNull(marObject);
+    }
+
+    /**
+     * @tests java.rmi.MarshalledObject<T>#get()
+     */
+    public void test_get() throws Exception {
+        Hashtable object = new Hashtable();
+        object.put(new Integer(1), "One");
+        MarshalledObject<Hashtable> marObject = 
+            new MarshalledObject<Hashtable>(object);
+        assertEquals(object, marObject.get());
+        object.put(new Integer(2), "Two");
+        assertFalse(marObject.get().equals(object));
+        
+        object = null;
+        marObject = new MarshalledObject<Hashtable>(object);
+        assertNull(marObject.get());
+    }
 
     /**
      * Tests {@link MarshalledObject#equals(Object)} method.



Mime
View raw message