fix for jsr routines that do not have returns

Dan Walter d2walter@oakland.edu
Sun Dec 2 18:42:00 GMT 2001


attached are the .class .java and jcf-dump files                          
> >>>>> "Dan" == Dan  <d2walter@Oakland.edu> writes:                      
>                                                                         
> Dan> void fail(){                                                       
> Dan>         try {                                                      
> Dan>                 test();                                            
> Dan>         } finally {                                                
> Dan>                 throw new RuntimeException("test exceptions");     
> Dan>         }                                                          
> Dan> }                                                                  
>                                                                         
> For this, see also PR 4766.                                             
> `gcj -C' generates invalid bytecode from this source (it generates a    
> `goto' that is out of range).                                           
>                                                                         
> Dan> When this is compiled with Sun's javac it produces .class files    
> Dan> that fail to verify or to compile because the jsr does not havee   
> Dan> a ret.  I modified gcj to treat such jsr's as gotos.               
>                                                                         
> With my javac this doesn't happen -- no jsr is generated.               
> What version of javac are you using?                                    
>                                                                         
> Could you send the output of `jcf-dump -c' on the javac-generated code? 
> I'd like to see it.  In fact, could you run the appended program        
> through your javac and then send the whole .class file (suitably        
> encoded to protect it from email)?  I'd really appreciate that.         
>                                                                         
> Thanks,                                                                 
> Tom                                                                     
>                                                                         
> import java.math.*;                                                     
>                                                                         
> public class t                                                          
> {                                                                       
>   public void fail ()                                                   
>   {                                                                     
>     try                                                                 
>       {                                                                 
> 	System.out.println ("foo");                                            
>       }                                                                 
>     finally                                                             
>       {                                                                 
> 	throw new RuntimeException ("hi!");                                    
>       }                                                                 
>   }                                                                     
>                                                                         
>   public static void main (String[] args)                               
>   {                                                                     
>   }                                                                     
> }                                                                       
>                                                                         
Attachment:
TestV3.class
Description: application/java-vm
Attachment:
TestV3.dump
Description: Binary data
Attachment:
TestV3.java
Description: Text document

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestV3.class
Type: application/x-java-applet
Size: 768 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20011202/f9b6c6a9/attachment.bin>
-------------- next part --------------
Reading .class from ./TestV3.class.
Magic number: 0xcafebabe, minor_version: 3, major_version: 45.

Constant pool (count: 50):
#1: Methodref class: 14=java.lang.Object name_and_type: 26=<<init> ()void>
#2: Methodref class: 6=TestV3 name_and_type: 27=<test ()boolean>
#3: Class name: 28="java/lang/RuntimeException"
#4: String 29="test exceptions"
#5: Methodref class: 3=java.lang.RuntimeException name_and_type: 30=<<init> (java.lang.String)void>
#6: Class name: 31="TestV3"
#7: Methodref class: 6=TestV3 name_and_type: 26=<<init> ()void>
#8: Methodref class: 6=TestV3 name_and_type: 32=<fail ()void>
#9: Class name: 33="java/lang/Exception"
#10: Methodref class: 34=java.lang.Throwable name_and_type: 35=<printStackTrace ()void>
#11: Fieldref class: 36=java.lang.System name_and_type: 37=<out java.io.PrintStream>
#12: String 38="Exception test done"
#13: Methodref class: 39=java.io.PrintStream name_and_type: 40=<println (java.lang.String)void>
#14: Class name: 41="java/lang/Object"
#15: Utf8: "<init>"
#16: Utf8: "()V"
#17: Utf8: "Code"
#18: Utf8: "LineNumberTable"
#19: Utf8: "fail"
#20: Utf8: "test"
#21: Utf8: "()Z"
#22: Utf8: "main"
#23: Utf8: "([Ljava/lang/String;)V"
#24: Utf8: "SourceFile"
#25: Utf8: "TestV3.java"
#26: NameAndType name: 15=<init>, signature: 16=()void
#27: NameAndType name: 20=test, signature: 21=()boolean
#28: Utf8: "java/lang/RuntimeException"
#29: Utf8: "test exceptions"
#30: NameAndType name: 15=<init>, signature: 42=(java.lang.String)void
#31: Utf8: "TestV3"
#32: NameAndType name: 19=fail, signature: 16=()void
#33: Utf8: "java/lang/Exception"
#34: Class name: 43="java/lang/Throwable"
#35: NameAndType name: 44=printStackTrace, signature: 16=()void
#36: Class name: 45="java/lang/System"
#37: NameAndType name: 46=out, signature: 47=java.io.PrintStream
#38: Utf8: "Exception test done"
#39: Class name: 48="java/io/PrintStream"
#40: NameAndType name: 49=println, signature: 42=(java.lang.String)void
#41: Utf8: "java/lang/Object"
#42: Utf8: "(Ljava/lang/String;)V"
#43: Utf8: "java/lang/Throwable"
#44: Utf8: "printStackTrace"
#45: Utf8: "java/lang/System"
#46: Utf8: "out"
#47: Utf8: "Ljava/io/PrintStream;"
#48: Utf8: "java/io/PrintStream"
#49: Utf8: "println"

Access flags: 0x21 public super
This class: 6=TestV3, super: 14=java.lang.Object
Interfaces (count: 0):

Fields (count: 0):

Methods (count: 4):

Method name:"<init>" public Signature: 16=()void
Attribute "Code", length:29, max_stack:1, max_locals:1, code_length:5
  0: aload_0
  1: invokespecial #1=<Method java.lang.Object.<init> ()void>
  4: return
Attribute "LineNumberTable", length:6, count: 1
  line: 1 at pc: 0

Method name:"fail" Signature: 16=()void
Attribute "Code", length:69, max_stack:3, max_locals:3, code_length:29
  0: aload_0
  1: invokevirtual #2=<Method TestV3.test ()boolean>
  4: pop
  5: jsr 17
  8: goto 28
 11: astore_1
 12: jsr 17
 15: aload_1
 16: athrow
 17: astore_2
 18: new #3=<Class java.lang.RuntimeException>
 21: dup
 22: ldc #4=<String "test exceptions">
 24: invokespecial #5=<Method java.lang.RuntimeException.<init> (java.lang.String)void>
 27: athrow
 28: return
Exceptions (count: 1):
  start: 0, end: 11, handler: 11, type: 0 /* finally */
Attribute "LineNumberTable", length:14, count: 3
  line: 6 at pc: 0
  line: 8 at pc: 11
  line: 10 at pc: 28

Method name:"test" Signature: 21=()boolean
Attribute "Code", length:26, max_stack:1, max_locals:1, code_length:2
  0: iconst_1
  1: ireturn
Attribute "LineNumberTable", length:6, count: 1
  line: 13 at pc: 0

Method name:"main" public static Signature: 23=(java.lang.String[])void
Attribute "Code", length:71, max_stack:2, max_locals:2, code_length:27
  0: new #6=<Class TestV3>
  3: dup
  4: invokespecial #7=<Method TestV3.<init> ()void>
  7: invokevirtual #8=<Method TestV3.fail ()void>
 10: goto 18
 13: astore_1
 14: aload_1
 15: invokevirtual #10=<Method java.lang.Throwable.printStackTrace ()void>
 18: getstatic #11=<Field java.lang.System.out java.io.PrintStream>
 21: ldc #12=<String "Exception test done">
 23: invokevirtual #13=<Method java.io.PrintStream.println (java.lang.String)void>
 26: return
Exceptions (count: 1):
  start: 0, end: 10, handler: 13, type: 9=java.lang.Exception
Attribute "LineNumberTable", length:18, count: 4
  line: 18 at pc: 0
  line: 20 at pc: 13
  line: 22 at pc: 18
  line: 23 at pc: 26

Attributes (count: 1):
Attribute "SourceFile", length:2, #25="TestV3.java"


More information about the Java-patches mailing list