diff a/test/jdk/java/util/Collections/Disjoint.java b/test/jdk/java/util/Collections/Disjoint.java --- a/test/jdk/java/util/Collections/Disjoint.java +++ b/test/jdk/java/util/Collections/Disjoint.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -25,13 +25,16 @@ * @test * @bug 4339792 * @summary Basic test for Collections.disjoint * @author Josh Bloch * @key randomness + * @library /test/lib */ +import jdk.test.lib.valueclass.VClass; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Random; @@ -69,7 +72,13 @@ if (Collections.disjoint(new HashSet(a), new HashSet(b)) != disjoint) throw new RuntimeException("C: " + i + ", " + j); } } + + List va = Arrays.asList(new VClass(1, new int[] { 1 }), new VClass(2, new int[] { 2 })); + List vb = Arrays.asList(new VClass(3, new int[] { 3 }), new VClass(4, new int[] { 4 })); + List vc = Arrays.asList(new VClass(2, new int[] { 2 }), new VClass(5, new int[] { 5 })); + if (!Collections.disjoint(va, vb)) throw new RuntimeException("value disjoint failed"); + if (Collections.disjoint(va, vc)) throw new RuntimeException("value non-disjoint failed"); } }