Summary: | Use reflection instead of byte-code to resolve types during LTW | ||||||
---|---|---|---|---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Matthew Webster <matthew_webster> | ||||
Component: | Compiler | Assignee: | Adrian Colyer <adrian.colyer> | ||||
Status: | RESOLVED FIXED | QA Contact: | |||||
Severity: | enhancement | ||||||
Priority: | P3 | CC: | avasseur, holger | ||||
Version: | unspecified | ||||||
Target Milestone: | 1.5.2 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Matthew Webster
2005-10-28 06:49:15 EDT
This should be target 1.5.1 I have started working on an implementation of LTWWorld; see the attached patch for what I have so far. This code is better than any previous attempts to implement this because it's now checking parent hierarchies for already defined classes using resource URL's to check for delegation. However, I'm hitting 4 problems, at least 3 of which look like bugs in the AJ 1.5 reflection delegates implementation. I think that the next step to making this work is more tests on the reflection cases.... 1. One Matthew and I hit before. In UnresolvedType, there are cases where it is calling nameToSignature on a signature. This seems to happen predicably if you call getDeclaredMethods() on the delegate for anything that defines an array of generic types, E.g., javax.servlet.http.HttpServlet. Matthew was able to isolate a problem like this by replacing one of the reflection reference type delegate test cases to test behavior on Class instead of on Object. I worked around this problem by just returning the signature: private static String nameToSignature(String name) { ... if (name.length() != 0) { // lots more tests could be made here... // check if someone is calling us with something that is a signature already if (name.charAt(0)=='[') { //XXX hack System.err.println("still need hack"); return name; //throw new BCException("Do not call nameToSignature with something that looks like a signature (descriptor): '"+name+"'"); } 2. The other looks like a problem from calling getDeclaredMethods() on a raw type. I get this stack trace for a number of collection types. I tried commenting out the isRawType() case in ReferenceType:397 and it seems to avoid the problem if (isParameterizedType()) {// || isRawType()) { Can't ask to parameterize a member of a non-generic type java.lang.IllegalStateException: Can't ask to parameterize a member of a non-generic type at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:605) at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:590) at org.aspectj.weaver.ReferenceType.getDeclaredMethods(ReferenceType.java:402) at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:252) at org.aspectj.weaver.ResolvedType.addAndRecurse(ResolvedType.java:266) at org.aspectj.weaver.ResolvedType.getMethodsWithoutIterator(ResolvedType.java:247) at org.aspectj.weaver.ResolvedType.lookupResolvedMember(ResolvedType.java:365) at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:167) at org.aspectj.weaver.JoinPointSignatureIterator.hasNext(JoinPointSignatureIterator.java:68) at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:285) at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:105) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:57) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:55) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:55) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:55) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:64) at org.aspectj.weaver.Advice.match(Advice.java:109) at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:105) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:2113) at org.aspectj.weaver.bcel.BcelClassWeaver.matchInvokeInstruction(BcelClassWeaver.java:2100) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1882) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1708) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:455) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:102) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1534) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1485) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1266) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1088) at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:267) at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:199) at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:67) at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52) ... 3. I also get a similar error as in #2 from ReferenceType.getDeclaredMethods on overridden methods. E.g., int java.util.Map.hashCode() appears as a declared method on the ReferenceType for java.util.Map<java.lang.Object,java.lang.Object>, but its declaring type, java.util.Map is raw. This if test on ReferenceType:403 works around this problem: if (delegateMethods[i].getDeclaringType().equals(this)) { parameterizedMethods[i] = delegateMethods[i].parameterizedWith(parameters,this,isParameterizedType()); } 4. However, I now get this NPE when looking for aMember representing java.lang.Object java.util.AbstractMap.put(K, java.lang.Object), with an array of null parameterizedMethods (probably because of my workaround to #3 java.lang.NullPointerException at org.aspectj.weaver.ResolvedType.lookupResolvedMember(ResolvedType.java:373) at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:167) at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:197) at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:165) at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:197) at org.aspectj.weaver.JoinPointSignatureIterator.hasNext(JoinPointSignatureIterator.java:68) at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:285) at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:105) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:57) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:55) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:55) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:55) at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:145) at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:64) at org.aspectj.weaver.Advice.match(Advice.java:109) at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:105) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:2113) at org.aspectj.weaver.bcel.BcelClassWeaver.matchInvokeInstruction(BcelClassWeaver.java:2100) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1882) at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:1708) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:455) at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:102) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1534) at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1485) at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1266) at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1088) at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:267) at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:199) at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:67) at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52) at sun.instrument.TransformerManager.transform(TransformerManager.java:122) ... Created attachment 30363 [details]
implementation of LTWWorld
still pending more testing
Over the last few weeks I've hit all of the problems Ron is describing (whilst investigating other stuff...) and I've not done any LTW or used a reflection world - I think there are just bugs in that code and we don't have enough test programs for generic types (whether they are referred to in RAW form or not). I will write a few and see what comes out... Interesting... See also bug #117622 with some tests and bug #117624 with one fix. The unit test for bug #117622 exhibits the same failure as item 1 below and with the same work-around, the same failure as item 2 below, with that work-around it exhibits failure 3. I have submitted a new tracking bug #117628 for this specific problem. is this now resolved with LTWWorld in use for LTW? anyone going to reply to my previous comment? I'll close this soon if no-one says otherwise... I have opened Bug 149140. |