Merge branch 'ignite-1.5' into ignite-2213-1
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryUtils.java
new file mode 100644
index 0000000..bdbe1da
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryUtils.java
@@ -0,0 +1,41 @@
+/*
+ * 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.binary;
+
+/**
+ * Utility methods for binary objects.
+ */
+public class BinaryUtils {
+    /**
+     * Create qualified field name.
+     *
+     * @param cls Class.
+     * @param fieldName Field name.
+     * @return Qualified field name.
+     */
+    public static String qualifiedFieldName(Class cls, String fieldName) {
+        return (cls.getName() + "." + fieldName).replace('.', '_').replace("$", "__");
+    }
+
+    /**
+     * Private constructor.
+     */
+    private BinaryUtils() {
+        // No-op.
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
index 39189f0..419976b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryCachingMetadataHandler.java
@@ -54,7 +54,7 @@
                 BinaryMetadata oldMeta = ((BinaryTypeImpl)oldType).metadata();
                 BinaryMetadata newMeta = ((BinaryTypeImpl)type).metadata();
 
-                BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta);
+                BinaryMetadata mergedMeta = BinaryUtilsEx.mergeMetadata(oldMeta, newMeta);
 
                 BinaryType mergedType = mergedMeta.wrap(((BinaryTypeImpl)oldType).context());
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index 1eb3882..cf402a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -22,6 +22,7 @@
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryReflectiveSerializer;
 import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryUtils;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
 import org.apache.ignite.internal.util.GridUnsafe;
@@ -35,6 +36,7 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.ArrayList;
@@ -44,11 +46,9 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 
-import static java.lang.reflect.Modifier.isStatic;
-import static java.lang.reflect.Modifier.isTransient;
-
 /**
  * Binary class descriptor.
  */
@@ -171,7 +171,7 @@
             if (cls == BinaryEnumObjectImpl.class)
                 mode = BinaryWriteMode.BINARY_ENUM;
             else
-                mode = serializer != null ? BinaryWriteMode.BINARY : BinaryUtils.mode(cls);
+                mode = serializer != null ? BinaryWriteMode.BINARY : BinaryUtilsEx.mode(cls);
         }
 
         if (useOptMarshaller && userType) {
@@ -250,21 +250,24 @@
 
                 BinarySchema.Builder schemaBuilder = BinarySchema.Builder.newBuilder();
 
+                Set<String> duplicates = duplicateFields(cls);
+
                 Collection<String> names = new HashSet<>();
                 Collection<Integer> ids = new HashSet<>();
 
                 for (Class<?> c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass()) {
                     for (Field f : c.getDeclaredFields()) {
-                        int mod = f.getModifiers();
-
-                        if (!isStatic(mod) && !isTransient(mod)) {
+                        if (serializeField(f)) {
                             f.setAccessible(true);
 
                             String name = f.getName();
 
-                            if (!names.add(name))
-                                throw new BinaryObjectException("Duplicate field name [fieldName=" + name +
-                                    ", cls=" + cls.getName() + ']');
+                            if (duplicates.contains(name))
+                                name = BinaryUtils.qualifiedFieldName(c, name);
+
+                            boolean added = names.add(name);
+
+                            assert added : name;
 
                             int fieldId = idMapper.fieldId(typeId, name);
 
@@ -308,6 +311,42 @@
     }
 
     /**
+     * Find all fields with duplicate names in the class.
+     *
+     * @param cls Class.
+     * @return Fields with duplicate names.
+     */
+    private static Set<String> duplicateFields(Class cls) {
+        Set<String> all = new HashSet<>();
+        Set<String> duplicates = new HashSet<>();
+
+        for (Class<?> c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass()) {
+            for (Field f : c.getDeclaredFields()) {
+                if (serializeField(f)) {
+                    String name = f.getName();
+
+                    if (!all.add(name))
+                        duplicates.add(name);
+                }
+            }
+        }
+
+        return duplicates;
+    }
+
+    /**
+     * Whether the field must be serialized.
+     *
+     * @param f Field.
+     * @return {@code True} if must be serialized.
+     */
+    private static boolean serializeField(Field f) {
+        int mod = f.getModifiers();
+
+        return !Modifier.isStatic(mod) && !Modifier.isTransient(mod);
+    }
+
+    /**
      * @return {@code True} if enum.
      */
     boolean isEnum() {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 5c63fbd..8419893 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -887,7 +887,7 @@
      * @return {@code True} if reflective serializer can be used.
      */
     private static boolean canUseReflectiveSerializer(Class cls) {
-        return BinaryUtils.isBinarylizable(cls) || !BinaryUtils.isCustomJavaSerialization(cls);
+        return BinaryUtilsEx.isBinarylizable(cls) || !BinaryUtilsEx.isCustomJavaSerialization(cls);
     }
 
     /**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index 001d2d7..5d7e21c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -112,7 +112,7 @@
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T deserialize() throws BinaryObjectException {
-        Class cls = BinaryUtils.resolveClass(ctx, typeId, clsName, null, true);
+        Class cls = BinaryUtilsEx.resolveClass(ctx, typeId, clsName, null, true);
 
         return BinaryEnumCache.get(cls, ord);
     }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
index 2d69cbd..044b97b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
@@ -48,7 +48,7 @@
      * @return Accessor.
      */
     public static BinaryFieldAccessor create(Field field, int id) {
-        BinaryWriteMode mode = BinaryUtils.mode(field.getType());
+        BinaryWriteMode mode = BinaryUtilsEx.mode(field.getType());
 
         switch (mode) {
             case P_BYTE:
@@ -846,7 +846,7 @@
          */
         protected BinaryWriteMode mode(Object val) {
             return dynamic ?
-                val == null ? BinaryWriteMode.OBJECT : BinaryUtils.mode(val.getClass()) :
+                val == null ? BinaryWriteMode.OBJECT : BinaryUtilsEx.mode(val.getClass()) :
                 mode;
         }
     }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
index 0911d46..be4de03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadata.java
@@ -124,7 +124,7 @@
     @Nullable public String fieldTypeName(String fieldName) {
         Integer typeId = fields != null ? fields.get(fieldName) : null;
 
-        return typeId != null ? BinaryUtils.fieldTypeName(typeId) : null;
+        return typeId != null ? BinaryUtilsEx.fieldTypeName(typeId) : null;
     }
 
     /**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
index 54f2b13..47d5621 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
@@ -267,8 +267,8 @@
         if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
             throw new BinaryObjectException(
                 "Field is written twice with different types [" + "typeName=" + typeName + ", fieldName=" + name +
-                ", fieldTypeName1=" + BinaryUtils.fieldTypeName(oldFieldTypeId) +
-                ", fieldTypeName2=" + BinaryUtils.fieldTypeName(fieldTypeId) + ']'
+                ", fieldTypeName1=" + BinaryUtilsEx.fieldTypeName(oldFieldTypeId) +
+                ", fieldTypeName2=" + BinaryUtilsEx.fieldTypeName(fieldTypeId) + ']'
             );
         }
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index 2342766..0ed8a06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -254,16 +254,16 @@
 
         short flags = BinaryPrimitives.readShort(arr, start + GridBinaryMarshaller.FLAGS_POS);
 
-        int fieldIdLen = BinaryUtils.isCompactFooter(flags) ? 0 : BinaryUtils.FIELD_ID_LEN;
-        int fieldOffsetLen = BinaryUtils.fieldOffsetLength(flags);
+        int fieldIdLen = BinaryUtilsEx.isCompactFooter(flags) ? 0 : BinaryUtilsEx.FIELD_ID_LEN;
+        int fieldOffsetLen = BinaryUtilsEx.fieldOffsetLength(flags);
 
         int fieldOffsetPos = start + schemaOffset + order * (fieldIdLen + fieldOffsetLen) + fieldIdLen;
 
         int fieldPos;
 
-        if (fieldOffsetLen == BinaryUtils.OFFSET_1)
+        if (fieldOffsetLen == BinaryUtilsEx.OFFSET_1)
             fieldPos = start + ((int)BinaryPrimitives.readByte(arr, fieldOffsetPos) & 0xFF);
-        else if (fieldOffsetLen == BinaryUtils.OFFSET_2)
+        else if (fieldOffsetLen == BinaryUtilsEx.OFFSET_2)
             fieldPos = start + ((int)BinaryPrimitives.readShort(arr, fieldOffsetPos) & 0xFFFF);
         else
             fieldPos = start + BinaryPrimitives.readInt(arr, fieldOffsetPos);
@@ -375,7 +375,7 @@
                 break;
 
             default:
-                val = BinaryUtils.unmarshal(BinaryHeapInputStream.create(arr, fieldPos), ctx, null);
+                val = BinaryUtilsEx.unmarshal(BinaryHeapInputStream.create(arr, fieldPos), ctx, null);
 
                 break;
         }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
index 696a34b..df290e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
@@ -170,16 +170,16 @@
 
         short flags = BinaryPrimitives.readShort(ptr, start + GridBinaryMarshaller.FLAGS_POS);
 
-        int fieldIdLen = BinaryUtils.isCompactFooter(flags) ? 0 : BinaryUtils.FIELD_ID_LEN;
-        int fieldOffsetLen = BinaryUtils.fieldOffsetLength(flags);
+        int fieldIdLen = BinaryUtilsEx.isCompactFooter(flags) ? 0 : BinaryUtilsEx.FIELD_ID_LEN;
+        int fieldOffsetLen = BinaryUtilsEx.fieldOffsetLength(flags);
 
         int fieldOffsetPos = start + schemaOffset + order * (fieldIdLen + fieldOffsetLen) + fieldIdLen;
 
         int fieldPos;
 
-        if (fieldOffsetLen == BinaryUtils.OFFSET_1)
+        if (fieldOffsetLen == BinaryUtilsEx.OFFSET_1)
             fieldPos = start + ((int)BinaryPrimitives.readByte(ptr, fieldOffsetPos) & 0xFF);
-        else if (fieldOffsetLen == BinaryUtils.OFFSET_2)
+        else if (fieldOffsetLen == BinaryUtilsEx.OFFSET_2)
             fieldPos = start + ((int)BinaryPrimitives.readShort(ptr, fieldOffsetPos) & 0xFFFF);
         else
             fieldPos = start + BinaryPrimitives.readInt(ptr, fieldOffsetPos);
@@ -296,7 +296,7 @@
 
                 stream.position(fieldPos);
 
-                val = BinaryUtils.unmarshal(stream, ctx, null);
+                val = BinaryUtilsEx.unmarshal(stream, ctx, null);
 
                 break;
         }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 8f9cc92..e63c41b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -188,7 +188,7 @@
         // Perform full header parsing in case of binary object.
         if (!skipHdrCheck && (in.readByte() == GridBinaryMarshaller.OBJ)) {
             // Ensure protocol is fine.
-            BinaryUtils.checkProtocolVersion(in.readByte());
+            BinaryUtilsEx.checkProtocolVersion(in.readByte());
 
             // Read header content.
             short flags = in.readShort();
@@ -201,16 +201,16 @@
             int offset = in.readInt();
 
             // Get trivial flag values.
-            userType = BinaryUtils.isUserType(flags);
-            fieldIdLen = BinaryUtils.fieldIdLength(flags);
-            fieldOffsetLen = BinaryUtils.fieldOffsetLength(flags);
+            userType = BinaryUtilsEx.isUserType(flags);
+            fieldIdLen = BinaryUtilsEx.fieldIdLength(flags);
+            fieldOffsetLen = BinaryUtilsEx.fieldOffsetLength(flags);
 
             // Calculate footer borders and raw offset.
-            if (BinaryUtils.hasSchema(flags)) {
+            if (BinaryUtilsEx.hasSchema(flags)) {
                 // Schema exists.
                 footerStart = start + offset;
 
-                if (BinaryUtils.hasRaw(flags)) {
+                if (BinaryUtilsEx.hasRaw(flags)) {
                     footerLen = len - offset - 4;
                     rawOff = start + in.readIntPositioned(start + len - 4);
                 }
@@ -224,7 +224,7 @@
                 footerStart = start + len;
                 footerLen = 0;
 
-                if (BinaryUtils.hasRaw(flags))
+                if (BinaryUtilsEx.hasRaw(flags))
                     rawOff = start + offset;
                 else
                     rawOff = start + len;
@@ -235,7 +235,7 @@
                 int off = in.position();
 
                 // Registers class by type ID, at least locally if the cache is not ready yet.
-                typeId = ctx.descriptorForClass(BinaryUtils.doReadClass(in, ctx, ldr, typeId0), false).typeId();
+                typeId = ctx.descriptorForClass(BinaryUtilsEx.doReadClass(in, ctx, ldr, typeId0), false).typeId();
 
                 int clsNameLen = in.position() - off;
 
@@ -248,7 +248,7 @@
             }
 
             idMapper = userType ? ctx.userTypeIdMapper(typeId) : BinaryInternalIdMapper.defaultInstance();
-            schema = BinaryUtils.hasSchema(flags) ? getOrCreateSchema() : null;
+            schema = BinaryUtilsEx.hasSchema(flags) ? getOrCreateSchema() : null;
         }
         else {
             dataStart = 0;
@@ -289,7 +289,7 @@
     public Object unmarshal(int offset) throws BinaryObjectException {
         streamPosition(offset);
 
-        return in.position() >= 0 ? BinaryUtils.unmarshal(in, ctx, ldr, this) : null;
+        return in.position() >= 0 ? BinaryUtilsEx.unmarshal(in, ctx, ldr, this) : null;
     }
 
     /**
@@ -298,7 +298,7 @@
      * @throws BinaryObjectException In case of error.
      */
     @Nullable Object unmarshalField(String fieldName) throws BinaryObjectException {
-        return findFieldByName(fieldName) ? BinaryUtils.unmarshal(in, ctx, ldr, this) : null;
+        return findFieldByName(fieldName) ? BinaryUtilsEx.unmarshal(in, ctx, ldr, this) : null;
     }
 
     /**
@@ -307,7 +307,7 @@
      * @throws BinaryObjectException In case of error.
      */
     @Nullable Object unmarshalField(int fieldId) throws BinaryObjectException {
-        return findFieldById(fieldId) ? BinaryUtils.unmarshal(in, ctx, ldr, this) : null;
+        return findFieldById(fieldId) ? BinaryUtilsEx.unmarshal(in, ctx, ldr, this) : null;
     }
 
     /**
@@ -320,7 +320,7 @@
             if (checkFlag(BINARY_OBJ) == Flag.NULL)
                 return null;
 
-            return new BinaryObjectImpl(ctx, BinaryUtils.doReadByteArray(in), in.readInt());
+            return new BinaryObjectImpl(ctx, BinaryUtilsEx.doReadByteArray(in), in.readInt());
         }
         else
             return null;
@@ -336,7 +336,7 @@
             if (checkFlag(CLASS) == Flag.NULL)
                 return null;
 
-            return BinaryUtils.doReadClass(in, ctx, ldr);
+            return BinaryUtilsEx.doReadClass(in, ctx, ldr);
         }
 
         return null;
@@ -374,7 +374,7 @@
      * @return Field.
      */
     private <T> T readHandleField() {
-        int handlePos = BinaryUtils.positionForHandle(in) - in.readInt();
+        int handlePos = BinaryUtilsEx.positionForHandle(in) - in.readInt();
 
         Object obj = getHandle(handlePos);
 
@@ -383,7 +383,7 @@
 
             streamPosition(handlePos);
 
-            obj = BinaryUtils.doReadObject(in, ctx, ldr, this);
+            obj = BinaryUtilsEx.doReadObject(in, ctx, ldr, this);
 
             streamPosition(retPos);
         }
@@ -436,7 +436,7 @@
     @Nullable @Override public byte[] readByteArray() throws BinaryObjectException {
         switch (checkFlag(BYTE_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadByteArray(in);
+                return BinaryUtilsEx.doReadByteArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -492,7 +492,7 @@
     @Nullable @Override public boolean[] readBooleanArray() throws BinaryObjectException {
         switch (checkFlag(BOOLEAN_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadBooleanArray(in);
+                return BinaryUtilsEx.doReadBooleanArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -548,7 +548,7 @@
     @Nullable @Override public short[] readShortArray() throws BinaryObjectException {
         switch (checkFlag(SHORT_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadShortArray(in);
+                return BinaryUtilsEx.doReadShortArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -604,7 +604,7 @@
     @Nullable @Override public char[] readCharArray() throws BinaryObjectException {
         switch (checkFlag(CHAR_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadCharArray(in);
+                return BinaryUtilsEx.doReadCharArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -660,7 +660,7 @@
     @Nullable @Override public int[] readIntArray() throws BinaryObjectException {
         switch (checkFlag(INT_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadIntArray(in);
+                return BinaryUtilsEx.doReadIntArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -716,7 +716,7 @@
     @Nullable @Override public long[] readLongArray() throws BinaryObjectException {
         switch (checkFlag(LONG_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadLongArray(in);
+                return BinaryUtilsEx.doReadLongArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -772,7 +772,7 @@
     @Nullable @Override public float[] readFloatArray() throws BinaryObjectException {
         switch (checkFlag(FLOAT_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadFloatArray(in);
+                return BinaryUtilsEx.doReadFloatArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -828,7 +828,7 @@
     @Nullable @Override public double[] readDoubleArray() throws BinaryObjectException {
         switch (checkFlag(DOUBLE_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadDoubleArray(in);
+                return BinaryUtilsEx.doReadDoubleArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -854,7 +854,7 @@
 
     /** {@inheritDoc} */
     @Override @Nullable public BigDecimal readDecimal() throws BinaryObjectException {
-        return checkFlagNoHandles(DECIMAL) == Flag.NORMAL ? BinaryUtils.doReadDecimal(in) : null;
+        return checkFlagNoHandles(DECIMAL) == Flag.NORMAL ? BinaryUtilsEx.doReadDecimal(in) : null;
     }
 
     /** {@inheritDoc} */
@@ -875,7 +875,7 @@
     @Override @Nullable public BigDecimal[] readDecimalArray() throws BinaryObjectException {
         switch (checkFlag(DECIMAL_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadDecimalArray(in);
+                return BinaryUtilsEx.doReadDecimalArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -901,7 +901,7 @@
 
     /** {@inheritDoc} */
     @Override @Nullable public String readString() throws BinaryObjectException {
-        return checkFlagNoHandles(STRING) == Flag.NORMAL ? BinaryUtils.doReadString(in) : null;
+        return checkFlagNoHandles(STRING) == Flag.NORMAL ? BinaryUtilsEx.doReadString(in) : null;
     }
 
     /** {@inheritDoc} */
@@ -922,7 +922,7 @@
     @Override @Nullable public String[] readStringArray() throws BinaryObjectException {
         switch (checkFlag(STRING_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadStringArray(in);
+                return BinaryUtilsEx.doReadStringArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -948,7 +948,7 @@
 
     /** {@inheritDoc} */
     @Override @Nullable public UUID readUuid() throws BinaryObjectException {
-        return checkFlagNoHandles(UUID) == Flag.NORMAL ? BinaryUtils.doReadUuid(in) : null;
+        return checkFlagNoHandles(UUID) == Flag.NORMAL ? BinaryUtilsEx.doReadUuid(in) : null;
     }
 
     /** {@inheritDoc} */
@@ -969,7 +969,7 @@
     @Override @Nullable public UUID[] readUuidArray() throws BinaryObjectException {
         switch (checkFlag(UUID_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadUuidArray(in);
+                return BinaryUtilsEx.doReadUuidArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -995,7 +995,7 @@
 
     /** {@inheritDoc} */
     @Override @Nullable public Date readDate() throws BinaryObjectException {
-        return checkFlagNoHandles(DATE) == Flag.NORMAL ? BinaryUtils.doReadDate(in) : null;
+        return checkFlagNoHandles(DATE) == Flag.NORMAL ? BinaryUtilsEx.doReadDate(in) : null;
     }
 
     /** {@inheritDoc} */
@@ -1016,7 +1016,7 @@
     @Override @Nullable public Date[] readDateArray() throws BinaryObjectException {
         switch (checkFlag(DATE_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadDateArray(in);
+                return BinaryUtilsEx.doReadDateArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -1042,7 +1042,7 @@
 
     /** {@inheritDoc} */
     @Override @Nullable public Timestamp readTimestamp() throws BinaryObjectException {
-        return checkFlagNoHandles(TIMESTAMP) == Flag.NORMAL ? BinaryUtils.doReadTimestamp(in) : null;
+        return checkFlagNoHandles(TIMESTAMP) == Flag.NORMAL ? BinaryUtilsEx.doReadTimestamp(in) : null;
     }
 
     /** {@inheritDoc} */
@@ -1063,7 +1063,7 @@
     @Override @Nullable public Timestamp[] readTimestampArray() throws BinaryObjectException {
         switch (checkFlag(TIMESTAMP_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadTimestampArray(in);
+                return BinaryUtilsEx.doReadTimestampArray(in);
 
             case HANDLE:
                 return readHandleField();
@@ -1076,7 +1076,7 @@
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override public <T> T readObject(String fieldName) throws BinaryObjectException {
-        return findFieldByName(fieldName) ? (T)BinaryUtils.doReadObject(in, ctx, ldr, this) : null;
+        return findFieldByName(fieldName) ? (T) BinaryUtilsEx.doReadObject(in, ctx, ldr, this) : null;
     }
 
     /**
@@ -1085,17 +1085,17 @@
      * @throws BinaryObjectException In case of error.
      */
     @Nullable Object readObject(int fieldId) throws BinaryObjectException {
-        return findFieldById(fieldId) ? BinaryUtils.doReadObject(in, ctx, ldr, this) : null;
+        return findFieldById(fieldId) ? BinaryUtilsEx.doReadObject(in, ctx, ldr, this) : null;
     }
 
     /** {@inheritDoc} */
     @Override public Object readObject() throws BinaryObjectException {
-        return BinaryUtils.doReadObject(in, ctx, ldr, this);
+        return BinaryUtilsEx.doReadObject(in, ctx, ldr, this);
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public Object readObjectDetached() throws BinaryObjectException {
-        return BinaryUtils.unmarshal(in, ctx, ldr, this, true);
+        return BinaryUtilsEx.unmarshal(in, ctx, ldr, this, true);
     }
 
     /** {@inheritDoc} */
@@ -1116,7 +1116,7 @@
     @Nullable @Override public Object[] readObjectArray() throws BinaryObjectException {
         switch (checkFlag(OBJ_ARR)) {
             case NORMAL:
-                return BinaryUtils.doReadObjectArray(in, ctx, ldr, this, true);
+                return BinaryUtilsEx.doReadObjectArray(in, ctx, ldr, this, true);
 
             case HANDLE:
                 return readHandleField();
@@ -1156,12 +1156,12 @@
     private Enum<?> readEnum0(@Nullable Class<?> cls) throws BinaryObjectException {
         if (checkFlagNoHandles(ENUM) == Flag.NORMAL) {
             // Read class even if we know it in advance to set correct stream position.
-            Class<?> cls0 = BinaryUtils.doReadClass(in, ctx, ldr);
+            Class<?> cls0 = BinaryUtilsEx.doReadClass(in, ctx, ldr);
 
             if (cls == null)
                 cls = cls0;
 
-            return BinaryUtils.doReadEnum(in, cls);
+            return BinaryUtilsEx.doReadEnum(in, cls);
         }
         else
             return null;
@@ -1199,12 +1199,12 @@
         switch (checkFlag(ENUM_ARR)) {
             case NORMAL:
                 // Read class even if we know it in advance to set correct stream position.
-                Class<?> cls0 = BinaryUtils.doReadClass(in, ctx, ldr);
+                Class<?> cls0 = BinaryUtilsEx.doReadClass(in, ctx, ldr);
 
                 if (cls == null)
                     cls = cls0;
 
-                return BinaryUtils.doReadEnumArray(in, ctx, ldr, cls);
+                return BinaryUtilsEx.doReadEnumArray(in, ctx, ldr, cls);
 
             case HANDLE:
                 return readHandleField();
@@ -1258,10 +1258,10 @@
         throws BinaryObjectException {
         switch (checkFlag(COL)) {
             case NORMAL:
-                return (Collection)BinaryUtils.doReadCollection(in, ctx, ldr, this, true, factory);
+                return (Collection) BinaryUtilsEx.doReadCollection(in, ctx, ldr, this, true, factory);
 
             case HANDLE: {
-                int handlePos = BinaryUtils.positionForHandle(in) - in.readInt();
+                int handlePos = BinaryUtilsEx.positionForHandle(in) - in.readInt();
 
                 Object obj = getHandle(handlePos);
 
@@ -1325,10 +1325,10 @@
     private Map readMap0(@Nullable BinaryMapFactory factory) throws BinaryObjectException {
         switch (checkFlag(MAP)) {
             case NORMAL:
-                return (Map)BinaryUtils.doReadMap(in, ctx, ldr, this, true, factory);
+                return (Map) BinaryUtilsEx.doReadMap(in, ctx, ldr, this, true, factory);
 
             case HANDLE: {
-                int handlePos = BinaryUtils.positionForHandle(in) - in.readInt();
+                int handlePos = BinaryUtilsEx.positionForHandle(in) - in.readInt();
 
                 Object obj = getHandle(handlePos);
 
@@ -1367,7 +1367,7 @@
         else if (flag == HANDLE)
             return Flag.HANDLE;
 
-        int pos = BinaryUtils.positionForHandle(in);
+        int pos = BinaryUtilsEx.positionForHandle(in);
 
         throw new BinaryObjectException("Unexpected flag value [pos=" + pos + ", expected=" + expFlag +
             ", actual=" + flag + ']');
@@ -1388,7 +1388,7 @@
         else if (flag == NULL)
             return Flag.NULL;
 
-        int pos = BinaryUtils.positionForHandle(in);
+        int pos = BinaryUtilsEx.positionForHandle(in);
 
         throw new BinaryObjectException("Unexpected flag value [pos=" + pos + ", expected=" + expFlag +
             ", actual=" + flag + ']');
@@ -1432,7 +1432,7 @@
 
                     streamPosition(handlePos);
 
-                    obj = BinaryUtils.doReadObject(in, ctx, ldr, this);
+                    obj = BinaryUtilsEx.doReadObject(in, ctx, ldr, this);
 
                     streamPosition(retPos);
                 }
@@ -1494,112 +1494,112 @@
                 break;
 
             case DECIMAL:
-                obj = BinaryUtils.doReadDecimal(in);
+                obj = BinaryUtilsEx.doReadDecimal(in);
 
                 break;
 
             case STRING:
-                obj = BinaryUtils.doReadString(in);
+                obj = BinaryUtilsEx.doReadString(in);
 
                 break;
 
             case UUID:
-                obj = BinaryUtils.doReadUuid(in);
+                obj = BinaryUtilsEx.doReadUuid(in);
 
                 break;
 
             case DATE:
-                obj = BinaryUtils.doReadDate(in);
+                obj = BinaryUtilsEx.doReadDate(in);
 
                 break;
 
             case TIMESTAMP:
-                obj = BinaryUtils.doReadTimestamp(in);
+                obj = BinaryUtilsEx.doReadTimestamp(in);
 
                 break;
 
             case BYTE_ARR:
-                obj = BinaryUtils.doReadByteArray(in);
+                obj = BinaryUtilsEx.doReadByteArray(in);
 
                 break;
 
             case SHORT_ARR:
-                obj = BinaryUtils.doReadShortArray(in);
+                obj = BinaryUtilsEx.doReadShortArray(in);
 
                 break;
 
             case INT_ARR:
-                obj = BinaryUtils.doReadIntArray(in);
+                obj = BinaryUtilsEx.doReadIntArray(in);
 
                 break;
 
             case LONG_ARR:
-                obj = BinaryUtils.doReadLongArray(in);
+                obj = BinaryUtilsEx.doReadLongArray(in);
 
                 break;
 
             case FLOAT_ARR:
-                obj = BinaryUtils.doReadFloatArray(in);
+                obj = BinaryUtilsEx.doReadFloatArray(in);
 
                 break;
 
             case DOUBLE_ARR:
-                obj = BinaryUtils.doReadDoubleArray(in);
+                obj = BinaryUtilsEx.doReadDoubleArray(in);
 
                 break;
 
             case CHAR_ARR:
-                obj = BinaryUtils.doReadCharArray(in);
+                obj = BinaryUtilsEx.doReadCharArray(in);
 
                 break;
 
             case BOOLEAN_ARR:
-                obj = BinaryUtils.doReadBooleanArray(in);
+                obj = BinaryUtilsEx.doReadBooleanArray(in);
 
                 break;
 
             case DECIMAL_ARR:
-                obj = BinaryUtils.doReadDecimalArray(in);
+                obj = BinaryUtilsEx.doReadDecimalArray(in);
 
                 break;
 
             case STRING_ARR:
-                obj = BinaryUtils.doReadStringArray(in);
+                obj = BinaryUtilsEx.doReadStringArray(in);
 
                 break;
 
             case UUID_ARR:
-                obj = BinaryUtils.doReadUuidArray(in);
+                obj = BinaryUtilsEx.doReadUuidArray(in);
 
                 break;
 
             case DATE_ARR:
-                obj = BinaryUtils.doReadDateArray(in);
+                obj = BinaryUtilsEx.doReadDateArray(in);
 
                 break;
 
             case TIMESTAMP_ARR:
-                obj = BinaryUtils.doReadTimestampArray(in);
+                obj = BinaryUtilsEx.doReadTimestampArray(in);
 
                 break;
 
             case OBJ_ARR:
-                obj = BinaryUtils.doReadObjectArray(in, ctx, ldr, this, true);
+                obj = BinaryUtilsEx.doReadObjectArray(in, ctx, ldr, this, true);
 
                 break;
 
             case COL:
-                obj = BinaryUtils.doReadCollection(in, ctx, ldr, this, true, null);
+                obj = BinaryUtilsEx.doReadCollection(in, ctx, ldr, this, true, null);
 
                 break;
 
             case MAP:
-                obj = BinaryUtils.doReadMap(in, ctx, ldr, this, true, null);
+                obj = BinaryUtilsEx.doReadMap(in, ctx, ldr, this, true, null);
 
                 break;
 
             case BINARY_OBJ:
-                obj = BinaryUtils.doReadBinaryObject(in, ctx);
+                obj = BinaryUtilsEx.doReadBinaryObject(in, ctx);
 
                 ((BinaryObjectImpl)obj).context(ctx);
 
@@ -1609,22 +1609,22 @@
                 break;
 
             case ENUM:
-                obj = BinaryUtils.doReadEnum(in, BinaryUtils.doReadClass(in, ctx, ldr));
+                obj = BinaryUtilsEx.doReadEnum(in, BinaryUtilsEx.doReadClass(in, ctx, ldr));
 
                 break;
 
             case ENUM_ARR:
-                obj = BinaryUtils.doReadEnumArray(in, ctx, ldr, BinaryUtils.doReadClass(in, ctx, ldr));
+                obj = BinaryUtilsEx.doReadEnumArray(in, ctx, ldr, BinaryUtilsEx.doReadClass(in, ctx, ldr));
 
                 break;
 
             case CLASS:
-                obj = BinaryUtils.doReadClass(in, ctx, ldr);
+                obj = BinaryUtilsEx.doReadClass(in, ctx, ldr);
 
                 break;
 
             case OPTM_MARSH:
-                obj = BinaryUtils.doReadOptimized(in, ctx, ldr);
+                obj = BinaryUtilsEx.doReadOptimized(in, ctx, ldr);
 
                 break;
 
@@ -1665,7 +1665,7 @@
         BinarySchema schema = ctx.schemaRegistry(typeId).schema(schemaId);
 
         if (schema == null) {
-            if (fieldIdLen != BinaryUtils.FIELD_ID_LEN) {
+            if (fieldIdLen != BinaryUtilsEx.FIELD_ID_LEN) {
                 BinaryTypeImpl type = (BinaryTypeImpl)ctx.metadata(typeId);
 
                 if (type == null || type.metadata() == null)
@@ -1701,7 +1701,7 @@
      * @return Schema.
      */
     private BinarySchema createSchema() {
-        assert fieldIdLen == BinaryUtils.FIELD_ID_LEN;
+        assert fieldIdLen == BinaryUtilsEx.FIELD_ID_LEN;
 
         BinarySchema.Builder builder = BinarySchema.Builder.newBuilder();
 
@@ -1713,7 +1713,7 @@
 
             builder.addField(fieldId);
 
-            searchPos += BinaryUtils.FIELD_ID_LEN + fieldOffsetLen;
+            searchPos += BinaryUtilsEx.FIELD_ID_LEN + fieldOffsetLen;
         }
 
         return builder.build();
@@ -1849,7 +1849,7 @@
         if (order != BinarySchema.ORDER_NOT_FOUND) {
             int offsetPos = footerStart + order * (fieldIdLen + fieldOffsetLen) + fieldIdLen;
 
-            int pos = start + BinaryUtils.fieldOffsetRelative(in, offsetPos, fieldOffsetLen);
+            int pos = start + BinaryUtilsEx.fieldOffsetRelative(in, offsetPos, fieldOffsetLen);
 
             streamPosition(pos);
 
@@ -1867,7 +1867,7 @@
      */
     private boolean trySetSystemFieldPosition(int id) {
         // System types are never written with compact footers because they do not have metadata.
-        assert fieldIdLen == BinaryUtils.FIELD_ID_LEN;
+        assert fieldIdLen == BinaryUtilsEx.FIELD_ID_LEN;
 
         int searchPos = footerStart;
         int searchTail = searchPos + footerLen;
@@ -1879,7 +1879,7 @@
             int id0 = in.readIntPositioned(searchPos);
 
             if (id0 == id) {
-                int pos = start + BinaryUtils.fieldOffsetRelative(in, searchPos + BinaryUtils.FIELD_ID_LEN,
+                int pos = start + BinaryUtilsEx.fieldOffsetRelative(in, searchPos + BinaryUtilsEx.FIELD_ID_LEN,
                     fieldOffsetLen);
 
                 streamPosition(pos);
@@ -1887,7 +1887,7 @@
                 return true;
             }
 
-            searchPos += BinaryUtils.FIELD_ID_LEN + fieldOffsetLen;
+            searchPos += BinaryUtilsEx.FIELD_ID_LEN + fieldOffsetLen;
         }
     }
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinarySchema.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinarySchema.java
index 04124e0..42d35dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinarySchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinarySchema.java
@@ -414,7 +414,7 @@
      */
     public static class Builder {
         /** Schema ID. */
-        private int schemaId = BinaryUtils.schemaInitialId();
+        private int schemaId = BinaryUtilsEx.schemaInitialId();
 
         /** Fields. */
         private final ArrayList<Integer> fields = new ArrayList<>();
@@ -443,7 +443,7 @@
         public void addField(int fieldId) {
             fields.add(fieldId);
 
-            schemaId = BinaryUtils.updateSchemaId(schemaId, fieldId);
+            schemaId = BinaryUtilsEx.updateSchemaId(schemaId, fieldId);
         }
 
         /**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtilsEx.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
rename to modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtilsEx.java
index 8cb4b38..f11de91 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtilsEx.java
@@ -64,7 +64,7 @@
 /**
  * Binary utils.
  */
-public class BinaryUtils {
+public class BinaryUtilsEx {
     /** */
     public static final Map<Class<?>, Byte> PLAIN_CLASS_TO_FLAG = new HashMap<>();
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 6e05b40..607f8d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -72,7 +72,7 @@
     private BinaryWriterHandles handles;
 
     /** Schema ID. */
-    private int schemaId = BinaryUtils.schemaInitialId();
+    private int schemaId = BinaryUtilsEx.schemaInitialId();
 
     /** Amount of written fields. */
     private int fieldCnt;
@@ -248,11 +248,11 @@
 
         if (userType) {
             if (ctx.isCompactFooter()) {
-                flags = BinaryUtils.FLAG_USR_TYP | BinaryUtils.FLAG_COMPACT_FOOTER;
+                flags = BinaryUtilsEx.FLAG_USR_TYP | BinaryUtilsEx.FLAG_COMPACT_FOOTER;
                 useCompactFooter = true;
             }
             else {
-                flags = BinaryUtils.FLAG_USR_TYP;
+                flags = BinaryUtilsEx.FLAG_USR_TYP;
                 useCompactFooter = false;
             }
         }
@@ -269,18 +269,18 @@
             offset = out.position() - start;
 
             // Write the schema.
-            flags |= BinaryUtils.FLAG_HAS_SCHEMA;
+            flags |= BinaryUtilsEx.FLAG_HAS_SCHEMA;
 
             int offsetByteCnt = schema.write(out, fieldCnt, useCompactFooter);
 
-            if (offsetByteCnt == BinaryUtils.OFFSET_1)
-                flags |= BinaryUtils.FLAG_OFFSET_ONE_BYTE;
-            else if (offsetByteCnt == BinaryUtils.OFFSET_2)
-                flags |= BinaryUtils.FLAG_OFFSET_TWO_BYTES;
+            if (offsetByteCnt == BinaryUtilsEx.OFFSET_1)
+                flags |= BinaryUtilsEx.FLAG_OFFSET_ONE_BYTE;
+            else if (offsetByteCnt == BinaryUtilsEx.OFFSET_2)
+                flags |= BinaryUtilsEx.FLAG_OFFSET_TWO_BYTES;
 
             // Write raw offset if needed.
             if (rawOffPos != 0) {
-                flags |= BinaryUtils.FLAG_HAS_RAW;
+                flags |= BinaryUtilsEx.FLAG_HAS_RAW;
 
                 out.writeInt(rawOffPos - start);
             }
@@ -291,7 +291,7 @@
                 offset = rawOffPos - start;
 
                 // If there is no schema, we are free to write raw offset to schema offset.
-                flags |= BinaryUtils.FLAG_HAS_RAW;
+                flags |= BinaryUtilsEx.FLAG_HAS_RAW;
             }
             else {
                 finalSchemaId = 0;
@@ -1658,7 +1658,7 @@
         int fieldOff = out.position() - start;
 
         // Advance schema hash.
-        schemaId = BinaryUtils.updateSchemaId(schemaId, fieldId);
+        schemaId = BinaryUtilsEx.updateSchemaId(schemaId, fieldId);
 
         schema.push(fieldId, fieldOff);
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterSchemaHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterSchemaHolder.java
index 22ae8e3..562a3e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterSchemaHolder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterSchemaHolder.java
@@ -94,19 +94,19 @@
                 for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
                     out.unsafeWriteByte((byte)data[curIdx]);
 
-                res = BinaryUtils.OFFSET_1;
+                res = BinaryUtilsEx.OFFSET_1;
             }
             else if (lastOffset < MAX_OFFSET_2) {
                 for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
                     out.unsafeWriteShort((short) data[curIdx]);
 
-                res = BinaryUtils.OFFSET_2;
+                res = BinaryUtilsEx.OFFSET_2;
             }
             else {
                 for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
                     out.unsafeWriteInt(data[curIdx]);
 
-                res = BinaryUtils.OFFSET_4;
+                res = BinaryUtilsEx.OFFSET_4;
             }
         }
         else {
@@ -116,7 +116,7 @@
                     out.unsafeWriteByte((byte) data[curIdx++]);
                 }
 
-                res = BinaryUtils.OFFSET_1;
+                res = BinaryUtilsEx.OFFSET_1;
             }
             else if (lastOffset < MAX_OFFSET_2) {
                 for (int curIdx = startIdx; curIdx < idx;) {
@@ -124,7 +124,7 @@
                     out.unsafeWriteShort((short) data[curIdx++]);
                 }
 
-                res = BinaryUtils.OFFSET_2;
+                res = BinaryUtilsEx.OFFSET_2;
             }
             else {
                 for (int curIdx = startIdx; curIdx < idx;) {
@@ -132,7 +132,7 @@
                     out.unsafeWriteInt(data[curIdx++]);
                 }
 
-                res = BinaryUtils.OFFSET_4;
+                res = BinaryUtilsEx.OFFSET_4;
             }
         }
 
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index b21c679..b5bcd4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -237,7 +237,7 @@
     @Nullable public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws BinaryObjectException {
         assert bytes != null;
 
-        return (T)BinaryUtils.unmarshal(BinaryHeapInputStream.create(bytes, 0), ctx, clsLdr);
+        return (T) BinaryUtilsEx.unmarshal(BinaryHeapInputStream.create(bytes, 0), ctx, clsLdr);
     }
 
     /**
@@ -247,7 +247,7 @@
      */
     @SuppressWarnings("unchecked")
     @Nullable public <T> T unmarshal(BinaryInputStream in) throws BinaryObjectException {
-        return (T)BinaryUtils.unmarshal(in, ctx, null);
+        return (T) BinaryUtilsEx.unmarshal(in, ctx, null);
     }
 
     /**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
index 662ad1d..fb8ae34 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
@@ -27,7 +27,7 @@
 import org.apache.ignite.internal.binary.BinaryPrimitives;
 import org.apache.ignite.internal.binary.BinarySchema;
 import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 
 import java.sql.Timestamp;
 import java.util.Date;
@@ -840,7 +840,7 @@
 
         /** {@inheritDoc} */
         @Override public Object value() {
-            return BinaryUtils.unwrapLazy(wrappedCollection());
+            return BinaryUtilsEx.unwrapLazy(wrappedCollection());
         }
     }
 }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
index a095242..f3cbba7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
@@ -23,7 +23,7 @@
 import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryContext;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 
 import java.util.Collection;
 import java.util.IdentityHashMap;
@@ -145,10 +145,10 @@
             return;
         }
 
-        Byte flag = BinaryUtils.PLAIN_CLASS_TO_FLAG.get(val.getClass());
+        Byte flag = BinaryUtilsEx.PLAIN_CLASS_TO_FLAG.get(val.getClass());
 
         if (flag != null) {
-            BinaryUtils.writePlainObject(writer, val);
+            BinaryUtilsEx.writePlainObject(writer, val);
 
             return;
         }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyArrayList.java
index 21d7dcb..7f250b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyArrayList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyArrayList.java
@@ -23,7 +23,7 @@
 import java.util.List;
 import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 
 /**
  *
@@ -72,7 +72,7 @@
     @Override public Object get(int idx) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.get(idx));
+        return BinaryUtilsEx.unwrapLazy(delegate.get(idx));
     }
 
     /** {@inheritDoc} */
@@ -93,14 +93,14 @@
     @Override public Object set(int idx, Object element) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.set(idx, element));
+        return BinaryUtilsEx.unwrapLazy(delegate.set(idx, element));
     }
 
     /** {@inheritDoc} */
     @Override public Object remove(int idx) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.remove(idx));
+        return BinaryUtilsEx.unwrapLazy(delegate.remove(idx));
     }
 
     /** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyLinkedList.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyLinkedList.java
index 1813fcc..3f19eb3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyLinkedList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyLinkedList.java
@@ -25,7 +25,7 @@
 import java.util.ListIterator;
 import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 
 /**
  *
@@ -74,7 +74,7 @@
     @Override public Object get(int idx) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.get(idx));
+        return BinaryUtilsEx.unwrapLazy(delegate.get(idx));
     }
 
     /** {@inheritDoc} */
@@ -95,14 +95,14 @@
     @Override public Object set(int idx, Object element) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.set(idx, element));
+        return BinaryUtilsEx.unwrapLazy(delegate.set(idx, element));
     }
 
     /** {@inheritDoc} */
     @Override public Object remove(int idx) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.remove(idx));
+        return BinaryUtilsEx.unwrapLazy(delegate.remove(idx));
     }
 
     /** {@inheritDoc} */
@@ -148,7 +148,7 @@
             }
 
             @Override public Object next() {
-                return BinaryUtils.unwrapLazy(delegate.next());
+                return BinaryUtilsEx.unwrapLazy(delegate.next());
             }
 
             @Override public boolean hasPrevious() {
@@ -156,7 +156,7 @@
             }
 
             @Override public Object previous() {
-                return BinaryUtils.unwrapLazy(delegate.previous());
+                return BinaryUtilsEx.unwrapLazy(delegate.previous());
             }
 
             @Override public int nextIndex() {
@@ -185,7 +185,7 @@
     @Override public Iterator<Object> iterator() {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazyIterator(super.iterator());
+        return BinaryUtilsEx.unwrapLazyIterator(super.iterator());
     }
 
     /** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyMap.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyMap.java
index 6afe798..08ea6bf7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazyMap.java
@@ -25,7 +25,7 @@
 import java.util.Set;
 import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -81,7 +81,7 @@
             delegate = new LinkedHashMap<>();
 
             for (int i = 0; i < size; i++)
-                delegate.put(BinaryUtils.unwrapLazy(reader.parseValue()), reader.parseValue());
+                delegate.put(BinaryUtilsEx.unwrapLazy(reader.parseValue()), reader.parseValue());
         }
     }
 
@@ -154,21 +154,21 @@
     @Override public Object get(Object key) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.get(key));
+        return BinaryUtilsEx.unwrapLazy(delegate.get(key));
     }
 
     /** {@inheritDoc} */
     @Override public Object put(Object key, Object val) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.put(key, val));
+        return BinaryUtilsEx.unwrapLazy(delegate.put(key, val));
     }
 
     /** {@inheritDoc} */
     @Override public Object remove(Object key) {
         ensureDelegateInit();
 
-        return BinaryUtils.unwrapLazy(delegate.remove(key));
+        return BinaryUtilsEx.unwrapLazy(delegate.remove(key));
     }
 
     /** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazySet.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazySet.java
index 6be4c76..85e260d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazySet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryLazySet.java
@@ -21,7 +21,7 @@
 import java.util.Set;
 import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
 /**
@@ -85,7 +85,7 @@
         Set<Object> res = U.newLinkedHashSet(size);
 
         for (int i = 0; i < size; i++)
-            res.add(BinaryUtils.unwrapLazy(reader.parseValue()));
+            res.add(BinaryUtilsEx.unwrapLazy(reader.parseValue()));
 
         return res;
     }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index 8353cdb..b221b30 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -30,7 +30,7 @@
 import org.apache.ignite.internal.binary.BinarySchema;
 import org.apache.ignite.internal.binary.BinarySchemaRegistry;
 import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
@@ -131,7 +131,7 @@
 
         byte ver = reader.readBytePositioned(start + GridBinaryMarshaller.PROTO_VER_POS);
 
-        BinaryUtils.checkProtocolVersion(ver);
+        BinaryUtilsEx.checkProtocolVersion(ver);
 
         int typeId = reader.readIntPositioned(start + GridBinaryMarshaller.TYPE_ID_POS);
         ctx = reader.binaryContext();
@@ -214,16 +214,16 @@
                     assignedFldsById = Collections.emptyMap();
 
                 // Get footer details.
-                int fieldIdLen = BinaryUtils.fieldIdLength(flags);
-                int fieldOffsetLen = BinaryUtils.fieldOffsetLength(flags);
+                int fieldIdLen = BinaryUtilsEx.fieldIdLength(flags);
+                int fieldOffsetLen = BinaryUtilsEx.fieldOffsetLength(flags);
 
-                IgniteBiTuple<Integer, Integer> footer = BinaryUtils.footerAbsolute(reader, start);
+                IgniteBiTuple<Integer, Integer> footer = BinaryUtilsEx.footerAbsolute(reader, start);
 
                 int footerPos = footer.get1();
                 int footerEnd = footer.get2();
 
                 // Get raw position.
-                int rawPos = BinaryUtils.rawOffsetAbsolute(reader, start);
+                int rawPos = BinaryUtilsEx.rawOffsetAbsolute(reader, start);
 
                 // Position reader on data.
                 reader.position(start + hdrLen);
@@ -251,7 +251,7 @@
                     else {
                         int type = fieldLen != 0 ? reader.readByte(0) : 0;
 
-                        if (fieldLen != 0 && !BinaryUtils.isPlainArrayType(type) && BinaryUtils.isPlainType(type)) {
+                        if (fieldLen != 0 && !BinaryUtilsEx.isPlainArrayType(type) && BinaryUtilsEx.isPlainType(type)) {
                             writer.writeFieldId(fieldId);
 
                             writer.write(reader.array(), reader.position(), fieldLen);
@@ -314,19 +314,19 @@
                             nullObjField = true;
                     }
                     else
-                        newFldTypeId = BinaryUtils.typeByClass(val.getClass());
+                        newFldTypeId = BinaryUtilsEx.typeByClass(val.getClass());
 
-                    String newFldTypeName = BinaryUtils.fieldTypeName(newFldTypeId);
+                    String newFldTypeName = BinaryUtilsEx.fieldTypeName(newFldTypeId);
 
                     if (oldFldTypeName == null) {
                         // It's a new field, we have to add it to metadata.
                         if (fieldsMeta == null)
                             fieldsMeta = new HashMap<>();
 
-                        fieldsMeta.put(name, BinaryUtils.fieldTypeId(newFldTypeName));
+                        fieldsMeta.put(name, BinaryUtilsEx.fieldTypeId(newFldTypeName));
                     }
                     else if (!nullObjField) {
-                        String objTypeName = BinaryUtils.fieldTypeName(GridBinaryMarshaller.OBJ);
+                        String objTypeName = BinaryUtilsEx.fieldTypeName(GridBinaryMarshaller.OBJ);
 
                         if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
                             throw new BinaryObjectException(
@@ -343,8 +343,8 @@
 
             if (reader != null) {
                 // Write raw data if any.
-                int rawOff = BinaryUtils.rawOffsetAbsolute(reader, start);
-                int footerStart = BinaryUtils.footerStartAbsolute(reader, start);
+                int rawOff = BinaryUtilsEx.rawOffsetAbsolute(reader, start);
+                int footerStart = BinaryUtilsEx.footerStartAbsolute(reader, start);
 
                 if (rawOff < footerStart) {
                     writer.rawWriter();
@@ -353,7 +353,7 @@
                 }
 
                 // Shift reader to the end of the object.
-                reader.position(start + BinaryUtils.length(reader, start));
+                reader.position(start + BinaryUtilsEx.length(reader, start));
             }
 
             writer.postWrite(true, registeredType, hashCode);
@@ -405,7 +405,7 @@
     private IgniteBiTuple<Integer, Integer> fieldPositionAndLength(int footerPos, int footerEnd, int rawPos,
         int fieldIdLen, int fieldOffsetLen) {
         // Get field offset first.
-        int fieldOffset = BinaryUtils.fieldOffsetRelative(reader, footerPos + fieldIdLen, fieldOffsetLen);
+        int fieldOffset = BinaryUtilsEx.fieldOffsetRelative(reader, footerPos + fieldIdLen, fieldOffsetLen);
         int fieldPos = start + fieldOffset;
 
         // Get field length.
@@ -416,7 +416,7 @@
             fieldLen = rawPos - fieldPos;
         else {
             // Field is somewhere in the middle, get difference with the next offset.
-            int nextFieldOffset = BinaryUtils.fieldOffsetRelative(reader,
+            int nextFieldOffset = BinaryUtilsEx.fieldOffsetRelative(reader,
                 footerPos + fieldIdLen + fieldOffsetLen + fieldIdLen, fieldOffsetLen);
 
             fieldLen = nextFieldOffset - fieldOffset;
@@ -432,19 +432,19 @@
         assert reader != null;
 
         if (readCache == null) {
-            int fieldIdLen = BinaryUtils.fieldIdLength(flags);
-            int fieldOffsetLen = BinaryUtils.fieldOffsetLength(flags);
+            int fieldIdLen = BinaryUtilsEx.fieldIdLength(flags);
+            int fieldOffsetLen = BinaryUtilsEx.fieldOffsetLength(flags);
 
             BinarySchema schema = reader.schema();
 
             Map<Integer, Object> readCache = new HashMap<>();
 
-            IgniteBiTuple<Integer, Integer> footer = BinaryUtils.footerAbsolute(reader, start);
+            IgniteBiTuple<Integer, Integer> footer = BinaryUtilsEx.footerAbsolute(reader, start);
 
             int footerPos = footer.get1();
             int footerEnd = footer.get2();
 
-            int rawPos = BinaryUtils.rawOffsetAbsolute(reader, start);
+            int rawPos = BinaryUtilsEx.rawOffsetAbsolute(reader, start);
 
             int idx = 0;
 
@@ -485,12 +485,12 @@
             val = readCache.get(fldId);
         }
 
-        return (T)BinaryUtils.unwrapLazy(val);
+        return (T) BinaryUtilsEx.unwrapLazy(val);
     }
 
     /** {@inheritDoc} */
     @Override public BinaryObjectBuilder setField(String name, Object val0) {
-        Object val = val0 == null ? new BinaryValueWithType(BinaryUtils.typeByClass(Object.class), null) : val0;
+        Object val = val0 == null ? new BinaryValueWithType(BinaryUtilsEx.typeByClass(Object.class), null) : val0;
 
         if (assignedVals == null)
             assignedVals = new LinkedHashMap<>();
@@ -511,7 +511,7 @@
         if (assignedVals == null)
             assignedVals = new LinkedHashMap<>();
 
-        assignedVals.put(name, new BinaryValueWithType(BinaryUtils.typeByClass(type), val));
+        assignedVals.put(name, new BinaryValueWithType(BinaryUtilsEx.typeByClass(type), val));
 
         return this;
     }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
index 7401434..b071362 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
@@ -23,7 +23,7 @@
 import java.util.Set;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
 import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.apache.ignite.internal.util.typedef.F;
 
@@ -203,7 +203,7 @@
         if (keepBinary)
             return map;
 
-        Map<Object, Object> map0 = BinaryUtils.newMap(map);
+        Map<Object, Object> map0 = BinaryUtilsEx.newMap(map);
 
         for (Map.Entry<Object, Object> e : map.entrySet())
             map0.put(unwrapBinary(e.getKey(), keepBinary, cpy), unwrapBinary(e.getValue(), keepBinary, cpy));
@@ -241,7 +241,7 @@
      * @return Unwrapped set.
      */
     private Set<Object> unwrapBinaries(Set<Object> set, boolean keepBinary, boolean cpy) {
-        Set<Object> set0 = BinaryUtils.newSet(set);
+        Set<Object> set0 = BinaryUtilsEx.newSet(set);
 
         for (Object obj : set)
             set0.add(unwrapBinary(obj, keepBinary, cpy));
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 6aee7a9..167860e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -59,7 +59,7 @@
 import org.apache.ignite.internal.binary.BinaryTypeImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryContext;
-import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtilsEx;
 import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
 import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
@@ -170,11 +170,11 @@
 
                     if (metaDataCache == null) {
                         BinaryMetadata oldMeta = metaBuf.get(typeId);
-                        BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
+                        BinaryMetadata mergedMeta = BinaryUtilsEx.mergeMetadata(oldMeta, newMeta0);
 
                         if (oldMeta != mergedMeta) {
                             synchronized (this) {
-                                mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
+                                mergedMeta = BinaryUtilsEx.mergeMetadata(oldMeta, newMeta0);
 
                                 if (oldMeta != mergedMeta)
                                     metaBuf.put(typeId, mergedMeta);
@@ -315,7 +315,7 @@
                 BinaryMetadata oldMeta0 = oldMeta != null ? oldMeta.metadata() : null;
 
                 try {
-                    res = BinaryUtils.mergeMetadata(oldMeta0, newMeta);
+                    res = BinaryUtilsEx.mergeMetadata(oldMeta0, newMeta);
                 }
                 catch (BinaryObjectException e) {
                     res = oldMeta0;
@@ -379,7 +379,7 @@
         if (obj == null)
             return null;
 
-        if (BinaryUtils.isBinaryType(obj.getClass()))
+        if (BinaryUtilsEx.isBinaryType(obj.getClass()))
             return obj;
 
         if (obj instanceof Object[]) {
@@ -408,7 +408,7 @@
             Collection<Object> pCol;
 
             if (col instanceof Set)
-                pCol = (Collection<Object>)BinaryUtils.newSet((Set<?>)col);
+                pCol = (Collection<Object>) BinaryUtilsEx.newSet((Set<?>) col);
             else
                 pCol = new ArrayList<>(col.size());
 
@@ -421,7 +421,7 @@
         if (obj instanceof Map) {
             Map<?, ?> map = (Map<?, ?>)obj;
 
-            Map<Object, Object> pMap = BinaryUtils.newMap((Map<Object, Object>)obj);
+            Map<Object, Object> pMap = BinaryUtilsEx.newMap((Map<Object, Object>) obj);
 
             for (Map.Entry<?, ?> e : map.entrySet())
                 pMap.put(marshalToBinary(e.getKey()), marshalToBinary(e.getValue()));
@@ -484,7 +484,7 @@
 
         try {
             BinaryMetadata oldMeta = metaDataCache.localPeek(key);
-            BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
+            BinaryMetadata mergedMeta = BinaryUtilsEx.mergeMetadata(oldMeta, newMeta0);
 
             BinaryObjectException err = metaDataCache.invoke(key, new MetadataProcessor(mergedMeta));
 
@@ -810,7 +810,7 @@
             try {
                 BinaryMetadata oldMeta = entry.getValue();
 
-                BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta);
+                BinaryMetadata mergedMeta = BinaryUtilsEx.mergeMetadata(oldMeta, newMeta);
 
                 if (mergedMeta != oldMeta)
                     entry.setValue(mergedMeta);
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index fcd511b..1c1898c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -54,6 +54,7 @@
 import junit.framework.Assert;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryCollectionFactory;
+import org.apache.ignite.binary.BinaryField;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryMapFactory;
 import org.apache.ignite.binary.BinaryObject;
@@ -63,6 +64,7 @@
 import org.apache.ignite.binary.BinaryRawWriter;
 import org.apache.ignite.binary.BinaryReader;
 import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryType;
 import org.apache.ignite.binary.BinaryTypeConfiguration;
 import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
@@ -88,6 +90,7 @@
 import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
 
 /**
  * Binary marshaller tests.
@@ -2315,6 +2318,63 @@
     }
 
     /**
+     * Test duplicate fields.
+     *
+     * @throws Exception If failed.
+     */
+    public void testDuplicateFields() throws Exception {
+        BinaryMarshaller marsh = binaryMarshaller();
+
+        DuplicateFieldsB obj = new DuplicateFieldsB(1, 2);
+
+        BinaryObjectImpl objBin = marshal(obj, marsh);
+
+        String fieldName = "x";
+        String fieldNameA = DuplicateFieldsA.class.getName() + "." + fieldName;
+        String fieldNameB = DuplicateFieldsB.class.getName() + "." + fieldName;
+
+        // Check "hasField".
+        assert !objBin.hasField(fieldName);
+        assert objBin.hasField(fieldNameA);
+        assert objBin.hasField(fieldNameB);
+
+        // Check direct field access.
+        assertNull(objBin.field(fieldName));
+        assertEquals(1, objBin.field(fieldNameA));
+        assertEquals(2, objBin.field(fieldNameB));
+
+        // Check metadata.
+        BinaryType type = objBin.type();
+
+        Collection<String> fieldNames = type.fieldNames();
+
+        assertEquals(2, fieldNames.size());
+
+        assert !fieldNames.contains(fieldName);
+        assert fieldNames.contains(fieldNameA);
+        assert fieldNames.contains(fieldNameB);
+
+        // Check field access through type.
+        BinaryField field = type.field(fieldName);
+        BinaryField fieldA = type.field(fieldNameA);
+        BinaryField fieldB = type.field(fieldNameB);
+
+        assert !field.exists(objBin);
+        assert fieldA.exists(objBin);
+        assert fieldB.exists(objBin);
+
+        assertNull(field.value(objBin));
+        assertEquals(1, fieldA.value(objBin));
+        assertEquals(2, fieldB.value(objBin));
+
+        // Check object deserialization.
+        DuplicateFieldsB deserialized = objBin.deserialize();
+
+        assertEquals(obj.xA(), deserialized.xA());
+        assertEquals(obj.xB(), deserialized.xB());
+    }
+
+    /**
      *
      */
     private static interface SomeItf {
@@ -4120,6 +4180,57 @@
     }
 
     /**
+     * Class B for duplicate fields test.
+     */
+    private static class DuplicateFieldsA {
+        /** Field. */
+        int x;
+
+        /**
+         * Constructor.
+         *
+         * @param x Field.
+         */
+        protected DuplicateFieldsA(int x) {
+            this.x = x;
+        }
+
+        /**
+         * @return A's field.
+         */
+        public int xA() {
+            return x;
+        }
+    }
+
+    /**
+     * Class B for duplicate fields test.
+     */
+    private static class DuplicateFieldsB extends DuplicateFieldsA {
+        /** Field. */
+        int x;
+
+        /**
+         * Constructor.
+         *
+         * @param xA Field for parent class.
+         * @param xB Field for current class.
+         */
+        public DuplicateFieldsB(int xA, int xB) {
+            super(xA);
+
+            this.x = xB;
+        }
+
+        /**
+         * @return B's field.
+         */
+        public int xB() {
+            return x;
+        }
+    }
+
+    /**
      *
      */
     private static class DecimalReflective {
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryDuplicateFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryDuplicateFieldsQuerySelfTest.java
new file mode 100644
index 0000000..ab45467
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryDuplicateFieldsQuerySelfTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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.processors.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryUtils;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheTypeMetadata;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import javax.cache.Cache;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Tests for class with duplicate field names.
+ */
+public class BinaryDuplicateFieldsQuerySelfTest extends GridCommonAbstractTest {
+    /** Field 1. */
+    private static final String FIELD_1 = BinaryUtils.qualifiedFieldName(Entity1.class, "x");
+
+    /** Field 2. */
+    private static final String FIELD_2 = BinaryUtils.qualifiedFieldName(Entity2.class, "x");
+
+    /** Ignite instance. */
+    private Ignite ignite;
+
+    /** Cache. */
+    private IgniteCache<Integer, Entity2> cache;
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("deprecation")
+    @Override protected void beforeTest() throws Exception {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setLocalHost("127.0.0.1");
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+        cfg.setDiscoverySpi(discoSpi);
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        CacheConfiguration cacheCfg = new CacheConfiguration();
+
+        cacheCfg.setName(null);
+        cacheCfg.setCacheMode(CacheMode.PARTITIONED);
+        cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+
+        CacheTypeMetadata meta = new CacheTypeMetadata();
+
+        meta.setKeyType(Integer.class);
+        meta.setValueType(Entity2.class);
+
+        Map<String, Class<?>> qryFields = new HashMap<>();
+
+        qryFields.put(FIELD_1, Integer.class);
+        qryFields.put(FIELD_2, Integer.class);
+
+        meta.setQueryFields(qryFields);
+
+        cacheCfg.setTypeMetadata(Collections.singleton(meta));
+
+        cfg.setCacheConfiguration(cacheCfg);
+
+        ignite = Ignition.start(cfg);
+
+        cache = ignite.cache(null);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        G.stopAll(true);
+
+        ignite = null;
+        cache = null;
+    }
+
+    /**
+     * Test duplicate fields querying.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void testDuplicateFields() throws Exception {
+        cache.put(1, new Entity2(10, 11));
+        cache.put(2, new Entity2(20, 21));
+        cache.put(3, new Entity2(30, 31));
+
+        // Test first field.
+        Iterator iter = cache.query(new SqlQuery(Entity2.class, FIELD_1 + "=20")).iterator();
+
+        assert iter.hasNext();
+
+        Cache.Entry<Integer, Entity2> res = (Cache.Entry)iter.next();
+
+        assertEquals(2, (int)res.getKey());
+        assertEquals(20, res.getValue().get1());
+        assertEquals(21, res.getValue().get2());
+
+        assert !iter.hasNext();
+
+        // Test second field.
+        iter = cache.query(new SqlQuery(Entity2.class, FIELD_2 + "=21")).iterator();
+
+        assert iter.hasNext();
+
+        res = (Cache.Entry)iter.next();
+
+        assertEquals(2, (int)res.getKey());
+        assertEquals(20, res.getValue().get1());
+        assertEquals(21, res.getValue().get2());
+
+        assert !iter.hasNext();
+
+        iter = cache.query(
+            new SqlFieldsQuery("SELECT p." + FIELD_1 + ", p." + FIELD_2 + " " +
+                "FROM " + Entity2.class.getSimpleName() + " p " +
+                "WHERE p." + FIELD_1 + "=20 AND p." + FIELD_2 + "=21")).iterator();
+
+        assert iter.hasNext();
+
+        List<Object> fieldsRes = (List<Object>)iter.next();
+
+        assertEquals(20, fieldsRes.get(0));
+        assertEquals(21, fieldsRes.get(1));
+
+        assert !iter.hasNext();
+    }
+
+    /**
+     * First entity.
+     */
+    private static class Entity1 {
+        /** Value. */
+        private int x;
+
+        /**
+         * Default constructor.
+         */
+        protected Entity1() {
+            // No-op.
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param x Value.
+         */
+        protected Entity1(int x) {
+            this.x = x;
+        }
+
+        /**
+         * @return Value.
+         */
+        public int get1() {
+            return x;
+        }
+    }
+
+    private static class Entity2 extends Entity1 {
+        /** Value. */
+        private int x;
+
+        /**
+         * Default ctor.
+         */
+        public Entity2() {
+            // No-op.
+        }
+
+        /**
+         * Constructor.
+         *
+         * @param x1 X1.
+         * @param x2 X2.
+         */
+        public Entity2(int x1, int x2) {
+            super(x1);
+
+            x = x2;
+        }
+
+        /**
+         * @return Value.
+         */
+        public int get2() {
+            return x;
+        }
+    }
+}
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index 6abc2d4..7ed7c4d 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.cache.BinaryDuplicateFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest;
 import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest;
@@ -32,7 +34,6 @@
 import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest;
@@ -100,7 +101,6 @@
 import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest;
 import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
 import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest;
 import org.apache.ignite.testframework.config.GridTestProperties;
 
@@ -120,6 +120,7 @@
         // Serialization.
         suite.addTestSuite(BinarySerializationQuerySelfTest.class);
         suite.addTestSuite(BinarySerializationQueryWithReflectiveSerializerSelfTest.class);
+        suite.addTestSuite(BinaryDuplicateFieldsQuerySelfTest.class);
 
         // Parsing.
         suite.addTestSuite(GridQueryParsingTest.class);