harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r396838 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/Beans.java test/java/org/apache/harmony/tests/java/beans/BeansTest.java
Date Tue, 25 Apr 2006 11:02:40 GMT
Author: mloenko
Date: Tue Apr 25 04:02:36 2006
New Revision: 396838

URL: http://svn.apache.org/viewcvs?rev=396838&view=rev
Log:
fixes for HARMONY-402:
java.beans.Beans.InstanceOf(Object bean,Class targetType) method works incorrectly

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java?rev=396838&r1=396837&r2=396838&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
Tue Apr 25 04:02:36 2006
@@ -144,7 +144,11 @@
 	 * @com.intel.drl.spec_ref
 	 */
     public static boolean isInstanceOf(Object bean, Class targetType) {
-        return bean.getClass().isAssignableFrom(targetType);            
+        if (targetType == null) {
+            return false;
+        } else {
+            return targetType.isInstance(bean);
+        }
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java?rev=396838&r1=396837&r2=396838&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java
Tue Apr 25 04:02:36 2006
@@ -22,7 +22,10 @@
 
 import org.apache.harmony.tests.java.beans.auxiliary.SampleBean;
 import java.beans.Beans;
+import java.io.Externalizable;
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -105,6 +108,18 @@
         }
         assertNotNull(Beans.instantiate(null, this.getClass().getName()));
     } 
+
+    //regression test for HARMONY-402
+    public void test_isInstanceOf_Object_Class() {
+        ObjectBean bean = new ObjectBean();
+        // correct non-null targetType
+        Class targetType = Externalizable.class;
+        assertTrue(Beans.isInstanceOf(bean, targetType));
+
+        // null targetType
+        targetType = null;
+        assertFalse(Beans.isInstanceOf(bean, targetType));
+    } 
     
     /**
      * 
@@ -132,4 +147,9 @@
     private void checkValues(SampleBean sampleBean) {
         assertEquals(null, sampleBean.getText());
     }
+
+    private class ObjectBean implements Externalizable { 
+        public void writeExternal(ObjectOutput out) {}; 
+        public void readExternal(ObjectInput in){}; 
+    } 
 }



Mime
View raw message