Bug 262943 - [model] NumberFormatException on a call to AJProjectModelFacade.programElementToJavaElement
Summary: [model] NumberFormatException on a call to AJProjectModelFacade.programElemen...
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 1.6.3   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 1.6.4   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-29 13:35 EST by Johan Fabry CLA
Modified: 2009-03-13 12:57 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Fabry CLA 2009-01-29 13:35:12 EST
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)
Comment 1 Andrew Eisenberg CLA 2009-01-29 13:38:13 EST
Thanks.  Will look into it.
Comment 2 Andrew Eisenberg CLA 2009-01-29 19:08:35 EST
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.
Comment 3 Andrew Eisenberg CLA 2009-01-30 11:21:35 EST
This bug has been fix and is available in HEAD.