[jboss-jira] [JBoss JIRA] (JASSIST-173) No Exception is thrown by CtNewMethod.make() when return type is wrong
Shigeru Chiba (JIRA)
jira-events at lists.jboss.org
Wed Apr 17 10:10:54 EDT 2013
[ https://issues.jboss.org/browse/JASSIST-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12768073#comment-12768073 ]
Shigeru Chiba commented on JASSIST-173:
---------------------------------------
Well, to minimize runtime overhead due to bytecode generation,
Javassist's compiler does not check type errors; it assumes that
the given source code is always correct. So throwing no exception
is part of the specifications.
> No Exception is thrown by CtNewMethod.make() when return type is wrong
> ----------------------------------------------------------------------
>
> Key: JASSIST-173
> URL: https://issues.jboss.org/browse/JASSIST-173
> Project: Javassist
> Issue Type: Bug
> Affects Versions: 3.16.1-GA
> Environment: Windows Vista, JDK 1.6
> Reporter: Maxime Dubois
> Assignee: Shigeru Chiba
>
> When using the CtNewMethod.make() method to create a method that returns data with a wrong type, no Exception is thrown.
> Steps to reproduce:
> -----------------
> - use the method "public static CtMethod make(java.lang.String src, CtClass declaring)" to create a method that looks like this:
> public static boolean myMethod() { return ("toto"); }
> - add it to a CtClass object using the addMethod() method
> Result :
> -----------------
> No CannotCompileException is thrown, the method is created and added to the class without any problem even though it is not correct.
> When trying to use the resulting class, the following error is thrown: "java.lang.VerifyError: Wrong return type in function"
> Expected result :
> ------------------
> The CtNewMethod.make() method should throw a CannotCompileException indicating that the return type is wrong.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list