Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/sound/sampled/Mixers/DisabledAssertionCrash.java
41153 views
1
/*
2
* Copyright (c) 2003, 2016, 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
import javax.sound.sampled.AudioFormat;
25
import javax.sound.sampled.AudioSystem;
26
import javax.sound.sampled.DataLine;
27
import javax.sound.sampled.Line;
28
import javax.sound.sampled.LineUnavailableException;
29
import javax.sound.sampled.SourceDataLine;
30
import javax.sound.sampled.TargetDataLine;
31
32
/**
33
* @test
34
* @bug 4991672
35
* @summary disabled assertion at maximum thread priority causes audio crash
36
* @run main/timeout=600 DisabledAssertionCrash
37
*/
38
public class DisabledAssertionCrash {
39
private static final int bufferSize = 1024;
40
41
public static void main(String[] args) {
42
43
System.out.println("This program hangs if priority is set,");
44
System.out.println("and assertion is in the code.");
45
System.out.println("The program crashes the entire Windows system");
46
System.out.println("if assertions are disabled.");
47
try {
48
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
49
AudioFormat audioFormat = new AudioFormat(44100,16,1,true,true);
50
Line.Info sourceDataLineInfo = new DataLine.Info(SourceDataLine.class,audioFormat);
51
SourceDataLine sourceDataLine =
52
(SourceDataLine) AudioSystem.getLine(sourceDataLineInfo);
53
System.out.println("SourceDataLine: "+sourceDataLine);
54
sourceDataLine.open(audioFormat, bufferSize);
55
sourceDataLine.start();
56
Line.Info targetDataLineInfo =
57
new DataLine.Info(TargetDataLine.class,audioFormat);
58
TargetDataLine targetDataLine =
59
(TargetDataLine) AudioSystem.getLine(targetDataLineInfo);
60
System.out.println("TargetDataLine: "+targetDataLine);
61
targetDataLine.open(audioFormat, bufferSize);
62
targetDataLine.start();
63
byte[] data = new byte[bufferSize];
64
65
// execute for 20 seconds
66
float bufferTime = (((float) data.length) / audioFormat.getFrameSize()) / audioFormat.getFrameRate();
67
int count = (int) (20.0f / bufferTime);
68
System.out.println("Buffer time: "+(bufferTime * 1000)+" millis. "+count+" iterations.");
69
for (int i = 0; i < count; i++) {
70
int cnt = targetDataLine.read(data,0,data.length);
71
sourceDataLine.write(data,0,cnt);
72
assert cnt == data.length;
73
}
74
System.out.println("Successfully recorded/played "+count+" buffers. Passed");
75
} catch(LineUnavailableException lue) {
76
System.out.println("Audio hardware is not available!");
77
lue.printStackTrace();
78
System.out.println("Cannot execute test. NOT failed.");
79
} catch(IllegalArgumentException iae) {
80
System.out.println("No audio hardware is installed!");
81
iae.printStackTrace();
82
System.out.println("Test system not correctly setup.");
83
System.out.println("Cannot execute test. NOT failed.");
84
} catch(Exception e) {
85
System.out.println("Unexpected Exception: "+e);
86
e.printStackTrace();
87
System.out.println("Cannot execute test. NOT failed.");
88
}
89
}
90
}
91
92