This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 7cd8ad1c7c1 IGNITE-28972 Generation must fail Message to byte[]
marshalling (#13461)
7cd8ad1c7c1 is described below
commit 7cd8ad1c7c1c3512bf8945a1cb93a2738175178c
Author: Nikolay <[email protected]>
AuthorDate: Tue Aug 11 23:50:12 2026 +0300
IGNITE-28972 Generation must fail Message to byte[] marshalling (#13461)
---
.../internal/MessageMarshallerGenerator.java | 91 ++++++++++++++++++++--
.../internal/codegen/MessageProcessorTest.java | 57 ++++++++++++++
.../codegen/IncorrectMarshalledOnMessage.java | 31 ++++++++
.../codegen/IncorrectMarshalledOnMessageArray.java | 31 ++++++++
.../IncorrectMarshalledOnMessageCollection.java | 32 ++++++++
.../IncorrectMarshalledOnMessageCollection2.java | 32 ++++++++
.../IncorrectMarshalledOnMessageCollection3.java | 32 ++++++++
.../IncorrectMarshalledOnMessageCollection4.java | 32 ++++++++
...ncorrectMarshalledOnMessageCollectionArray.java | 32 ++++++++
.../codegen/IncorrectMarshalledOnMessageList.java | 32 ++++++++
.../codegen/IncorrectMarshalledOnMessageList2.java | 32 ++++++++
.../codegen/IncorrectMarshalledOnMessageMap.java | 32 ++++++++
.../codegen/IncorrectMarshalledOnMessageMap2.java | 33 ++++++++
.../codegen/IncorrectMarshalledOnMessageMap3.java | 32 ++++++++
.../codegen/IncorrectMarshalledOnMessageMap4.java | 32 ++++++++
.../codegen/IncorrectMarshalledOnMessageSet.java | 32 ++++++++
.../codegen/IncorrectRawCollectionMessage.java | 32 ++++++++
.../codegen/IncorrectRawCollectionMessage2.java | 32 ++++++++
.../resources/codegen/IncorrectRawListMessage.java | 32 ++++++++
.../codegen/IncorrectRawListMessage2.java | 32 ++++++++
.../resources/codegen/IncorrectRawMapMessage.java | 32 ++++++++
.../resources/codegen/IncorrectRawMapMessage2.java | 32 ++++++++
22 files changed, 780 insertions(+), 7 deletions(-)
diff --git
a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java
b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java
index 34e60541417..adb45e3a50d 100644
---
a/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java
+++
b/modules/codegen/src/main/java/org/apache/ignite/internal/MessageMarshallerGenerator.java
@@ -40,6 +40,7 @@ import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
+import javax.lang.model.type.WildcardType;
import javax.lang.model.util.ElementFilter;
import javax.tools.Diagnostic;
import
org.apache.ignite.internal.systemview.SystemViewRowAttributeWalkerProcessor;
@@ -1156,18 +1157,94 @@ public class MessageMarshallerGenerator extends
MessageCompanionGenerator {
return null;
}
+ MarshalledKind res;
+
if (map)
- return MarshalledKind.MAP;
+ res = MarshalledKind.MAP;
+ else {
+ TypeMirror wire = requireEnclosed(enclosed, ann.value(),
"@Marshalled").asType();
+
+ if (wire.getKind() == TypeKind.ARRAY) {
+ res = ((ArrayType)wire).getComponentType().getKind() ==
TypeKind.BYTE
+ ? MarshalledKind.BLOB
+ : MarshalledKind.ELEMENTS;
+ }
+ else
+ res = MarshalledKind.ELEMENT_BLOBS;
+ }
+
+ /*
+ * Ensures that field annotated with {@link Marshalled} doesn't
perform {@code Message} -> {@code byte[]} transformation
+ * which escapes {@link Order} and other rules implemented on top of
communication {@code MessageWriter, MessageReader} logic.
+ */
+ if (messageToBytesTransformation(field.asType(), field, ann)) {
+ env.getMessager().printMessage(Diagnostic.Kind.ERROR,
+ "Message must be written by dedicated message serializers. " +
+ "Remove @" + Marshalled.class.getSimpleName() + " annotation
and remove companion field " +
+ "and set @" + Order.class.getSimpleName(), field);
+ }
+
+ return res;
+ }
+
+ /**
+ * Recursively checks no {@code Message} -> {@code byte[]} transformation.
+ * @return {@code True} in case error transformation found.
+ */
+ private boolean messageToBytesTransformation(TypeMirror type,
VariableElement field, Marshalled ann) {
+ if (assignableFrom(type, msgType))
+ return true;
+
+ if (isCollection(type)) {
+ DeclaredType colType = (DeclaredType)type;
+
+ List<? extends TypeMirror> typeArgs = colType.getTypeArguments();
- TypeMirror wire = requireEnclosed(enclosed, ann.value(),
"@Marshalled").asType();
+ if (typeArgs.size() != 1) {
+ env.getMessager().printMessage(Diagnostic.Kind.ERROR, "Raw
collection not supported.", field);
- if (wire.getKind() == TypeKind.ARRAY) {
- return ((ArrayType)wire).getComponentType().getKind() ==
TypeKind.BYTE
- ? MarshalledKind.BLOB
- : MarshalledKind.ELEMENTS;
+ return false;
+ }
+
+ return messageToBytesTransformation(typeArgs.get(0), field, ann);
}
- return MarshalledKind.ELEMENT_BLOBS;
+ if (type.getKind() == TypeKind.ARRAY)
+ return
messageToBytesTransformation(((ArrayType)type).getComponentType(), field, ann);
+
+ if (isMap(type) && !ann.value().isEmpty()) {
+ DeclaredType mapType = (DeclaredType)type;
+
+ List<? extends TypeMirror> typeArgs = mapType.getTypeArguments();
+
+ if (typeArgs.size() != 2) {
+ env.getMessager().printMessage(Diagnostic.Kind.ERROR, "Raw Map
not supported.", field);
+
+ return false;
+ }
+
+ TypeMirror keyType = typeArgs.get(0);
+ TypeMirror valType = typeArgs.get(1);
+
+ return assignableFrom(keyType, msgType)
+ || assignableFrom(valType, msgType)
+ || messageToBytesTransformation(keyType, field, ann)
+ || messageToBytesTransformation(valType, field, ann);
+ }
+
+ if (type instanceof WildcardType) {
+ WildcardType wt = (WildcardType)type;
+
+ if (wt.getExtendsBound() != null)
+ return messageToBytesTransformation(wt.getExtendsBound(),
field, ann);
+
+ if (wt.getSuperBound() != null)
+ return messageToBytesTransformation(wt.getSuperBound(), field,
ann);
+
+ env.getMessager().printMessage(Diagnostic.Kind.ERROR, "Raw types
not supported.", field);
+ }
+
+ return false;
}
/** Returns the enclosed field named {@code name}, or throws if absent. */
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
index 76df5d5548e..5169af45414 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/codegen/MessageProcessorTest.java
@@ -22,6 +22,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -683,6 +685,61 @@ public class MessageProcessorTest {
"or SelfMarshallingMessage, nor declare @Marshalled fields");
}
+ /** Test that {@code @Marshalled} annotation on {@link Message} field will
fail generation. */
+ @Test
+ public void testMarshalledOnMessageFieldFailGeneration() {
+ List<String> cases = Arrays.asList(
+ "IncorrectMarshalledOnMessage.java",
+ "IncorrectMarshalledOnMessageCollection.java",
+ "IncorrectMarshalledOnMessageCollection2.java",
+ "IncorrectMarshalledOnMessageCollection3.java",
+ "IncorrectMarshalledOnMessageCollection4.java",
+ "IncorrectMarshalledOnMessageMap.java",
+ "IncorrectMarshalledOnMessageMap2.java",
+ "IncorrectMarshalledOnMessageMap3.java",
+ "IncorrectMarshalledOnMessageMap4.java",
+ "IncorrectMarshalledOnMessageArray.java",
+ "IncorrectMarshalledOnMessageCollectionArray.java",
+ "IncorrectMarshalledOnMessageSet.java",
+ "IncorrectMarshalledOnMessageList.java",
+ "IncorrectMarshalledOnMessageList2.java"
+ );
+
+ for (String file : cases) {
+ Compilation compilation = compile("TestMessage.java", file);
+
+ assertThat(compilation).failed();
+ assertThat(compilation).hadErrorContaining("Message must be
written by dedicated message serializers");
+ }
+ }
+
+ /** Test that {@code @Marshalled} annotation on raw {@link Collection} or
{@link Map} fail generation. */
+ @Test
+ public void testRawClassesFailGeneration() {
+ List<String> cases = Arrays.asList("IncorrectRawListMessage.java",
"IncorrectRawCollectionMessage.java");
+
+ for (String file : cases) {
+ Compilation compilation = compile("TestMessage.java", file);
+
+ assertThat(compilation).failed();
+ assertThat(compilation).hadErrorContaining("Raw collection not
supported");
+ }
+
+ cases = Arrays.asList("IncorrectRawListMessage2.java",
"IncorrectRawCollectionMessage2.java", "IncorrectRawMapMessage2.java");
+
+ for (String file : cases) {
+ Compilation compilation = compile("TestMessage.java", file);
+
+ assertThat(compilation).failed();
+ assertThat(compilation).hadErrorContaining("Raw types not
supported");
+ }
+
+ Compilation compilation = compile("TestMessage.java",
"IncorrectRawMapMessage.java");
+
+ assertThat(compilation).failed();
+ assertThat(compilation).hadErrorContaining("Raw Map not supported");
+ }
+
/** */
private Compilation compile(String... srcFiles) {
return compile(new MessageProcessor(), srcFiles);
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessage.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessage.java
new file mode 100644
index 00000000000..4d0334c1054
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessage.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessage implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ TestMessage msg;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageArray.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageArray.java
new file mode 100644
index 00000000000..4a261d7c654
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageArray.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageArray implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ TestMessage[] msgArr;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection.java
new file mode 100644
index 00000000000..ffb8f8f261e
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageCollection implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection<TestMessage> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection2.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection2.java
new file mode 100644
index 00000000000..2ffca3663ac
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection2.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageCollection2 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection<TestMessage> msgColl;
+
+ /** */
+ @Order(0)
+ Collection<byte[]> msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection3.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection3.java
new file mode 100644
index 00000000000..73633a1a453
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection3.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageCollection3 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection<Collection<TestMessage>> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection4.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection4.java
new file mode 100644
index 00000000000..ba5fac2f2fe
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollection4.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageCollection4 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection<? extends Message> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollectionArray.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollectionArray.java
new file mode 100644
index 00000000000..8e708b946bf
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageCollectionArray.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageCollectionArray implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection<TestMessage>[] msgArr;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageList.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageList.java
new file mode 100644
index 00000000000..1ad895b7387
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageList.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.List;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageList implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ List<TestMessage> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageList2.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageList2.java
new file mode 100644
index 00000000000..97554cff03b
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageList2.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.List;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageList2 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ List<List<TestMessage>> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap.java
new file mode 100644
index 00000000000..991ec5d5a69
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Map;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageMap implements Message {
+ /** */
+ @Marshalled("bytes")
+ Map<Integer, TestMessage> msgMap;
+
+ /** */
+ @Order(0)
+ byte[] bytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap2.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap2.java
new file mode 100644
index 00000000000..f6af1b8710f
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap2.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageMap2 implements Message {
+ /** */
+ @Marshalled("bytes")
+ Map<Integer, List<TestMessage>> msgMap;
+
+ /** */
+ @Order(0)
+ byte[] bytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap3.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap3.java
new file mode 100644
index 00000000000..7feb91d9e15
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap3.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Map;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageMap3 implements Message {
+ /** */
+ @Marshalled("bytes")
+ Map<Integer, Map<Integer, TestMessage>> msgMap;
+
+ /** */
+ @Order(0)
+ byte[] bytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap4.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap4.java
new file mode 100644
index 00000000000..664bb9dff18
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageMap4.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Map;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageMap4 implements Message {
+ /** */
+ @Marshalled("bytes")
+ Map<Integer, ? extends Message> msgMap;
+
+ /** */
+ @Order(0)
+ byte[] bytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageSet.java
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageSet.java
new file mode 100644
index 00000000000..dc671cf748e
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectMarshalledOnMessageSet.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Set;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectMarshalledOnMessageSet implements Message {
+ /** */
+ @Marshalled("msgArray")
+ Set<TestMessage> msgColl;
+
+ /** */
+ @Order(0)
+ TestMessage[] msgArray;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectRawCollectionMessage.java
b/modules/core/src/test/resources/codegen/IncorrectRawCollectionMessage.java
new file mode 100644
index 00000000000..ea3251dd122
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/IncorrectRawCollectionMessage.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectRawCollectionMessage implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectRawCollectionMessage2.java
b/modules/core/src/test/resources/codegen/IncorrectRawCollectionMessage2.java
new file mode 100644
index 00000000000..ef9d4a87386
--- /dev/null
+++
b/modules/core/src/test/resources/codegen/IncorrectRawCollectionMessage2.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Collection;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectRawCollectionMessage2 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Collection<?> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectRawListMessage.java
b/modules/core/src/test/resources/codegen/IncorrectRawListMessage.java
new file mode 100644
index 00000000000..6cdc5a98c6c
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/IncorrectRawListMessage.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.List;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectRawListMessage implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ List msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectRawListMessage2.java
b/modules/core/src/test/resources/codegen/IncorrectRawListMessage2.java
new file mode 100644
index 00000000000..db821272f97
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/IncorrectRawListMessage2.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.List;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectRawListMessage2 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ List<?> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectRawMapMessage.java
b/modules/core/src/test/resources/codegen/IncorrectRawMapMessage.java
new file mode 100644
index 00000000000..fa5bc3ecf3b
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/IncorrectRawMapMessage.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Map;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectRawMapMessage implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Map msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}
diff --git
a/modules/core/src/test/resources/codegen/IncorrectRawMapMessage2.java
b/modules/core/src/test/resources/codegen/IncorrectRawMapMessage2.java
new file mode 100644
index 00000000000..6a1d65866b2
--- /dev/null
+++ b/modules/core/src/test/resources/codegen/IncorrectRawMapMessage2.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal;
+
+import java.util.Map;
+import org.apache.ignite.plugin.extensions.communication.Message;
+
+/** */
+public class IncorrectRawMapMessage2 implements Message {
+ /** */
+ @Marshalled("msgBytes")
+ Map<Integer, ?> msgColl;
+
+ /** */
+ @Order(0)
+ byte[] msgBytes;
+}