Bug 214994 - ArrayIndexOutOfBoundsException
Summary: ArrayIndexOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows Vista
: P3 major with 1 vote (vote)
Target Milestone: 1.6.0 RC1   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-11 01:28 EST by kunalrock CLA
Modified: 2008-03-24 15:48 EDT (History)
2 users (show)

See Also:


Attachments
Aspect J program in which I got bug (2.39 KB, application/octet-stream)
2008-01-11 01:28 EST, kunalrock CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description kunalrock CLA 2008-01-11 01:28:13 EST
Created attachment 86642 [details]
Aspect J program in which I got bug

Hi,
I got ArrayOutOfBoundException for my aspectJ program that is attached with this email.
Just before the compilation, I added a generic element <E> while declaring an inter-type variable.

Initially the successfully compiled code was :
public List < Observer< LinkedList<E>> > LinkedList.observersList = new Vector< Observer<LinkedList<E>> >();

I changed to 
public List < Observer< LinkedList<E>> > LinkedList<E>.observersList = new Vector< Observer<LinkedList<E>> >();

and I got below exception message:


java.lang.ArrayIndexOutOfBoundsException
at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.internalMakeMethodBinding(EclipseFactory.java:824)
at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.internalMakeMethodBinding(EclipseFactory.java:793)
at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.makeMethodBinding(EclipseFactory.java:773)
at org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration.resolve ... ob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Compile error: ArrayIndexOutOfBoundsException thrown: 0


Thanks,
Kunal Pathak.
Comment 1 Ludger Solbach CLA 2008-03-24 13:16:30 EDT
Hi,

I've got the same exception on the same line while compiling a generic aspect.

The problem seems to be caused by trying to access a field declared on a generic type via an inter-type declaration.


public abstract aspect Composite<Item, Container> {

  private C CompositeItem<C>.container;

  public List<I> CompositeContainer<I>.itemList = new ArrayList<I>();

  public CompositeContainer<I> CompositeContainer<I>.addItem(I i) {
    itemList.add(i);

// Commenting out this line results in the described Exception
//  i.container = this;

    return this;
  }

// interface/parents declaration and further methods left out
}

Replacing the field access with a setter method doesn't help...

The Bug is still present in AJDT 1.5.1.
Comment 2 Andrew Clement CLA 2008-03-24 15:48:40 EDT
test and fix committed for AspectJ1.6.0rc1.  Will be in AJDT shortly.