Community
Participate
Working Groups
With the AspectJ 1.5.0M5 compiler, an inter-type field declaration of type int with an initializer is not type-checked to prevent an attempt to assign null into the field by default. The result is a VerifyError at runtime. Is this the intended behavior? I couldn't find any evidence in the AspectJ documentation that initializers on inter-type field declarations should not be type checked, but I can't admit to being particularly experienced with AspectJ. Here is code that reproduces the problem: ------------------ // Foo.java public class Foo { public static void main(String[] args) { Foo f = new Foo(); } } ------------------ // Bar.java public aspect Bar { public int Foo.x = null; } ------------------ I compiled the code with the following command: ajc -1.5 -source 1.5 Foo.java Bar.java
Created attachment 30735 [details] The example files: Foo.java, Bar.java
almost got a fix for this...
turns out my 'almost fix' breaks some other testcases. The problem is that there is no validity checking for the 'initialization' object for an intertype field declaration. The solution is to copy the validation logic from FieldDeclaration.resolve(MethodScope) - about line 207 - into the IntertypeFieldDeclaration resolve() method. This then causes my test programs for this bug to pass (the test programs *are* checked into CVS, but commented out in Ajc150Tests). However, there are side effects in that initialization checking code (seems to be this call: initializationType = this.initialization.resolveType(initializationScope)) which cause other tests to break... as this is a long standing problem and we *need* to get 1.5.0 finished, I'm deferring for a proper look in 1.5.1...
unsetting the target field which is currently set for something already released