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 03bc1498d18 IGNITE-29174 Cleanup of binary modules (#13709)
03bc1498d18 is described below

commit 03bc1498d18d016d736f723f9acb1e08f0807596
Author: Nikolay <[email protected]>
AuthorDate: Tue Oct 20 13:12:38 2026 +0300

    IGNITE-29174 Cleanup of binary modules (#13709)
---
 .../ignite/internal/binary/BinariesFactory.java    |  9 -----
 .../ignite/internal/binary/BinaryContext.java      | 29 ++++++++-------
 .../apache/ignite/internal/binary/BinaryUtils.java | 34 ------------------
 .../internal/binary/GridBinaryMarshaller.java      | 41 +++++++---------------
 .../internal/marshaller/ClassLoaderUtils.java      |  6 ++--
 .../apache/ignite/marshaller/MarshallerUtils.java  | 18 +++++-----
 .../internal/binary/BinariesFactoryImpl.java       |  5 ---
 .../apache/ignite/internal/binary/BinaryArray.java |  2 +-
 .../internal/binary/BinaryEnumObjectImpl.java      |  2 +-
 .../ignite/internal/binary/BinaryImplUtils.java    | 35 ++++++++++++++++++
 .../ignite/internal/binary/BinaryObjectImpl.java   | 28 ++++++---------
 .../internal/binary/BinaryObjectOffheapImpl.java   | 34 +++++++-----------
 .../ignite/internal/binary/BinaryReaderExImpl.java | 30 ++++++++--------
 .../ignite/internal/binary/BinaryWriterExImpl.java |  2 +-
 .../binary/builder/BinaryBuilderReader.java        |  5 ++-
 .../optimized/OptimizedMarshallerImpl.java         |  3 +-
 .../java/org/apache/ignite/dump/DumpReader.java    |  2 +-
 .../processors/platform/PlatformContextImpl.java   | 11 +++---
 .../platform/client/ClientMessageParser.java       | 15 ++++----
 .../dotnet/PlatformDotNetConfigurationClosure.java |  9 ++---
 .../processors/platform/utils/PlatformUtils.java   |  6 ++--
 .../apache/ignite/internal/util/IgniteUtils.java   | 27 --------------
 .../checkpoint/sharedfs/SharedFsCheckpointSpi.java |  4 +--
 .../internal/binary/BinaryMarshallerSelfTest.java  |  8 ++---
 ...rMetricsSnapshotSerializeCompatibilityTest.java | 11 ++++--
 25 files changed, 153 insertions(+), 223 deletions(-)

diff --git 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinariesFactory.java
 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinariesFactory.java
index 616dbebe532..10f004ca065 100644
--- 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinariesFactory.java
+++ 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinariesFactory.java
@@ -133,15 +133,6 @@ public interface BinariesFactory {
      */
     public BinaryObjectEx binaryEnum(BinaryContext ctx, byte[] arr);
 
-    /**
-     * @param ctx Context.
-     * @param ptr Memory address.
-     * @param start Object start.
-     * @param size Memory size.
-     * @return Binary object based on offheap memory.
-     */
-    public BinaryObjectEx binaryOffheapObject(BinaryContext ctx, long ptr, int 
start, int size);
-
     /**
      * @param ctx Context
      * @param compCls Component class.
diff --git 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 5b8c565fb39..d5e08498535 100644
--- 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -81,9 +81,6 @@ import static 
org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID;
  * Binary context.
  */
 public class BinaryContext {
-    /** System loader. */
-    private static final ClassLoader sysLdr = CommonUtils.gridClassLoader();
-
     /** */
     private static final BinaryInternalMapper DFLT_MAPPER =
         new BinaryInternalMapper(new BinaryBasicNameMapper(false), new 
BinaryBasicIdMapper(true), false);
@@ -129,10 +126,10 @@ public class BinaryContext {
     private final @Nullable ClassLoader clsLdr;
 
     /** Actual marshaller. */
-    private BinaryMarshaller marsh;
+    private final BinaryMarshaller marsh;
 
     /** */
-    private MarshallerContext marshCtx;
+    private final MarshallerContext marshCtx;
 
     /** */
     private final @Nullable BinarySerializer dfltSerializer;
@@ -276,8 +273,7 @@ public class BinaryContext {
 
         if (marsh != null) {
             this.marsh = marsh;
-
-            marshCtx = marsh.getContext();
+            this.marshCtx = marsh.getContext();
 
             assert marshCtx != null;
 
@@ -285,6 +281,10 @@ public class BinaryContext {
 
             configure(nameMapper, idMapper, dfltSerializer, typeCfgs, affFlds);
         }
+        else {
+            this.marsh = null;
+            this.marshCtx = null;
+        }
     }
 
     /**
@@ -703,7 +703,7 @@ public class BinaryContext {
     /**
      * @param userType User type or not.
      * @param typeId Type ID.
-     * @param ldr Class loader.
+     * @param ldr Class loader or {@code null} to use {@link 
CommonUtils#gridClassLoader()}.
      * @param registerMeta If {@code true}, then metadata will be registered 
along with the type descriptor.
      * @return Class descriptor.
      */
@@ -721,9 +721,6 @@ public class BinaryContext {
         if (desc != null)
             return desc;
 
-        if (ldr == null)
-            ldr = sysLdr;
-
         Class cls;
 
         try {
@@ -749,14 +746,20 @@ public class BinaryContext {
         }
         catch (ClassNotFoundException e) {
             // Class might have been loaded by default class loader.
-            if (userType && !ldr.equals(sysLdr) && (desc = 
descriptorForTypeId(true, typeId, sysLdr, registerMeta)) != null)
+            if (userType
+                && ldr != null
+                && !ldr.equals(CommonUtils.gridClassLoader())
+                && (desc = descriptorForTypeId(true, typeId, null, 
registerMeta)) != null)
                 return desc;
 
             throw new BinaryInvalidTypeException(e);
         }
         catch (IgniteCheckedException e) {
             // Class might have been loaded by default class loader.
-            if (userType && !ldr.equals(sysLdr) && (desc = 
descriptorForTypeId(true, typeId, sysLdr, registerMeta)) != null)
+            if (userType
+                && ldr != null
+                && !ldr.equals(CommonUtils.gridClassLoader())
+                && (desc = descriptorForTypeId(true, typeId, null, 
registerMeta)) != null)
                 return desc;
 
             throw new BinaryObjectException("Failed resolve class for ID: " + 
typeId, e);
diff --git 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 79bfe6f1f05..efd5d0d1ccc 100644
--- 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -60,7 +60,6 @@ import org.apache.ignite.IgniteCommonsSystemProperties;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryInvalidTypeException;
 import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectException;
@@ -72,7 +71,6 @@ import org.apache.ignite.cache.affinity.AffinityKeyMapped;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
 import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
-import org.apache.ignite.internal.marshaller.ClassLoaderUtils;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.CommonUtils;
 import org.apache.ignite.internal.util.MutableSingletonList;
@@ -803,38 +801,6 @@ public class BinaryUtils {
         return arr;
     }
 
-    /**
-     * Resolve the class.
-     *
-     * @param ctx Binary context.
-     * @param typeId Type ID.
-     * @param clsName Class name.
-     * @param ldr Class loaded.
-     * @return Resovled class.
-     */
-    static Class resolveClass(BinaryContext ctx, int typeId, @Nullable String 
clsName,
-        @Nullable ClassLoader ldr, boolean registerMeta) {
-        Class cls;
-
-        if (ldr == null)
-            ldr = ctx.classLoader();
-
-        if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID)
-            cls = ctx.descriptorForTypeId(true, typeId, ldr, 
registerMeta).describedClass();
-        else {
-            try {
-                cls = ClassLoaderUtils.forName(clsName, ldr);
-            }
-            catch (ClassNotFoundException e) {
-                throw new BinaryInvalidTypeException("Failed to load the 
class: " + clsName, e);
-            }
-
-            ctx.registerType(cls, false, false);
-        }
-
-        return cls;
-    }
-
     /**
      * Convert {@link java.sql.Types} to binary type constant (See {@link 
GridBinaryMarshaller} constants).
      *
diff --git 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index 1489a11c1d5..09fa3e096d1 100644
--- 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -352,7 +352,7 @@ public class GridBinaryMarshaller {
      */
     @Nullable public <T> T unwrapBinary(BinaryInputStream in, Class<?> clazz) 
throws BinaryObjectException {
         BinaryReaderHandles hnds = new BinaryReaderHandles();
-        Object obj = deserialize(in, null, hnds);
+        Object obj = deserialize(in, hnds);
 
         return (T)unwrapBinary(obj, hnds, clazz);
     }
@@ -365,7 +365,7 @@ public class GridBinaryMarshaller {
             BinaryObjectEx obj0 = (BinaryObjectEx)obj;
             BinaryInputStream in = BinaryStreams.inputStream(obj0.bytes(), 
obj0.start());
 
-            return deserialize(in, null, hnds);
+            return deserialize(in, hnds);
         }
         else if (obj instanceof BinaryObject)
             return ((BinaryObject)obj).deserialize();
@@ -435,22 +435,27 @@ public class GridBinaryMarshaller {
         if (arr[0] == NULL)
             return null;
 
-        return deserialize(BinaryStreams.inputStream(arr), ldr, null);
+        BinaryContext oldCtx = pushContext(ctx);
+
+        try {
+            return (T)BinaryUtils.reader(ctx, BinaryStreams.inputStream(arr), 
ldr, null, true).deserialize();
+        }
+        finally {
+            popContext(oldCtx);
+        }
     }
 
     /**
      * @param in Input stream.
-     * @param ldr Class loader.
      * @param hnds Handles.
      * @return Deserialized object.
      * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
      */
-    @Nullable <T> T deserialize(BinaryInputStream in, @Nullable ClassLoader 
ldr,
-        @Nullable BinaryReaderHandles hnds) throws BinaryObjectException {
+    @Nullable <T> T deserialize(BinaryInputStream in, @Nullable 
BinaryReaderHandles hnds) throws BinaryObjectException {
         BinaryContext oldCtx = pushContext(ctx);
 
         try {
-            return (T)BinaryUtils.reader(ctx, in, ldr, hnds, 
true).deserialize();
+            return (T)BinaryUtils.reader(ctx, in, null, hnds, 
true).deserialize();
         }
         finally {
             popContext(oldCtx);
@@ -485,18 +490,6 @@ public class GridBinaryMarshaller {
         BINARY_CTX.get().set(oldCtx);
     }
 
-    /**
-     * Creates a reader.
-     *
-     * @param stream Stream.
-     * @return Reader.
-     */
-    public BinaryReaderEx reader(BinaryInputStream stream) {
-        assert stream != null;
-
-        return BinaryUtils.reader(ctx, stream, null, true);
-    }
-
     /**
      * Whether object must be deserialized anyway. I.e. it cannot be converted 
to BinaryObject.
      *
@@ -507,16 +500,6 @@ public class GridBinaryMarshaller {
         return obj != null && ctx.mustDeserialize(obj.getClass());
     }
 
-    /**
-     * Gets writer for the given output stream.
-     *
-     * @param out Output stream.
-     * @return Writer.
-     */
-    public BinaryWriterEx writer(BinaryOutputStream out) {
-        return BinaryUtils.writer(ctx, out);
-    }
-
     /**
      * @return Context.
      */
diff --git 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/marshaller/ClassLoaderUtils.java
 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/marshaller/ClassLoaderUtils.java
index 9c6be55dd34..10c8f697e28 100644
--- 
a/modules/binary/api/src/main/java/org/apache/ignite/internal/marshaller/ClassLoaderUtils.java
+++ 
b/modules/binary/api/src/main/java/org/apache/ignite/internal/marshaller/ClassLoaderUtils.java
@@ -100,7 +100,7 @@ public class ClassLoaderUtils {
      * Gets class for provided name. Accepts primitive types names.
      *
      * @param clsName Class name.
-     * @param ldr Class loader.
+     * @param ldr Class loader or {@code null} to use {@link 
CommonUtils#gridClassLoader()}.
      * @param useCache If true class loader and result should be cached 
internally, false otherwise.
      * @return Class.
      * @throws ClassNotFoundException If class not found.
@@ -159,7 +159,7 @@ public class ClassLoaderUtils {
      * Gets class for provided name. Accepts primitive types names.
      *
      * @param clsName Class name.
-     * @param ldr Class loader.
+     * @param ldr Class loader or {@code null} to use {@link 
CommonUtils#gridClassLoader()}.
      * @return Class.
      * @throws ClassNotFoundException If class not found.
      */
@@ -168,7 +168,7 @@ public class ClassLoaderUtils {
     }
 
     /**
-     * Gets class for provided name. Accepts primitive types names.
+     * Gets class for provided name using {@link 
CommonUtils#gridClassLoader()}. Accepts primitive types names.
      *
      * @param clsName Class name.
      * @return Class.
diff --git 
a/modules/binary/api/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
 
b/modules/binary/api/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index 428e0a673a7..7ddaa3eb7fe 100644
--- 
a/modules/binary/api/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ 
b/modules/binary/api/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -81,10 +81,10 @@ public class MarshallerUtils {
         if (fileName != null && !fileName.isBlank()) {
             clsSet = new ClassSet();
 
-            addClassNames(JDK_CLS_NAMES_FILE, clsSet, 
CommonUtils.gridClassLoader());
-            addClassNames(CLS_NAMES_FILE, clsSet, 
CommonUtils.gridClassLoader());
-            addClassNames(DEFAULT_WHITELIST_CLS_NAMES_FILE, clsSet, 
CommonUtils.gridClassLoader());
-            addClassNames(fileName, clsSet, CommonUtils.gridClassLoader());
+            addClassNames(JDK_CLS_NAMES_FILE, clsSet);
+            addClassNames(CLS_NAMES_FILE, clsSet);
+            addClassNames(DEFAULT_WHITELIST_CLS_NAMES_FILE, clsSet);
+            addClassNames(fileName, clsSet);
         }
 
         return clsSet;
@@ -96,12 +96,12 @@ public class MarshallerUtils {
     private static ClassSet classBlackList() {
         ClassSet clsSet = new ClassSet();
 
-        addClassNames(DEFAULT_BLACKLIST_CLS_NAMES_FILE, clsSet, 
CommonUtils.gridClassLoader());
+        addClassNames(DEFAULT_BLACKLIST_CLS_NAMES_FILE, clsSet);
 
         String blackListFileName = 
IgniteCommonsSystemProperties.getString(IGNITE_MARSHALLER_BLACKLIST);
 
         if (blackListFileName != null && !blackListFileName.isBlank())
-            addClassNames(blackListFileName, clsSet, 
CommonUtils.gridClassLoader());
+            addClassNames(blackListFileName, clsSet);
 
         return clsSet;
     }
@@ -111,14 +111,12 @@ public class MarshallerUtils {
      *
      * @param fileName File name containing list of classes.
      * @param clsSet Class set for update.
-     * @param clsLdr Class loader.
      */
     private static void addClassNames(
         String fileName,
-        ClassSet clsSet,
-        ClassLoader clsLdr
+        ClassSet clsSet
     ) {
-        InputStream is = clsLdr.getResourceAsStream(fileName);
+        InputStream is = 
CommonUtils.gridClassLoader().getResourceAsStream(fileName);
 
         if (is == null) {
             try {
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinariesFactoryImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinariesFactoryImpl.java
index ef45ddb2d7f..91435e89c37 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinariesFactoryImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinariesFactoryImpl.java
@@ -168,11 +168,6 @@ public class BinariesFactoryImpl implements 
BinariesFactory {
         return new BinaryEnumObjectImpl(ctx, arr);
     }
 
-    /** {@inheritDoc} */
-    @Override public BinaryObjectEx binaryOffheapObject(BinaryContext ctx, 
long ptr, int start, int size) {
-        return new BinaryObjectOffheapImpl(ctx, ptr, start, size);
-    }
-
     /** {@inheritDoc} */
     @Override public BinaryObjectEx binaryArray(BinaryContext ctx, Class<?> 
compCls, Object[] arr) {
         boolean isBinaryArr = BinaryObject.class.isAssignableFrom(compCls);
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryArray.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryArray.java
index 38fc69fe1a4..6fd7ef9bff3 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryArray.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryArray.java
@@ -108,7 +108,7 @@ class BinaryArray implements BinaryObjectEx, 
Externalizable, Comparable<BinaryAr
             Marshallers.USE_CACHE.set(Boolean.FALSE);
 
         try {
-            Class<?> compType = BinaryUtils.resolveClass(ctx, compTypeId, 
compClsName, ldr, false);
+            Class<?> compType = BinaryImplUtils.resolveClass(ctx, compTypeId, 
compClsName, ldr, false);
 
             // Skip deserialization if already deserialized.
             // Prepared result is in arr, already.
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index 1daea71a44a..4242ac535fe 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -173,7 +173,7 @@ class BinaryEnumObjectImpl implements BinaryObjectEx, 
Externalizable, CacheObjec
             Marshallers.USE_CACHE.set(Boolean.FALSE);
 
         try {
-            Class cls = BinaryUtils.resolveClass(ctx, typeId, clsName, ldr, 
false);
+            Class cls = BinaryImplUtils.resolveClass(ctx, typeId, clsName, 
ldr, false);
 
             return (T)(ldr == null ? BinaryEnumCache.get(cls, ord) : 
uncachedValue(cls));
         }
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryImplUtils.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryImplUtils.java
index 5771f05ba23..0ca035ef9b7 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryImplUtils.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryImplUtils.java
@@ -19,8 +19,10 @@ package org.apache.ignite.internal.binary;
 import java.io.ByteArrayInputStream;
 
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.marshaller.ClassLoaderUtils;
 import org.apache.ignite.internal.util.CommonUtils;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.lang.IgniteBiTuple;
@@ -377,4 +379,37 @@ public class BinaryImplUtils {
             in.position(in.position() + len);
         }
     }
+
+    /**
+     * Resolve the class.
+     *
+     * @param ctx Binary context.
+     * @param typeId Type ID.
+     * @param clsName Class name.
+     * @param ldr Custom class loader or {@code null} to use {@link 
BinaryContext#classLoader()}.
+     * @param registerMeta If {@code true}, then metadata will be registered 
along with the type descriptor.
+     * @return Resolved class.
+     */
+    static Class resolveClass(BinaryContext ctx, int typeId, @Nullable String 
clsName,
+                              @Nullable ClassLoader ldr, boolean registerMeta) 
{
+        Class cls;
+
+        if (ldr == null)
+            ldr = ctx.classLoader();
+
+        if (typeId != GridBinaryMarshaller.UNREGISTERED_TYPE_ID)
+            cls = ctx.descriptorForTypeId(true, typeId, ldr, 
registerMeta).describedClass();
+        else {
+            try {
+                cls = ClassLoaderUtils.forName(clsName, ldr);
+            }
+            catch (ClassNotFoundException e) {
+                throw new BinaryInvalidTypeException("Failed to load the 
class: " + clsName, e);
+            }
+
+            ctx.registerType(cls, false, false);
+        }
+
+        return cls;
+    }
 }
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
index f3c8501c110..a0bac1118da 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectImpl.java
@@ -391,12 +391,12 @@ public final class BinaryObjectImpl extends 
BinaryObjectExImpl implements Extern
 
     /** {@inheritDoc} */
     @Nullable @Override public <F> F field(String fieldName) throws 
BinaryObjectException {
-        return (F)reader(null, false).unmarshalField(fieldName);
+        return (F)reader().unmarshalField(fieldName);
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public <F> F field(int fieldId) throws 
BinaryObjectException {
-        return (F)reader(null, false).unmarshalField(fieldId);
+        return (F)reader().unmarshalField(fieldId);
     }
 
     /** {@inheritDoc} */
@@ -690,13 +690,13 @@ public final class BinaryObjectImpl extends 
BinaryObjectExImpl implements Extern
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override protected <F> F field(BinaryReaderHandles rCtx, String 
fieldName) {
-        return (F)reader(rCtx, false).unmarshalField(fieldName);
+    @Nullable @Override protected <F> F field(BinaryReaderHandles hnds, String 
fieldName) {
+        return (F)reader(hnds, ctx.classLoader(), 
false).unmarshalField(fieldName);
     }
 
     /** {@inheritDoc} */
     @Override public boolean hasField(String fieldName) {
-        return reader(null, false).findFieldByName(fieldName);
+        return reader().findFieldByName(fieldName);
     }
 
     /** {@inheritDoc} */
@@ -748,7 +748,7 @@ public final class BinaryObjectImpl extends 
BinaryObjectExImpl implements Extern
 
     /** {@inheritDoc} */
     @Override BinarySchema createSchema() {
-        return reader(null, false).getOrCreateSchema();
+        return reader().getOrCreateSchema();
     }
 
     /** {@inheritDoc} */
@@ -806,20 +806,16 @@ public final class BinaryObjectImpl extends 
BinaryObjectExImpl implements Extern
     /**
      * Create new reader for this object.
      *
-     * @param rCtx Reader context.
+     * @param hnds Reader context.
      * @param ldr Class loader.
      * @param forUnmarshal {@code True} if reader is need to unmarshal object.
      * @return Reader.
      */
-    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx, 
@Nullable ClassLoader ldr,
-        boolean forUnmarshal) {
-        if (ldr == null)
-            ldr = ctx.classLoader();
-
+    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles hnds, 
ClassLoader ldr, boolean forUnmarshal) {
         return new BinaryReaderExImpl(ctx,
             BinaryStreams.inputStream(arr, start),
             ldr,
-            rCtx,
+            hnds,
             false,
             forUnmarshal);
     }
@@ -827,12 +823,10 @@ public final class BinaryObjectImpl extends 
BinaryObjectExImpl implements Extern
     /**
      * Create new reader for this object.
      *
-     * @param rCtx Reader context.
-     * @param forUnmarshal {@code True} if reader is need to unmarshal object.
      * @return Reader.
      */
-    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx, 
boolean forUnmarshal) {
-        return reader(rCtx, null, forUnmarshal);
+    private BinaryReaderExImpl reader() {
+        return reader(null, ctx.classLoader(), false);
     }
 
     /**
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
index 3c3f2289b17..3f21909780a 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
@@ -128,7 +128,7 @@ class BinaryObjectOffheapImpl extends BinaryObjectExImpl 
implements Externalizab
 
     /** {@inheritDoc} */
     @Override BinarySchema createSchema() {
-        return reader(null, false).getOrCreateSchema();
+        return reader().getOrCreateSchema();
     }
 
     /** {@inheritDoc} */
@@ -196,12 +196,12 @@ class BinaryObjectOffheapImpl extends BinaryObjectExImpl 
implements Externalizab
 
     /** {@inheritDoc} */
     @Nullable @Override public <F> F field(String fieldName) throws 
BinaryObjectException {
-        return (F)reader(null, false).unmarshalField(fieldName);
+        return (F)reader().unmarshalField(fieldName);
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public <F> F field(int fieldId) throws 
BinaryObjectException {
-        return (F)reader(null, false).unmarshalField(fieldId);
+        return (F)reader().unmarshalField(fieldId);
     }
 
     /** {@inheritDoc} */
@@ -389,13 +389,13 @@ class BinaryObjectOffheapImpl extends BinaryObjectExImpl 
implements Externalizab
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override protected <F> F field(BinaryReaderHandles rCtx, String 
fieldName) {
-        return (F)reader(rCtx, false).unmarshalField(fieldName);
+    @Nullable @Override protected <F> F field(BinaryReaderHandles hnds, String 
fieldName) {
+        return (F)reader(hnds, ctx.classLoader(), 
false).unmarshalField(fieldName);
     }
 
     /** {@inheritDoc} */
     @Override public boolean hasField(String fieldName) {
-        return reader(null, false).findFieldByName(fieldName);
+        return reader().findFieldByName(fieldName);
     }
 
     /** {@inheritDoc} */
@@ -415,7 +415,7 @@ class BinaryObjectOffheapImpl extends BinaryObjectExImpl 
implements Externalizab
 
     /** {@inheritDoc} */
     @Nullable @Override public <T> T deserialize() throws 
BinaryObjectException {
-        return (T)deserializeValue();
+        return (T)reader(null, ctx.classLoader(), true).deserialize();
     }
 
     /** {@inheritDoc} */
@@ -483,34 +483,24 @@ class BinaryObjectOffheapImpl extends BinaryObjectExImpl 
implements Externalizab
         return length();
     }
 
-    /**
-     * @return Deserialized value.
-     */
-    private Object deserializeValue() {
-        return reader(null, true).deserialize();
-    }
-
     /**
      * Create new reader for this object.
      *
-     * @param rCtx Reader context.
-     * @param forUnmarshal {@code True} if reader is needed to unmarshal 
object.
      * @return Reader.
      */
-    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx, 
boolean forUnmarshal) {
-        return reader(rCtx, ctx.classLoader(), forUnmarshal);
+    private BinaryReaderExImpl reader() {
+        return reader(null, ctx.classLoader(), false);
     }
 
     /**
      * Create new reader for this object.
      *
-     * @param rCtx Reader context.
+     * @param hnds Reader context.
      * @param ldr Class loader.
      * @param forUnmarshal {@code True} if reader is needed to unmarshal 
object.
      * @return Reader.
      */
-    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles rCtx, 
@Nullable ClassLoader ldr,
-        boolean forUnmarshal) {
+    private BinaryReaderExImpl reader(@Nullable BinaryReaderHandles hnds, 
@Nullable ClassLoader ldr, boolean forUnmarshal) {
         BinaryInputStream stream = BinaryStreams.inputStream(ptr, size);
 
         stream.position(start);
@@ -518,7 +508,7 @@ class BinaryObjectOffheapImpl extends BinaryObjectExImpl 
implements Externalizab
         return new BinaryReaderExImpl(ctx,
             stream,
             ldr,
-            rCtx,
+            hnds,
             false,
             forUnmarshal);
     }
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 0b5f85ed034..9fd4ba5c572 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -103,7 +103,7 @@ import static 
org.apache.ignite.internal.binary.GridBinaryMarshaller.UUID_ARR;
  * Binary reader implementation.
  */
 @SuppressWarnings("unchecked")
-public class BinaryReaderExImpl extends BinaryReaderHandlesHolder implements 
BinaryReaderEx {
+public final class BinaryReaderExImpl extends BinaryReaderHandlesHolder 
implements BinaryReaderEx {
     /** Binary context. */
     private final BinaryContext ctx;
 
@@ -131,9 +131,6 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
     /** Footer end. */
     private final int footerLen;
 
-    /** Class descriptor. */
-    private BinaryClassDescriptor desc;
-
     /** Mapper. */
     private final BinaryInternalMapper mapper;
 
@@ -161,6 +158,9 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
     /** Whether stream is in raw mode. */
     private boolean raw;
 
+    /** Class descriptor. */
+    private BinaryClassDescriptor desc;
+
     /**
      * Constructor.
      *
@@ -1527,7 +1527,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
         throws BinaryObjectException {
         switch (checkFlag(COL)) {
             case NORMAL:
-                return (Collection)doReadCollection(in, ctx, ldr, this, false, 
true, factory);
+                return doReadCollection(in, ctx, ldr, this, false, true, 
factory);
 
             case HANDLE: {
                 int handlePos = positionForHandle(in) - in.readInt();
@@ -1605,7 +1605,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
     private Map readMap0(@Nullable BinaryMapFactory factory) throws 
BinaryObjectException {
         switch (checkFlag(MAP)) {
             case NORMAL:
-                return (Map)doReadMap(in, ctx, ldr, this, false, true, 
factory);
+                return doReadMap(in, ctx, ldr, this, false, true, factory);
 
             case HANDLE: {
                 int handlePos = positionForHandle(in) - in.readInt();
@@ -1967,7 +1967,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
         if (!findFieldById(fieldId))
             return null;
 
-        return BinaryUtils.reader(ctx, in, ldr, hnds, false, 
true).deserialize();
+        return new BinaryReaderExImpl(ctx, in, ldr, hnds, false, 
true).deserialize();
     }
 
     /**
@@ -3206,13 +3206,13 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
 
             int start = in.readInt();
 
-            return BinaryUtils.binariesFactory.binaryOffheapObject(ctx, 
in.offheapPointer() + pos, start, len);
+            return new BinaryObjectOffheapImpl(ctx, in.offheapPointer() + pos, 
start, len);
         }
         else {
             byte[] arr = BinaryUtils.doReadByteArray(in);
             int start = in.readInt();
 
-            BinaryObject binO = BinaryUtils.binariesFactory.binaryObject(ctx, 
arr, start);
+            BinaryObject binO = new BinaryObjectImpl(ctx, arr, start);
 
             if (detach)
                 return BinaryUtils.detach(binO);
@@ -3332,7 +3332,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
      */
     private static BinaryObjectEx doReadBinaryEnum(BinaryInputStream in, 
BinaryContext ctx,
         EnumType type) {
-        return BinaryUtils.binariesFactory.binaryEnum(ctx, type.typeId, 
type.clsName, in.readInt());
+        return new BinaryEnumObjectImpl(ctx, type.typeId, type.clsName, 
in.readInt());
     }
 
     /**
@@ -3345,7 +3345,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
     private static Object[] doReadBinaryEnumArray(BinaryInputStream in, 
BinaryContext ctx) {
         int len = in.readInt();
 
-        Object[] arr = 
(Object[])Array.newInstance(BinaryUtils.binariesFactory.binaryEnumClass(), len);
+        Object[] arr = (Object[])Array.newInstance(BinaryEnumObjectImpl.class, 
len);
 
         for (int i = 0; i < len; i++) {
             byte flag = in.readByte();
@@ -3365,7 +3365,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
      */
     @Nullable private static Object doReadObject(BinaryInputStream in, 
BinaryContext ctx, ClassLoader ldr,
         BinaryReaderHandlesHolder handles) throws BinaryObjectException {
-        return BinaryUtils.reader(ctx, in, ldr, handles.handles(), false, 
true).deserialize();
+        return new BinaryReaderExImpl(ctx, in, ldr, handles.handles(), false, 
true).deserialize();
     }
 
     /**
@@ -3426,7 +3426,7 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
                 BinaryObjectEx po;
 
                 if (detach) {
-                    BinaryObjectEx binObj = 
BinaryUtils.binariesFactory.binaryObject(ctx, in.array(), start);
+                    BinaryObjectEx binObj = new BinaryObjectImpl(ctx, 
in.array(), start);
 
                     binObj.detachAllowed(true);
 
@@ -3434,9 +3434,9 @@ public class BinaryReaderExImpl extends 
BinaryReaderHandlesHolder implements Bin
                 }
                 else {
                     if (in.offheapPointer() == 0)
-                        po = BinaryUtils.binariesFactory.binaryObject(ctx, 
in.array(), start);
+                        po = new BinaryObjectImpl(ctx, in.array(), start);
                     else
-                        po = 
BinaryUtils.binariesFactory.binaryOffheapObject(ctx, in.offheapPointer(), start,
+                        po = new BinaryObjectOffheapImpl(ctx, 
in.offheapPointer(), start,
                             in.remaining() + in.position());
                 }
 
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 1356fe89f2c..c11f2fc7ef9 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -107,7 +107,7 @@ public class BinaryWriterExImpl implements BinaryWriterEx {
      * @param failIfUnregistered Flag to fail while writing object of 
unregistered type.
      * @param typeId Type id.
      */
-    public BinaryWriterExImpl(
+    BinaryWriterExImpl(
         BinaryContext ctx,
         BinaryOutputStream out,
         @Nullable BinaryWriterSchemaHolder schema,
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
index f88972bffa3..2c650e8e75f 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderReader.java
@@ -34,7 +34,6 @@ import org.apache.ignite.internal.binary.BinaryWriterExImpl;
 import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
 import org.apache.ignite.internal.binary.streams.BinaryStreams;
-import org.apache.ignite.internal.util.CommonUtils;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static 
org.apache.ignite.internal.binary.builder.BinaryObjectBuildersFactoryImpl.unwrapLazy;
@@ -492,7 +491,7 @@ class BinaryBuilderReader implements BinaryPositionReadable 
{
             case GridBinaryMarshaller.OPTM_MARSH: {
                 final BinaryInputStream bin = BinaryStreams.inputStream(arr, 
pos + 1);
 
-                final Object obj = BinaryImplUtils.doReadOptimized(bin, ctx, 
CommonUtils.resolveClassLoader(null, ctx.classLoader()));
+                final Object obj = BinaryImplUtils.doReadOptimized(bin, ctx, 
ctx.classLoader());
 
                 return obj;
             }
@@ -844,7 +843,7 @@ class BinaryBuilderReader implements BinaryPositionReadable 
{
             case GridBinaryMarshaller.OPTM_MARSH: {
                 final BinaryInputStream bin = BinaryStreams.inputStream(arr, 
pos);
 
-                final Object obj = BinaryImplUtils.doReadOptimized(bin, ctx, 
CommonUtils.resolveClassLoader(null, ctx.classLoader()));
+                final Object obj = BinaryImplUtils.doReadOptimized(bin, ctx, 
ctx.classLoader());
 
                 pos = bin.position();
 
diff --git 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerImpl.java
 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerImpl.java
index 6a5c4e0d1cc..6da379afaf5 100644
--- 
a/modules/binary/impl/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerImpl.java
+++ 
b/modules/binary/impl/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerImpl.java
@@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentMap;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.marshaller.ClassLoaderUtils;
+import org.apache.ignite.internal.util.CommonUtils;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller;
 import org.apache.ignite.marshaller.Marshallers;
@@ -83,7 +84,7 @@ import sun.misc.Unsafe;
  */
 public class OptimizedMarshallerImpl extends AbstractNodeNameAwareMarshaller 
implements OptimizedMarshaller {
     /** Default class loader. */
-    private final ClassLoader dfltClsLdr = getClass().getClassLoader();
+    private final ClassLoader dfltClsLdr = CommonUtils.gridClassLoader();
 
     /** Whether or not to require an object to be serializable in order to be 
marshalled. */
     private final boolean requireSer;
diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java 
b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
index 039b7941fd3..6a438192848 100644
--- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
@@ -321,7 +321,7 @@ public class DumpReader implements Runnable {
     public static List<SnapshotMetadata> metadata(File dumpDir) {
         JdkMarshaller marsh = Marshallers.jdk();
 
-        ClassLoader clsLdr = U.resolveClassLoader(new IgniteConfiguration());
+        ClassLoader clsLdr = U.gridClassLoader();
 
         // First filter only specific file to exclude overlapping with other 
nodes making dump on the local host.
         File[] files = dumpDir.listFiles(SnapshotFileTree::snapshotMetaFile);
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 2be1c9303b7..7e5b3d664a1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -47,7 +47,6 @@ import org.apache.ignite.internal.binary.BinaryReaderEx;
 import org.apache.ignite.internal.binary.BinaryTypeImpl;
 import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.binary.BinaryWriterEx;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import 
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import 
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
@@ -94,8 +93,8 @@ public class PlatformContextImpl implements PlatformContext, 
PartitionsExchangeA
     /** Kernal context. */
     private final GridKernalContext ctx;
 
-    /** Marshaller. */
-    private final GridBinaryMarshaller marsh;
+    /** Binary context. */
+    private final BinaryContext bctx;
 
     /** Memory manager. */
     private final PlatformMemoryManagerImpl mem;
@@ -153,7 +152,7 @@ public class PlatformContextImpl implements 
PlatformContext, PartitionsExchangeA
 
         cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
 
-        marsh = cacheObjProc.marshaller();
+        bctx = cacheObjProc.binaryContext();
 
         ctx.cache().context().exchange().registerExchangeAwareComponent(this);
     }
@@ -180,7 +179,7 @@ public class PlatformContextImpl implements 
PlatformContext, PartitionsExchangeA
 
     /** {@inheritDoc} */
     @Override public BinaryReaderEx reader(PlatformInputStream in) {
-        return BinaryUtils.reader(marsh.context(),
+        return BinaryUtils.reader(bctx,
             in,
             ctx.config().getClassLoader(),
             true,
@@ -194,7 +193,7 @@ public class PlatformContextImpl implements 
PlatformContext, PartitionsExchangeA
 
     /** {@inheritDoc} */
     @Override public BinaryWriterEx writer(PlatformOutputStream out) {
-        return marsh.writer(out);
+        return BinaryUtils.writer(bctx, out);
     }
 
     /** {@inheritDoc} */
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
index d0f54ef2136..11b4e71e26f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
@@ -17,14 +17,13 @@
 
 package org.apache.ignite.internal.processors.platform.client;
 
+import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryReaderEx;
 import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.binary.BinaryWriterEx;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
 import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
 import org.apache.ignite.internal.binary.streams.BinaryStreams;
-import 
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
 import org.apache.ignite.internal.processors.odbc.ClientListenerMessageParser;
 import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
 import org.apache.ignite.internal.processors.odbc.ClientListenerResponse;
@@ -414,8 +413,8 @@ public class ClientMessageParser implements 
ClientListenerMessageParser {
     /** Stop warmup. */
     private static final short OP_STOP_WARMUP = 10000;
 
-    /** Marshaller. */
-    private final GridBinaryMarshaller marsh;
+    /** Binary context. */
+    private final BinaryContext bctx;
 
     /** Client connection context */
     private final ClientConnectionContext ctx;
@@ -432,9 +431,7 @@ public class ClientMessageParser implements 
ClientListenerMessageParser {
 
         this.ctx = ctx;
         this.protocolCtx = protocolCtx;
-
-        CacheObjectBinaryProcessorImpl cacheObjProc = 
(CacheObjectBinaryProcessorImpl)ctx.kernalContext().cacheObjects();
-        marsh = cacheObjProc.marshaller();
+        this.bctx = ctx.kernalContext().cacheObjects().binaryContext();
     }
 
     /** {@inheritDoc} */
@@ -444,7 +441,7 @@ public class ClientMessageParser implements 
ClientListenerMessageParser {
         BinaryInputStream inStream = BinaryStreams.inputStream(msg.payload());
 
         // skipHdrCheck must be true (we have 103 op code).
-        BinaryReaderEx reader = BinaryUtils.reader(marsh.context(), inStream, 
null, true, true);
+        BinaryReaderEx reader = BinaryUtils.reader(bctx, inStream, null, true, 
true);
 
         ClientListenerRequest req = decode(reader);
 
@@ -749,7 +746,7 @@ public class ClientMessageParser implements 
ClientListenerMessageParser {
 
         BinaryOutputStream outStream = 
BinaryStreams.createPooledOutputStream(32, false);
 
-        BinaryWriterEx writer = marsh.writer(outStream);
+        BinaryWriterEx writer = BinaryUtils.writer(bctx, outStream);
 
         assert resp instanceof ClientOutgoingMessage : "Unexpected response 
type: " + resp.getClass();
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 6f3c8f599d2..14874028434 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -23,9 +23,10 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.PlatformConfiguration;
+import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryReaderEx;
+import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.binary.BinaryWriterEx;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.logger.platform.PlatformLogger;
 import 
org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
 import 
org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
@@ -119,8 +120,8 @@ public class PlatformDotNetConfigurationClosure extends 
PlatformAbstractConfigur
             try (PlatformMemory inMem = memMgr.allocate()) {
                 PlatformOutputStream out = outMem.output();
 
-                GridBinaryMarshaller marshaller = PlatformUtils.marshaller();
-                BinaryWriterEx writer = marshaller.writer(out);
+                BinaryContext bctx = PlatformUtils.binaryContext();
+                BinaryWriterEx writer = BinaryUtils.writer(bctx, out);
 
                 PlatformConfigurationUtils.writeDotNetConfiguration(writer, 
interopCfg.unwrap());
 
@@ -149,7 +150,7 @@ public class PlatformDotNetConfigurationClosure extends 
PlatformAbstractConfigur
                 gate.extensionCallbackInLongLongOutLong(
                     PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), 
inMem.pointer());
 
-                processPrepareResult(marshaller.reader(inMem.input()));
+                processPrepareResult(BinaryUtils.reader(bctx, inMem.input(), 
null, true));
             }
         }
     }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 68d3501764b..0d6e9af90f5 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -43,13 +43,13 @@ import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.binary.BinaryContext;
 import org.apache.ignite.internal.binary.BinaryFieldMetadata;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.internal.binary.BinaryMetadata;
 import org.apache.ignite.internal.binary.BinaryReaderEx;
 import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.binary.BinaryWriterEx;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
 import org.apache.ignite.internal.binary.streams.BinaryInputStream;
 import org.apache.ignite.internal.marshaller.ClassLoaderUtils;
 import org.apache.ignite.internal.processors.cache.CacheObject;
@@ -878,12 +878,12 @@ public class PlatformUtils {
      *
      * @return Marshaller.
      */
-    public static GridBinaryMarshaller marshaller() {
+    public static BinaryContext binaryContext() {
         BinaryMarshaller marsh = new BinaryMarshaller();
 
         marsh.setContext(new MarshallerContextImpl(null));
 
-        return new 
GridBinaryMarshaller(U.binaryContext(BinaryUtils.noopMetadataHandler(), marsh));
+        return U.binaryContext(BinaryUtils.noopMetadataHandler(), marsh);
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 40779934a03..f0c4b094aa9 100755
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -124,7 +124,6 @@ import java.util.stream.Collectors;
 import java.util.zip.Deflater;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 import javax.management.DynamicMBean;
 import javax.management.JMException;
@@ -6317,32 +6316,6 @@ public abstract class IgniteUtils extends CommonUtils {
         }
     }
 
-    /**
-     * @param marsh Marshaller.
-     * @param zipBytes Zip-compressed bytes.
-     * @param clsLdr Class loader to use.
-     * @return Unmarshalled object.
-     * @throws IgniteCheckedException
-     */
-    public static <T> T unmarshalZip(Marshaller marsh, byte[] zipBytes, 
@Nullable ClassLoader clsLdr) throws IgniteCheckedException {
-        assert marsh != null;
-        assert zipBytes != null;
-
-        try {
-            ZipInputStream in = new ZipInputStream(new 
ByteArrayInputStream(zipBytes));
-
-            in.getNextEntry();
-
-            return marsh.unmarshal(in, clsLdr);
-        }
-        catch (IgniteCheckedException e) {
-            throw e;
-        }
-        catch (Exception e) {
-            throw new IgniteCheckedException(e);
-        }
-    }
-
     /**
      * Unmarshals object from the input stream using given class loader.
      * This method should not close given input stream.
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
index eb7143f3e0a..3a945e72a92 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
@@ -35,7 +35,7 @@ import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.resources.IgniteInstanceResource;
 import org.apache.ignite.resources.LoggerResource;
 import org.apache.ignite.spi.IgniteSpiAdapter;
@@ -171,7 +171,7 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter 
implements Checkpoin
     private CheckpointListener lsnr;
 
     /** Marshaller. */
-    private Marshaller marsh;
+    private JdkMarshaller marsh;
 
     /**
      * Initializes default directory paths.
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 32c4cbc9b51..bbaf824d738 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
@@ -3260,13 +3260,13 @@ public class BinaryMarshallerSelfTest extends 
AbstractBinaryArraysTest {
 
         BinaryOutputStream os = BinaryStreams.outputStream(1024);
 
-        BinaryWriterEx writer = marsh.binaryMarshaller().writer(os);
+        BinaryWriterEx writer = 
BinaryUtils.writer(marsh.binaryMarshaller().context(), os);
 
         writer.writeObject(obj);
 
         BinaryInputStream is = BinaryStreams.inputStream(os.array());
 
-        BinaryReaderEx reader = marsh.binaryMarshaller().reader(is);
+        BinaryReaderEx reader = 
BinaryUtils.reader(marsh.binaryMarshaller().context(), is, null, true);
 
         Object bObj = reader.readObjectDetached(deserialize);
 
@@ -3792,11 +3792,11 @@ public class BinaryMarshallerSelfTest extends 
AbstractBinaryArraysTest {
         BinaryMarshaller marsh = binaryMarshaller();
         BinaryOutputStream out = BinaryStreams.outputStream(1024);
 
-        meta.writeTo(marsh.binaryMarshaller().writer(out));
+        meta.writeTo(BinaryUtils.writer(marsh.binaryMarshaller().context(), 
out));
 
         BinaryMetadata restoredMeta = new BinaryMetadata();
 
-        
restoredMeta.readFrom(marsh.binaryMarshaller().reader(BinaryStreams.inputStream(out.array())));
+        
restoredMeta.readFrom(BinaryUtils.reader(marsh.binaryMarshaller().context(), 
BinaryStreams.inputStream(out.array()), null, true));
 
         assertArrayEquals(fieldNames, restoredMeta.fields().toArray());
     }
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeCompatibilityTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeCompatibilityTest.java
index 1ab1885c02c..a53338663ff 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeCompatibilityTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/ClusterMetricsSnapshotSerializeCompatibilityTest.java
@@ -17,8 +17,9 @@
 
 package org.apache.ignite.spi.discovery;
 
+import java.io.ByteArrayInputStream;
 import java.util.HashMap;
-import org.apache.ignite.IgniteCheckedException;
+import java.util.zip.ZipInputStream;
 import org.apache.ignite.internal.marshaller.ClassLoaderUtils;
 import org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller;
 import org.apache.ignite.internal.processors.cache.CacheMetricsSnapshot;
@@ -42,7 +43,7 @@ public class ClusterMetricsSnapshotSerializeCompatibilityTest 
extends GridCommon
 
     /** */
     @Test
-    public void testSerializationAndDeserialization() throws 
IgniteCheckedException {
+    public void testSerializationAndDeserialization() throws Exception {
         HashMap<Integer, CacheMetricsSnapshot> metrics = new HashMap<>();
 
         metrics.put(1, createMetricsWithBorderMarker());
@@ -51,7 +52,11 @@ public class 
ClusterMetricsSnapshotSerializeCompatibilityTest extends GridCommon
 
         byte[] zipMarshal = U.zip(U.marshal(marshaller, metrics));
 
-        HashMap<Integer, CacheMetricsSnapshot> unmarshalMetrics = 
U.unmarshalZip(marshaller, zipMarshal, null);
+        ZipInputStream in = new ZipInputStream(new 
ByteArrayInputStream(zipMarshal));
+
+        in.getNextEntry();
+
+        HashMap<Integer, CacheMetricsSnapshot> unmarshalMetrics = 
U.unmarshal(marshaller, in, null);
 
         assertTrue(isMetricsEquals(metrics.get(1), unmarshalMetrics.get(1)));
 

Reply via email to