changeset 439:9c1ee05d1f2e icedtea-2.2.5

8002068: Build broken: corba code changes unable to use new JDK 7 classes Reviewed-by: alanb, ahgross
author coffeys
date Wed, 31 Oct 2012 20:31:52 +0000
parents 1e843dd9b9e4
children 5a9a1b4aecd3
files src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java
diffstat 1 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java	Mon Feb 11 23:13:37 2013 +0000
+++ b/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java	Wed Oct 31 20:31:52 2012 +0000
@@ -56,6 +56,8 @@
 
 import java.util.Arrays;
 import java.util.Comparator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import com.sun.corba.se.impl.util.RepositoryId;
 
@@ -381,11 +383,23 @@
          */
     }
 
-    private static final class PersistentFieldsValue
-            extends ClassValue<ObjectStreamField[]> {
+    private static final class PersistentFieldsValue {
+        private final ConcurrentMap map = new ConcurrentHashMap();
+        private static final Object NULL_VALUE =
+            (PersistentFieldsValue.class.getName() + ".NULL_VALUE");
+
         PersistentFieldsValue() { }
 
-        protected ObjectStreamField[] computeValue(Class<?> type) {
+        ObjectStreamField[] get(Class type) {
+            Object value = map.get(type);
+            if (value == null) {
+                value = computeValue(type);
+                map.putIfAbsent(type, value);
+            }
+            return ((value == NULL_VALUE) ? null : (ObjectStreamField[])value);
+        }
+
+        private static Object computeValue(Class<?> type) {
             try {
                 Field pf = type.getDeclaredField("serialPersistentFields");
                 int mods = pf.getModifiers();
@@ -396,14 +410,15 @@
                         (java.io.ObjectStreamField[])pf.get(type);
                     return translateFields(fields);
                 }
-            } catch (NoSuchFieldException | IllegalAccessException |
-                    IllegalArgumentException | ClassCastException e) {
-            }
-            return null;
+            } catch (NoSuchFieldException e1) {
+            } catch (IllegalAccessException e2) {
+            } catch (IllegalArgumentException e3) {
+            } catch (ClassCastException e4) { }
+            return NULL_VALUE;
         }
 
         private static ObjectStreamField[] translateFields(
-            java.io.ObjectStreamField[] fields) {
+                java.io.ObjectStreamField[] fields) {
             ObjectStreamField[] translation =
                 new ObjectStreamField[fields.length];
             for (int i = 0; i < fields.length; i++) {
@@ -449,7 +464,7 @@
                  * If it is declared, use the declared serialPersistentFields.
                  * Otherwise, extract the fields from the class itself.
                  */
-                    fields = persistentFieldsValue.get(cl);
+                fields = persistentFieldsValue.get(cl);
 
                 if (fields == null) {
                     /* Get all of the declared fields for this
@@ -646,7 +661,6 @@
         superclass = null;
     }
 
-
     /*
      * Set the class this version descriptor matches.
      * The base class name and serializable hash must match.