Community
Participate
Working Groups
This is actually on AJ compiler 1.5.4. To reproduce, use the following code: aspect MyAspect{ Factory AnyClass.myfactory = Factory.create(); } with Factory defined as follows: class Factory{ public static Factory[] create(){ return null; } } This aspect code actually PASSES type checking. You then get a runtime error: Exception in thread "Main Thread" java.lang.VerifyError: (class: AspectTest, method: ajc$interFieldInit$AspectTest$Client$myfactory signature: (LClient;)V) Incompatible argument to function at Client.<init>(Client.java:8) at Client.main(Client.java:14)
I don't have enough info to go on there, I added a class to the two you suggested: class AnyClass {public static void main(String[]argv) {}} and 'ajc *.java -showWeaveInfo' Type 'AnyClass' (A.java) has intertyped field from 'MyAspect' (A.java:'Factory AnyClass.myfactory') But when I then run it: java AnyClass it works fine. Are you able to supply the missing bits that actually fail?
Sorry for late responding. You could try instantiate the class: class AnyClass { public static void main(String []args){ new AnyClass(); } } (In reply to comment #1) > I don't have enough info to go on there, I added a class to the two you > suggested: > > > class AnyClass {public static void main(String[]argv) {}} > > > and 'ajc *.java -showWeaveInfo' > > Type 'AnyClass' (A.java) has intertyped field from 'MyAspect' (A.java:'Factory > AnyClass.myfactory') > > But when I then run it: > java AnyClass > > it works fine. > > Are you able to supply the missing bits that actually fail? >
Thanks. i recreated the problem. InterTypeFieldDeclaration.resolve(ClassScope) is where the check should go - unfortunately in addition to getting the real error out, I also get an error about problems resolving Factory, which is nonsense. This occurs because of problems resolving the type of the initializer in order to determine there is a mismatch between field type and initializer type. still thinking...
testcase committed - commented out in Ajc160Tests
unsetting the target field which is currently set for something already released