Java Code Examples for java.util.Locale#hashCode()
The following examples show how to use
java.util.Locale#hashCode() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dragonwell8_jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 2
Source Project: dragonwell8_jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 3
Source Project: TencentKona-8 File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 4
Source Project: TencentKona-8 File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 5
Source Project: jdk8u60 File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 6
Source Project: jdk8u60 File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 7
Source Project: openjdk-jdk8u File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 8
Source Project: jdk8u-jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 9
Source Project: openjdk-jdk8u-backup File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 10
Source Project: openjdk-jdk8u-backup File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 11
Source Project: jdk8u-jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 12
Source Project: jdk8u_jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 13
Source Project: hottub File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 14
Source Project: jdk8u-jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 15
Source Project: openjdk-8-source File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 16
Source Project: openjdk-8-source File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 17
Source Project: jdk8u_jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
/** * @bug 4110613 */ public void TestSerialization() throws ClassNotFoundException, OptionalDataException, IOException, StreamCorruptedException { ObjectOutputStream ostream; ByteArrayOutputStream obstream; byte[] bytes = null; obstream = new ByteArrayOutputStream(); ostream = new ObjectOutputStream(obstream); Locale test1 = new Locale("zh", "TW", ""); int dummy = test1.hashCode(); // fill in the cached hash-code value ostream.writeObject(test1); bytes = obstream.toByteArray(); ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes)); Locale test2 = (Locale)(istream.readObject()); if (!test1.equals(test2) || test1.hashCode() != test2.hashCode()) errln("Locale failed to deserialize correctly."); }
Example 18
Source Project: jdk8u-dev-jdk File: LocaleTest.java License: GNU General Public License v2.0 | 6 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale)test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) errln("Some of the test variables point to the same locale!"); if (test3 == null) errln("clone() failed to produce a valid object!"); if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) errln("clone() or equals() failed: objects that should compare equal don't"); if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) errln("equals() failed: objects that shouldn't compare equal do"); int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) errln("hashCode() failed: objects that should have the same hash code don't"); }
Example 19
Source Project: openjdk-jdk9 File: LocaleTest.java License: GNU General Public License v2.0 | 5 votes |
public void TestSimpleObjectStuff() { Locale test1 = new Locale("aa", "AA"); Locale test2 = new Locale("aa", "AA"); Locale test3 = (Locale) test1.clone(); Locale test4 = new Locale("zz", "ZZ"); if (test1 == test2 || test1 == test3 || test1 == test4 || test2 == test3) { errln("Some of the test variables point to the same locale!"); } if (test3 == null) { errln("clone() failed to produce a valid object!"); } if (!test1.equals(test2) || !test1.equals(test3) || !test2.equals(test3)) { errln("clone() or equals() failed: objects that should compare equal don't"); } if (test1.equals(test4) || test2.equals(test4) || test3.equals(test4)) { errln("equals() failed: objects that shouldn't compare equal do"); } int hash1 = test1.hashCode(); int hash2 = test2.hashCode(); int hash3 = test3.hashCode(); if (hash1 != hash2 || hash1 != hash3 || hash2 != hash3) { errln("hashCode() failed: objects that should have the same hash code don't"); } }
Example 20
Source Project: openjdk-jdk9 File: HashCodeTest.java License: GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { Locale[] locales = Locale.getAvailableLocales(); int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; Map<Integer, Locale> map = new HashMap<>(locales.length); int conflicts = 0; for (int i = 0; i < locales.length; i++) { Locale loc = locales[i]; int hc = loc.hashCode(); min = Math.min(hc, min); max = Math.max(hc, max); Integer key = hc; if (map.containsKey(key)) { conflicts++; System.out.println("conflict: " + map.get(key) + ", " + loc); } else { map.put(key, loc); } } System.out.println(locales.length + " locales: conflicts=" + conflicts + ", min=" + min + ", max=" + max + ", diff=" + (max - min)); if (conflicts >= (locales.length / 10)) { throw new RuntimeException("too many conflicts: " + conflicts + " per " + locales.length + " locales"); } }