JDK-2146549 : LTP: DefaultPersistenceDelegate does not handle boolean properties in a superclass.
  • Type: Backport
  • Backport of: JDK-4950122
  • Component: client-libs
  • Sub-Component: java.beans
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2007-02-05
  • Updated: 2011-03-14
  • Resolved: 2007-03-28
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 6 JDK 7
6u2 b01Fixed 7Fixed
Description
A class with an immutable boolean property "ascending", accessed by the public method isAscending(), cannot be encoded using XMLEncoder on Java 6, even though the encoding succeeds on Java 5. I attached TestBean.java and SortCriteria.java to reproduce the bug:

1. Set Java 5 (as root):
; rm /usr/java
; ln -s /usr/jdk/jdk1.5.0_08 /usr/java
; java -version
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Server VM (build 1.5.0_08-b03, mixed mode)
;

2. Compile and run attached classes (as non-root):
; javac -cp . TestBean.java SortCriteria.java
; java -cp . TestBean
encoded: Count descending
decoded: Count descending
;

3. Set Java 6 (as root):
; rm /usr/java
; ln -s /usr/jdk/jdk1.6.0 /usr/java
; java -version
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b100)
Java HotSpot(TM) Server VM (build 1.6.0-rc-b100, mixed mode)
;

4. Compile and run attached classes (as non-root):
; javac -cp . TestBean.java SortCriteria.java
; java -cp . TestBean
java.lang.NoSuchMethodException: SortCriteria.getAscending
Continuing ...
java.lang.IllegalArgumentException
Continuing ...
java.lang.Exception: XMLEncoder: discarding statement XMLEncoder.writeObject(SortCriteria);
Continuing ...
encoded: Count descending
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at com.sun.beans.ObjectHandler.dequeueResult(ObjectHandler.java:139)
        at java.beans.XMLDecoder.readObject(XMLDecoder.java:201)
        at TestBean.main(TestBean.java:44)
;

This was reproducible on sparc and amd64.

Comments
EVALUATION It looks like regression after 4741757. But it is duplicate of 4950122 that is fixed in 7. So we should backport the fix of 4950122 into 6u2.
05-02-2007