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

Bug 341451

Summary: [Performance] Use of IModelMetaDescriptors must not trigger initialization of the metamodel's EPackages
Product: [Automotive] Sphinx Reporter: Stephan Eberle <stephaneberle9>
Component: CoreAssignee: Stephan Eberle <stephaneberle9>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 0.7.0   
Target Milestone: 0.7.0   
Hardware: All   
OS: All   
Whiteboard:

Description Stephan Eberle CLA 2011-03-31 04:21:32 EDT
= Problem description =
Information exposed on IMetaModelDescriptor has declarative character and is used for many different kind of purposes. On example is the analysis of files in the workspace to see if they contain instances of a given metamodel or not. However, a part of the information exposed on IMetaModelDescriptors, in particular its name and the default content type id, is currently retrieved from static constants on the EPackages of the underlying metamodel implementation. As a consequence, it happens that the (potentially quite big) EPackages and sub EPackages of a metamodel get initialized just because the IMetaModelDescriptor's name or default content type is requested. This can have significant impact on runtime performance, e.g., in the UI when IMetaModelDescriptors are used to determine if some common navigator content needs to be activated or not, and may cause that the EPackages of a metamodel get initialized even though 
not a single instance of that metamodel exists in the workspace.

= Resolution approach =
Make sure that IMetaModelDescriptor implementations never access any information (static or non-static) on the EPackages of the underlying metamodel. Therefore the implementation of IMetaModelDescriptors must be modified in the following way:

1. It should be possible to initialize the AbstractMetaModelDescriptor#getName() via an optional constructor parameter; when no name is provided it must not be deduced from the the AbstractMetaModelDescriptor#getRootEPackage()'s name.

2. AbstractMetaModelDescriptor#getRootEPackageContentTypeId() should be deprecated and no longer be used for implementing AbstractMetaModelDescriptor#getDefaultContentTypeId(); IMetaModelDescriptor implementations which need to advertise default content type should always explicitly override AbstractMetaModelDescriptor#getDefaultContentTypeId() and return a value as appropriate.

3. IMetaModelDescriptor implementations (i.e., Hummingbird10MMDescriptor, UML2MMDescriptor, EXTLibraryMMDescriptor, GMFNotationDescriptor, etc.) must not refer to static eNS_URI or eCONTENT_TYPE fields of EPackages to retrieve name and default content type id information. They should redefine those pieces of information on their own and expose them as public constants on instead.
Comment 1 Stephan Eberle CLA 2011-03-31 10:32:34 EDT
Fixed as propose in description.
Comment 2 Balazs Grill CLA 2021-07-14 02:16:56 EDT
Mass-closing Resolved tickets