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

Bug 122382

Summary: Potentially silent NPE for genModel of null reference
Product: [Modeling] EMF Reporter: Ed Willink <ed>
Component: ToolsAssignee: Dave Steinberg <davidms>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 2.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 75933    

Description Ed Willink CLA 2005-12-30 06:14:06 EST
When genmodel is invoked for a model with a null EReference.eType a warning appears in the Error Log View regarding a

java.lang.NullPointerException
	at org.eclipse.emf.codegen.ecore.genmodel.impl.GenTypedElementImpl.getTypeGenPackage(GenTypedElementImpl.java:65)
	at org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl$DependencyHelper.<init>(GenPackageImpl.java:1864)
	at org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl.generate(GenPackageImpl.java:2385)
	at org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl.generate(GenModelImpl.java:1932)
	at org.eclipse.emf.codegen.ecore.genmodel.impl.GenBaseImpl.generate(GenBaseImpl.java:350)
	at org.eclipse.emf.codegen.ecore.genmodel.presentation.GenModelActionBarContributor$3.generate(GenModelActionBarContributor.java:167)
	at org.eclipse.emf.codegen.ecore.genmodel.presentation.GenModelActionBarContributor$14.execute(GenModelActionBarContributor.java:295)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:100)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1714)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:112)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)

a) The warning should have a non-empty short message description

b) The warning should be an error

c) The error should also appear as a PopUp Dialog alerting the user interactively to the failure of the interactive generate model command.

This problem can easily occur through over-enthusiastic pruning of dead classes
from a model. If the Error Log is not visible, the only clue that Generate Model
is failing is the rather quicker execution of the progress pop up. If that is missed, then the generated code just obstinately refuses to respond to further
model changes!
Comment 1 Marcelo Paternostro CLA 2005-12-30 12:15:11 EST
Thx for pointing this out.  We will cover this as we work on 104727.

*** This bug has been marked as a duplicate of 104727 ***
Comment 2 Dave Steinberg CLA 2006-05-17 15:01:51 EDT
This could be handled as an Ecore constraint: EReference.eType, EAttribute.eType, and EParameter.eType must be non-null (EOperation.eType can be null).
Comment 3 Dave Steinberg CLA 2006-05-17 15:04:11 EDT

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