[jboss-jira] [JBoss JIRA] (JASSIST-164) MethodHandler.invoke() should not be throwing Throwable as it may be invoked from forwarder methods that do not have a throws clause
Nikita Tovstoles (JIRA)
jira-events at lists.jboss.org
Mon Apr 2 14:48:47 EDT 2012
Nikita Tovstoles created JASSIST-164:
----------------------------------------
Summary: MethodHandler.invoke() should not be throwing Throwable as it may be invoked from forwarder methods that do not have a throws clause
Key: JASSIST-164
URL: https://issues.jboss.org/browse/JASSIST-164
Project: Javassist
Issue Type: Bug
Affects Versions: 3.16.1-GA
Reporter: Nikita Tovstoles
Assignee: Shigeru Chiba
Given some method to be proxied, like a typical POJO getter:
{code}
public String getName() {
return this.name;
}
{code}
...ProxyFactory.makeForwarder() generates a method that includes call to MethodHandler.invoke(), ie:
{code}
//decompiled proxy
public final String getName()
{
//other stuff
return (String)this.handler.invoke(this, arrayOfMethod[14], arrayOfMethod[15], new Object[0]);
}
{code}
the code above would not compile because handler.invoke() throws Throwable but getName() does not have a throws clause. Since there is no guarantee that a proxied method will declare a throws clause, invoke() should only be throwing RuntimeExceptions and 'throws Throwable' should be removed from the method signature - or this method should not be used when proxying arbitrary methods.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list