1
1
/*
2
- * Copyright (c) 2007, 2013 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2007, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
32
32
import java .net .URL ;
33
33
import java .net .URLClassLoader ;
34
34
import java .util .ArrayList ;
35
+ import java .util .Objects ;
35
36
import javax .sound .midi .InvalidMidiDataException ;
36
37
import javax .sound .midi .Soundbank ;
37
38
import javax .sound .midi .spi .SoundbankReader ;
45
46
*/
46
47
public final class JARSoundbankReader extends SoundbankReader {
47
48
49
+ /*
50
+ * Name of the system property that enables the Jar soundbank loading
51
+ * true if jar sound bank is allowed to be loaded
52
+ * default is false
53
+ */
54
+ private final static String JAR_SOUNDBANK_ENABLED = "jdk.sound.jarsoundbank" ;
55
+
48
56
private static boolean isZIP (URL url ) {
49
57
boolean ok = false ;
50
58
try {
@@ -68,8 +76,10 @@ private static boolean isZIP(URL url) {
68
76
69
77
public Soundbank getSoundbank (URL url )
70
78
throws InvalidMidiDataException , IOException {
71
- if (!isZIP (url ))
79
+ Objects .requireNonNull (url );
80
+ if (!Boolean .getBoolean (JAR_SOUNDBANK_ENABLED ) || !isZIP (url ))
72
81
return null ;
82
+
73
83
ArrayList <Soundbank > soundbanks = new ArrayList <Soundbank >();
74
84
URLClassLoader ucl = URLClassLoader .newInstance (new URL []{url });
75
85
InputStream stream = ucl .getResourceAsStream (
@@ -117,6 +127,7 @@ public Soundbank getSoundbank(InputStream stream)
117
127
118
128
public Soundbank getSoundbank (File file )
119
129
throws InvalidMidiDataException , IOException {
130
+ Objects .requireNonNull (file );
120
131
return getSoundbank (file .toURI ().toURL ());
121
132
}
122
133
}
0 commit comments