Community
Participate
Working Groups
Build Identifier: 20110615-0604 When you create a default constructor with a body generated in code, it is ignored. Debugging at JvmModelGenerator._generateMember(final JvmConstructor it,...), there's a condition that check if it hasn't any parameters, tries to check if it has a XExpression body and if not, exit the method. The correct code must do the same that there is in generateBody method, where it also check if there is a CompilationStrategyAdapter for it. Reproducible: Always
Pushed to MASTER
I added one more condition: If there is a default constructor without any implementation hint next to another constructor, it is generated with an empty body. We are able to link aginst it, so it has to exist in Java, too.
The same problem is there also in the presence of constructor parameters...
(In reply to comment #3) > The same problem is there also in the presence of constructor parameters... The reason for the empty body lies in the fact that the JvmTypesBuilder already added the empty body to the constructor before applying the init procedure. If a body was added it becomes the second adapter in the eAdapters and is hence ignored. Extending the JvmTypesBuilder and commenting this out removed this particular problem for me: public class ConstructorCapableJvmTypesBuilder extends JvmTypesBuilder { public JvmConstructor toConstructor(EObject sourceElement, String simpleName, Procedure1<JvmConstructor> init) { JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); constructor.setSimpleName(nullSaveName(simpleName)); // setBody(constructor, new Function1<ImportManager, CharSequence>() { // public CharSequence apply(ImportManager p) { // return "{}"; // } // }); if (init != null && simpleName != null) init.apply(constructor); return associate(sourceElement, constructor); } }
This has also already been fixed in current master.
(In reply to comment #5) > This has also already been fixed in current master. Great! Looking forward to 2.3!
Closing all bugs that were set to RESOLVED before Neon.0