Bug 203646 - NPE compiling inter-type declaration on inner generic interface
Summary: NPE compiling inter-type declaration on inner generic interface
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 1.5.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-17 15:56 EDT by Joshua Caplan CLA
Modified: 2007-11-07 05:06 EST (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 Joshua Caplan CLA 2007-09-17 15:56:14 EDT
The following program causes an NPE:

interface I {
	interface J< T > {
		T getT();
	}
}
public aspect InnerGenericInterface {
	public T I.J< T >.intro() {
		return null;
	}
}

The following very similar program compiles and works fine:

interface J< T > {
	T getT();
}
public aspect InnerGenericInterface {
	public T J< T >.intro() {
		return null;
	}
}

Here's the exception trace:
java.lang.NullPointerException
at org.aspectj.ajdt.internal.core.builder.AsmElementFormatter.genLabelAndKind(AsmElementFormatter.java:162)
at org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder.visit(AsmHierarchyBuilder.java:392)
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:185)
at org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.ja ... on$1.run(GlobalBuildAction.java:183)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

Compile error: NullPointerException thrown: null
Comment 1 Joshua Caplan CLA 2007-09-17 15:59:12 EDT
removing some noise from test program:

// fails

interface I {
	interface J< T > {}
}
public aspect InnerGenericInterface {
	public void I.J< T >.intro() {}
}

// succeeds

interface J< T > {}
public aspect InnerGenericInterface {
	public void J< T >.intro() {}
}

Comment 2 Andrew Clement CLA 2007-10-29 12:03:31 EDT
ok - i've committed fixes for this.  If you go further with ITDs on generic types, we still break, but I think that may need some parsing rule changes.  For example:

interface I1<A> {
  interface I2<B> {}
}

aspect X {
  public void I1<X>.I2<Y>.foo(X x,Y y) {}
}

could be possible but doesn't compile at the moment:

ajc -1.5 Cool.java
Cool.java:8 [error] Syntax error on token(s), misplaced construct(s)
public void I1<X>.I2<Y>.foo(X x,Y y) {}
              ^^^

1 error

Comment 3 Andrew Clement CLA 2007-11-07 05:06:06 EST
bug 208991 raised to cover the double type parameterization case, closing this issue as fixed in 1.5.4