You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Loenko (JIRA)" <ji...@apache.org> on 2006/04/25 13:03:06 UTC

[jira] Resolved: (HARMONY-402) java.beans.Beans.InstanceOf(Object bean,Class targetType) method works incorrectly

     [ http://issues.apache.org/jira/browse/HARMONY-402?page=all ]
     
Mikhail Loenko resolved HARMONY-402:
------------------------------------

    Resolution: Fixed

fixed in revision 396838
Svetlana, please check that it fully resolves the problem

> java.beans.Beans.InstanceOf(Object bean,Class targetType) method works incorrectly
> ----------------------------------------------------------------------------------
>
>          Key: HARMONY-402
>          URL: http://issues.apache.org/jira/browse/HARMONY-402
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Mikhail Loenko
>  Attachments: Beans.diffs, BeansTest.java, ObjectBean.java
>
> Accodring to java 1.4.2 and 1.5 specifications  java.beans.Beans.InstanceOf(Object bean,Class targetType) method returns "true" if the given bean supports the given targetType.
> As a result  isInstanceOf(Object bean, null) should return false.
> Harmony throws NPE in this case and returns false for correct non-null targetType.
>  
> Code for reproduce: 
> Put ObjectBean class in the same directory as the test.
> import java.beans.Beans; 
> import java.io.*; 
>  
> public class test { 
>     public static void main(String[] args) { 
>              ObjectBean bean = new ObjectBean();
>  
>              try {
>                  Class targetType = Externalizable.class;
>                  //correct non-null targetType
>                  System.out.println("***"+Beans.isInstanceOf(bean, targetType));                    
>              } catch (Exception e) {
>                  e.printStackTrace();   
>              }
>              
>              try {
>                  Class targetType = null;
>                  // null targetType
>                  System.out.println("***"+Beans.isInstanceOf(bean, targetType));
>              } catch (Exception e) {
>                  e.printStackTrace();   
>              } 
>        } 
> } 
>  
> class ObjectBean implements Externalizable {
>     public void writeExternal(ObjectOutput out) {}; 
>     public void readExternal(ObjectInput in){};
> }
> Harmony output: 
> ***false
> java.lang.NullPointerException
>         at java.lang.Class.isAssignableFrom(Native Method)
>         at java.beans.Beans.isInstanceOf(Beans.java:147)
>         at test.main(test.java:18)
> BEA optput: 
> ***true
> ***false
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira