Last change
on this file was 2, checked in by bird, 22 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
819 bytes
|
Line | |
---|
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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.