Title: [1966] trunk:

Diff

Modified: trunk/xstream/src/java/com/thoughtworks/xstream/core/JVM.java (1965 => 1966)


--- trunk/xstream/src/java/com/thoughtworks/xstream/core/JVM.java	2012-03-20 18:48:37 UTC (rev 1965)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/core/JVM.java	2012-03-21 00:29:42 UTC (rev 1966)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004, 2005, 2006 Joe Walnes.
- * Copyright (C) 2006, 2007, 2008, 2010, 2011 XStream Committers.
+ * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -211,15 +211,16 @@
     }
 
     public Class loadClass(String name) {
+        Class cached = (Class) loaderCache.get(name);
+        if (cached != null) {
+            return cached;
+        }
         try {
-            Class cached = (Class) loaderCache.get(name);
-            if (cached != null) {
-                return cached;
-            }
-            
-            Class clazz = Class.forName(name, false, getClass().getClassLoader());
+            Class clazz = Class.forName(name, true, getClass().getClassLoader());
             loaderCache.put(name, clazz);
             return clazz;
+        } catch (LinkageError e) {
+            return null;
         } catch (ClassNotFoundException e) {
             return null;
         }

Modified: trunk/xstream/src/test/com/thoughtworks/xstream/core/JVMTest.java (1965 => 1966)


--- trunk/xstream/src/test/com/thoughtworks/xstream/core/JVMTest.java	2012-03-20 18:48:37 UTC (rev 1965)
+++ trunk/xstream/src/test/com/thoughtworks/xstream/core/JVMTest.java	2012-03-21 00:29:42 UTC (rev 1966)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004, 2005 Joe Walnes.
- * Copyright (C) 2006, 2007 XStream Committers.
+ * Copyright (C) 2006, 2007, 2012 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -15,11 +15,11 @@
 
 public class JVMTest extends TestCase {
 
-    public void testDoesNotInsantiateStaticBlocksWhenLoadingClasses() {
+    public void testDoesIgnoreLinkageErrors() {
         try {
-            new JVM().loadClass("com.thoughtworks.xstream.core.EvilClass");
-        } catch (ExceptionInInitializerError error) {
-            fail("Static block was called");
+            assertNull(new JVM().loadClass("com.thoughtworks.xstream.core.EvilClass"));
+        } catch (LinkageError error) {
+            fail("Error thrown");
         }
     }
 }

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


--- trunk/xstream-distribution/src/content/changes.html	2012-03-20 18:48:37 UTC (rev 1965)
+++ trunk/xstream-distribution/src/content/changes.html	2012-03-21 00:29:42 UTC (rev 1966)
@@ -40,6 +40,8 @@
     <h2>Minor changes</h2>
     
     <ul>
+    	<li>JVM.loadClass will now also initialize the loaded class and ignore any occurring LinkageError.</li>
+    	<li>JIRA:XSTR-596: SubjectConverter will be no longer registered if initialization of javax.security.auth.Subject fails.</li>
     	<li>JIRA:XSTR-683: Inheritance of implicit collections, arrays or maps is dependent on declaration sequence.</li>
     	<li>Inherited implicit collections, arrays or maps can be overwritten with own definition in subtype.</li>
     	<li>JIRA:XSTR-688: Cannot omit XML elements from derived fields.</li>

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to