Name: rmT116609 Date: 10/16/2002
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Reflection does not return transient fields for some java core classes. For example, class java.lang.Throwable has field "private transient Object backtrace" which is not included into the result of java.lang.Class.getDeclaredFields() method. There was no problem with 1.4.0_02. Lets note that private transient fields from a custom class (see attached sample program) are returned both under 1.4.0 and 1.4.1.
REGRESSION. Last worked in version 1.4
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run sample class TransientTest with 1.4.0
2. Run sample class TransientTest with 1.4.1
3. See the difference in output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Actual output under 1.4.1:
declaredField = public int TestClass.field1
declaredField = private transient int TestClass.field2
-----------------------------------
declaredField = private static final long
java.lang.Throwable.serialVersionUID
declaredField = private java.lang.String
java.lang.Throwable.detailMessage
declaredField = private java.lang.Throwable
java.lang.Throwable.cause
declaredField = private java.lang.StackTraceElement[]
java.lang.Throwable.stackTrace
Expected output under 1.4.1 (at the same time it is the
actual results for 1.4.0):
declaredField = public int TestClass.field1
declaredField = private transient int TestClass.field2
-----------------------------------
declaredField = private static final long
java.lang.Throwable.serialVersionUID
declaredField = private transient java.lang.Object
java.lang.Throwable.backtrace
declaredField = private java.lang.String
java.lang.Throwable.detailMessage
declaredField = private java.lang.Throwable
java.lang.Throwable.cause
declaredField = private java.lang.StackTraceElement[]
java.lang.Throwable.stackTrace
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
TransientTest class:
--------------------
import java.lang.reflect.Field;
public class TransientTest {
public static void main(String[] args) {
Field[] declaredFields = TestClass.class.getDeclaredFields();
for (int i = 0; i < declaredFields.length; i++) {
Field declaredField = declaredFields[i];
System.out.println("declaredField = " + declaredField);
}
System.out.println("-----------------------------------");
Class aClass = Throwable.class;
declaredFields = aClass.getDeclaredFields();
for (int i = 0; i < declaredFields.length; i++) {
Field declaredField = declaredFields[i];
System.out.println("declaredField = " + declaredField);
}
}
}
Test class:
-----------
public class TestClass {
public int field1;
private transient int field2;
}
---------- END SOURCE ----------
Release Regression From : 1.4.0_02
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 165844)
======================================================================