JDK-8000949 : REGRESSION:Java 7's JavaBeans persistence ignoring the "transient" flag on properties
  • Type: Backport
  • Backport of: JDK-7193977
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 7u6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2012-10-15
  • Updated: 2013-09-12
  • Resolved: 2012-10-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u10 b12Fixed 8Fixed
Description
Java 7's JavaBeans persistence ignoring the "transient" flag on properties

but XMLEncoder is not ignoring "transient".

Rather the JavaBeans Introspector is somehow dropping "transient" from 1 of 2 properties when composing the subclass BeanInfo.  In the parent class' BeanInfo "transient" is present on both properties.  In the subclass, however, it is only present on 1 of the 2 properties.  Java 6 doesn't have this issue.  

Have a BeanInfo class, InfoBeanInfo, for a base class, Info, that
marks the CustomDelegateFactory property (any capitalization thereof)
as transient and PropertyDescriptor.setValue( "transient", Boolean.TRUE ).

This is obeyed just fine in testing with the Java 6 Update 34 when
outputting instances of subclasses of Info.  This seems to be ignored
by the test JDK provided -- resulting in undesirable output.

Checked Java 7 Update 6 and it also seems to ignore this BeanInfo.
Note that although the classes reside in various packages, they're all in one directory 

The test execution is encapsulated in Test.main().

Java 6 Update 34 produces:

    INFO (BASE CLASS) TRANSIENT PROPERTIES:
    ---------------------------------------
    customDelegateFactory
    customDelegateFactoryClass

    SUMMARY (SUB-CLASS) TRANSIENT PROPERTIES:
    -----------------------------------------
    customDelegateFactory
    customDelegateFactoryClass

Java 7 Update 6 produces:

    INFO (BASE CLASS) TRANSIENT PROPERTIES:
    ---------------------------------------
    customDelegateFactory
    customDelegateFactoryClass

    SUMMARY (SUB-CLASS) TRANSIENT PROPERTIES:
    -----------------------------------------
    customDelegateFactoryClass

Note that 'customDelegateFactory' is transient in the Info class' BeanInfo in both cases, but is not transient in the Summary class' BeanInfo in Java 7.