test/jdk/sun/security/util/Cache/EbaHash.java
author igerasim
Wed, 04 Oct 2017 01:08:36 -0700
changeset 47310 eca11f20586e
permissions -rw-r--r--
8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode() Reviewed-by: coffeys
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47310
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     1
/*
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     4
 *
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     7
 * published by the Free Software Foundation.
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     8
 *
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    13
 * accompanied this code).
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    14
 *
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    18
 *
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    21
 * questions.
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    22
 */
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    23
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    24
/*
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    25
 * @test
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    26
 * @bug 8186654
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    27
 * @summary Transpositions of an array result in the same
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    28
 *          EqualByteArray.hashCode()
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    29
 * @modules java.base/sun.security.util
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    30
 */
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    31
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    32
import sun.security.util.Cache;
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    33
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    34
public class EbaHash {
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    35
    public static void main(String[] args) throws Throwable {
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    36
        int h1 = new Cache.EqualByteArray(new byte[] {1,2,3}).hashCode();
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    37
        int h2 = new Cache.EqualByteArray(new byte[] {2,3,1}).hashCode();
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    38
        int h3 = new Cache.EqualByteArray(new byte[] {3,1,2}).hashCode();
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    39
        if (h1 == h2 && h2 == h3) {
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    40
            throw new RuntimeException("Transpositions of an array" +
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    41
                " resulted in the same hashCode()");
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    42
        }
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    43
    }
eca11f20586e 8186654: Poor quality of sun.security.util.Cache.EqualByteArray.hashCode()
igerasim
parents:
diff changeset
    44
}