Project: AspectJ
Bug 138286 perthis() causes ClassCastException
Reported: 2006-04-24 18:29:34 | Status: resolved fixed

When using perthis() with an aspect, I see the following Internal Compiler AJDT 1.3.1 / AspectJ 1.5.1a Build 20060406092046 Eclipse 3.1.2, Windows XP, JDK 1.5 Error: java.lang.ClassCastException at org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor.getPerTypePointcut(PerThisOrTargetPointcutVisitor.java:41) at org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor.visit(PerThisOrTargetPointcutVisitor.java:108) at org.aspectj.weaver.patterns.AndPointcut.accept(AndPointcut.java:119) at org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor.getPerTypePointcut(PerThisOrTargetPointcutVisitor.java:41) at org.aspectj.weaver.PerObjectInterfaceTypeMunger.getTestTypePattern(PerObjectInterfaceTypeMunger.java:64) at org.aspectj.weaver.PerObjectInterfaceTypeMunger.matches(PerObjectInterfaceTypeMunger.java:85) at org.aspectj.weaver.ConcreteTypeMunger.matches(ConcreteTypeMunger.java:65) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:508) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:109) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1560) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1511) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1291) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1089) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:311) at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:183) at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70) at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:367) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:862) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:242) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:161) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:278) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:168) at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:117) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191) trouble in: public abstract class org.apache.tapestry.internal.aspects.AbstractClassTargetting extends java.lang.Object: public void <init>(): ALOAD_0 // Lorg/apache/tapestry/internal/aspects/AbstractClassTargetting; this (line 10) INVOKESPECIAL java.lang.Object.<init> ()V initialization(void org.apache.tapestry.internal.aspects.AbstractClassTargetting.<init>()) | ALOAD_0 | INVOKEVIRTUAL java.lang.Object.getClass ()Ljava/lang/Class; | LDC org.apache.tapestry.internal.annotations.Synchronized | INVOKEVIRTUAL java.lang.Class.isAnnotationPresent (Ljava/lang/Class;)Z | IFEQ L0 | ALOAD_0 | INVOKESTATIC org.apache.tapestry.internal.aspects.InternalSynchronization.ajc$perObjectBind (Ljava/lang/Object;)V | constructor-execution(void org.apache.tapestry.internal.aspects.AbstractClassTargetting.<init>()) | | L0: ALOAD_0 | | INVOKEVIRTUAL java.lang.Object.getClass ()Ljava/lang/Class; | | LDC org.apache.tapestry.internal.annotations.Synchronized | | INVOKEVIRTUAL java.lang.Class.isAnnotationPresent (Ljava/lang/Class;)Z | | IFEQ L1 | | ALOAD_0 | | INVOKESTATIC org.apache.tapestry.internal.aspects.InternalSynchronization.ajc$perObjectBind (Ljava/lang/Object;)V | | L1: RETURN | constructor-execution(void org.apache.tapestry.internal.aspects.AbstractClassTargetting.<init>()) initialization(void org.apache.tapestry.internal.aspects.AbstractClassTargetting.<init>()) end public void <init>() abstract void ajc$pointcut$$targetClasses$274() org.aspectj.weaver.MethodDeclarationLineNumber: 16:628 ; end public abstract class org.apache.tapestry.internal.aspects.AbstractClassTargetting when weaving type org.apache.tapestry.internal.aspects.AbstractClassTargetting when weaving aspects when weaving when batch building BuildConfig[C:\workspace\.metadata\.plugins\org.eclipse.ajdt.core\tapestry5.generated.lst] #Files=70 I'll attach the corresponding files.

Files changed in fix:
tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java weaver/src/org/aspectj/weaver/patterns/PerThisOrTargetPointcutVisitor.java