[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Generics and Abstract Pointcut

Hi all,

I've been struggling to create a very simple interceptor aspect using generics and abstract pointcuts. The code is below:

// A simple class using generics
public abstract class AbstractAdapter<T extends Serializable> {
   protected abstract T execute(T message);
}

// The concrete class to be intercepted
public class Adapter extends AbstractAdapter<String> {
   @Override
    public String execute(String message) {
      return message;
    }
}

// The abstract aspect using generics
@Aspect
public abstract class AbstractProbingAspect<T> {
   @Pointcut("")
   protected abstract void adapterMethodExecution();

   @Around("adapterMethodExecution()")
   public Object around(ProceedingJoinPoint thisJoinPoint) throws Throwable {
      return thisJoinPoint.proceed();     
   }

   protected abstract String extractFunctionName(T command);
}

// The concrete aspect
@Aspect
public class ProbingAspect extends AbstractProbingAspect<String> {
   @Pointcut("execution(String test.aop.Adapter.execute(String))")
   protected void adapterMethodExecution() {};
  
   @Override
   protected String extractFunctionName(String command) {  
      return String.valueOf(command);
   }
}

It seems ok to me but when I try to compile it I receive the error below (aspectj 1.6.10, aspectjweaver 1.6.1). Any ideas about what I'm doing wrong?

Thanks in advance,

Andre

[INFO] --- aspectj-maven-plugin:1.3.1:compile (default) @ test-aop ---
[ERROR] Internal compiler error
java.lang.NullPointerException
   at org.aspectj.weaver.ResolvedPointcutDefinition.parameterizedWith(ResolvedPointcutDefinition.java:121)
   at org.aspectj.weaver.ReferenceType.getDeclaredPointcuts(ReferenceType.java:783)
   at org.aspectj.weaver.ResolvedType.getExposedPointcuts(ResolvedType.java:2317)
   at org.aspectj.weaver.ResolvedType.getExposedPointcuts(ResolvedType.java:2310)
   at org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType.checkPointcutDeclarations(EclipseSourceType.java:462)
   at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.resolvePointcutDeclarations(AjLookupEnvironment.java:489)
   at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:279)
   at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:616)
   at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:357)
   at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:371)
   at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1021)
   at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:268)
   at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:181)
   at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
   at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
   at org.aspectj.tools.ajc.Main.run(Main.java:371)
   at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
   at org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:370)
   at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
   at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
   at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
   at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
   at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
   at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
   at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
   at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
   at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
   at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:592)
   at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
   at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
   at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
   at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)