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 b86cdaa3542 IGNITE-24847 Move IgniteException, IgniteCheckedException 
to ignite-commons (#11981)
b86cdaa3542 is described below

commit b86cdaa3542087e4f6aa956cd2aca8633fb999ef
Author: Ilya Shishkov <[email protected]>
AuthorDate: Mon Apr 7 17:32:23 2025 +0300

    IGNITE-24847 Move IgniteException, IgniteCheckedException to ignite-commons 
(#11981)
---
 .../org/apache/ignite/IgniteCheckedException.java  |   0
 .../java/org/apache/ignite/IgniteException.java    |   0
 .../apache/ignite/internal/util/CommonUtils.java   | 160 +++++++++++++++++++++
 .../ignite/internal/util/GridCommonFunc.java       | 152 ++++++++++++++++++++
 .../apache/ignite/internal/util/GridLeanMap.java   |   2 +-
 .../ignite/internal/util/GridSerializableMap.java  |   0
 .../apache/ignite/internal/util/typedef/CF.java}   |  23 +--
 .../org/apache/ignite/internal/util/typedef/X.java |  55 +------
 .../apache/ignite/internal/util/IgniteUtils.java   | 147 +------------------
 .../apache/ignite/internal/util/lang/GridFunc.java | 110 +-------------
 .../ignite/internal/util/IgniteUtilsSelfTest.java  |   2 +-
 11 files changed, 327 insertions(+), 324 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/IgniteCheckedException.java 
b/modules/commons/src/main/java/org/apache/ignite/IgniteCheckedException.java
similarity index 100%
rename from 
modules/core/src/main/java/org/apache/ignite/IgniteCheckedException.java
rename to 
modules/commons/src/main/java/org/apache/ignite/IgniteCheckedException.java
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteException.java 
b/modules/commons/src/main/java/org/apache/ignite/IgniteException.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/IgniteException.java
rename to modules/commons/src/main/java/org/apache/ignite/IgniteException.java
diff --git 
a/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
new file mode 100644
index 00000000000..489b9968962
--- /dev/null
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
@@ -0,0 +1,160 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import org.apache.ignite.IgniteCheckedException;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Collection of utility methods used in 'ignite-commons' and throughout the 
system.
+ */
+public abstract class CommonUtils {
+    /** Sun-specific JDK constructor factory for objects that don't have empty 
constructor. */
+    private static final Method CTOR_FACTORY;
+
+    /** Sun JDK reflection factory. */
+    private static final Object SUN_REFLECT_FACTORY;
+
+    /** Public {@code java.lang.Object} no-argument constructor. */
+    private static final Constructor OBJECT_CTOR;
+
+    static {
+        try {
+            OBJECT_CTOR = Object.class.getConstructor();
+        }
+        catch (NoSuchMethodException e) {
+            throw new AssertionError("Object class does not have empty 
constructor (is JDK corrupted?).", e);
+        }
+
+        // Constructor factory.
+        Method ctorFac = null;
+        Object refFac = null;
+
+        try {
+            Class<?> refFactoryCls = 
Class.forName("sun.reflect.ReflectionFactory");
+
+            refFac = 
refFactoryCls.getMethod("getReflectionFactory").invoke(null);
+
+            ctorFac = 
refFac.getClass().getMethod("newConstructorForSerialization", Class.class,
+                Constructor.class);
+        }
+        catch (NoSuchMethodException | ClassNotFoundException | 
IllegalAccessException | InvocationTargetException ignored) {
+            // No-op.
+        }
+
+        CTOR_FACTORY = ctorFac;
+        SUN_REFLECT_FACTORY = refFac;
+    }
+
+    /**
+     * Creates new instance of a class even if it does not have public 
constructor.
+     *
+     * @param cls Class to instantiate.
+     * @return New instance of the class or {@code null} if empty constructor 
could not be assigned.
+     * @throws IgniteCheckedException If failed.
+     */
+    @Nullable public static <T> T forceNewInstance(Class<?> cls) throws 
IgniteCheckedException {
+        Constructor ctor = forceEmptyConstructor(cls);
+
+        if (ctor == null)
+            return null;
+
+        boolean set = false;
+
+        try {
+
+            if (!ctor.isAccessible()) {
+                ctor.setAccessible(true);
+
+                set = true;
+            }
+
+            return (T)ctor.newInstance();
+        }
+        catch (InstantiationException | InvocationTargetException | 
IllegalAccessException e) {
+            throw new IgniteCheckedException("Failed to create new instance 
for class: " + cls, e);
+        }
+        finally {
+            if (set)
+                ctor.setAccessible(false);
+        }
+    }
+
+    /**
+     * Gets empty constructor for class even if the class does not have empty 
constructor
+     * declared. This method is guaranteed to work with SUN JDK and other JDKs 
still need
+     * to be tested.
+     *
+     * @param cls Class to get empty constructor for.
+     * @return Empty constructor if one could be found or {@code null} 
otherwise.
+     * @throws IgniteCheckedException If failed.
+     */
+    @Nullable public static Constructor<?> forceEmptyConstructor(Class<?> cls) 
throws IgniteCheckedException {
+        Constructor<?> ctor = null;
+
+        try {
+            return cls.getDeclaredConstructor();
+        }
+        catch (Exception ignore) {
+            Method ctorFac = CTOR_FACTORY;
+            Object sunRefFac = sunReflectionFactory();
+
+            if (ctorFac != null && sunRefFac != null)
+                try {
+                    ctor = (Constructor)ctorFac.invoke(sunRefFac, cls, 
OBJECT_CTOR);
+                }
+                catch (IllegalAccessException | InvocationTargetException e) {
+                    throw new IgniteCheckedException("Failed to get object 
constructor for class: " + cls, e);
+                }
+        }
+
+        return ctor;
+    }
+
+    /**
+     * SUN JDK specific reflection factory for objects without public 
constructor.
+     *
+     * @return Reflection factory for objects without public constructor.
+     */
+    @Nullable public static Object sunReflectionFactory() {
+        return SUN_REFLECT_FACTORY;
+    }
+
+    /**
+     * Returns a capacity that is sufficient to keep the map from being 
resized as
+     * long as it grows no larger than expSize and the load factor is >= its
+     * default (0.75).
+     *
+     * Copy pasted from guava. See com.google.common.collect.Maps#capacity(int)
+     *
+     * @param expSize Expected size of created map.
+     * @return Capacity.
+     */
+    public static int capacity(int expSize) {
+        if (expSize < 3)
+            return expSize + 1;
+
+        if (expSize < (1 << 30))
+            return expSize + expSize / 3;
+
+        return Integer.MAX_VALUE; // any large value
+    }
+}
diff --git 
a/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
new file mode 100644
index 00000000000..53acc7b7480
--- /dev/null
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridCommonFunc.java
@@ -0,0 +1,152 @@
+/*
+ * 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.util;
+
+import java.util.Collection;
+import java.util.Map;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Contains factory and utility methods for {@code closures}, {@code 
predicates}, and {@code tuples}.
+ * It also contains functional style collection comprehensions.
+ * <p>
+ * Most of the methods in this class can be divided into two groups:
+ * <ul>
+ * <li><b>Factory</b> higher-order methods for closures, predicates and 
tuples, and</li>
+ * <li><b>Utility</b> higher-order methods for processing collections with 
closures and predicates.</li>
+ * </ul>
+ * Note that contrary to the usual design this class has substantial number of
+ * methods (over 200). This design is chosen to simulate a global namespace
+ * (like a {@code Predef} in Scala) to provide general utility and functional
+ * programming functionality in a shortest syntactical context using {@code F}
+ * typedef.
+ * <p>
+ * Also note, that in all methods with predicates, null predicate has a {@code 
true} meaning. So does
+ * the empty predicate array.
+ *
+ * <b>Remove when GridFunc migrated</b>
+ */
+public class GridCommonFunc {
+    /**
+     * Tests if given string is {@code null} or empty.
+     *
+     * @param s String to test.
+     * @return Whether or not the given string is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable String s) {
+        return s == null || s.isEmpty();
+    }
+
+    /**
+     * Tests if the given array is either {@code null} or empty.
+     *
+     * @param c Array to test.
+     * @return Whether or not the given array is {@code null} or empty.
+     */
+    public static <T> boolean isEmpty(@Nullable T[] c) {
+        return c == null || c.length == 0;
+    }
+
+    /**
+     * Tests if the given array is {@code null}, empty or contains only {@code 
null} values.
+     *
+     * @param c Array to test.
+     * @return Whether or not the given array is {@code null}, empty or 
contains only {@code null} values.
+     */
+    public static <T> boolean isEmptyOrNulls(@Nullable T[] c) {
+        if (isEmpty(c))
+            return true;
+
+        for (T element : c)
+            if (element != null)
+                return false;
+
+        return true;
+    }
+
+    /**
+     * Tests if the given array is either {@code null} or empty.
+     *
+     * @param c Array to test.
+     * @return Whether or not the given array is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable int[] c) {
+        return c == null || c.length == 0;
+    }
+
+    /**
+     * Tests if the given array is either {@code null} or empty.
+     *
+     * @param c Array to test.
+     * @return Whether or not the given array is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable byte[] c) {
+        return c == null || c.length == 0;
+    }
+
+    /**
+     * Tests if the given array is either {@code null} or empty.
+     *
+     * @param c Array to test.
+     * @return Whether or not the given array is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable long[] c) {
+        return c == null || c.length == 0;
+    }
+
+    /**
+     * Tests if the given array is either {@code null} or empty.
+     *
+     * @param c Array to test.
+     * @return Whether or not the given array is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable char[] c) {
+        return c == null || c.length == 0;
+    }
+
+    /**
+     * Tests if the given collection is either {@code null} or empty.
+     *
+     * @param c Collection to test.
+     * @return Whether or not the given collection is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable Iterable<?> c) {
+        return c == null || (c instanceof Collection<?> ? 
((Collection<?>)c).isEmpty() : !c.iterator().hasNext());
+    }
+
+    /**
+     * Tests if the given collection is either {@code null} or empty.
+     *
+     * @param c Collection to test.
+     * @return Whether or not the given collection is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable Collection<?> c) {
+        return c == null || c.isEmpty();
+    }
+
+    /**
+     * Tests if the given map is either {@code null} or empty.
+     *
+     * @param m Map to test.
+     * @return Whether or not the given collection is {@code null} or empty.
+     */
+    public static boolean isEmpty(@Nullable Map<?, ?> m) {
+        return m == null || m.isEmpty();
+    }
+
+}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLeanMap.java 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridLeanMap.java
similarity index 99%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/GridLeanMap.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/GridLeanMap.java
index 431a277ec45..5a29c14b3c5 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLeanMap.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridLeanMap.java
@@ -77,7 +77,7 @@ public class GridLeanMap<K, V> extends GridSerializableMap<K, 
V> implements Clon
         else if (size == 5)
             map = new Map5<>();
         else
-            map = new LeanHashMap<>(IgniteUtils.capacity(size), 0.75f);
+            map = new LeanHashMap<>(CommonUtils.capacity(size), 0.75f);
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
similarity index 100%
copy from 
modules/core/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
copy to 
modules/commons/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
 b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/CF.java
similarity index 51%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/CF.java
index fbb1fe742fd..576e81f8175 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSerializableMap.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/CF.java
@@ -15,23 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.internal.util;
+package org.apache.ignite.internal.util.typedef;
 
-import java.io.Serializable;
-import java.util.AbstractMap;
+import org.apache.ignite.internal.util.GridCommonFunc;
 
 /**
- * Makes {@link AbstractMap} as {@link Serializable} and is
- * useful for making anonymous serializable maps. It has no extra logic or 
state in addition
- * to {@link AbstractMap}.
- * <b>NOTE:</b> methods {@link #get(Object)}, {@link #remove(Object)} and
- * {@link #containsKey(Object)} implemented in {@link AbstractMap} <b>fully 
iterate through
- * collection</b> so you need to make sure to override these methods if it's 
possible to create
- * efficient implementations.
+ * Defines {@code alias} for {@link GridCommonFunc} by extending it. Since 
Java doesn't provide type aliases
+ * (like Scala, for example) we resort to these types of measures. This is 
intended to provide for more
+ * concise code in cases when readability won't be sacrificed. For more 
information see {@link GridCommonFunc}.
+ * @see GridCommonFunc
  */
-public abstract class GridSerializableMap<K, V> extends AbstractMap<K, V> 
implements Serializable {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    // No-op.
-}
+public class CF extends GridCommonFunc { /* No-op. */ }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/typedef/X.java 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/X.java
similarity index 96%
rename from 
modules/core/src/main/java/org/apache/ignite/internal/util/typedef/X.java
rename to 
modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/X.java
index 789cf824869..f3a69af092d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/typedef/X.java
+++ 
b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/X.java
@@ -35,10 +35,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.CommonUtils;
 import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteFuture;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -398,7 +396,7 @@ public final class X {
             return clone;
         }
 
-        clone = U.forceNewInstance(cls);
+        clone = CommonUtils.forceNewInstance(cls);
 
         if (clone == null)
             throw new IgniteException("Failed to clone object (empty 
constructor could not be assigned): " + obj);
@@ -465,7 +463,7 @@ public final class X {
      *      {@code false} otherwise.
      */
     public static boolean hasCause(@Nullable Throwable t, @Nullable String 
msg, @Nullable Class<?>... types) {
-        if (t == null || F.isEmpty(types))
+        if (t == null || CF.isEmpty(types))
             return false;
 
         Set<Throwable> dejaVu = Collections.newSetFromMap(new 
IdentityHashMap<>());
@@ -872,53 +870,6 @@ public final class X {
         return sw.getBuffer().toString();
     }
 
-    /**
-     * Synchronously waits for all futures in the collection.
-     *
-     * @param futs Futures to wait for.
-     */
-    public static void waitAll(@Nullable Iterable<IgniteFuture<?>> futs) {
-        if (F.isEmpty(futs))
-            return;
-
-        for (IgniteFuture fut : futs)
-            fut.get();
-    }
-
-    /**
-     * Pretty-formatting for minutes.
-     *
-     * @param mins Minutes to format.
-     * @return Formatted presentation of minutes.
-     */
-    public static String formatMins(long mins) {
-        assert mins >= 0;
-
-        if (mins == 0)
-            return "< 1 min";
-
-        SB sb = new SB();
-
-        long dd = mins / 1440; // 1440 mins = 60 mins * 24 hours
-
-        if (dd > 0)
-            sb.a(dd).a(dd == 1 ? " day " : " days ");
-
-        mins %= 1440;
-
-        long hh = mins / 60;
-
-        if (hh > 0)
-            sb.a(hh).a(hh == 1 ? " hour " : " hours ");
-
-        mins %= 60;
-
-        if (mins > 0)
-            sb.a(mins).a(mins == 1 ? " min " : " mins ");
-
-        return sb.toString().trim();
-    }
-
     /**
      * Exits with code {@code -1} if maximum memory is below 90% of minimally 
allowed threshold.
      *
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 5593158f049..17d1ee93dd2 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
@@ -316,7 +316,7 @@ import static 
org.apache.ignite.internal.util.GridUnsafe.staticFieldOffset;
  * Collection of utility methods used throughout the system.
  */
 @SuppressWarnings({"UnusedReturnValue"})
-public abstract class IgniteUtils {
+public abstract class IgniteUtils extends CommonUtils {
     /** Logger. */
     private static final Logger log = 
Logger.getLogger(IgniteUtils.class.getName());
 
@@ -354,15 +354,6 @@ public abstract class IgniteUtils {
     /** {@code True} if {@code unsafe} should be used for array copy. */
     private static final boolean UNSAFE_BYTE_ARR_CP = 
unsafeByteArrayCopyAvailable();
 
-    /** Sun-specific JDK constructor factory for objects that don't have empty 
constructor. */
-    private static final Method CTOR_FACTORY;
-
-    /** Sun JDK reflection factory. */
-    private static final Object SUN_REFLECT_FACTORY;
-
-    /** Public {@code java.lang.Object} no-argument constructor. */
-    private static final Constructor OBJECT_CTOR;
-
     /** All grid event names. */
     private static final Map<Integer, String> GRID_EVT_NAMES = new HashMap<>();
 
@@ -822,32 +813,6 @@ public abstract class IgniteUtils {
         boxedClsMap.put(boolean.class, Boolean.class);
         boxedClsMap.put(void.class, Void.class);
 
-        try {
-            OBJECT_CTOR = Object.class.getConstructor();
-        }
-        catch (NoSuchMethodException e) {
-            throw withCause(new AssertionError("Object class does not have 
empty constructor (is JDK corrupted?)."), e);
-        }
-
-        // Constructor factory.
-        Method ctorFac = null;
-        Object refFac = null;
-
-        try {
-            Class<?> refFactoryCls = 
Class.forName("sun.reflect.ReflectionFactory");
-
-            refFac = 
refFactoryCls.getMethod("getReflectionFactory").invoke(null);
-
-            ctorFac = 
refFac.getClass().getMethod("newConstructorForSerialization", Class.class,
-                Constructor.class);
-        }
-        catch (NoSuchMethodException | ClassNotFoundException | 
IllegalAccessException | InvocationTargetException ignored) {
-            // No-op.
-        }
-
-        CTOR_FACTORY = ctorFac;
-        SUN_REFLECT_FACTORY = refFac;
-
         // Disable hostname SSL verification for development and testing with 
self-signed certificates.
         if 
(Boolean.parseBoolean(System.getProperty(IGNITE_DISABLE_HOSTNAME_VERIFIER))) {
             HttpsURLConnection.setDefaultHostnameVerifier(new 
HostnameVerifier() {
@@ -1214,31 +1179,6 @@ public abstract class IgniteUtils {
         return i > 0 && (i & (i - 1)) == 0;
     }
 
-    /**
-     * Return SUN specific constructor factory.
-     *
-     * @return SUN specific constructor factory.
-     */
-    @Nullable public static Method ctorFactory() {
-        return CTOR_FACTORY;
-    }
-
-    /**
-     * @return Empty constructor for object class.
-     */
-    public static Constructor objectConstructor() {
-        return OBJECT_CTOR;
-    }
-
-    /**
-     * SUN JDK specific reflection factory for objects without public 
constructor.
-     *
-     * @return Reflection factory for objects without public constructor.
-     */
-    @Nullable public static Object sunReflectionFactory() {
-        return SUN_REFLECT_FACTORY;
-    }
-
     /**
      * Gets name for given grid event type.
      *
@@ -1674,37 +1614,6 @@ public abstract class IgniteUtils {
             sb.a(NL).a("        ").a(info);
     }
 
-    /**
-     * Gets empty constructor for class even if the class does not have empty 
constructor
-     * declared. This method is guaranteed to work with SUN JDK and other JDKs 
still need
-     * to be tested.
-     *
-     * @param cls Class to get empty constructor for.
-     * @return Empty constructor if one could be found or {@code null} 
otherwise.
-     * @throws IgniteCheckedException If failed.
-     */
-    @Nullable public static Constructor<?> forceEmptyConstructor(Class<?> cls) 
throws IgniteCheckedException {
-        Constructor<?> ctor = null;
-
-        try {
-            return cls.getDeclaredConstructor();
-        }
-        catch (Exception ignore) {
-            Method ctorFac = U.ctorFactory();
-            Object sunRefFac = U.sunReflectionFactory();
-
-            if (ctorFac != null && sunRefFac != null)
-                try {
-                    ctor = (Constructor)ctorFac.invoke(sunRefFac, cls, 
U.objectConstructor());
-                }
-                catch (IllegalAccessException | InvocationTargetException e) {
-                    throw new IgniteCheckedException("Failed to get object 
constructor for class: " + cls, e);
-                }
-        }
-
-        return ctor;
-    }
-
     /**
      * Gets class for the given name if it can be loaded or default given 
class.
      *
@@ -1818,40 +1727,6 @@ public abstract class IgniteUtils {
         }
     }
 
-    /**
-     * Creates new instance of a class even if it does not have public 
constructor.
-     *
-     * @param cls Class to instantiate.
-     * @return New instance of the class or {@code null} if empty constructor 
could not be assigned.
-     * @throws IgniteCheckedException If failed.
-     */
-    @Nullable public static <T> T forceNewInstance(Class<?> cls) throws 
IgniteCheckedException {
-        Constructor ctor = forceEmptyConstructor(cls);
-
-        if (ctor == null)
-            return null;
-
-        boolean set = false;
-
-        try {
-
-            if (!ctor.isAccessible()) {
-                ctor.setAccessible(true);
-
-                set = true;
-            }
-
-            return (T)ctor.newInstance();
-        }
-        catch (InstantiationException | InvocationTargetException | 
IllegalAccessException e) {
-            throw new IgniteCheckedException("Failed to create new instance 
for class: " + cls, e);
-        }
-        finally {
-            if (set)
-                ctor.setAccessible(false);
-        }
-    }
-
     /**
      * Pretty-formatting for minutes.
      *
@@ -10180,26 +10055,6 @@ public abstract class IgniteUtils {
         return res;
     }
 
-    /**
-     * Returns a capacity that is sufficient to keep the map from being 
resized as
-     * long as it grows no larger than expSize and the load factor is >= its
-     * default (0.75).
-     *
-     * Copy pasted from guava. See com.google.common.collect.Maps#capacity(int)
-     *
-     * @param expSize Expected size of created map.
-     * @return Capacity.
-     */
-    public static int capacity(int expSize) {
-        if (expSize < 3)
-            return expSize + 1;
-
-        if (expSize < (1 << 30))
-            return expSize + expSize / 3;
-
-        return Integer.MAX_VALUE; // any large value
-    }
-
     /**
      * Creates new {@link HashMap} with expected size.
      *
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java 
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 432225df1ae..546f3c67260 100755
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -41,6 +41,7 @@ import org.apache.ignite.cluster.BaselineNode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.binary.BinaryArray;
 import org.apache.ignite.internal.util.F0;
+import org.apache.ignite.internal.util.GridCommonFunc;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.GridEmptyIterator;
 import org.apache.ignite.internal.util.GridLeanMap;
@@ -106,7 +107,7 @@ import org.jetbrains.annotations.Nullable;
  * the empty predicate array.
  */
 @SuppressWarnings("unchecked")
-public class GridFunc {
+public class GridFunc extends GridCommonFunc {
     /** */
     private static final GridAbsClosure NOOP = new NoOpClosure();
 
@@ -812,113 +813,6 @@ public class GridFunc {
         return new PredicateSetView<>(c, mapClo, p);
     }
 
-    /**
-     * Tests if given string is {@code null} or empty.
-     *
-     * @param s String to test.
-     * @return Whether or not the given string is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable String s) {
-        return s == null || s.isEmpty();
-    }
-
-    /**
-     * Tests if the given array is either {@code null} or empty.
-     *
-     * @param c Array to test.
-     * @return Whether or not the given array is {@code null} or empty.
-     */
-    public static <T> boolean isEmpty(@Nullable T[] c) {
-        return c == null || c.length == 0;
-    }
-
-    /**
-     * Tests if the given array is {@code null}, empty or contains only {@code 
null} values.
-     *
-     * @param c Array to test.
-     * @return Whether or not the given array is {@code null}, empty or 
contains only {@code null} values.
-     */
-    public static <T> boolean isEmptyOrNulls(@Nullable T[] c) {
-        if (isEmpty(c))
-            return true;
-
-        for (T element : c)
-            if (element != null)
-                return false;
-
-        return true;
-    }
-
-    /**
-     * Tests if the given array is either {@code null} or empty.
-     *
-     * @param c Array to test.
-     * @return Whether or not the given array is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable int[] c) {
-        return c == null || c.length == 0;
-    }
-
-    /**
-     * Tests if the given array is either {@code null} or empty.
-     *
-     * @param c Array to test.
-     * @return Whether or not the given array is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable byte[] c) {
-        return c == null || c.length == 0;
-    }
-
-    /**
-     * Tests if the given array is either {@code null} or empty.
-     *
-     * @param c Array to test.
-     * @return Whether or not the given array is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable long[] c) {
-        return c == null || c.length == 0;
-    }
-
-    /**
-     * Tests if the given array is either {@code null} or empty.
-     *
-     * @param c Array to test.
-     * @return Whether or not the given array is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable char[] c) {
-        return c == null || c.length == 0;
-    }
-
-    /**
-     * Tests if the given collection is either {@code null} or empty.
-     *
-     * @param c Collection to test.
-     * @return Whether or not the given collection is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable Iterable<?> c) {
-        return c == null || (c instanceof Collection<?> ? 
((Collection<?>)c).isEmpty() : !c.iterator().hasNext());
-    }
-
-    /**
-     * Tests if the given collection is either {@code null} or empty.
-     *
-     * @param c Collection to test.
-     * @return Whether or not the given collection is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable Collection<?> c) {
-        return c == null || c.isEmpty();
-    }
-
-    /**
-     * Tests if the given map is either {@code null} or empty.
-     *
-     * @param m Map to test.
-     * @return Whether or not the given collection is {@code null} or empty.
-     */
-    public static boolean isEmpty(@Nullable Map<?, ?> m) {
-        return m == null || m.isEmpty();
-    }
-
     /**
      * Returns a factory closure that creates new {@link Set} instance. Note 
that this
      * method does not create a new closure but returns a static one.
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
index 0724902f78e..ae594d9fa35 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
@@ -239,7 +239,7 @@ public class IgniteUtilsSelfTest extends 
GridCommonAbstractTest {
      * @param mins Minutes to test.
      */
     private void printFormatMins(long mins) {
-        System.out.println("For " + mins + " minutes: " + X.formatMins(mins));
+        System.out.println("For " + mins + " minutes: " + U.formatMins(mins));
     }
 
     /**

Reply via email to