Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/java2d/cmm/ProfileOp/DisposalCrashTest.java
41153 views
1
/*
2
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/**
25
* @test
26
* @bug 8024511
27
* @summary Verifies that instances of color profiles are destroyed correctly.
28
* A crash during profile destruction indicates failure.
29
*
30
* @run main DisposalCrashTest
31
*/
32
33
import static java.awt.color.ColorSpace.*;
34
import java.awt.color.ICC_Profile;
35
import java.lang.ref.Reference;
36
import java.lang.ref.ReferenceQueue;
37
import java.lang.ref.WeakReference;
38
import java.util.Vector;
39
40
public class DisposalCrashTest {
41
42
static final ReferenceQueue<ICC_Profile> queue = new ReferenceQueue<>();
43
static final Vector<Reference<? extends ICC_Profile>> v = new Vector<>();
44
45
public static void main(String[] args) {
46
int[] ids = new int[]{
47
CS_sRGB, CS_CIEXYZ, CS_GRAY, CS_LINEAR_RGB, CS_PYCC
48
};
49
50
for (int id : ids) {
51
ICC_Profile p = getCopyOf(id);
52
}
53
54
while (!v.isEmpty()) {
55
System.gc();
56
System.out.println(".");
57
try {
58
Thread.sleep(500);
59
} catch (InterruptedException e) {};
60
61
final Reference<? extends ICC_Profile> ref = queue.poll();
62
System.out.println("Got reference: " + ref);
63
64
v.remove(ref);
65
}
66
67
System.out.println("Test PASSED.");
68
}
69
70
private static ICC_Profile getCopyOf(int id) {
71
ICC_Profile std = ICC_Profile.getInstance(id);
72
73
byte[] data = std.getData();
74
75
ICC_Profile p = ICC_Profile.getInstance(data);
76
77
WeakReference<ICC_Profile> ref = new WeakReference<>(p, queue);
78
79
v.add(ref);
80
81
return p;
82
}
83
}
84
85