Bug 201748 - ITD static array, type check error
Summary: ITD static array, type check error
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-30 10:58 EDT by charles CLA
Modified: 2013-06-24 11:03 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description charles CLA 2007-08-30 10:58:34 EDT
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)
Comment 1 Andrew Clement CLA 2007-10-09 12:55:23 EDT
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?
Comment 2 charles CLA 2007-12-07 23:40:08 EST
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?
> 

Comment 3 Andrew Clement CLA 2008-03-08 14:44:21 EST
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...
Comment 4 Andrew Clement CLA 2008-03-11 12:22:29 EDT
testcase committed - commented out in Ajc160Tests
Comment 5 Andrew Clement CLA 2013-06-24 11:03:52 EDT
unsetting the target field which is currently set for something already released