Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.tools.Diagnostic;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteBiTuple;

import static org.apache.ignite.internal.MessageSerializerGenerator.DLFT_ENUM_MAPPER_CLS;
Expand Down Expand Up @@ -115,6 +117,9 @@ public class MessageProcessor extends AbstractProcessor {
if (clazz.getModifiers().contains(Modifier.ABSTRACT))
continue;

if (!checkConstructors(clazz))
continue;

List<VariableElement> fields = orderedFields(clazz);

if (fields.isEmpty() && emptyMsgs.stream().noneMatch(t -> isAssignable(t, clazz))) {
Expand Down Expand Up @@ -146,6 +151,34 @@ public class MessageProcessor extends AbstractProcessor {
return true;
}

/** */
private boolean checkConstructors(TypeElement clazz) {
boolean isMarshallableMsg = isAssignable(
clazz.asType(),
processingEnv.getElementUtils().getTypeElement("org.apache.ignite.internal.MarshallableMessage")
);

for (Element el : clazz.getEnclosedElements()) {
if (el.getKind() != ElementKind.CONSTRUCTOR)
continue;

ExecutableElement c = (ExecutableElement)el;

boolean isDfltConstructor = F.isEmpty(c.getParameters());

if (isDfltConstructor && !isMarshallableMsg)

@shishkovilja shishkovilja Jun 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need check that message is marshallable, because MarshallableMessage inheritors should have default constructor too:

Also we need to check that constructor is pulbic, eg.:

c.getModifiers().contains(Modifier.PUBLIC);

return true;
}

processingEnv.getMessager().printMessage(
Diagnostic.Kind.ERROR,
"A class must have a default constructor: " + clazz.getQualifiedName(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"A class must have a default constructor: " + clazz.getQualifiedName(),
"A class must have a public default constructor: " + clazz.getQualifiedName(),

clazz
);

return false;
}

/**
* Collects all fields annotated with {@link Order} from the given {@link TypeElement} and all its superclasses.
* <p>
Expand Down
Loading