Bug 224968 - NPE at TypeVariableBinding.constantPoolName()
Summary: NPE at TypeVariableBinding.constantPoolName()
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.4   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 1.6.1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-31 14:54 EDT by Ludger Solbach CLA
Modified: 2008-06-12 18:37 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludger Solbach CLA 2008-03-31 14:54:53 EDT
I'm getting all kinds of strange effects with the aspect below...

On a stripped down version of my project with just the aspect in Eclipse 3.3 with AJDT 1.5.1 I'm getting this exception.

java.lang.NullPointerException
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding.constantPoolName(TypeVariableBinding.java:226)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.signature(ReferenceBinding.java:1015)
at org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding.signature(MethodBinding.java:724)
at org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile.generateMethodInf ... AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Compiling with the ant iajc task works for the abstract aspect, but then I get a compiler error instanciating it for 2 classes (MenuItem, Menu).

---8<---

package org.soulspace.pattern.composite;

import java.util.List;
import java.util.ArrayList;

public abstract aspect AbstractCompositeAspect<Item, Container> {

	public interface CompositeItem<C extends CompositeContainer> {
		C getContainer();
		int getRootDistance();
	}
	
	public interface CompositeContainer<I extends CompositeItem> extends CompositeItem {
		List<I> getItemList();
		CompositeContainer<I> addItem(I item);
		CompositeContainer<I> removeItem(I item);
	}

	private C CompositeItem<C>.container;
	public C CompositeItem<C>.getContainer() {
		return container;
	}
    public void CompositeItem<C>.setContainer(C c) {
    	container = c;
    }
	
	public int CompositeItem<C>.getRootDistance() {
		if(container == null) {
			return 0;
		} else {
			return container.getRootDistance() + 1;
		}
	}

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

	public List<I> CompositeContainer<I>.getItemList() {
		return itemList;
	}

	public CompositeContainer<I> CompositeContainer<I>.addItem(I i) {
		itemList.add(i);
//		i.container = this;
//		i.setContainer(this);
		return this;
	}

	public CompositeContainer<I> CompositeContainer<I>.removeItem(I i) {
		if(itemList.remove(i)) {
//			i.container = null;
		}
		return this;
	}
	
	declare parents : Item implements CompositeItem;
	declare parents : Container implements CompositeContainer<Item>;


	public pointcut addingItem(Item i, Container c) :
		execution(* CompositeContainer.addItem(CompositeItem))
		&& this(c)
		&& args(i)
		;
	
}
Comment 1 Ludger Solbach CLA 2008-03-31 14:59:22 EDT
uncommenting any of the commented lines results in Bug 166514 (as commented there) by the way.
	

Comment 2 Andrew Clement CLA 2008-04-01 01:38:36 EDT
investigate for rc1
Comment 3 Andrew Clement CLA 2008-04-01 20:17:36 EDT
Are you on eclipse 3.3.1 or 3.3.2?

I defined a new project in eclipse 3.3.1.1 with AJDT 1.5.1.200801111942 installed.  I defined the single file included here and it compiles ok, i can't get it to NPE.

I then uncommented all the commented out lines and just got a type safety warning, no error.  Can I recommend you upgrade to a dev build of AJDT1.5.2 and see if it still happens?  if I can recreate it and fix it, the fix will be put into AJDT1.5.2 final.

Do I need the concrete aspect definitions around too? in order to make it fail?
Comment 4 Andrew Clement CLA 2008-06-11 16:55:03 EDT
no reply for a couple of months.  However, in looking at bug 223226 I recreated the NPE described here and I think it might be the same problem.  The problem is that there is something the compiler wants to tell you about (a real problem) but it crashes with the NPE before it gets reported (the real error leaves us in a broken state that leads to the NPE).  I've fixed the NPE from occurring which means the real problem should now get reported and can be addressed.

fix for 223226 should make it into ajdt shortly
Comment 5 Andrew Clement CLA 2008-06-12 18:37:31 EDT
fix is in todays AJDT I believe, 1.5.3.200806121750 - which is replicating across servers as I write this.

please reopen if it still fails like this for you.