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

Anonymous inner class with null constructor parameter throws compiler error

XMLWordPrintable

    • 1.2beta3
    • generic, x86, sparc
    • generic, solaris_2.5.1, solaris_2.6, windows_95, windows_nt
    • Not verified

      While compiling an anonymous inner class that takes in non-empty parameter list
      for its initializer causes a "stackSize is null" error. The class being extended is neither abstract nor an interface. Things work fine if the inner class is given a name. Please see attachment for code causing trouble. The part that doesn't compile is commented. Happens with 1.1.1, 1.1.2 and 1.2 builds.

      The error 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.AssignExpression.checkValue(AssignExpression.java)
              at
      sun.tools.tree.BinaryAssignExpression.check(BinaryAssignExpression.java)
              at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java)
              at sun.tools.tree.Statement.checkBlockStatement(Statement.java)
              at sun.tools.tree.CompoundStatement.check(CompoundStatement.java)
              at sun.tools.tree.IfStatement.check(IfStatement.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)
      error: An error has occurred in the compiler; please file a bug report
      (http://java.sun.com/cgi-bin/bugreport.cgi).

      ===============================================================
      Another report:

      If you compile test1.java, you will get the exception dump listed [above].

      <test.java>

      public class test {
        public test(test x) {
        }
      }

      <test1.java>
      public class test1 {
        private test T = new test(null) {
        };
      }

      brian.klock@Eng 1997-10-21
      ========================================================
      Another report:

      To reproduce the problem run:
          javac Bug.java

      Source code Bug.java:

      /**
       * A double linked list structure.
       */
      public class Bug
      {
          /**
           * An immutable "null" list element used as a marker for list ends.
           * All list operations are legal in order to reduce tests for NONE
           * in calling code, but no operation actually changes NONE.
           */
          public static final Bug NONE =
              new Bug(null)
              {
                  protected void setLeft(Bug newLeft) { }
                  protected void setRight(Bug newRight) { }
              };

          protected void setLeft(Bug newLeft)
          {
              left = newLeft;
          }

          protected void setRight(Bug newRight)
          {
              right = newRight;
          }

          private Bug left = NONE;
          private Bug right = NONE;
          private Object value = null;
      }

      brian.klock@eng 1997-10-21
      ========================================================


            tturnidgsunw Todd Turnidge (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: