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

Call to constructor via 'this()' fails in inner class with uplevel references

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 1.1.7, 1.2.0
    • tools
    • generic, x86
    • solaris_2.5.1, windows_nt

    Description

      public class UpLevel {

          class Inner {

      void foo() throws Exception {
      final int xx = 12345;

      class Local {
      Local() { System.out.println("init Local()"); }
      Local(int dummy) {
      // This line crashes the compiler.
      this();
      System.out.println("init Local(int)");
      }
      void baz() throws Exception {
      System.out.println(xx);
      if (xx != 12345) {
      throw new Exception("error");
      }
      }
      }

      Local o1 = new Local(1);
      Local o2 = new Local();

      o1.baz();
      o2.baz();
      }
          }

          public static void main(String[] args) throws Exception {
      UpLevel o1 = new UpLevel();
      Inner o2 = o1.new Inner();
      o2.foo();
          }

      }

      Compiling with javac from JDK 1.2beta3 results in a compiler error:

      ERROR: sun.tools.java.CompilerError: stack under flow: 12: invokespecial UpLevel. 1$Local(int) = -1
      -- listing --
      $9:
      12: aload 0
      12: invokespecial UpLevel. 1$Local(int)
      13: getstatic java.io.PrintStream out
      13: ldc "init Local(int)"
      13: invokevirtual void println(java.lang.String)
      10: return
      sun.tools.java.CompilerError: stack under flow: 12: invokespecial UpLevel. 1$Local(int) = -1
      at sun.tools.asm.Assembler.balance(Assembler.java:246)
      at sun.tools.asm.Assembler.write(Assembler.java:378)
      at sun.tools.javac.SourceClass.compileClass(SourceClass.java:1969)
      at sun.tools.javac.SourceClass.compile(SourceClass.java:1690)
      at sun.tools.javac.Main.compile(Main.java:408)
      at sun.tools.javac.Main.main(Main.java:571)
      error: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
      1 error

      william.maddox@Eng 1998-05-05

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: