JDK-8060027 : Tests java/beans/XMLEncoder/Test4903007.java and java/beans/XMLEncoder/java_awt_GridBagLayout.java
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-10-09
  • Updated: 2021-11-05
  • Resolved: 2015-09-07
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 8 JDK 9 Other
8u270Fixed 9 b83Fixed openjdk8u322Fixed
Related Reports
Relates :  
Relates :  
Description
Test name(s):java/beans/XMLEncoder/Test4903007.java           
                       java/beans/XMLEncoder/java_awt_GridBagLayout.java
JDK tested: 9b32,9b31,9b30
OS tested:Windows,Linux
Is it a regression? Yes
Regression introduced in release/build: b31
                     
Is it platform specific? No 
            
The is failure reproduced:Windows,Linux

java/beans/XMLEncoder/Test4903007.java      
----------System.err:(50/3767)----------
java.lang.Error: unexpected exception
	at AbstractTest.exceptionThrown(AbstractTest.java:39)
	at com.sun.beans.decoder.DocumentHandler.handleException(DocumentHandler.java:359)
	at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:126)
	at com.sun.beans.decoder.ObjectElementHandler.startElement(ObjectElementHandler.java:113)
	at com.sun.beans.decoder.DocumentHandler.startElement(DocumentHandler.java:300)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:508)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1342)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2785)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:509)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:868)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:797)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:140)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1212)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:332)
	at com.sun.beans.decoder.DocumentHandler$1.run(DocumentHandler.java:375)
	at com.sun.beans.decoder.DocumentHandler$1.run(DocumentHandler.java:372)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
	at com.sun.beans.decoder.DocumentHandler.parse(DocumentHandler.java:372)
	at java.beans.XMLDecoder$1.run(XMLDecoder.java:201)
	at java.beans.XMLDecoder$1.run(XMLDecoder.java:199)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.beans.XMLDecoder.parsingComplete(XMLDecoder.java:199)
	at java.beans.XMLDecoder.readObject(XMLDecoder.java:250)
	at AbstractTest.readObject(AbstractTest.java:151)
	at AbstractTest.testObject(AbstractTest.java:133)
	at AbstractTest.test(AbstractTest.java:103)
	at Test4903007.main(Test4903007.java:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchFieldException: Field 'width' is not static
	at com.sun.beans.finder.FieldFinder.findStaticField(FieldFinder.java:99)
	at com.sun.beans.decoder.FieldElementHandler.findField(FieldElementHandler.java:186)
	at com.sun.beans.decoder.FieldElementHandler.getFieldValue(FieldElementHandler.java:158)
	at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:141)
	at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123)
	... 34 more

JavaTest Message: Test threw exception: java.lang.Error: unexpected exception
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.Error: unexpected exception

java/beans/XMLEncoder/java_awt_GridBagLayout.java
----------System.err:(50/3793)----------
java.lang.Error: unexpected exception
	at AbstractTest.exceptionThrown(AbstractTest.java:39)
	at com.sun.beans.decoder.DocumentHandler.handleException(DocumentHandler.java:359)
	at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:126)
	at com.sun.beans.decoder.ObjectElementHandler.startElement(ObjectElementHandler.java:113)
	at com.sun.beans.decoder.DocumentHandler.startElement(DocumentHandler.java:300)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:508)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1342)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2785)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:509)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:868)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:797)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:140)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1212)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:332)
	at com.sun.beans.decoder.DocumentHandler$1.run(DocumentHandler.java:375)
	at com.sun.beans.decoder.DocumentHandler$1.run(DocumentHandler.java:372)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
	at com.sun.beans.decoder.DocumentHandler.parse(DocumentHandler.java:372)
	at java.beans.XMLDecoder$1.run(XMLDecoder.java:201)
	at java.beans.XMLDecoder$1.run(XMLDecoder.java:199)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.beans.XMLDecoder.parsingComplete(XMLDecoder.java:199)
	at java.beans.XMLDecoder.readObject(XMLDecoder.java:250)
	at AbstractTest.readObject(AbstractTest.java:151)
	at AbstractTest.testObject(AbstractTest.java:133)
	at AbstractTest.test(AbstractTest.java:103)
	at java_awt_GridBagLayout.main(java_awt_GridBagLayout.java:43)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchFieldException: Field 'gridwidth' is not static
	at com.sun.beans.finder.FieldFinder.findStaticField(FieldFinder.java:99)
	at com.sun.beans.decoder.FieldElementHandler.findField(FieldElementHandler.java:186)
	at com.sun.beans.decoder.FieldElementHandler.getFieldValue(FieldElementHandler.java:158)
	at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:141)
	at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123)
	... 34 more

JavaTest Message: Test threw exception: java.lang.Error: unexpected exception
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.Error: unexpected exception

Comments
Fix request (8u) Backport is requested for parity with 8u-oracle. Patch applies cleanly with the path change. Testing: checked that added test fails without the patch and passes with the patch, ran jtreg:java/beans/XMLEncoder . 8u exported commit: https://cr.openjdk.java.net/~akasko/jdk8u/8060027/8060027_8u.patch
03-11-2021

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/f7b346d83034 User: lana Date: 2015-09-23 23:04:33 +0000
23-09-2015

URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/f7b346d83034 User: serb Date: 2015-09-07 20:31:21 +0000
07-09-2015

Short description: XMLEncoder incorrectly reference a non static fields when this fields were assigned to some other fields. The bug was uncovered by some existing tests after the fix for [1]. Long description: The next code is serialized incorrectly: public static final class Test { public Integer integer_10_default = new Integer(10); public Integer integer_10_set1; // will be set to the same as default } Result: <?xml version="1.0" encoding="UTF-8"?> <java version="1.9.0-internal" class="java.beans.XMLDecoder"> <object class="FieldsEncode$Test" id="FieldsEncode$Test0"> <void class="FieldsEncode$Test" method="getField"> <string>integer_10_set1</string> <void method="set"> <object idref="FieldsEncode$Test0"/> <object class="FieldsEncode$Test" field="integer_10_default"/> </void> </void> </object> </java> Note that the encoder reference to the integer_10_default as a static field. So when the decoder will try to load it, it will fail: java.lang.NoSuchFieldException: Field 'integer_10_default' is not static at com.sun.beans.finder.FieldFinder.findStaticField(FieldFinder.java:99) at com.sun.beans.decoder.FieldElementHandler.findField(FieldElementHandler.java:186) at com.sun.beans.decoder.FieldElementHandler.getFieldValue(FieldElementHandler.java:158) at com.sun.beans.decoder.ObjectElementHandler.getValueObject(ObjectElementHandler.java:141) at com.sun.beans.decoder.NewElementHandler.getValueObject(NewElementHandler.java:123) at com.sun.beans.decoder.ObjectElementHandler.startElement(ObjectElementHandler.java:113) at com.sun.beans.decoder.DocumentHandler.startElement(DocumentHandler.java:300) After the fix we will use "<object class=" only for static field, and resulted xml will be: <?xml version="1.0" encoding="UTF-8"?> <java version="1.9.0-internal" class="java.beans.XMLDecoder"> <object class="FieldsEncode$Test" id="FieldsEncode$Test0"> <void class="FieldsEncode$Test" method="getField"> <string>integer_10_set1</string> <void method="set"> <object idref="FieldsEncode$Test0"/> <void class="FieldsEncode$Test" id="Field0" method="getField"> <string>integer_10_default</string> <void id="Integer0" method="get"> <object idref="FieldsEncode$Test0"/> </void> </void> <object idref="Integer0"/> </void> </void> </object> </java> Note that in this case we will access the integer_10_default using getField. The new test which covers this issue in general is provided.
25-08-2015

Regression of JDK-5043030
15-08-2015

RULE java/beans/XMLEncoder/Test4903007.java Exception java.lang.Error: unexpected exception RULE java/beans/XMLEncoder/Test4903007.java Exception java.lang.NoSuchFieldException: Field 'width' is not static RULE java/beans/XMLEncoder/java_awt_GridBagLayout.java Exception java.lang.Error: unexpected exception RULE java/beans/XMLEncoder/java_awt_GridBagLayout.java Exception java.lang.NoSuchFieldException: Field 'gridwidth' is not static
09-10-2014