Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313383 - NPE when getting most specific template with precondition
Summary: NPE when getting most specific template with precondition
Status: CLOSED DUPLICATE of bug 290532
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: All All
: P3 major
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-18 11:59 EDT by Mikaël Barbero CLA
Modified: 2010-09-10 08:37 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikaël Barbero CLA 2010-05-18 11:59:38 EDT
Hi,

If I define a template with a precondition like this : (UML2 metamodel)

[template public gen (e : DataType) ? (visibility = VisibilityKind::public)]

and my model contains a DataType with visibility = VisibilityKind::private, the Acceleo engine is crashing with a good ol' NPE:

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.acceleo.engine.internal.environment.AcceleoEvaluationEnvironment.getMostSpecificTemplate(AcceleoEvaluationEnvironment.java:256)
	at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.prepareInvocation(AcceleoEvaluationVisitor.java:1339)
	at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitAcceleoTemplateInvocation(AcceleoEvaluationVisitor.java:804)
	at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.switchExpression(AcceleoEvaluationVisitor.java:1483)
	at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitExpression(AcceleoEvaluationVisitor.java:902)

I have to add a template with the complementary precondition or a template without precondition.

[template public gen (e : DataType) ? (visibility <> VisibilityKind::public)] or
[template public gen (e : DataType)]

Acceleo should crash gentler than NPE, don't you think ? Or maybe it should mute itself. I let you define the best behavior ;)

Regards,
Mikael
Comment 1 Stephane Begaudeau CLA 2010-09-10 08:37:04 EDT

*** This bug has been marked as a duplicate of bug 290532 ***