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

1.2.2 javac doesn't correctly compile classes containing an inner class

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: avC70361 Date: 02/11/99



        javac of jdk 1.2.2 doesn't correctly compile a class which contains a final private field
      and an inner non-static class. The field is initialized in the class constructor and the inner
      class code should reference to the field. In that case the javac throws an error: "Blank final
      variable 'a' may not have been initialized. It must be assigned a value in an initializer, or
      in every constructor". But the field has been initialized in the constructor.
        If the field is not private, or is not refferenced to in the inner class, or initialized by
      not a constructor code the bug doesn't arises.

      Here is a test demonstrating the bug.
      ---------------A.java--------------
      public class A {
        final private Object a;

        public A() {
          a = null;
        }

        public class B {
          Object b;

          public B() {
            b = a;
          }
        }
      }
      --------------The test output---------
      > javac A.java
      A.java:2: Blank final variable 'a' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
        final private Object a;
                              ^
      1 error

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              wmaddoxsunw William Maddox (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: