Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351183 - [Java] NPE in AnnotationImpl.toString
Summary: [Java] NPE in AnnotationImpl.toString
Status: NEW
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: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-05 09:08 EDT by Nicolas Bros CLA
Modified: 2017-01-06 07:32 EST (History)
2 users (show)

See Also:


Attachments
stacktrace (2.01 KB, text/plain)
2011-07-05 09:08 EDT, Nicolas Bros CLA
gdupe: iplog-
Details

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

When trying to execute the Java to KDM ATL transformation, I get a NPE in the Java model. See attached stacktrace.
Comment 1 Gregoire Dupe CLA 2011-09-28 12:12:05 EDT
Hello,

I'm really sorry, but to guaranty maintainability of MoDisco (and EMF Facet) we
have to focus this year on the move to EMF Facet. That's why I cannot plan this
bug for Juno (of course if someone provides the fix we will commit it).

Regards,
Gregoire Dupe
Comment 2 Sven Peldszus CLA 2017-01-06 07:32:31 EST
Hello,

I also got this NullpointerException and had a closer look into the source code.

The problem is a fieldreference in the 'toString()' method of the class 'org.eclipse.gmt.modisco.java.emf.impl.AnnotationImpl' due to the lazy initialization of lists in EMF code a NPE is thrown in the following line if the Annotation has no value: 

old line 253: 'for (AnnotationMemberValuePair member : this.values) {'

To fix this bug the 'this.values' fiels access has to be replaced with the according getter 'getValues()' in which an empty list is created if the annotation has no values:


new line 253: 'for (AnnotationMemberValuePair member : getValues()) {'

As I've the impression after reading the contribution guide lines that pull request are unwanted for bug fixes I am just reporting my solution here. It would be nice if this fix will be included in the next release.

Best regards,

Sven Peldszus