Log Message
Fix usage of StackTraceElement constructor, that is not yet available for Java 1.4.
Modified Paths
- branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java
- branches/v-1.4.x/xstream-distribution/src/content/changes.html
Property Changed
Diff
Property changes: branches/v-1.4.x
Modified: svn:mergeinfo
Modified: branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java (2165 => 2166)
--- branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java 2013-12-02 23:55:50 UTC (rev 2165)
+++ branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java 2013-12-03 00:11:14 UTC (rev 2166)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004 Joe Walnes.
- * Copyright (C) 2006, 2007, 2013 XStream Committers.
+ * Copyright (C) 2006, 2007 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -11,8 +11,13 @@
*/
package com.thoughtworks.xstream.converters.extended;
+import com.thoughtworks.xstream.converters.ConversionException;
+
+import java.lang.reflect.Field;
+
/**
* Factory for creating StackTraceElements.
+ * Factory for creating StackTraceElements.
*
* @author <a href="" K. Oxley (binkley)</a>
* @author Joe Walnes
@@ -36,6 +41,22 @@
}
private StackTraceElement create(String declaringClass, String methodName, String fileName, int lineNumber) {
- return new StackTraceElement(declaringClass, methodName, fileName, lineNumber);
+ StackTraceElement result = new Throwable().getStackTrace()[0];
+ setField(result, "declaringClass", declaringClass);
+ setField(result, "methodName", methodName);
+ setField(result, "fileName", fileName);
+ setField(result, "lineNumber", new Integer(lineNumber));
+ return result;
}
+
+ private void setField(StackTraceElement element, String fieldName, Object value) {
+ try {
+ final Field field = StackTraceElement.class.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ field.set(element, value);
+ } catch (Exception e) {
+ throw new ConversionException(e);
+ }
+ }
+
}
Modified: branches/v-1.4.x/xstream-distribution/src/content/changes.html (2165 => 2166)
--- branches/v-1.4.x/xstream-distribution/src/content/changes.html 2013-12-02 23:55:50 UTC (rev 2165)
+++ branches/v-1.4.x/xstream-distribution/src/content/changes.html 2013-12-03 00:11:14 UTC (rev 2166)
@@ -58,7 +58,6 @@
<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>
<li>JIRA:XSTR-739 and JIRA:XSTR-746: OrderRetainingMap fails if HashMap.putAll(Map) of Java Runtime is not
To unsubscribe from this list please visit:
