Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: dsR10051 Date: 12/15/2003 Filed By : SPB JCK team (###@###.###) JDK : java full version "1.5.0-beta-b30" JCK : 1.5 Platform[s] : Solaris switch/Mode : JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto Failing Test [s] : N/A Specification excerpt: ====================== --------- J2SE API spec v.1.5 --------- * @(#)Encoder.java 1.17 03/09/18 ... /** * Sets the persistence delegate associated with this <code>type</code> to * <code>persistenceDelegate</code>. * * @param type The class of objects that <code>persistenceDelegate</code> applies to. * @param persistenceDelegate The persistence delegate for instances of <code>type</code>. * * @see #getPersistenceDelegate * @see java.beans.Introspector#getBeanInfo * @see java.beans.BeanInfo#getBeanDescriptor */ public void setPersistenceDelegate(Class type, PersistenceDelegate persistenceDelegate) { ... ---------- end-of-excerpt --------------- Problem description =================== Javadoc for method of class java.beans.Encoder public void setPersistenceDelegate(Class type, PersistenceDelegate persistenceDelegate) says nothing about static nature for method behavior. If developer sets persistence delegate for one Encoder, this persistent delegate is used for another encoder instances to express the state of an instance of a given type. It should be documented. Minimized test demonstrates this bug. Minimized test: =============== ------- Test01.java ------- import java.io.ByteArrayOutputStream; import java.beans.*; public class Test01 { public static void main(String[] args) { ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLEncoder xml = new XMLEncoder(out); MyDelegate delegate = new MyDelegate("statement"); xml.setPersistenceDelegate(MyBean2.class, delegate); ByteArrayOutputStream out_new = new ByteArrayOutputStream(); XMLEncoder xml_new = new XMLEncoder(out_new); if (delegate == xml.getPersistenceDelegate(MyBean2.class)) { System.out.println("Failed: XMLEncoder has persistence delegate that has been set " + "for another XMLEncoder"); } else { System.out.println("OKAY"); } } } class MyDelegate extends PersistenceDelegate { public MyDelegate(String statement) { } protected Expression instantiate(Object obj, Encoder encoder) { return null; } protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) { } } MyBean2 public class MyBean2 { private String s; public MyBean2(String s) { setString(s); } public void setString(String s) { this.s = s; } public String getString() { return s; } } ------- end-of-Test01.java ------- Minimized test output: ====================== /set/java/jdk1.5.0/solaris/bin/java Test01 Failed: XMLEncoder has persistence delegate that has been set for another XMLEncoder JCK test source location: ========================== /java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests ======================================================================
|