@ConstructorProperties
annotationThe
@ConstructorProperties
annotation was introduced
in Java SE 6.0 to show how the parameters of annotated constructor
correspond to an object's properties. Previously, the constructor
DefaultPersistenceDelegate(String[]
constructorPropertyNames)
was used for the same goal, but
was not an appropriate approach for library classes.
Technically, an annotation is used for copying beans with
read-only properties. In the following code example the
Food
properties are read-only.
public class Food { private final int varieties; private final String country; @ConstructorProperties({"varieties", "country"}) public Point(int varieties, String country) { this.varieties = varieties; this.country = country; } public int getVarieties() { return this.varieties; } public String getCountry() { return this.country; } }
To create a vegetable
object with the same
properties that the fruit
object has, use the
following code:
Food fruit = new Food (5, "Argentina"); Food vegetable = new Food (fruit.getVarieties(), fruit.getCountry());Defining the annotation accomplishes two goals:
DefaultPersistenceDelegate
class.NullPointerException
error with the
EventHandler
classThe NPR exception was thrown by the EventHandler
class. The create
method of the
EventHandler
class checks the null
value,
and javadoc is corrected accordingly.
Documentation on the EventHandler
class of the
eventPropertyName
argument did not clearly explain
waht the argument supports. Information about what the
eventProperName
property is capable of is included in
the documentation for the
create
method.
EventHandler
class should not cache the
Method
objectThe method search is improved, and the method is prevented from
being cached in the EventHandler
class field.
EventHandler
class did support
same syntax as the event propertyThe target property syntax is fixed and now supports an arbitrary number of methods or properties. This was accomplished by separating each property or method with a ".".
XMLEncoder
classThe following fixes were performed to improve the long-term persistence process.
java.beans.XMLEncoder
class does not encode
java.net.URI
objectsThe Statement
class could not access a member of
the java.net.URI
class with modifiers private. In JDK
6.0 an appropriate PersistenceDelegate
is provided to
solve this problem.
XMLEncoder
class does not encode null
entries in HashMap
objectsA null Key
entry of the HashMap
object
was not included into the XML output. The fix includes a null
Key
entry to the XML file.
XMLEncoder
class emits invalid XMLThe XMLEncoder
class produces an XML output only
for valid XML characters. A new code
attribute was
introduced for a character element. The code
contains
a hexadecimal value if it starts with "#". Otherwise it
contains a decimal value.
XMLEncoder
class does not encode enumerations
correctlyThe XMLEncoder
class was not serializing an
enumeration correctly. The EnumPersistenceDelegate
class, a new persistence delegate, was introduced to support the
serialization of enum classes.
XMLEncoder
class ignores persistence delegates when
used with Java Web StartA DefaultPersistenceDelegate
class for some classes
was created improperly. As a result the hack that adds field access
for properties and breaking JavaBeans specification was detected.
The performed fix removes the hack that was intended for the
following classes: java.awt.Dimension
,
java.awt.Point
, and
java.awt.Rectangle
.
XMLDecoder
class ignores statements made to owner
unless the read()
method is calledInitially the XMLDecoder class was created with lazy
initialization. The fix enables parsing in the close()
method if a file is not parsed by the readObject()
method.
XMLDecoder
class fails when using Turkish LocaleThe XMLDecoder
class did not function correctly
when reading an English XML file on a machine with the locale set
to Turkish. To fix this bug the toLowerCase
and
toUpperCase
methods are invoked in the English
locale.
Component
object is missing during xml
serializingContainer
objects were not serialized. The fix adds
special behavior to the persistence delegate for containers with
BorderLayout
.