harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r926547 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
Date Tue, 23 Mar 2010 12:57:45 GMT
Author: odeakin
Date: Tue Mar 23 12:57:45 2010
New Revision: 926547

URL: http://svn.apache.org/viewvc?rev=926547&view=rev
Log:
Apply patch for HARMONY-4307 ([classlib][luni] java.io.ObjectStreamField.getType() sometimes
returns null)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java?rev=926547&r1=926546&r2=926547&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
Tue Mar 23 12:57:45 2010
@@ -125,6 +125,7 @@ public class ObjectStreamField implement
         }
         this.name = name;
         this.typeString = signature.replace('.', '/').intern();
+        defaultResolve();
         this.isDeserialized = true;
     }
 
@@ -337,34 +338,13 @@ public class ObjectStreamField implement
             // primitive type declared in a serializable class
             typeString = String.valueOf(getTypeCode());
         }
+
         if (typeString.length() == 1) {
-            switch (typeString.charAt(0)) {
-                case 'I':
-                    type = Integer.TYPE;
-                    return;
-                case 'B':
-                    type = Byte.TYPE;
-                    return;
-                case 'C':
-                    type = Character.TYPE;
-                    return;
-                case 'S':
-                    type = Short.TYPE;
-                    return;
-                case 'Z':
-                    type = Boolean.TYPE;
-                    return;
-                case 'J':
-                    type = Long.TYPE;
-                    return;
-                case 'F':
-                    type = Float.TYPE;
-                    return;
-                case 'D':
-                    type = Double.TYPE;
-                    return;
+            if (defaultResolve()) {
+                return;
             }
         }
+
         String className = typeString.replace('/', '.');
         if (className.charAt(0) == 'L') {
             // remove L and ;
@@ -380,7 +360,7 @@ public class ObjectStreamField implement
     }
 
     /**
-     * Indicats whether this field is unshared.
+     * Indicates whether this field is unshared.
      * 
      * @return {@code true} if this field is unshared, {@code false} otherwise.
      */
@@ -391,4 +371,40 @@ public class ObjectStreamField implement
     void setUnshared(boolean unshared) {
         this.unshared = unshared;
     }
+
+    /**
+     * Resolves typeString into type. Returns true if the type is primitive
+     * and false otherwise.
+     */
+    private boolean defaultResolve() {
+        switch (typeString.charAt(0)) {
+            case 'I':
+                type = Integer.TYPE;
+                return true;
+            case 'B':
+                type = Byte.TYPE;
+                return true;
+            case 'C':
+                type = Character.TYPE;
+                return true;
+            case 'S':
+                type = Short.TYPE;
+                return true;
+            case 'Z':
+                type = Boolean.TYPE;
+                return true;
+            case 'J':
+                type = Long.TYPE;
+                return true;
+            case 'F':
+                type = Float.TYPE;
+                return true;
+            case 'D':
+                type = Double.TYPE;
+                return true;
+            default:
+                type = Object.class;
+                return false;
+        }
+    }
 }



Mime
View raw message