JDK-4763881 : REGRESSION: Class.getDeclaredFields() doesn't return Throwable.backtrace
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2002-10-16
  • Updated: 2014-02-06
  • Resolved: 2002-10-28
Related Reports
Relates :  
Relates :  
Description

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) 
======================================================================

Comments
EVALUATION Class.getDeclaredFields calls Class.privateGetDeclaredFields which calls native method Class.getDeclaredFields0 which is defined in the VM. -- iag@sfbay 2002-10-16 This is intended behavior. Only the field Throwable.backtrace is filtered out, as it represents internal data and cannot be further introspected. Please see bug 4496456 for further details. 4496456: Segmentation fault introspecting ((Throwable) obj).backtrace[0][0] We are investigating whether Throwable.backtrace would be needed since Throwable.stackTrace was added in 1.4. However, this bug will likely be closed as 'will not fix', because the behavior currently is what we expect. ###@###.### 2002-10-23
23-10-2002