Project: AspectJ
Bug 153535 Bug in reflection delegate signature for array of object type
Reported: 2006-08-11 03:34:59 | Status: resolved fixed

The following problem is interesting because the advice weaves correctly with Java 1.5 LTW and also using Java 1.4 with build-time weaving. However, the following call pointcut isn't matching the expected call site in Java 1.4 load-time weaving (*). Pointcut: private pointcut inExecQuery() : (within(uk.ltd.getahead.dwr.impl.ExecuteQuery) || within(uk.ltd.getahead.dwr.ExecuteQuery)); public pointcut dwrQuery(Method method, Object receiver, Object[] params) : inExecQuery() && withincode(* execute(..)) && call(* Method.invoke(..)) && args(receiver, params) && target(method); protected pointcut monitorEnd() : dwrQuery(*, *, *); Matching call site: Object reply = method.invoke(object, params); I've tracked it down to failing to find the method in ResolvedType.matches. On line 405: "m1.getSignature()"= "(Ljava/lang/Object;[Ljava.lang.Object;)Ljava/lang/Object;" "m2.getSignature()"= "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;" Note the difference between . and / ^ ^ It looks to me like the signature for array types in the reflection delegate is erroneously using . instead of /. I have attached a patch to the ReflectionBasedReferenceTypeDelegateTest that isolates this unexpected signature return. Hopefully you agree that this is not correct. If not, some more information follows. Here's the stack trace where the match fails: ResolvedType.matches(Member, Member) line: 405 ReferenceType(ResolvedType).lookupMember(Member, Iterator) line: 347 ReferenceType(ResolvedType).lookupMethod(Member) line: 326 LTWWorld(World).resolve(Member) line: 504 MemberImpl.resolve(World) line: 93 JoinPointSignatureIterator.addSignaturesUpToFirstDefiningMember() line: 109 JoinPointSignatureIterator.<init>(Member, World) line: 51 MemberImpl.getJoinPointSignatures(World) line: 943 SignaturePattern.matches(Member, World, boolean) line: 286 KindedPointcut.matchInternal(Shadow) line: 106 KindedPointcut(Pointcut).match(Shadow) line: 146 AndPointcut.matchInternal(Shadow) line: 53 AndPointcut(Pointcut).match(Shadow) line: 146 AndPointcut.matchInternal(Shadow) line: 51 AndPointcut(Pointcut).match(Shadow) line: 146 AndPointcut.matchInternal(Shadow) line: 51 AndPointcut(Pointcut).match(Shadow) line: 146 AndPointcut.matchInternal(Shadow) line: 51 AndPointcut(Pointcut).match(Shadow) line: 146 OrPointcut.matchInternal(Shadow) line: 50 OrPointcut(Pointcut).match(Shadow) line: 146 BcelAdvice(ShadowMunger).match(Shadow, World) line: 71 BcelAdvice(Advice).match(Shadow, World) line: 112 BcelAdvice.match(Shadow, World) line: 107 BcelClassWeaver.match(BcelShadow, List) line: 2806 BcelClassWeaver.matchInvokeInstruction(LazyMethodGen, InstructionHandle, InvokeInstruction, BcelShadow, List) line: 2768 BcelClassWeaver.match(LazyMethodGen, InstructionHandle, BcelShadow, List) line: 2506 BcelClassWeaver.match(LazyMethodGen) line: 2332 BcelClassWeaver.weave() line: 494 BcelClassWeaver.weave(BcelWorld, LazyClassGen, List, List, List) line: 119 BcelWeaver.weave(UnwovenClassFile, BcelObjectType, boolean) line: 1613 BcelWeaver.weaveWithoutDump(UnwovenClassFile, BcelObjectType) line: 1564 BcelWeaver.weaveAndNotify(UnwovenClassFile, BcelObjectType, IWeaveRequestor) line: 1341 BcelWeaver.weave(IClassFileProvider) line: 1163 ClassLoaderWeavingAdaptor(WeavingAdaptor).getWovenBytes(String, byte[]) line: 319 ClassLoaderWeavingAdaptor(WeavingAdaptor).weaveClass(String, byte[]) line: 225 Aj.preProcess(String, byte[], ClassLoader) line: 77 ClassPreProcessorAdapter.preProcess(String, byte[], ClassLoader) line: 67 ClassPreProcessorHelper.defineClass0Pre(ClassLoader, String, byte[], int, int, ProtectionDomain) line: 107 WebappClassLoader(ClassLoader).defineClass(String, byte[], int, int, ProtectionDomain) line: 539 WebappClassLoader(SecureClassLoader).defineClass(String, byte[], int, int, CodeSource) line: 123 WebappClassLoader.findClassInternal(String) line: 1786 WebappClassLoader.findClass(String) line: 1048 WebappClassLoader.loadClass(String, boolean) line: 1506 WebappClassLoader.loadClass(String) line: 1385 WebappClassLoader(ClassLoader).loadClassInternal(String) line: 302 Class.forName0(String, boolean, ClassLoader) line: not available [native method] Class.forName(String) line: 141 InitializeLog.setWarnLogging(String) line: 121 InitializeLog.initializeLogging() line: 96 ContextLoaderServlet.init() line: 13 ContextLoaderServlet(GenericServlet).init(ServletConfig) line: 212 StandardWrapper.loadServlet() line: 879 StandardWrapper.load() line: 767 StandardContext.loadOnStartup(Container[]) line: 3483 StandardContext.start() line: 3709 StandardHost(ContainerBase).addChildInternal(Container) line: 776 StandardHost(ContainerBase).addChild(Container) line: 759 StandardHost.addChild(Container) line: 537 StandardHostDeployer.install(String, URL) line: 260 StandardHost.install(String, URL) line: 730 HostConfig.deployWARs(File, String[]) line: 558 HostConfig.deployApps() line: 373 HostConfig.start() line: 784 HostConfig.lifecycleEvent(LifecycleEvent) line: 330 LifecycleSupport.fireLifecycleEvent(String, Object) line: 119 StandardHost(ContainerBase).start() line: 1155 StandardHost.start() line: 696 StandardEngine(ContainerBase).start() line: 1147 StandardEngine.start() line: 310 StandardService.start() line: 449 StandardServer.start() line: 2212 Catalina.start() line: 458 Catalina.execute() line: 345 Catalina.process(String[]) line: 129 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object[]) line: 324 Bootstrap.main(String[]) line: 150 I'm using a modified version of Alex Vasseur's LTW plugin for a Java 1.4 VM although I haven't tested on the JRockIt plugin for a 1.4 VM: my guess is that this would fail there too.

Files changed in fix:
weaver/src/org/aspectj/weaver/reflect/ReflectionWorld.java weaver/testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java