java/8980: NullPointerException not being caught by exception handler

sergio-s-freire@ptinovacao.pt sergio-s-freire@ptinovacao.pt
Tue Dec 17 06:06:00 GMT 2002


>Number:         8980
>Category:       java
>Synopsis:       NullPointerException not being caught by exception handler
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 17 06:06:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     sergio-s-freire@ptinovacao.pt
>Release:        gcc-3.2
>Organization:
>Environment:
i386-redhat-linux  (RedHat Linux 8.0, Intel Pentium III)
>Description:
NullPointerException is not being caught correctly in the
following code. Output is 'Exception in thread "main"' instead of 'Works
fine'.

public class Foo {
  public static void main(String[] args) {
    Object nada = null;
    try {
      nada.toString();
    } catch (Throwable t) {
      System.out.println("Works fine");
    }
  }
}
>How-To-Repeat:
gcj -c Foo.java && ./a.out
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list