JDK-4968709 : JCK: java.beans.PropertyEditorManager.findEditor works incorrectly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2003-12-15
  • Updated: 2004-03-15
  • Resolved: 2004-03-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b43Fixed
Related Reports
Relates :  
Description

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


Problem description
===================
Method of class java.beans.PropertyEditorManager
public static synchronized PropertyEditor findEditor(Class targetType)
could not find editors for primitive type wrapters if 
editor search path has been changed and restored before.
Minimized test demonstrates this bug.
    
Minimized test:
===============
------- PropertyEditorTest01.java -------
import java.beans.*;

public class PropertyEditorTest01 {

    public static void main (String[] args) {
        String oldPath[] = PropertyEditorManager.getEditorSearchPath();
        String newPath[] = {"aaa.bbb", "aaa.ccc"};
        PropertyEditorManager.setEditorSearchPath(newPath);
        PropertyEditor pe = null;
        pe = PropertyEditorManager.findEditor(Argle.class);

        PropertyEditorManager.setEditorSearchPath(oldPath);
        pe = PropertyEditorManager.findEditor(java.lang.Double.TYPE);
        if (pe == null) {
            System.out.println("Failed: could not find editor for " + java.lang.Double.TYPE);
        } else {
            System.out.println("OKAY");
        }
    }
}

Argle.java
public class Argle {
    public Argle () {}
}

------- end-of-PropertyEditorTest01.java -------

JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests

======================================================================

Minimized test output:                                                                                                               
======================                                                                                                               
/set/java/jdk1.5.0/solaris/bin/java PropertyEditorTest01                                                                             
load of aaa.ccc.ByteEditor failed                                                                                                    
load of aaa.ccc.ShortEditor failed                                                                                                   
load of aaa.ccc.IntEditor failed                                                                                                     
load of aaa.ccc.LongEditor failed                                                                                                    
load of aaa.ccc.BoolEditor failed                                                                                                    
load of aaa.ccc.FloatEditor failed                                                                                                   
load of aaa.ccc.DoubleEditor failed                                                                                                  
Failed: could not find editor for double                                                                                             
                                                                                                                                     
                                                                                                                                     
Failing Test [s] :                                                                                                                   
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0012]                                 
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0013]                                 
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0014]                                 
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0015]                                 
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0016]                                 
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0017]                                 
    api/java_beans/PropertyEditorManager/descriptions.html#PropertyEditor[PropertyEditorManager0018]
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b43 tiger-beta2
14-06-2004

SUGGESTED FIX When the editor search path has changed, the registry shold be flushed since it contains references to the old registry. OR The sun.beans.editors primitive editors should *always* be in the registry unless explicitly overriden by the developer. --- My solution does the second, ensuring that the primitive editors are loaded before changing the search path. *** /home/bchristi/jano/bchristi/swing-new/webrev/./src/share/classes/java/beans/PropertyEditorManager.java- Fri Feb 27 13:45:27 2004 --- PropertyEditorManager.java Fri Feb 27 13:41:03 2004 *** 145,154 **** --- 145,155 ---- public static synchronized void setEditorSearchPath(String path[]) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPropertiesAccess(); } + initialize(); if (path == null) { path = new String[0]; } searchPath = path; } ###@###.### 2004-02-27
27-02-2004

EVALUATION This bug has been in the API forever. The problem is that that Hashtable that holds loads the primitive editors in the table assumes that the editors are in the sun.beans.editors package. Changing the search path before the default editors have been loaded will make them unreachable. Since the javadoc mentions that default editors will be provided, this should be fixed. ###@###.### 2004-01-12 Initializing the PropertyEditorManager (and therefore loading the default primitive editors) before changing the search path fixes this bug. ###@###.### 2004-02-27
12-01-2004