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

A block scoped class isn't seen by a reference from a nested block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.2.0
    • 1.1, 1.1.1, 1.1.4
    • tools
    • 1.2beta
    • generic, sparc
    • generic, solaris_2.5.1
    • Not verified


      /* A block scoped class isn't seen by a reference from a
       * nested block. The example below doesn't compile unless
       * the braces marked "XXX" are removed.

      mushmouth% javac BlockScopedClassBug1.java
      BlockScopedClassBug1.java:9: Class bar not found in type declaration.
            return new bar().getX();
                       ^
      1 error

       */

      public class BlockScopedClassBug1
      {
        protected int foo(final int x)
        {
          final class bar { int getX() {return x;} }

          { // XXX
            return new bar().getX();
          } // XXX
        }
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: