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

CompilerError on undeclared type

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

      The following program causes JDK1.0 compiler to give a compiler error.

      Note the typo in the type of the declaration of DIFFERENT.


      ---------------------------------------------
      import java.io.IOException;

      class Status {
          Status(String s) {
          }
      }

      class bug {
          public Status compare(int a, int[] b) {
      for (int i = 0; i < b.length; i++) {
      try {
      boolean same = compare(a, b[i]);
      return (same ? SAME : DIFFERENT);
      }
      catch (IOException e) {
      return ERROR;
      }
      }
      return NOT_FOUND;
          }

          public boolean compare(int a, int b) throws IOException {
      return (a == b);
          }

           private static final Status SAME = new Status("same");
           private static final tatus DIFFERENT = new Status("different");
           private static final Status ERROR = new Status("error");
           private static final Status NOT_FOUND = new Status("not found");
      }
      -------------------------------


      gzilla% javac bug.java
      sun.tools.java.CompilerError: tatus
      at sun.tools.tree.ConditionalExpression.checkValue(ConditionalExpression.java:92)
      at sun.tools.tree.UnaryExpression.checkValue(UnaryExpression.java:62)
      at sun.tools.tree.ReturnStatement.check(ReturnStatement.java:46)
      at sun.tools.tree.CompoundStatement.check(CompoundStatement.java:48)
      at sun.tools.tree.TryStatement.check(TryStatement.java:53)
      at sun.tools.tree.CompoundStatement.check(CompoundStatement.java:48)
      at sun.tools.tree.ForStatement.check(ForStatement.java:58)
      at sun.tools.tree.CompoundStatement.check(CompoundStatement.java:48)
      at sun.tools.tree.Statement.checkMethod(Statement.java:64)
      at sun.tools.javac.SourceField.check(SourceField.java:209)
      at sun.tools.javac.SourceClass.check(SourceClass.java:431)
      at sun.tools.javac.SourceClass.compileClass(SourceClass.java:540)
      at sun.tools.javac.SourceClass.compile(SourceClass.java:527)
      at sun.tools.javac.Main.compile(Main.java:193)
      at sun.tools.javac.Main.main(Main.java:289)
      error: An error has occurred in the compiler; please file a bug report (###@###.###).
      1 error
      gzilla%

            fyellinsunw Frank Yellin (Inactive)
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: