Issue description
The class-diagram generator creates a builder and a concrete build() method for classes declared as abstract when ${decConfig.withBuilders().defaultApply()} is configured. The generated build() method instantiates the abstract type, causing the generated Java sources to fail compilation.
Abstract CD classes map to Java abstract classes and must not be instantiated directly.
Reproduction
Example CD:
public abstract class MCConcept extends Class {
boolean top;
}
The same issue occurs for an abstract class such as:
public abstract class Class { }
Actual behavior
The generator creates a builder implementation that contains code equivalent to:
This produces a Java compiler error:
ERROR in ...\montiarc\generator\meta\Java\ClassBuilder.java (at line 150)
var v = new Class();
^^^^^
The generated builder tries to instantiate Class, although Class is declared abstract.
Expected behavior
For an abstract CD class, the generator must not emit a build() implementation that instantiates that class.
Possible valid generator behavior would be one of:
- Do not generate a builder for abstract classes.
- Generate the builder but omit
build().
- Generate an abstract builder and declare
build() as abstract.
- Generate builders only for concrete subclasses, whose
build() methods instantiate the respective concrete class.
Impact
Any CD containing an abstract class can produce Java code that does not compile. This prevents use of abstract base classes in generated POJO models and forces users to avoid a standard object-oriented modeling mechanism.
Issue description
The class-diagram generator creates a builder and a concrete
build()method for classes declared asabstractwhen${decConfig.withBuilders().defaultApply()}is configured. The generatedbuild()method instantiates the abstract type, causing the generated Java sources to fail compilation.Abstract CD classes map to Java abstract classes and must not be instantiated directly.
Reproduction
Example CD:
The same issue occurs for an abstract class such as:
Actual behavior
The generator creates a builder implementation that contains code equivalent to:
This produces a Java compiler error:
The generated builder tries to instantiate
Class, althoughClassis declaredabstract.Expected behavior
For an abstract CD class, the generator must not emit a
build()implementation that instantiates that class.Possible valid generator behavior would be one of:
build().build()as abstract.build()methods instantiate the respective concrete class.Impact
Any CD containing an abstract class can produce Java code that does not compile. This prevents use of abstract base classes in generated POJO models and forces users to avoid a standard object-oriented modeling mechanism.