throw null gives bizarre error message

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 1.4.0
    • Affects Version/s: 1.3.0
    • Component/s: tools
    • None
    • beta
    • generic
    • generic
    • Verified

      Consider the program:

      class ThrowNull {

        void foo() throws Throwable {
          throw(Throwable) null;
        }


        void bar() throws Throwable {
          throw null;
        }
      }

      Compiling this yields:

      javac ThrowNull.java
      ThrowNull.java:8: unreported exception <null>; must be caught or declared to be thrown
          throw null;
          ^
      1 error

      The literal null is an element of every type, including Throwable. The program
      should compile without error; it is legal.


      gilad.bracha@eng 2000-04-08

            Assignee:
            Btplusnull User (Inactive)
            Reporter:
            Gilad Bracha (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: