Bug 100227 - [generics][itds] inner class with generic enclosing class
Summary: [generics][itds] inner class with generic enclosing class
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.5.0 M3   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-15 12:24 EDT by Samuel Gélineau CLA
Modified: 2005-06-20 05:37 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Gélineau CLA 2005-06-15 12:24:09 EDT
ajc crashes with a NullPointerException when an intertype declaration tries to
modify an inner class, if the enclosing (outer) class is generic:

class Outer {
  class Inner {}
}

class Generic_Outer<T> {
  class Inner {}
}

aspect Injector {
  int Outer.outer; // works
  int Outer.Inner.inner; // works
  int Generic_Outer.outer; // works
  int Generic_Outer.Inner.inner; // crashes
}


/home/user/sgelin3/dev/java/ajc/new_bug/Bug.java [error] Internal compiler error
java.lang.NullPointerException
        at
org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.fromBinding(EclipseFactory.java:202)
        at
org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration.build(InterTypeFieldDeclaration.java:173)
        at
org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration.buildInterTypeAndPerClause(AspectDeclaration.java:1020)
        at
org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.buildInterTypeAndPerClause(AjLookupEnvironment.java:306)
        at
org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:122)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:302)
        at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:316)
...
Comment 1 Samuel Gélineau CLA 2005-06-15 12:32:43 EDT
I've sent quite a few bug reports on the interaction of ITD with generics, so by
now I know that they all get "1.5.0 M3" as a target. I'd save you the trouble of
setting that target every time but:

"You tried to change the Target Milestone field from --- to 1.5.0 M3, but only
the owner or submitter of the bug, or a sufficiently empowered user, may change
that field."

strange, since I _am_ the submitter of the bug!


anyway, sorry to bother you with so many similar looking bugs (98320, 98592,
99168, 99228 and now 100227), I know that I am not supposed to expect generics
to work completely until M3, and keep up the good work!
Comment 2 Andrew Clement CLA 2005-06-16 04:15:04 EDT
Its great that you are spending time creating these minimal testcases for bugs
that I can work on, keep it up!  You are bound to hit something we've not
created testcases for yet.

In this case it appears there is a special form of ParameterizedTypeBinding
known to the compiler.  It is a PTB whose arguments (type parameters) are null -
this doesn't mean it is a raw type as raw type is a subtype of
ParameterizedTypeBinding.  From a quick look round the JDT compiler, it *looks*
like a PTB with null arguments represents an inner type of a parameterized type
that itself specifies no type parameters.  Presumably it 'inherits' any from the
enclosing type.

So, the fix is to allow for null type parameters - and ensure we don't
misintepret the null as a raw type ref.
Comment 3 Andrew Clement CLA 2005-06-16 04:30:09 EDT
Fix checked in, waiting on build.
Comment 4 Andrew Clement CLA 2005-06-20 05:37:14 EDT
Dev build available from the download page: 
aspectj-DEVELOPMENT-20050620091600.jar