gcj/83: Failure to compile try/finally?

gback@cs.utah.edu gback@cs.utah.edu
Thu Nov 4 08:30:00 GMT 1999

>Number:         83
>Category:       gcj
>Synopsis:       Failure to compile try/finally?
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 04 08:30:00 PST 1999
>Originator:     Godmar Back
>Release:        CVS October
An old problem I've mentioned in April still hasn't been

The following program produces incorrect results when
compiled from the java source.
It works when compiled from a .class file generated by
say jikes.
Sun's JDK executes the .class file generated by gcj -C.
gcj cannot compile the .class file it generates with -C.

 * test that caught null pointers exceptions in finalizers work correctly
 * and that local variables are accessible in null pointer exception handlers.
import java.io.*;

public class NullPointerTest {

    static String s;

    public static void main(String[] args) {
         System.out.println(tryfinally() + s);

    public static String tryfinally() {
       String yuck = null;
       String local_s = null;

       try {
           return "This is ";
       } finally {
           try {
        local_s = "Perfect";
        /* trigger null pointer exception */
        String x = yuck.toLowerCase();
           } catch (Exception _) {
         * when the null pointer exception is caught, we must still
         * be able to access local_s.
         * Our return address for the finally clause must also still
         * be intact.
        s = local_s;

/* Expected Output:
This is Perfect

More information about the Java-prs mailing list