Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351183

Summary: [Java] NPE in AnnotationImpl.toString
Product: [Modeling] MoDisco Reporter: Nicolas Bros <nicolas.bros>
Component: TechnologiesAssignee: Project Inbox <modisco.web-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P5 CC: gdupe, speldszus
Version: 0.9.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
stacktrace gdupe: iplog-

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