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

Bad "null" handling in the compiler

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.0
    • 1.0
    • tools
    • None
    • 1.0beta
    • sparc
    • generic
    • Not verified

      The following code causes an internal Error in the compiler.

      class bug {
          void show_bug() {
      try {
      int i = 1;
      } finally {
      doit(null);
      }
          }

          void doit (String msg) {}
      }

      gives

      pan:~/public_html/classes[1106] oakc bug.oak
      oak.tools.oak.InternalError selectType: convert
      at oak.lang.Exception.<init>(Exception.oak)
      at oak.tools.oak.InternalError.<init>(InternalError.oak)
      at oak.tools.tree.UnaryExpression.selectType(UnaryExpression.oak)
      at oak.tools.tree.UnaryExpression.checkValue(UnaryExpression.oak)
      at oak.tools.tree.MethodExpression.checkValue(MethodExpression.oak)
      at oak.tools.tree.MethodExpression.check(MethodExpression.oak)
      at oak.tools.tree.ExpressionStatement.check(ExpressionStatement.oak)
      at oak.tools.tree.CompoundStatement.check(CompoundStatement.oak)
      at oak.tools.tree.FinallyStatement.check(FinallyStatement.oak)
      at oak.tools.tree.CompoundStatement.check(CompoundStatement.oak)
      oakc: an exception has occurred, please contact x47242.

      For whatever it's worth, a doit(null) in the try{ } causes no problem. It has to be
      in the finally { } clause to get the error.

      The description field as copied from bug report 1186173 follows:

      When I compile the following code:

      import oak.io.*;

      class foo {
          static void broken()
          {
      InputStream f = null;
      try {
      f = new FileInputStream("/tmp/junk");
      } finally {
      if (f != null)
      f.close();
      }
          }
      }

      I get the following:

      pan:/tmp[1028] oakc foo.oak
      oak.tools.oak.InternalError selectType: convert
      at oak.lang.Exception.<init>(Exception.oak)
      at oak.tools.oak.InternalError.<init>(InternalError.oak)
      at oak.tools.tree.UnaryExpression.selectType(UnaryExpression.oak)
      at oak.tools.tree.UnaryExpression.checkValue(UnaryExpression.oak)
      at oak.tools.tree.BinaryExpression.checkValue(BinaryExpression.oak)
      at oak.tools.tree.Expression.checkCondition(Expression.oak)
      at oak.tools.tree.Expression.checkCondition(Expression.oak)
      at oak.tools.tree.IfStatement.check(IfStatement.oak)
      at oak.tools.tree.CompoundStatement.check(CompoundStatement.oak)
      at oak.tools.tree.FinallyStatement.check(FinallyStatement.oak)
      oakc: an exception has occurred, please contact x47242.

            ahoffsunw Arthur Hoff (Inactive)
            fyellinsunw Frank Yellin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: