Community
Participate
Working Groups
Build ID: M20080911-1700 Steps To Reproduce: Get a ref to a AJProjectModelFacade for the project of the AJ Telecom example (say "model"). run model.programElementToJavaElement("=Telecom/src<telecom*Timing.aj}Timing&after&QConnection;!2?method-call(void telecom.Timer.stop())"); The argument string is the source handle from the second entry in the result of: AJRelationshipType[] relsTypes = {AJRelationshipManager.ADVISED_BY}; model.getRelationshipsForProject(relsTypes); More information: relevant stack trace: java.lang.NumberFormatException: For input string: "I" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:447) at java.lang.Integer.parseInt(Integer.java:497) at org.eclipse.jdt.internal.core.SourceRefElement.getHandleUpdatingCountFromMemento(SourceRefElement.java:156) at org.eclipse.jdt.internal.core.Member.getHandleFromMemento(Member.java:173) at org.eclipse.jdt.internal.core.SourceRefElement.getHandleUpdatingCountFromMemento(SourceRefElement.java:159) at org.eclipse.jdt.internal.core.Member.getHandleFromMemento(Member.java:173) at org.eclipse.jdt.internal.core.SourceRefElement.getHandleUpdatingCountFromMemento(SourceRefElement.java:159) at org.eclipse.jdt.internal.core.Member.getHandleFromMemento(Member.java:173) at org.eclipse.jdt.internal.core.SourceRefElement.getHandleUpdatingCountFromMemento(SourceRefElement.java:159) at org.eclipse.jdt.internal.core.Member.getHandleFromMemento(Member.java:173) at org.eclipse.jdt.internal.core.SourceRefElement.getHandleUpdatingCountFromMemento(SourceRefElement.java:159) at org.eclipse.jdt.internal.core.Member.getHandleFromMemento(Member.java:173) at org.eclipse.ajdt.core.javaelements.AspectElement.getHandleFromMemento(AspectElement.java:264) at org.eclipse.ajdt.core.javaelements.AJCompilationUnit.getHandleFromMemento(AJCompilationUnit.java:860) at org.eclipse.ajdt.core.AspectJCore.create(AspectJCore.java:169) at org.eclipse.ajdt.core.AspectJCore.create(AspectJCore.java:57) at org.eclipse.ajdt.core.model.AJProjectModelFacade.programElementToJavaElement(AJProjectModelFacade.java:371)
Thanks. Will look into it.
Nice find. What is happening here is that there is an occurrence count (this means two JavaElements have the same handle identifier). In this case, it is from advice. When this happens, the a count is appended to the identifier. This doesn't happen too often and is usually the case of an error. In AJ code, however, it is different. In AJ code, this can happen when there are two advice signatures that have the same arguments (and different pointcuts). It can also happen when there are two AJCodeElements that are to the same method (eg- two calls to Bar.foo()). We have to do a bit of munging to go from JDT handles to AspectJ handles. In this case, we do the munging wrong. We incorrectly assume that the count applies to the code element, when it really applies to the advice. Need to add a test: two advice of the same signature two code elements in each advice to same method ensure that all handles are proper.
This bug has been fix and is available in HEAD.