--- a/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java Wed Aug 06 21:46:17 2014 +0400
+++ b/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java Thu Aug 07 17:02:48 2014 +0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -25,6 +25,8 @@
package com.sun.media.sound;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -176,11 +178,11 @@
&& !Sequencer.class.equals(typeClass)) {
return null;
}
- String value;
- String propertyName = typeClass.getName();
- value = JSSecurityManager.getProperty(propertyName);
+ String name = typeClass.getName();
+ String value = AccessController.doPrivileged(
+ (PrivilegedAction<String>) () -> System.getProperty(name));
if (value == null) {
- value = getProperties().getProperty(propertyName);
+ value = getProperties().getProperty(name);
}
if ("".equals(value)) {
value = null;
--- a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java Wed Aug 06 21:46:17 2014 +0400
+++ b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java Thu Aug 07 17:02:48 2014 +0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -73,33 +73,6 @@
}
}
- static String getProperty(final String propertyName) {
- String propertyValue;
- if (hasSecurityManager()) {
- if(Printer.debug) Printer.debug("using JDK 1.2 security to get property");
- try{
- PrivilegedAction<String> action = new PrivilegedAction<String>() {
- public String run() {
- try {
- return System.getProperty(propertyName);
- } catch (Throwable t) {
- return null;
- }
- }
- };
- propertyValue = AccessController.doPrivileged(action);
- } catch( Exception e ) {
- if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties");
- propertyValue = System.getProperty(propertyName);
- }
- } else {
- if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties");
- propertyValue = System.getProperty(propertyName);
- }
- return propertyValue;
- }
-
-
/** Load properties from a file.
This method tries to load properties from the filename give into
the passed properties object.
--- a/jdk/src/share/classes/com/sun/media/sound/Platform.java Wed Aug 06 21:46:17 2014 +0400
+++ b/jdk/src/share/classes/com/sun/media/sound/Platform.java Thu Aug 07 17:02:48 2014 +0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, 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
@@ -74,17 +74,6 @@
// intel is little-endian. sparc is big-endian.
private static boolean bigEndian;
- // this is the value of the "java.home" system property. i am looking it up here
- // for use when trying to load the soundbank, just so
- // that all the privileged code is localized in this file....
- private static String javahome;
-
- // this is the value of the "java.class.path" system property
- private static String classpath;
-
-
-
-
static {
if(Printer.trace)Printer.trace(">> Platform.java: static");
@@ -129,26 +118,6 @@
return signed8;
}
-
- /**
- * Obtain javahome.
- * $$kk: 04.16.99: this is *bad*!!
- */
- static String getJavahome() {
-
- return javahome;
- }
-
- /**
- * Obtain classpath.
- * $$jb: 04.21.99: this is *bad* too!!
- */
- static String getClasspath() {
-
- return classpath;
- }
-
-
// PRIVATE METHODS
/**
@@ -157,21 +126,13 @@
private static void loadLibraries() {
if(Printer.trace)Printer.trace(">>Platform.loadLibraries");
- try {
- // load the main library
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- System.loadLibrary(libNameMain);
- return null;
- }
- });
- // just for the heck of it...
- loadedLibs |= LIB_MAIN;
- } catch (SecurityException e) {
- if(Printer.err)Printer.err("Security exception loading main native library. JavaSound requires access to these resources.");
- throw(e);
- }
+ // load the main library
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ System.loadLibrary(libNameMain);
+ return null;
+ });
+ // just for the heck of it...
+ loadedLibs |= LIB_MAIN;
// now try to load extra libs. They are defined at compile time in the Makefile
// with the define EXTRA_SOUND_JNI_LIBS
@@ -181,12 +142,9 @@
while (st.hasMoreTokens()) {
final String lib = st.nextToken();
try {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- System.loadLibrary(lib);
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+ System.loadLibrary(lib);
+ return null;
});
if (lib.equals(libNameALSA)) {
@@ -239,7 +197,5 @@
// $$fb 2002-03-06: implement check for endianness in native. Facilitates porting !
bigEndian = nIsBigEndian();
signed8 = nIsSigned8(); // Solaris on Sparc: signed, all others unsigned
- javahome = JSSecurityManager.getProperty("java.home");
- classpath = JSSecurityManager.getProperty("java.class.path");
}
}
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Wed Aug 06 21:46:17 2014 +0400
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Thu Aug 07 17:02:48 2014 +0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, 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
@@ -28,6 +28,7 @@
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -732,31 +733,28 @@
* Save generated soundbank to disk for faster future use.
*/
OutputStream out = AccessController
- .doPrivileged(new PrivilegedAction<OutputStream>() {
- public OutputStream run() {
- try {
- File userhome = new File(System
- .getProperty("user.home"),
- ".gervill");
- if (!userhome.exists())
- userhome.mkdirs();
- File emg_soundbank_file = new File(
- userhome, "soundbank-emg.sf2");
- if (emg_soundbank_file.exists())
- return null;
- return new FileOutputStream(
- emg_soundbank_file);
- } catch (IOException e) {
- } catch (SecurityException e) {
+ .doPrivileged((PrivilegedAction<OutputStream>) () -> {
+ try {
+ File userhome = new File(System
+ .getProperty("user.home"), ".gervill");
+ if (!userhome.exists()) {
+ userhome.mkdirs();
}
- return null;
+ File emg_soundbank_file = new File(
+ userhome, "soundbank-emg.sf2");
+ if (emg_soundbank_file.exists()) {
+ return null;
+ }
+ return new FileOutputStream(emg_soundbank_file);
+ } catch (final FileNotFoundException ignored) {
}
+ return null;
});
if (out != null) {
try {
((SF2Soundbank) defaultSoundBank).save(out);
out.close();
- } catch (IOException e) {
+ } catch (final IOException ignored) {
}
}
}
@@ -846,26 +844,24 @@
private Properties getStoredProperties() {
return AccessController
- .doPrivileged(new PrivilegedAction<Properties>() {
- public Properties run() {
- Properties p = new Properties();
- String notePath = "/com/sun/media/sound/softsynthesizer";
- try {
- Preferences prefroot = Preferences.userRoot();
- if (prefroot.nodeExists(notePath)) {
- Preferences prefs = prefroot.node(notePath);
- String[] prefs_keys = prefs.keys();
- for (String prefs_key : prefs_keys) {
- String val = prefs.get(prefs_key, null);
- if (val != null)
- p.setProperty(prefs_key, val);
+ .doPrivileged((PrivilegedAction<Properties>) () -> {
+ Properties p = new Properties();
+ String notePath = "/com/sun/media/sound/softsynthesizer";
+ try {
+ Preferences prefroot = Preferences.userRoot();
+ if (prefroot.nodeExists(notePath)) {
+ Preferences prefs = prefroot.node(notePath);
+ String[] prefs_keys = prefs.keys();
+ for (String prefs_key : prefs_keys) {
+ String val = prefs.get(prefs_key, null);
+ if (val != null) {
+ p.setProperty(prefs_key, val);
}
}
- } catch (BackingStoreException e) {
- } catch (SecurityException e) {
}
- return p;
+ } catch (final BackingStoreException ignored) {
}
+ return p;
});
}
@@ -1044,7 +1040,6 @@
return;
}
synchronized (control_mutex) {
- Throwable causeException = null;
try {
if (line != null) {
// can throw IllegalArgumentException
@@ -1117,24 +1112,17 @@
weakstream.sourceDataLine = sourceDataLine;
}
- } catch (LineUnavailableException e) {
- causeException = e;
- } catch (IllegalArgumentException e) {
- causeException = e;
- } catch (SecurityException e) {
- causeException = e;
- }
-
- if (causeException != null) {
- if (isOpen())
+ } catch (final LineUnavailableException | SecurityException
+ | IllegalArgumentException e) {
+ if (isOpen()) {
close();
+ }
// am: need MidiUnavailableException(Throwable) ctor!
MidiUnavailableException ex = new MidiUnavailableException(
"Can not open line");
- ex.initCause(causeException);
+ ex.initCause(e);
throw ex;
}
-
}
}