Skip to content

3. Origin Code Preparation

Timur Sağlam edited this page Sep 18, 2018 · 3 revisions

Default Constructor Stubs & Non-Public Class Exposition

The preparing the Origin Code consists out of two steps: Creating default constructor stubs to avoid the default constructor problem and exposing non-public classes to avoid errors introduced by invalid visibility.

Creating Default Constructor Stubs

Since the Ecore factories depend on default constructors, classes without one are problematic since they cannot be instantiated by the factories. For example, if a class only offers a parameterized constructor, the instantiation of this class depends on the constructor parameters. However, because the Ecore interfaces of the factories do not allow to parameterize the creation methods, these methods can only create one specific instance type of a class with a specific set of parameters. To circumvent this problem, we implemented the generation of default constructor stubs for every class that does only contain parameterized constructors and therefore does not offer an explicit or implicit default constructor. These stubs are default constructors with an empty constructor body. This means the initialization of the affected classes is not completely executed when using the default constructor, but it circumvents compilation issues. This means this fix is only temporary and not suitable when depending on the Ecore factories.

Exposing Non-Public Classes

Since the Ecorification uses a specific pattern to integrate the Ecore functionality into Java code classes, which were previously only accessed by classes inside of their own package, are accessed from packages outside of their own package. If these classes have non-public visibility, this is not possible. This motivates the need to expose non-public classes by changing their visibility to public. While this theoretically changes the API functionality, all calls that were previously valid will stay valid. It only opens up access to classes that were not accessible beforehand. This is also done for none-public inner classes.

Clone this wiki locally