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

Bug 313383

Summary: NPE when getting most specific template with precondition
Product: [Modeling] Acceleo Reporter: Mikaël Barbero <mikael.barbero>
Component: CoreAssignee: Project Inbox <acceleo-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: mikael.barbero, stephane.begaudeau
Version: 3.0.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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 ***