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

Instantiation of anonymous class implementing an interface may crash compiler

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • tools
    • None
    • generic
    • generic

      Compiling the following class crashes javac with a CompilerError:

      public class BAD {
          public Object foo() {
      // return new Cloneable() {} ; // OK
      return new Cloneable(null) {} ; // BAD
          }
      }

      The backtrace is:

      sun.tools.java.CompilerError: stackSize null
              at sun.tools.java.Type.stackSize(Type.java)
              at sun.tools.tree.Context.declare(Context.java)
              at sun.tools.javac.SourceField.check(SourceField.java)
              at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
              at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
              at sun.tools.javac.SourceClass.checkLocalClass(SourceClass.java)
              at sun.tools.tree.NewInstanceExpression.checkValue(NewInstanceExpression.java)
              at sun.tools.tree.ReturnStatement.check(ReturnStatement.java)
              at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
              at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
              at sun.tools.tree.Statement.checkMethod(Statement.java)
              at sun.tools.javac.SourceField.check(SourceField.java)
              at sun.tools.javac.SourceClass.checkFields(SourceClass.java)
              at sun.tools.javac.SourceClass.checkInternal(SourceClass.java)
              at sun.tools.javac.SourceClass.check(SourceClass.java)
              at sun.tools.javac.Main.compile(Main.java)
              at sun.tools.javac.Main.main(Main.java)

      william.maddox@Eng 1997-07-30

            tturnidgsunw Todd Turnidge (Inactive)
            wmaddoxsunw William Maddox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: