<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
javassist and interfaces defining a method which throws an exception question
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/amitabakoptier">ami tabak</a> in <i>Javassist Development</i> - <a href="https://community.jboss.org/message/777034#777034">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p> <span style="font-size: 10.0pt; font-family: 'Courier New';">A Question regarding the JVM spec and how javassist is expected to handle it.</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">I’ve an interface IMyFactory extending the Remote interface.</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">It declares a method foo() which declares throws RemoteException so will be deemed as remotable API</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">The implementing class implements the method but <strong style="text-decoration: underline;">doesn’t</strong> declare itself as throwing the remote.</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">Code wise the JVM picked this method as valid Remote API</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">Javassist when interrogated class MyFactory.foo() method doesn’t provide any data on its being a throwing RemoteException </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong style=": ; font-size: 10.0pt; font-family: 'Courier New'; text-decoration: underline;">Questions</strong></p><ol style="list-style-type: decimal;"><li><span style="font-size: 10.0pt; font-family: 'Courier New';">The JVM spec defines a method by its name and properties, not by its exception throwing.</span></li></ol><p><span style="font-size: 10.0pt; font-family: 'Courier New';">In addition it allows an implementing method to declare less “throws” then its super / defining interface without loss of polymorphism</span></p><ol style="list-style-type: lower-alpha;"><li><span style="font-size: 10.0pt; font-family: 'Courier New';">e.g. this foo() implementer is deemed the same as in the interface.</span></li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">Why wont javassist provide me the exception data defined in the Interface’s CtClass ? </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">   2) Is there a “recoursive” API in javassist that will wllow me to intergoate a method up to its interface definition to see if some one above it has defined it to be an   </span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">      Throwable thrower or do I need to implement such search myself ? </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong style=": ; font-size: 10.0pt; font-family: 'Courier New'; text-decoration: underline;">Code example: </strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ol style="list-style-type: decimal;"><li><span style="font-size: 10.0pt; font-family: 'Courier New';">1. MyFactory implements IMyFactory</span></li></ol><p><span style="font-size: 10.0pt; font-family: 'Courier New';">   {...</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">     @Override</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">     public int foo() //on purpose didn’t declare “throws java.rmi.RemoteException”</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">     { </span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">       // TODO Auto-generated method stub</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">       return 0;</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">     }   </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ol style="list-style-type: decimal;"><li><span style="font-size: 10.0pt; font-family: 'Courier New';">2. public interface IMyFactory extends Remote</span></li></ol><p><span style="font-size: 10.0pt; font-family: 'Courier New';">   {</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">     public int foo() throws RemoteException;</span></p><p><span style="font-size: 10.0pt; font-family: 'Courier New';">   }</span></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/777034#777034">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Javassist Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2063">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>