-
Enhancement
-
Resolution: Fixed
-
P5
-
6
-
b82
-
x86
-
linux_redhat_9.0
-
Verified
A try/finally with nothing in the finally results in additional byte codes being generated.
Here's the test case:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;
public class Test {
public static void main(String[] args) {
JComponent x = new JComponent() {
public boolean isShowing() {
return true;
}
public boolean isOpaque() {
return true;
}
};
// try {
x.setSize(200, 200);
x.paintImmediately(0, 0, 200, 200);
System.out.println("DONE!");
// } finally {}
}
}
Here's the output from javap as is:
Compiled from "Test.java"
public class Test extends java.lang.Object{
public Test();
Code:
0:aload_0
1:invokespecial#1; //Method java/lang/Object."<init>":()V
4:return
public static void main(java.lang.String[]);
Code:
0:new#2; //class Test$1
3:dup
4:invokespecial#3; //Method Test$1."<init>":()V
7:astore_1
8:aload_1
9:sipush200
12:sipush200
15:invokevirtual#4; //Method javax/swing/JComponent.setSize:(II)V
18:aload_1
19:iconst_0
20:iconst_0
21:sipush200
24:sipush200
27:invokevirtual#5; //Method javax/swing/JComponent.paintImmediately:(IIII)V
30:getstatic#6; //Field java/lang/System.out:Ljava/io/PrintStream;
33:ldc#7; //String DONE!
35:invokevirtual#8; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
38:return
}
And when you uncomment the try/finally here's the output:
Compiled from "Test.java"
public class Test extends java.lang.Object{
public Test();
Code:
0:aload_0
1:invokespecial#1; //Method java/lang/Object."<init>":()V
4:return
public static void main(java.lang.String[]);
Code:
0:new#2; //class Test$1
3:dup
4:invokespecial#3; //Method Test$1."<init>":()V
7:astore_1
8:aload_1
9:sipush200
12:sipush200
15:invokevirtual#4; //Method javax/swing/JComponent.setSize:(II)V
18:aload_1
19:iconst_0
20:iconst_0
21:sipush200
24:sipush200
27:invokevirtual#5; //Method javax/swing/JComponent.paintImmediately:(IIII)V
30:getstatic#6; //Field java/lang/System.out:Ljava/io/PrintStream;
33:ldc#7; //String DONE!
35:invokevirtual#8; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
38:goto44
41:astore_2
42:aload_2
43:athrow
44:return
Exception table:
from to target type
8 38 41 any
41 42 41 any
}
I'm not sure if this intentional for debugging purposes, hence filing as an RFE.
###@###.### 10/20/04 15:20 GMT
Here's the test case:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;
public class Test {
public static void main(String[] args) {
JComponent x = new JComponent() {
public boolean isShowing() {
return true;
}
public boolean isOpaque() {
return true;
}
};
// try {
x.setSize(200, 200);
x.paintImmediately(0, 0, 200, 200);
System.out.println("DONE!");
// } finally {}
}
}
Here's the output from javap as is:
Compiled from "Test.java"
public class Test extends java.lang.Object{
public Test();
Code:
0:aload_0
1:invokespecial#1; //Method java/lang/Object."<init>":()V
4:return
public static void main(java.lang.String[]);
Code:
0:new#2; //class Test$1
3:dup
4:invokespecial#3; //Method Test$1."<init>":()V
7:astore_1
8:aload_1
9:sipush200
12:sipush200
15:invokevirtual#4; //Method javax/swing/JComponent.setSize:(II)V
18:aload_1
19:iconst_0
20:iconst_0
21:sipush200
24:sipush200
27:invokevirtual#5; //Method javax/swing/JComponent.paintImmediately:(IIII)V
30:getstatic#6; //Field java/lang/System.out:Ljava/io/PrintStream;
33:ldc#7; //String DONE!
35:invokevirtual#8; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
38:return
}
And when you uncomment the try/finally here's the output:
Compiled from "Test.java"
public class Test extends java.lang.Object{
public Test();
Code:
0:aload_0
1:invokespecial#1; //Method java/lang/Object."<init>":()V
4:return
public static void main(java.lang.String[]);
Code:
0:new#2; //class Test$1
3:dup
4:invokespecial#3; //Method Test$1."<init>":()V
7:astore_1
8:aload_1
9:sipush200
12:sipush200
15:invokevirtual#4; //Method javax/swing/JComponent.setSize:(II)V
18:aload_1
19:iconst_0
20:iconst_0
21:sipush200
24:sipush200
27:invokevirtual#5; //Method javax/swing/JComponent.paintImmediately:(IIII)V
30:getstatic#6; //Field java/lang/System.out:Ljava/io/PrintStream;
33:ldc#7; //String DONE!
35:invokevirtual#8; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
38:goto44
41:astore_2
42:aload_2
43:athrow
44:return
Exception table:
from to target type
8 38 41 any
41 42 41 any
}
I'm not sure if this intentional for debugging purposes, hence filing as an RFE.
###@###.### 10/20/04 15:20 GMT
- relates to
-
JDK-4974302 inlined finally clauses confuse some debuggers
-
- Closed
-