<Beans Dev> XMLEncoder regression in OpenJDK
Matthew Hall
qualidafial at gmail.com
Wed Aug 15 23:37:20 UTC 2012
This bug was reported against and fixed in Sun JDK 6. See
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6852574 for background.
EnumPersistenceDelegate has a regression present in all versions of
OpenJDK, whereby any enum with custom methods (anonymous inner classes)
will fail to encode.
Example:
class Foo {
A(),
B() {
String bar() { return "aaa"; }
}
Foo() {}
String bar() { return "x"; }
}
For the value Foo.B, EnumPersistenceDelegate creates the expression
Enum.valueOf(e.getClass(), e.name()). However e.getClass() resolves not to
class Foo, but to anonymous inner class Foo$1.
When the expression is evaluated (prior to encoding),
Enum.valueOf(Foo$1.class, 'B') returns null since Foo$1 isn't considered an
enum class. Thus the original and encoded values do not match up, and
encoding fails.
EnumPersistenceDelegate should be patched to create the expression
Enum.valueOf(e.get*Declaring*Class(), e.name()) instead.
-Matthew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/beans-dev/attachments/20120815/ccb34557/attachment.html>
More information about the beans-dev
mailing list