Enhancements to the JavaBeansTM Component API in Java SE 6.0 |
Guide-Index |
Major Features
Fixed Bugs
@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 constructorDefaultPersistenceDelegate(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 thefruit
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:
- Eliminates the need for the developer to explicitly use the
DefaultPersistenceDelegate
class.- Describes the relationship between a constructor parameter and a property, but not an operational logic, therefore the annotation can be applied to both bean related areas, such as Long Term Persistence, and to non-beans related areas, such JMX.
6179222: Possible a
NullPointerException
error with theEventHandler
classThe NPR exception was thrown by the
EventHandler
class. Thecreate
method of theEventHandler
class checks thenull
value, and javadoc is corrected accordingly.6204552: The EventHandler documentation and exception handling problems
Documentation on the
EventHandler
class of theeventPropertyName
argument did not clearly explain waht the argument supports. Information about what theeventProperName
property is capable of is included in the documentation for thecreate
method.6210265: The
EventHandler
class should not cache theMethod
objectThe method search is improved, and the method is prevented from being cached in the
EventHandler
class field.6271692: The target property of the
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
class The following fixes were performed to improve the long-term persistence process.
6245149: The
java.beans.XMLEncoder
class does not encodejava.net.URI
objectsThe
Statement
class could not access a member of thejava.net.URI
class with modifiers private. In JDK 6.0 an appropriatePersistenceDelegate
is provided to solve this problem.4921212: The
XMLEncoder
class does not encodenull
entries inHashMap
objectsA null
Key
entry of theHashMap
object was not included into the XML output. The fix includes a nullKey
entry to the XML file.6256805: The
XMLEncoder
class emits invalid XMLThe
XMLEncoder
class produces an XML output only for valid XML characters. A newcode
attribute was introduced for a character element. Thecode
contains a hexadecimal value if it starts with "#". Otherwise it contains a decimal value.5015403: The
XMLEncoder
class does not encode enumerations correctlyThe
XMLEncoder
class was not serializing an enumeration correctly. TheEnumPersistenceDelegate
class, a new persistence delegate, was introduced to support the serialization of enum classes.4741757: The
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
, andjava.awt.Rectangle
.6338070: The
XMLDecoder
class ignores statements made to owner unless theread()
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 thereadObject()
method.6341798: The
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 thetoLowerCase
andtoUpperCase
methods are invoked in the English locale.6437265: Some
Component
object is missing during xml serializing
Container
objects were not serialized. The fix adds special behavior to the persistence delegate for containers withBorderLayout
.
Copyright © 1999-2006
Sun Microsystems, Inc.
All Rights Reserved.
|