Documentation Contents

Enhancements to the JavaBeans Component API in Java SE 6.0

java.beans

Major Features
Fixed Bugs

Major Features

The @ConstructorProperties annotation

The @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:

Fixed Bugs

The EventHandler class

6179222: Possible a NullPointerException error with the EventHandler class

The NPR exception was thrown by the EventHandler class. The create method of the EventHandler class checks the null value, and javadoc is corrected accordingly.

6204552: The EventHandler documentation and exception handling problems

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.

6210265: The EventHandler class should not cache the Method object

The 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 property

The 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 ".".

 

The XMLEncoder class

The following fixes were performed to improve the long-term persistence process.

6245149: The java.beans.XMLEncoder class does not encode java.net.URI objects

The 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.

4921212: The XMLEncoder class does not encode null entries in HashMap objects

A 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.

6256805: The XMLEncoder class emits invalid XML

The 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.

5015403: The XMLEncoder class does not encode enumerations correctly

The XMLEncoder class was not serializing an enumeration correctly. The EnumPersistenceDelegate 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 Start

A 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.

6338070: The XMLDecoder class ignores statements made to owner unless the read() method is called

Initially 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.

6341798: The XMLDecoder class fails when using Turkish Locale

The 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.

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 with BorderLayout.

 

 

 

 

 


Oracle and/or its affiliates Copyright © 1993, 2022, Oracle and/or its affiliates. All rights reserved.
Contact Us