Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4022782

javac reports throws clause errors in a code that has none.

    XMLWordPrintable

Details

    • sparc
    • solaris_2.5.1

    Description


      allan.jacobs@Eng 1996-12-18


      algol% cat c0846442.java
      /**
       ** JAVATEST : The Modena JAVA Test Suite, Version 2.0, November 1996
       ** Copyright (c) 1996 Modena Software (I) Pvt. Ltd., All Rights Reserved
       **/

      /*
       * Section: 8.4.6.4
       *
       * Filename: c0846442.java
       *
       * Purpose: Positive test for section 8.4.6.4, para 1:
       *
       * "A compile-time error occurs if, for any two such inherited
       * methods, either they have different return types or one
       * has a return type and the other is void. (The throws
       * clauses do not cause errors in this case)."
       *
       * Language Specification: October, 1996
       */

      import java.io.*;

      interface I1 {
        int f() throws RuntimeException;
      }
      interface I2 {
        int f() throws IOException;
      }

      abstract class Y implements I2,I1 {}
      // Note the order of implementation of I1 & I2

      class X {
         public static void main(String[] arg)
          {
            System.out.println("Done");
          }
      }
      algol% ls
      c0846442.java c0846442.java.orig
      algol% setenv CLASSPATH .
      algol% javac -d . c0846442.java
      c0846442.java:27: Invalid exception class java.io.IOException in throws clause. The exception must be a subclass of an exception thrown by int f() from interface I1.
        int f() throws IOException;
            ^
      1 error
      algol% ls
      I1.class X.class c0846442.java.orig
      I2.class c0846442.java
      algol% java X
      Done
      algol% echo $status
      0

      Attachments

        Issue Links

          Activity

            People

              tturnidgsunw Todd Turnidge (Inactive)
              ajacobssunw Allan Jacobs (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: