harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-5854) [classlib][beans] java.beans.Statement.findMethod() throw java.lang.NoSuchMethodException: Cannot decide which method to call
Date Mon, 02 Jun 2008 10:47:45 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-5854?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kevin Zhou updated HARMONY-5854:
--------------------------------

    Attachment: HARMONY-5854.diff

Please help me to try it.

> [classlib][beans] java.beans.Statement.findMethod() throw java.lang.NoSuchMethodException:
Cannot decide which method to call
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5854
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5854
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M6
>            Reporter: Kevin Zhou
>            Assignee: Sean Qiu
>             Fix For: 5.0M6
>
>         Attachments: HARMONY-5854.diff
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given the following scenario,
> public class TInspectorCluster {
> 	public interface Ancestor {
> 	}
> 	public interface Offspring extends Ancestor {
> 	}
> 	public interface Visitor<T> {
> 		public T visit(Ancestor o);
> 	}
> 	public static class StringInspector implements Visitor<String> {
> 		public String visit(Ancestor o) {
> 			System.out.println("Got the ancestor method")
> 			return null;
> 		}
> 		public String visit(Offspring o) {
> 			System.out.println("Got the offspring method")
> 			return null;
> 		}
> 	}
> }
> define the test as:
> public static void main(String[] args) throws Exception {
>         Ancestor ancestor = new Ancestor() {
>         };
>         new Statement(new StringInspector(), "visit", new Object[] { cat })
>                 .execute();
> }
> then it throws 
> java.lang.NoSuchMethodException: Cannot decide which method to call to match visit
> 	at java.beans.Statement.findMethod(Statement.java:376)
> 	at java.beans.Statement.invokeMethod(Statement.java:218)
> 	at java.beans.Statement.execute(Statement.java:18)
> I think the problem is caused by the java.beans.Statement.findMethod().
> If the target class has two candidate methods which have the identical signature (difference
equals to zero) but different return type, it will throws this kind of exception.
> Thus, I think the cure is to insert a routine check of their return types. If they have
the same return type, then throw the NoSuchMethodException.
> If not, check whether they are assignable to each other and reflect the specific one.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message