![]() | Documentation Contents |
Enhancements to the JavaBeansTM Component API in Java SE 6.0 |
Major Features
Fixed Bugs
@ConstructorProperties annotationThe
@ConstructorPropertiesannotation 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
Foodproperties 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
vegetableobject with the same properties that thefruitobject 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
DefaultPersistenceDelegateclass.- 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
NullPointerExceptionerror with theEventHandlerclassThe NPR exception was thrown by the
EventHandlerclass. Thecreatemethod of theEventHandlerclass checks thenullvalue, and javadoc is corrected accordingly.6204552: The EventHandler documentation and exception handling problems
Documentation on the
EventHandlerclass of theeventPropertyNameargument did not clearly explain waht the argument supports. Information about what theeventProperNameproperty is capable of is included in the documentation for thecreatemethod.6210265: The
EventHandlerclass should not cache theMethodobjectThe method search is improved, and the method is prevented from being cached in the
EventHandlerclass field.6271692: The target property of the
EventHandlerclass 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.
6245149: The
java.beans.XMLEncoderclass does not encodejava.net.URIobjectsThe
Statementclass could not access a member of thejava.net.URIclass with modifiers private. In JDK 6.0 an appropriatePersistenceDelegateis provided to solve this problem.4921212: The
XMLEncoderclass does not encodenullentries inHashMapobjectsA null
Keyentry of theHashMapobject was not included into the XML output. The fix includes a nullKeyentry to the XML file.6256805: The
XMLEncoderclass emits invalid XMLThe
XMLEncoderclass produces an XML output only for valid XML characters. A newcodeattribute was introduced for a character element. Thecodecontains a hexadecimal value if it starts with "#". Otherwise it contains a decimal value.5015403: The
XMLEncoderclass does not encode enumerations correctlyThe
XMLEncoderclass was not serializing an enumeration correctly. TheEnumPersistenceDelegateclass, a new persistence delegate, was introduced to support the serialization of enum classes.4741757: The
XMLEncoderclass ignores persistence delegates when used with Java Web StartA
DefaultPersistenceDelegateclass 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
XMLDecoderclass 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
XMLDecoderclass fails when using Turkish LocaleThe
XMLDecoderclass did not function correctly when reading an English XML file on a machine with the locale set to Turkish. To fix this bug thetoLowerCaseandtoUpperCasemethods are invoked in the English locale.6437265: Some
Componentobject is missing during xml serializing
Containerobjects were not serialized. The fix adds special behavior to the persistence delegate for containers withBorderLayout.
Copyright © 1993, 2010, Oracle and/or its affiliates. All rights reserved. Please send comments using this Feedback page. |
Java Technology |