OSDN Git Service

PR libgcj/12656:
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / libjava.lang / pr83.java
1 // PR 83
2
3 /*
4  * test that caught null pointers exceptions in finalizers work correctly
5  * and that local variables are accessible in null pointer exception handlers.
6  */
7 import java.io.*;
8
9 public class pr83 {
10     
11     static String s;
12     
13     public static void main(String[] args) {
14         System.out.println(tryfinally() + s);
15     }
16     
17     public static String tryfinally() {
18         String yuck = null;
19         String local_s = null;
20         
21         try {
22             return "This is ";
23         } finally {
24             try {
25                 local_s = "Perfect";
26                 /* trigger null pointer exception */
27                 String x = yuck.toLowerCase();
28             } catch (Exception _) {
29                 /* 
30                  * when the null pointer exception is caught, we must still
31                  * be able to access local_s.
32                  * Our return address for the finally clause must also still
33                  * be intact.
34                  */
35                 s = local_s;
36             }
37         }
38     }
39 }