Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351590 - [Java] ClassCastException while discovering Apache math commons
Summary: [Java] ClassCastException while discovering Apache math commons
Status: ASSIGNED
Alias: None
Product: MoDisco
Classification: Modeling
Component: Technologies (show other bugs)
Version: 0.9.0   Edit
Hardware: PC Windows 7
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: Fabien Giquel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-08 11:06 EDT by Nicolas Bros CLA
Modified: 2015-08-07 09:04 EDT (History)
4 users (show)

See Also:
fabien.giquel: review-


Attachments
stacktrace (3.50 KB, text/plain)
2011-07-08 11:06 EDT, Nicolas Bros CLA
gdupe: iplog-
Details
math-commons configured as Eclipse Java project (4.50 MB, application/octet-stream)
2011-07-08 11:09 EDT, Nicolas Bros CLA
no flags Details
patch (1.53 KB, patch)
2011-08-11 10:50 EDT, Nicolas Bros CLA
no flags Details | Diff
patch for the ClassCastException (1.46 KB, patch)
2011-08-12 03:04 EDT, Nicolas Bros CLA
no flags Details | Diff
New CCE Test use case (474294 bugzilla) (3.36 KB, application/zip)
2015-08-06 03:44 EDT, Fabien Giquel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Bros CLA 2011-07-08 11:06:42 EDT
Created attachment 199341 [details]
stacktrace

When trying to discover the project math-commons from Apache (http://commons.apache.org/math/) with the Java discoverer, we get a ClassCastException, followed by a NPE, and no model is produced.
(see attached stacktrace)
Comment 1 Nicolas Bros CLA 2011-07-08 11:09:07 EDT
Created attachment 199342 [details]
math-commons configured as Eclipse Java project
Comment 2 Gregoire Dupe CLA 2011-07-11 04:21:50 EDT
(In reply to comment #0)
>  no model is produced.

This bug is then "critical"
Comment 3 Nicolas Bros CLA 2011-08-11 10:50:40 EDT
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.
Comment 4 Fabien Giquel CLA 2011-08-11 13:11:04 EDT
ClassCastException and NPE are not related.
I have created the bug 354532 for dealing with NPE. The current one will deal
only with ClassCastException.
Comment 5 Fabien Giquel CLA 2011-08-11 13:17:43 EDT
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.
Comment 6 Nicolas Bros CLA 2011-08-12 03:04:53 EDT
Created attachment 201369 [details]
patch for the ClassCastException

Here is a patch for the ClassCastException only.
Comment 7 Nicolas Bros CLA 2011-08-12 03:12:06 EDT
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
Comment 8 Gregoire Dupe CLA 2011-09-28 10:41:21 EDT
We have to focus on the move to EMF Facet. We may not have time enough  to update the Java meta-model => P5
Comment 9 Gregoire Dupe CLA 2012-06-01 11:27:42 EDT
(In reply to comment #5)
> discovery goes to the end).

So not critical: back to normal.
Comment 10 Fabien Giquel CLA 2015-08-06 03:44:32 EDT
Created attachment 255658 [details]
New CCE Test use case (474294 bugzilla)
Comment 11 Fabien Giquel CLA 2015-08-06 03:47:12 EDT
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".
Comment 12 Fabien Giquel CLA 2015-08-07 09:03:57 EDT
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.