Name: dsR10051 Date: 06/07/2001
The method
java.beans.Encoder.setPersistenceDelegate(Class type, PersistenceDelegate persistenceDelegate)
works incorrectly if value of type parameter is null.
In this case it throws NullPointerException while
Encoder.getPersistentDelegate(Class type)
returns internal persistence delegate for null parameter.
So, user can not set own PersistentDelegate in this case.
It should be fixed or documented.
Here is minimized test:
import java.beans.*;
public class EncoderTest01 {
public static void main(String[] args) {
Encoder enc = new Encoder();
Class type = null;
PersistenceDelegate nullPD = enc.getPersistenceDelegate(type);
System.out.println(nullPD);
enc.setPersistenceDelegate(type, nullPD);
System.out.println("OKAY");
}
}
--- Output ---
$java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
$java EncoderTest01
java.beans.NullPersistenceDelegate@74a24a
Exception in thread "main" java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:320)
at java.beans.MetaData.getBeanInfo(MetaData.java:801)
at java.beans.MetaData.setPersistenceDelegate(MetaData.java:728)
at java.beans.Encoder.setPersistenceDelegate(Encoder.java:154)
at EncoderTest01.main(EncoderTest01.java:10)
======================================================================