Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6736248
Votes 0
Synopsis EnumEditor bug. Class check incorrect
Category java:classes_beans
Reported Against
Release Fixed 7(b46), 6-open(b16) (Bug ID:2166245)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 6710708
Submit Date 12-AUG-2008
Description
FULL PRODUCT VERSION :
openjdk version "1.6.0-internal"
OpenJDK Runtime Environment (build 1.6.0-internal-langel_02_jun_2008_10_58-b00)
OpenJDK Server VM (build 10.0-b19, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
$ uname -a
Linux towel.yyz. customer .com 2.6.25.9-76.fc9.i686 #1 SMP Fri Jun 27 16:14:35 EDT 2008 i686 i686 i386 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
maven2 must be installed

A DESCRIPTION OF THE PROBLEM :
download: http://www.opennms.org/~brozow/enum-spring-test.tar.gz
install maven2. untar and run:
$ mvn test -e


Reference: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=181

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
download: http://www.opennms.org/~brozow/enum-spring-test.tar.gz
install maven2. untar and run:
$ mvn test -e


Reference: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=181

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No Failures
ACTUAL -
1 Failure




ERROR MESSAGES/STACK TRACES THAT OCCUR :
-------------------------------------------------------------------------------
Test set: org.openjdk.test.BeanWrapperTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.189 sec <<<
FAILURE!
testBeanWrapper(org.openjdk.test.BeanWrapperTest)  Time elapsed: 0.13 sec  <<<
ERROR!
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property
value of type [java.lang.String] to required type
[org.openjdk.test.RelativeTime] for property 'time'; nested exception is
java.lang.IllegalArgumentException: Unsupported value: YESTERDAY
        at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:855)
        at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:55)
        at
org.openjdk.test.BeanWrapperTest.testBeanWrapper(BeanWrapperTest.java:30)
Caused by: java.lang.IllegalArgumentException: Unsupported value: YESTERDAY
        at sun.beans.editors.EnumEditor.setValue(EnumEditor.java:71)
        at sun.beans.editors.EnumEditor.setAsText(EnumEditor.java:101)
        at
org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:374)
        at
org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:350)
        at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
        at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
        at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:832)
        ... 31 more


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
download: http://www.opennms.org/~brozow/enum-spring-test.tar.gz
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
--- openjdkold/jdk/src/share/classes/sun/beans/editors/EnumEditor.java  2008-07-10 15:57:13.000000000 -0400
+++ openjdk/jdk/src/share/classes/sun/beans/editors/EnumEditor.java     2008-08-11 15:07:05.000000000 -0400
@@ -67,7 +67,7 @@
     }

     public void setValue( Object value ) {
-        if ( ( value != null ) && ( this.type != value.getClass() ) ) {
+       if ( ( value != null ) && ! ( this.type.isInstance( value ) ) ) {
             throw new IllegalArgumentException( "Unsupported value: " + value );
         }
         Object oldValue;
Posted Date : 2008-08-12 13:36:55.0
Work Around
N/A
Evaluation
The Enum class allows to create constants that extend methods. For every constant the subclass is generated. So we should check that the value is assignable to the specific Enum class.
Posted Date : 2008-12-25 16:08:42.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang