harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r545053 - in /harmony/enhanced/classlib/branches/java6/modules/luni/src: main/java/java/io/ObjectStreamClass.java test/java/tests/api/java/io/ObjectStreamClassTest.java
Date Thu, 07 Jun 2007 03:47:38 GMT
Author: pyang
Date: Wed Jun  6 20:47:36 2007
New Revision: 545053

URL: http://svn.apache.org/viewvc?view=rev&rev=545053
Log:
Apply patch for HARMONY-4054([classlib][luni][java6]new method in java.io.ObjectStreamClass)

Modified:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java?view=diff&rev=545053&r1=545052&r2=545053
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamClass.java
Wed Jun  6 20:47:36 2007
@@ -869,6 +869,22 @@
 
         return lookupStreamClass(cl, true);
     }
+    
+    /**
+     * Return the descriptor (ObjectStreamClass) corresponding to the class
+     * <code>cl</code>. This method does not check whether the class
+     * implements Serializable or Externalizable.
+     * 
+     * @param cl
+     *            a java.lang.Class for which to obtain the corresponding
+     *            descriptor
+     * @return The corresponding descriptor for the specified class
+     * @since 1.6
+     */
+    public static ObjectStreamClass lookupAny(Class<?> cl) {
+        return isSerializable(cl) ? lookupStreamClass(cl, true)
+                : lookupStreamClass(cl, false);
+    }
 
     /**
      * Return the descriptor (ObjectStreamClass) corresponding to the class

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java?view=diff&rev=545053&r1=545052&r2=545053
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java
Wed Jun  6 20:47:36 2007
@@ -17,6 +17,10 @@
 
 package tests.api.java.io;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.io.ObjectStreamClass;
 import java.io.ObjectStreamField;
 import java.io.Serializable;
@@ -34,6 +38,33 @@
 			return serialVersionUID;
 		}
 	}
+    
+    /**
+     * @since 1.6 
+     */
+    static class NonSerialzableClass {
+        private static final long serialVersionUID = 1l;
+        public static long getUID() {
+            return serialVersionUID;
+        }
+    }
+    
+    /**
+     * @since 1.6
+     */
+    static class ExternalizableClass implements Externalizable {
+
+        private static final long serialVersionUID = -4285635779249689129L;
+
+        public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException
{
+            throw new ClassNotFoundException();
+        }
+
+        public void writeExternal(ObjectOutput output) throws IOException {
+            throw new IOException();
+        }
+        
+    }
 
 	/**
 	 * @tests java.io.ObjectStreamClass#forClass()
@@ -108,6 +139,33 @@
 						"tests.api.java.io.ObjectStreamClassTest$DummyClass"));
 	}
 
+    /**
+     * @tests java.io.ObjectStreamClass#lookupAny(java.lang.Class)
+     * @since 1.6
+     */
+    public void test_lookupAnyLjava_lang_Class() {
+        // Test for method java.io.ObjectStreamClass
+        // java.io.ObjectStreamClass.lookupAny(java.lang.Class)
+        ObjectStreamClass osc = ObjectStreamClass.lookupAny(DummyClass.class);
+        assertTrue("lookup returned wrong class: " + osc.getName(), osc
+                .getName().equals(
+                        "tests.api.java.io.ObjectStreamClassTest$DummyClass"));
+        
+        osc = ObjectStreamClass.lookupAny(NonSerialzableClass.class);
+        assertEquals("lookup returned wrong class: " + osc.getName(),
+                "tests.api.java.io.ObjectStreamClassTest$NonSerialzableClass",
+                osc.getName());
+        
+        osc = ObjectStreamClass.lookupAny(ExternalizableClass.class);        
+        assertEquals("lookup returned wrong class: " + osc.getName(),
+                "tests.api.java.io.ObjectStreamClassTest$ExternalizableClass",
+                osc.getName());
+
+        osc = ObjectStreamClass.lookup(NonSerialzableClass.class);
+        assertNull(osc);
+        
+    }
+    
 	/**
 	 * @tests java.io.ObjectStreamClass#toString()
 	 */



Mime
View raw message