Summary: | ITCs don't run field initialisers | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Oege de Moor <oege> |
Component: | Compiler | Assignee: | Adrian Colyer <adrian.colyer> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | enhancement | ||
Priority: | P2 | ||
Version: | 1.2 | ||
Target Milestone: | 1.5.0RC1 | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Oege de Moor
2004-05-18 04:35:04 EDT
/* ITC's don't run field initialisers. Intertype constructors cannot possibly run the field initialisers of the target when you're weaving into byte code. ajc appears to take this as a license not to run the field initialisers, even when weaving into source. This is illustrated by the program below. Requests: * print warning when ITC applies to bytecode and does not call an existing constructor; * do run field initialisers when weaving into source and there is no call to an existing constructor. */ aspect Aspect { public A.new(int a) {} // no init of z } class A { int z = 3; public A() { } // init of z=3 } public class ITA3 { public static void main(String[] args) { System.out.println(new A(4).z); // print 0 System.out.println(new A().z); // print 3 } } this needs looking into in the AJ5 timeframe... we need to at least add the suggested warning before 1.5.0 RC1 - the current behaviour will be very surprising to users (if seldom encountered...) Warning implemented. If an ITDC does not contain an explicit cons call a new Xlint:noExplicitConstructorCall warning is issued. This can be suppressed using the @SuppressAjWarnings or @SuppressAjWarnings({"noExplicitConstructorCall"}) forms if desired. |