| Summary: | [Java] ClassCastException while discovering Apache math commons | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] MoDisco | Reporter: | Nicolas Bros <nicolas.bros> | ||||||||||||
| Component: | Technologies | Assignee: | Fabien Giquel <fabien.giquel> | ||||||||||||
| Status: | ASSIGNED --- | QA Contact: | |||||||||||||
| Severity: | normal | ||||||||||||||
| Priority: | P5 | CC: | fabien.giquel, gdupe, modisco.web-inbox, rom1.bernard | ||||||||||||
| Version: | 0.9.0 | Flags: | fabien.giquel:
review-
|
||||||||||||
| Target Milestone: | --- | ||||||||||||||
| Hardware: | PC | ||||||||||||||
| OS: | Windows 7 | ||||||||||||||
| Whiteboard: | |||||||||||||||
| Attachments: |
|
||||||||||||||
|
Description
Nicolas Bros
Created attachment 199342 [details]
math-commons configured as Eclipse Java project
(In reply to comment #0) > no model is produced. This bug is then "critical" Created attachment 201318 [details]
patch
The discoverer does the ClassCastException when analyzing the value() invocation in:
final Retry retry = method.getAnnotation(Retry.class);
...
final int numRetries = retry.value();
where "retry" is an annotation.
For MoDisco, the declaration corresponding to MethodInvocation "value()" is an AnnotationTypeMemberDeclaration, which is not a subtype of AbstractMethodDeclaration.
That's why the cast fails in JDTVisitor#endVisit(MethodInvocation).
This looks like an issue with the Java metamodel, that will have to be solved in the next major version (0.10), together with other necessary evolutions of the metamodel.
As for the second exception (NPE), it happens when building the signature of a method declaration (PolygonsSet#followLoop in math-commons) that has a parameter of type "final AVLTree<ComparableSegment>.Node".
MoDisco has not associated any type to this parameter, so it fails in MethodRedefinitionManager#getRawSignature when trying to access the type.
Here is a quick&dirty patch that works around the issues until they can be fixed in a better way.
ClassCastException and NPE are not related. I have created the bug 354532 for dealing with NPE. The current one will deal only with ClassCastException. Nicolas, since i have separated in two bugs, i validate the part of the patch proposed on JDTVisitor.java (that is why i set review as "-" for the global patch) The metamodel fix will not be done in Indigo SR1, so the work around proposed in the patch (JDTVisitor.java) must be commited for Indigo SR1 to minimize impact (discovery goes to the end). For the other problem (NPE) see on the other bug 354532. Created attachment 201369 [details]
patch for the ClassCastException
Here is a patch for the ClassCastException only.
I have committed the patch in the trunk for SR1 (revision 4484). I'm leaving the bug open, because we still need to fix the metamodel in 0.10 We have to focus on the move to EMF Facet. We may not have time enough to update the Java meta-model => P5 (In reply to comment #5) > discovery goes to the end). So not critical: back to normal. Created attachment 255658 [details]
New CCE Test use case (474294 bugzilla)
The workaround patch from Nicolas Bros does not cover all use cases, and must be completed. I join a "new CCE Test use case.zip". I propose some contribution for last use case, waiting for real Java metamodel evolution : - no more error statut - and one "UnresolvedMethod" instance is produced to identify the Annotation type member invoked. |