Title: [2163] trunk: AbstractAttributedCharacterIteratorAttributeConverter (and therefore TextAttributeConverter) will check first if it can access the possible constants of the type by reflection.
Revision
2163
Author
joehni
Date
2013-11-27 15:26:36 -0600 (Wed, 27 Nov 2013)

Log Message

AbstractAttributedCharacterIteratorAttributeConverter (and therefore TextAttributeConverter) will check first if it can access the possible constants of the type by reflection. NoClassDefFoundError raised in GAE accessing the fields of restricted types by reflection will be handled.

Modified Paths

Diff

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/AbstractAttributedCharacterIteratorAttributeConverter.java (2162 => 2163)


--- trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/AbstractAttributedCharacterIteratorAttributeConverter.java	2013-11-27 21:14:42 UTC (rev 2162)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/AbstractAttributedCharacterIteratorAttributeConverter.java	2013-11-27 21:26:36 UTC (rev 2163)
@@ -66,7 +66,7 @@
     }
 
     public boolean canConvert(final Class type) {
-        return type == this.type;
+        return type == this.type && !attributeMap.isEmpty();
     }
 
     public String toString(final Object source) {
@@ -134,8 +134,11 @@
                     attributeMap.clear();
                 } catch (ObjectAccessException e) {
                     attributeMap.clear();
+                } catch (NoClassDefFoundError e) {
+                    attributeMap.clear();
                 }
             }
+            instanceMaps.put(type.getName(), attributeMap);
         }
         return this;
     }

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/core/util/Fields.java (2162 => 2163)


--- trunk/xstream/src/java/com/thoughtworks/xstream/core/util/Fields.java	2013-11-27 21:14:42 UTC (rev 2162)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/core/util/Fields.java	2013-11-27 21:26:36 UTC (rev 2163)
@@ -35,11 +35,13 @@
                     }
                 }
             }
-            if (field != null) {
+            if (field != null && !field.isAccessible()) {
                 field.setAccessible(true);
             }
         } catch (SecurityException e) {
             // active SecurityManager
+        } catch (NoClassDefFoundError e) {
+            // restricted type in GAE
         }
         return field;
     }
@@ -53,6 +55,8 @@
             return result;
         } catch (NoSuchFieldException e) {
             throw new IllegalArgumentException("Could not access " + type.getName() + "." + name + " field: " + e.getMessage());
+        } catch (NoClassDefFoundError e) {
+            throw new ObjectAccessException("Could not access " + type.getName() + "." + name + " field: " + e.getMessage());
         }
     }
 
@@ -61,6 +65,8 @@
             field.set(instance, value);
         } catch (IllegalAccessException e) {
             throw new ObjectAccessException("Could not write " + field.getType().getName() + "." + field.getName() + " field", e);
+        } catch (NoClassDefFoundError e) {
+            throw new ObjectAccessException("Could not write " + field.getType().getName() + "." + field.getName() + " field", e);
         }
     }
 
@@ -69,6 +75,8 @@
             return field.get(instance);
         } catch (IllegalAccessException e) {
             throw new ObjectAccessException("Could not read " + field.getType().getName() + "." + field.getName() + " field", e);
+        } catch (NoClassDefFoundError e) {
+            throw new ObjectAccessException("Could not read " + field.getType().getName() + "." + field.getName() + " field", e);
         }
     }
 }

Modified: trunk/xstream-distribution/src/content/changes.html (2162 => 2163)


--- trunk/xstream-distribution/src/content/changes.html	2013-11-27 21:14:42 UTC (rev 2162)
+++ trunk/xstream-distribution/src/content/changes.html	2013-11-27 21:26:36 UTC (rev 2163)
@@ -55,6 +55,9 @@
     		<li>SerializationConverter and ExternalizableConverter will check if they can create an instance of a derived
     		OutputObjectStream first.</li>
     		<li>BeanProvider does no longer use reflection to locate default constructor.</li>
+    		<li>AbstractAttributedCharacterIteratorAttributeConverter (and therefore TextAttributeConverter) will check first if it
+    		can access the possible constants of the type by reflection.</li>
+    		<li>NoClassDefFoundError raised in GAE accessing the fields of restricted types by reflection will be handled.</li>
     		<li>No need for reflection in StackTraceElementFactory anymore, Java 1.4 is required since long ago.</li>
     	</ul>
     	</li>

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to