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

Compiler loops on illegal input involving inner classes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.1
    • tools
    • None
    • sparc
    • solaris_2.5.1

      Given the following illegal program, the compiler enters what appears to be an
      infinite loop:

          public class Bug {

      private void foo() {
      }

      private Thread bar
      = new Thread() {
      public void run() {
      for (;;) {
      Bug.this.foo();
      }
      }
      };

          }

      If the for loop is removed but the invocation of foo() left intact, then the
      compiler terminates. Both behaviors are wrong since foo() is private and
      access to it should not be allowed. The 1.1 compiler gets this right, but
      seems to have another problem:

          % /usr/local/java/jdk1.1/solaris/bin/javac Bug.java
          ERROR: sun.tools.java.CompilerError: stack under flow: 8: putfield java.lang.Thread bar = -1
          -- listing --
          $3:
          2: aload 0
          2: invokespecial java.lang.Object()
          8: aload 0
          8: new local class Bug. 1
          8: dup
          0: aload 0
          8: invokespecial Bug. 1(Bug,Bug)
          8: putfield java.lang.Thread bar
          2: return
          Bug.java:11: Access across scopes to the private member void foo() in class Bug is not implemented. The reference will succeed if the member is given package scope.
      Bug.this.foo();
      ^
          1 error
          %

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: