You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code generator silently drops parameters without a name #454
RoasterCodeGenerator silently drops a method or constructor parameter that has a type but no name. No exception is thrown, so the generated signature is wrong without any notice.
Reproduction
MethodDtomethod = newMethodDto();
method.setMethodName("run");
MethodParameterDtoparameter = newMethodParameterDto();
parameter.setParameterTypeName(newTypeName("java.lang", "String"));
method.addParameter(parameter); // DTO now contains one parameter// render the class containing `method` via RoasterCodeGenerator.generateClass(...)
Expected: void run(String …) or a CodeGenerationException because the parameter name is missing.
Actual: the method renders as
voidrun() {
}
The same happens for constructors (Target() { }).
Other incomplete DTOs fail loudly: a missing parameter type, field type or annotation type gives a wrapped NPE, and a missing field or method name gives a wrapped IllegalArgumentException. Only the unnamed parameter is skipped silently.
This also happens on main, because MethodParameterDto can be created without a name.
Expected JUnit behaviour
Rendering a method or constructor with an unnamed parameter must throw a CodeGenerationException with a message naming the missing parameter name, instead of omitting the parameter.
Context
Found while reviewing #429. #429 adds a build() check in MethodParameterDtoBuilder, but DTOs created directly still reach the renderer.
Activity