8142898: Prefer isFile()/isDirectory() over exists() in SoftSynthesizer
Reviewed-by: serb
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java Thu Nov 19 01:52:52 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java Thu Nov 19 12:52:41 2015 -0500
@@ -638,7 +638,7 @@
File javahome = new File(System.getProperties()
.getProperty("java.home"));
File libaudio = new File(new File(javahome, "lib"), "audio");
- if (libaudio.exists()) {
+ if (libaudio.isDirectory()) {
File foundfile = null;
File[] files = libaudio.listFiles();
if (files != null) {
@@ -686,9 +686,9 @@
* Look for a default.sf2
*/
for (File systemSoundFontDir : systemSoundFontsDir) {
- if (systemSoundFontDir.exists()) {
+ if (systemSoundFontDir.isDirectory()) {
File defaultSoundFont = new File(systemSoundFontDir, "default.sf2");
- if (defaultSoundFont.exists()) {
+ if (defaultSoundFont.isFile()) {
try {
return new FileInputStream(defaultSoundFont);
} catch (IOException e) {
@@ -708,7 +708,7 @@
.startsWith("Windows")) {
File gm_dls = new File(System.getenv("SystemRoot")
+ "\\system32\\drivers\\gm.dls");
- if (gm_dls.exists()) {
+ if (gm_dls.isFile()) {
try {
return new FileInputStream(gm_dls);
} catch (IOException e) {
@@ -728,7 +728,7 @@
".gervill");
File emg_soundbank_file = new File(userhome,
"soundbank-emg.sf2");
- if (emg_soundbank_file.exists()) {
+ if (emg_soundbank_file.isFile()) {
try {
return new FileInputStream(emg_soundbank_file);
} catch (IOException e) {
@@ -773,12 +773,14 @@
try {
File userhome = new File(System
.getProperty("user.home"), ".gervill");
- if (!userhome.exists()) {
- userhome.mkdirs();
+ if (!userhome.isDirectory()) {
+ if (!userhome.mkdirs()) {
+ return null;
+ }
}
File emg_soundbank_file = new File(
userhome, "soundbank-emg.sf2");
- if (emg_soundbank_file.exists()) {
+ if (emg_soundbank_file.isFile()) {
return null;
}
return new FileOutputStream(emg_soundbank_file);