Bug 298675 - Can't ask to parameterize a member of non-generic type:
Summary: Can't ask to parameterize a member of non-generic type:
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-31 06:23 EST by Adrian Smith CLA
Modified: 2014-12-18 17:12 EST (History)
2 users (show)

See Also:


Attachments
ajc compiler output (31.33 KB, text/plain)
2009-12-31 06:23 EST, Adrian Smith CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Smith CLA 2009-12-31 06:23:43 EST
Created attachment 155151 [details]
ajc compiler output

Code that compiles OK in Eclipse will not compile using ajc or Ant task.

ajc output attached
Comment 1 Andrew Clement CLA 2010-01-01 15:50:24 EST
are you able to distill it down to a simple case that fails?  If not, are you able to tell me what the rice.Continuation$MultiContinuation declaration is and how it is parameterized when used in the type com.bt.koala.p2p.past.internalcontinuation.KoalaPastGetHandlesInsertContinuation

thanks.
Comment 2 Andrew Clement CLA 2013-06-24 11:06:32 EDT
unsetting the target field which is currently set for something already released
Comment 3 Philipp Keck CLA 2014-12-18 17:12:27 EST
I am affected by this IllegalStateException, as well, maybe with a different use case and in 1.8.4.

I use load-time weaving and @AspectJ annotations. In my aop.xml, I define a concrete aspect, which extends an abstract aspect that is defined in Java. This abstract aspect inherits from another aspect aspect, which is Generic. From my production instance, I removed as many things as possible (in particular the pointcuts and advices and multiple generic parameters) and ended up with the following (in 2 files):

@Abstract public abstract class AbstractAspect<C> {}
@Abstract public class ConcreteAspect extends AbstractAspect<Object> {}
// And ConcreteAspect is defined in aop.xml

That's all it takes to provoke this error:
[AppClassLoader@6fafc4c2] warning register definition failed -- (IllegalStateException) Can't ask to parameterize a member of non-generic type: aspect.AbstractAspect  kind(raw)
Can't ask to parameterize a member of non-generic type: aspect.AbstractAspect  kind(raw)
java.lang.IllegalStateException: Can't ask to parameterize a member of non-generic type: aspect.AbstractAspect  kind(raw)
	at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:759)
	at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:742)
	at org.aspectj.weaver.ReferenceType.getDeclaredMethods(ReferenceType.java:859)
	at org.aspectj.weaver.ResolvedType.getDeclaredAdvice(ResolvedType.java:977)
	at org.aspectj.weaver.ResolvedType.getDeclaredShadowMungers(ResolvedType.java:1017)
	at org.aspectj.weaver.ResolvedType.collectShadowMungers(ResolvedType.java:843)
	at org.aspectj.weaver.ResolvedType.collectCrosscuttingMembers(ResolvedType.java:770)
	at org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect(CrosscuttingMembersSet.java:113)
	at org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect(CrosscuttingMembersSet.java:68)
	at org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect(BcelWeaver.java:200)
	at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects(ClassLoaderWeavingAdaptor.java:485)
	at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions(ClassLoaderWeavingAdaptor.java:304)
	at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(ClassLoaderWeavingAdaptor.java:171)
	at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(Aj.java:340)
	at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.getWeavingAdaptor(Aj.java:345)
	at org.aspectj.weaver.loadtime.Aj$WeaverContainer.getWeaver(Aj.java:319)
	at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:113)
	at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:54)
	at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

The exception is thrown by this piece of code:
if ((!(getDeclaringType().isGenericType())) && (getDeclaringType().getName().indexOf("$") == -1))
{
      throw new IllegalStateException("Can't ask to parameterize a member of non-generic type: " + getDeclaringType() + "  kind(" + getDeclaringType().typeKind + ")");
}
TypeVariable[] typeVariables = getDeclaringType().getTypeVariables();
....

I don't know much about AspectJ, so I do not understand why this check is there in the first place. It fails because the getDeclaringType() is a raw type (typeKind=raw), namely the raw version of the AbstractAspect. However, it should work just fine without this check. When I put the AbstractAspect into another class, it becomes an inner class and the name contains a dollar sign. For some reason, the check makes an exception for inner classes, so it won't fail. I debugged the values around the above code snippets and they have the same values for the normal and for the inner class, except for the dollar sign. With the inner class, the parameter resolving works fine and my aspect is executed properly. (So this is also a workaround.)

In other words, this works, although it is practically the same as the above code:

public class Container {
    @Abstract public static abstract class AbstractAspect<C> {}
}
@Abstract public class ConcreteAspect extends Container.AbstractAspect<Object> {}
// And ConcreteAspect is defined in aop.xml