[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] final ITD field

Shouldn't the ITD *look* final at compile-time,
(regardless of the implementation), since there's
no caveat in the programming guide?

If so, any other constructor (and since 1.1 there
always is one) will not have initialized the new final
member, so it provokes a compiler error.

Like this in Java:

----
public class Hello {

        public static int i1;

        public final int i2;

        public Hello(int i) {
                i2 = i; // ERROR
        }
        public Hello() {
                i1 = 9;
        }
}
----

Wes


Matthew Webster wrote:




While I know that a final ITD is not actually final and understand why (couldn't be initialized from outside target class) I am puzzled that an instance field cannot be set within an ITD constructor. Is this just a current compiler limitation or is there some more fundamental restriction. In the following example I can set in a constructor a final field defined in HelloWorld but not an ITD field within an ITD constructor

public class HelloWorld {

      public static int i1;

      public HelloWorld () {
            i1 = 9;
      }

      public void println () {
            System.out.println("Hello World!");
      }

      public static void main(String[] args) {
            new HelloWorld().println();
      }
}

public aspect ITDModifiersTest {

      public final int HelloWorld.i2;

      public HelloWorld.new (int i) {
            i2 = i; // ERROR
      }

}

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev