JVMUtil { public static boolean equals(final Object o1, final Object o2) { if ( o1 == o2 ) return true; if ( o1 == null || o2 == null ) return false; if ( o1.equals( o2 ) ) return true; if ( o1.getClass().isArray() && o2.getClass().isArray() ) { if ( o1 instanceof Object[] && o2 instanceof Object[] ) return Arrays.equals( (Object[]) o1, (Object[]) o2 ); if ( o1 instanceof boolean[] && o2 instanceof boolean[] ) return Arrays.equals( (boolean[]) o1, (boolean[]) o2 ); if ( o1 instanceof byte[] && o2 instanceof byte[] ) return Arrays.equals( (byte[]) o1, (byte[]) o2 ); if ( o1 instanceof char[] && o2 instanceof char[] ) return Arrays.equals( (char[]) o1, (char[]) o2 ); if ( o1 instanceof double[] && o2 instanceof double[] ) return Arrays.equals( (double[]) o1, (double[]) o2 ); if ( o1 instanceof float[] && o2 instanceof float[] ) return Arrays.equals( (float[]) o1, (float[]) o2 ); if ( o1 instanceof int[] && o2 instanceof int[] ) return Arrays.equals( (int[]) o1, (int[]) o2 ); if ( o1 instanceof long[] && o2 instanceof long[] ) return Arrays.equals( (long[]) o1, (long[]) o2 ); if ( o1 instanceof short[] && o2 instanceof short[] ) return Arrays.equals( (short[]) o1, (short[]) o2 ); } return false; } private  JVMUtil(); static void gc(); static void gcOnExit(); static Field fieldFor(final Class<?> clazz,
                                 final String name); @SuppressWarnings("unchecked") static T getPropertyValueUnsafe(final Object source,
                                               final Class<T> valueType,
                                               final long fieldOffset); static void setPropertyValueUnsafe(final Object source,
                                                  final T value,
                                                  final Class<T> valueType,
                                                  final long fieldOffset); static Exception runAndGetExecutionException(final Runnable runnable); static List<Throwable> repeatConcurrently(final int threads,
                                                         final int totalIterationsCount,
                                                         final Function<Integer, Object> task); static List<Throwable> repeatConcurrently(final int threads,
                                                         final int totalIterationsCount,
                                                         final Runnable task); static int murmurRehash(final int hash); static int jdkRehash(final int hash); static boolean equals(final Object o1,
                                 final Object o2); static void ensureEnoughMemoryCapacity(final ByteArrayPointer pointer,
                                                  final CapacityRestriction capacityRestriction,
                                                  final Sequence memoryUsed); static void ensureEnoughCapacity(final Object obj,
                                            final CapacityRestriction capacityRestriction,
                                            final Sequence itemsCount);  }
@Test public void equals() { Assert.assertFalse( JVMUtil.equals( new Object(), new Object() ) ); Assert.assertFalse( JVMUtil.equals( null, new Object() ) ); Assert.assertFalse( JVMUtil.equals( new Object(), null ) ); Assert.assertTrue( JVMUtil.equals( Integer.valueOf( 1 ), Integer.valueOf( 1 ) ) ); Assert.assertTrue( JVMUtil.equals( Integer.valueOf( 1 ), new Integer( 1 ) ) ); Assert.assertTrue( JVMUtil.equals( new int[] { 1, 2 }, new int[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new int[] { 1, 2 }, new int[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new long[] { 1, 2 }, new long[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new long[] { 1, 2 }, new long[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new short[] { 1, 2 }, new short[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new short[] { 1, 2 }, new short[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new byte[] { 1, 2 }, new byte[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new byte[] { 1, 2 }, new byte[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new char[] { 1, 2 }, new char[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new char[] { 1, 2 }, new char[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new float[] { 1, 2 }, new float[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new float[] { 1, 2 }, new float[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new double[] { 1, 2 }, new double[] { 1, 2 } ) ); Assert.assertFalse( JVMUtil.equals( new double[] { 1, 2 }, new double[] { 1, 2, 3 } ) ); Assert.assertTrue( JVMUtil.equals( new boolean[] { true, false }, new boolean[] { true, false } ) ); Assert.assertFalse( JVMUtil.equals( new boolean[] { true, true }, new boolean[] { true, false } ) ); }