() {
+ @Override
+ public ModifiableClassLoaderRepository run() {
+ return instantiator != null ? instantiator.getClassLoaderRepository() : null;
+ }
+ });
+ }
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java Wed Jun 19 11:04:39 2013 +0100
@@ -27,12 +27,14 @@
import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
+import java.security.Permission;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
+import javax.management.MBeanPermission;
import javax.management.ObjectName;
import javax.management.loading.PrivateClassLoader;
@@ -300,7 +302,19 @@
}
public final ClassLoader getClassLoader(ObjectName name) {
- return loadersWithNames.get(name);
+ ClassLoader instance = loadersWithNames.get(name);
+ if (instance != null) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ Permission perm =
+ new MBeanPermission(instance.getClass().getName(),
+ null,
+ name,
+ "getClassLoader");
+ sm.checkPermission(perm);
+ }
+ }
+ return instance;
}
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java Wed Jun 19 11:04:39 2013 +0100
@@ -33,6 +33,7 @@
import javax.management.MBeanException;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
+import sun.reflect.misc.MethodUtil;
final class ConvertingMethod {
static ConvertingMethod from(Method m) {
@@ -189,7 +190,7 @@
"from open values: " + e;
throw new MBeanException(e, msg);
}
- final Object javaReturn = method.invoke(obj, javaParams);
+ final Object javaReturn = MethodUtil.invoke(method, obj, javaParams);
try {
return returnMapping.toOpenValue(javaReturn);
} catch (OpenDataException e) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java Wed Jun 19 11:04:39 2013 +0100
@@ -74,6 +74,8 @@
import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
+import sun.reflect.misc.MethodUtil;
+import sun.reflect.misc.ReflectUtil;
/**
* A converter between Java types and the limited set of classes
@@ -299,6 +301,7 @@
private static > MXBeanMapping
makeEnumMapping(Class> enumClass, Class fake) {
+ ReflectUtil.checkPackageAccess(enumClass);
return new EnumMapping(Util.>cast(enumClass));
}
@@ -423,6 +426,7 @@
(c.getName().equals("com.sun.management.GcInfo") &&
c.getClassLoader() == null);
+ ReflectUtil.checkPackageAccess(c);
final List methods =
MBeanAnalyzer.eliminateCovariantMethods(Arrays.asList(c.getMethods()));
final SortedMap getterMap = newSortedMap();
@@ -828,7 +832,7 @@
Object[] values = new Object[getters.length];
for (int i = 0; i < getters.length; i++) {
try {
- Object got = getters[i].invoke(value, (Object[]) null);
+ Object got = MethodUtil.invoke(getters[i], value, (Object[]) null);
values[i] = getterMappings[i].toOpenValue(got);
} catch (Exception e) {
throw openDataException("Error calling getter for " +
@@ -1011,7 +1015,7 @@
MXBeanMapping[] converters)
throws InvalidObjectException {
try {
- return fromMethod.invoke(null, cd);
+ return MethodUtil.invoke(fromMethod, null, new Object[] {cd});
} catch (Exception e) {
final String msg = "Failed to invoke from(CompositeData)";
throw invalidObjectException(msg, e);
@@ -1107,13 +1111,15 @@
throws InvalidObjectException {
Object o;
try {
- o = getTargetClass().newInstance();
+ final Class> targetClass = getTargetClass();
+ ReflectUtil.checkPackageAccess(targetClass);
+ o = targetClass.newInstance();
for (int i = 0; i < itemNames.length; i++) {
if (cd.containsKey(itemNames[i])) {
Object openItem = cd.get(itemNames[i]);
Object javaItem =
converters[i].fromOpenValue(openItem);
- setters[i].invoke(o, javaItem);
+ MethodUtil.invoke(setters[i], o, new Object[] {javaItem});
}
}
} catch (Exception e) {
@@ -1363,6 +1369,7 @@
}
try {
+ ReflectUtil.checkPackageAccess(max.constructor.getDeclaringClass());
return max.constructor.newInstance(params);
} catch (Exception e) {
final String msg =
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java Wed Jun 19 11:04:39 2013 +0100
@@ -228,6 +228,11 @@
MXBeanIntrospector.getInstance().getAnalyzer(interfaceClass);
}
+ public static void testComplianceMBeanInterface(Class> interfaceClass)
+ throws NotCompliantMBeanException{
+ StandardMBeanIntrospector.getInstance().getAnalyzer(interfaceClass);
+ }
+
/**
* Basic method for testing if a given class is a JMX compliant
* Standard MBean. This method is only called by the legacy code
@@ -248,6 +253,7 @@
throws NotCompliantMBeanException {
if (mbeanInterface == null)
mbeanInterface = getStandardMBeanInterface(baseClass);
+ ReflectUtil.checkPackageAccess(mbeanInterface);
MBeanIntrospector> introspector = StandardMBeanIntrospector.getInstance();
return getClassMBeanInfo(introspector, baseClass, mbeanInterface);
}
@@ -372,13 +378,19 @@
for (Annotation a : annots) {
Class extends Annotation> c = a.annotationType();
Method[] elements = c.getMethods();
+ boolean packageAccess = false;
for (Method element : elements) {
DescriptorKey key = element.getAnnotation(DescriptorKey.class);
if (key != null) {
String name = key.value();
Object value;
try {
- value = element.invoke(a);
+ // Avoid checking access more than once per annotation
+ if (!packageAccess) {
+ ReflectUtil.checkPackageAccess(c);
+ packageAccess = true;
+ }
+ value = MethodUtil.invoke(element, a, null);
} catch (RuntimeException e) {
// we don't expect this - except for possibly
// security exceptions?
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java Wed Jun 19 11:04:39 2013 +0100
@@ -32,6 +32,7 @@
import java.io.ObjectInputStream;
import java.security.AccessController;
import java.security.Permission;
+import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Set;
@@ -227,8 +228,16 @@
clr = new ClassLoaderRepositorySupport();
instantiator = new MBeanInstantiator(clr);
}
+
+ final MBeanInstantiator fInstantiator = instantiator;
this.secureClr = new
- SecureClassLoaderRepository(instantiator.getClassLoaderRepository());
+ SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public ClassLoaderRepository run() {
+ return fInstantiator.getClassLoaderRepository();
+ }
+ })
+ );
if (delegate == null)
delegate = new MBeanServerDelegateImpl();
if (outer == null)
@@ -1242,8 +1251,14 @@
class loader. The ClassLoaderRepository knows how
to handle that case. */
ClassLoader myLoader = outerShell.getClass().getClassLoader();
- final ModifiableClassLoaderRepository loaders =
- instantiator.getClassLoaderRepository();
+ final ModifiableClassLoaderRepository loaders = AccessController.doPrivileged(new PrivilegedAction() {
+
+ @Override
+ public ModifiableClassLoaderRepository run() {
+ return instantiator.getClassLoaderRepository();
+ }
+ });
+
if (loaders != null) {
loaders.addClassLoader(myLoader);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Wed Jun 19 11:04:39 2013 +0100
@@ -33,7 +33,12 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
+import java.security.AccessControlContext;
+import java.security.AccessController;
import java.security.Permission;
+import java.security.Permissions;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
import java.util.Map;
import java.util.logging.Level;
@@ -127,9 +132,8 @@
// Retrieve the class loader from the repository
ClassLoader loader = null;
- synchronized(this) {
- if (clr!=null)
- loader = clr.getClassLoader(aLoader);
+ synchronized (this) {
+ loader = getClassLoader(aLoader);
}
if (loader == null) {
throw new InstanceNotFoundException("The loader named " +
@@ -429,8 +433,7 @@
try {
ClassLoader instance = null;
- if (clr!=null)
- instance = clr.getClassLoader(loaderName);
+ instance = getClassLoader(loaderName);
if (instance == null)
throw new ClassNotFoundException(className);
theClass = Class.forName(className, false, instance);
@@ -622,6 +625,7 @@
* Return the Default Loader Repository used by this instantiator object.
**/
public ModifiableClassLoaderRepository getClassLoaderRepository() {
+ checkMBeanPermission((String)null, null, null, "getClassLoaderRepository");
return clr;
}
@@ -733,9 +737,19 @@
String member,
ObjectName objectName,
String actions) {
+ if (clazz != null) {
+ checkMBeanPermission(clazz.getName(), member, objectName, actions);
+ }
+ }
+
+ private static void checkMBeanPermission(String classname,
+ String member,
+ ObjectName objectName,
+ String actions)
+ throws SecurityException {
SecurityManager sm = System.getSecurityManager();
- if (clazz != null && sm != null) {
- Permission perm = new MBeanPermission(clazz.getName(),
+ if (sm != null) {
+ Permission perm = new MBeanPermission(classname,
member,
objectName,
actions);
@@ -751,4 +765,22 @@
throw new IllegalAccessException("Class is not public and can't be instantiated");
}
}
+
+ private ClassLoader getClassLoader(final ObjectName name) {
+ if(clr == null){
+ return null;
+ }
+ // Restrict to getClassLoader permission only
+ Permissions permissions = new Permissions();
+ permissions.add(new MBeanPermission("*", null, name, "getClassLoader"));
+ ProtectionDomain protectionDomain = new ProtectionDomain(null, permissions);
+ ProtectionDomain[] domains = {protectionDomain};
+ AccessControlContext ctx = new AccessControlContext(domains);
+ ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction() {
+ public ClassLoader run() {
+ return clr.getClassLoader(name);
+ }
+ }, ctx);
+ return loader;
+ }
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java Wed Jun 19 11:04:39 2013 +0100
@@ -51,6 +51,7 @@
import javax.management.NotCompliantMBeanException;
import javax.management.NotificationBroadcaster;
import javax.management.ReflectionException;
+import sun.reflect.misc.ReflectUtil;
/**
* An introspector for MBeans of a certain type. There is one instance
@@ -175,7 +176,8 @@
/**
* Get the methods to be analyzed to build the MBean interface.
*/
- List getMethods(final Class> mbeanType) {
+ final List getMethods(final Class> mbeanType) {
+ ReflectUtil.checkPackageAccess(mbeanType);
return Arrays.asList(mbeanType.getMethods());
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java Wed Jun 19 11:04:39 2013 +0100
@@ -30,7 +30,7 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
-import java.io.StreamCorruptedException;
+import sun.reflect.misc.ReflectUtil;
/**
* This class deserializes an object in the context of a specific class loader.
@@ -61,6 +61,7 @@
return super.resolveClass(aClass);
} else {
String name = aClass.getName();
+ ReflectUtil.checkPackageAccess(name);
// Query the class loader ...
return Class.forName(name, false, loader);
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java Wed Jun 19 11:04:39 2013 +0100
@@ -38,6 +38,7 @@
import javax.management.NotCompliantMBeanException;
import javax.management.NotificationBroadcaster;
import javax.management.NotificationBroadcasterSupport;
+import sun.reflect.misc.MethodUtil;
/**
* @since 1.6
@@ -108,7 +109,7 @@
Object invokeM2(Method m, Object target, Object[] args, Object cookie)
throws InvocationTargetException, IllegalAccessException,
MBeanException {
- return m.invoke(target, args);
+ return MethodUtil.invoke(m, target, args);
}
@Override
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -397,6 +397,20 @@
if (nextSeq < nextSequenceNumber()) {
candidate = notificationAt(nextSeq);
+ // Skip security check if NotificationBufferFilter is not overloaded
+ if (!(filter instanceof ServerNotifForwarder.NotifForwarderBufferFilter)) {
+ try {
+ ServerNotifForwarder.checkMBeanPermission(this.mBeanServer,
+ candidate.getObjectName(),"addNotificationListener");
+ } catch (InstanceNotFoundException | SecurityException e) {
+ if (logger.debugOn()) {
+ logger.debug("fetchNotifications", "candidate: " + candidate + " skipped. exception " + e);
+ }
+ ++nextSeq;
+ continue;
+ }
+ }
+
if (logger.debugOn()) {
logger.debug("fetchNotifications", "candidate: " +
candidate);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -226,8 +226,9 @@
* why we add the found notifications to a supplied List rather than
* just returning a boolean.
*/
- private final NotificationBufferFilter bufferFilter =
- new NotificationBufferFilter() {
+ private final NotifForwarderBufferFilter bufferFilter = new NotifForwarderBufferFilter();
+
+ final class NotifForwarderBufferFilter implements NotificationBufferFilter {
public void apply(List targetedNotifs,
ObjectName source, Notification notif) {
// We proceed in two stages here, to avoid holding the listenerMap
@@ -366,9 +367,16 @@
* Explicitly check the MBeanPermission for
* the current access control context.
*/
- public void checkMBeanPermission(
+ public final void checkMBeanPermission(
final ObjectName name, final String actions)
throws InstanceNotFoundException, SecurityException {
+ checkMBeanPermission(mbeanServer,name,actions);
+ }
+
+ static void checkMBeanPermission(
+ final MBeanServer mbs, final ObjectName name, final String actions)
+ throws InstanceNotFoundException, SecurityException {
+
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
AccessControlContext acc = AccessController.getContext();
@@ -378,7 +386,7 @@
new PrivilegedExceptionAction() {
public ObjectInstance run()
throws InstanceNotFoundException {
- return mbeanServer.getObjectInstance(name);
+ return mbs.getObjectInstance(name);
}
});
} catch (PrivilegedActionException e) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java
--- a/jdk/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java Wed Jun 19 11:04:39 2013 +0100
@@ -25,6 +25,8 @@
package com.sun.jmx.remote.util;
+import sun.reflect.misc.ReflectUtil;
+
public class OrderClassLoaders extends ClassLoader {
public OrderClassLoaders(ClassLoader cl1, ClassLoader cl2) {
super(cl1);
@@ -32,9 +34,10 @@
this.cl2 = cl2;
}
- protected Class> findClass(String name) throws ClassNotFoundException {
+ protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ ReflectUtil.checkPackageAccess(name);
try {
- return super.findClass(name);
+ return super.loadClass(name, resolve);
} catch (ClassNotFoundException cne) {
if (cl2 != null) {
return cl2.loadClass(name);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java
--- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java Wed Jun 19 11:04:39 2013 +0100
@@ -396,7 +396,7 @@
// do we need to begin with the first token?
if(proto.charAt(0) != WILDCARD_TOKEN &&
- !value.toString().toLowerCase(Locale.ENGLISH).startsWith(
+ !value.toLowerCase(Locale.ENGLISH).startsWith(
subStrs.nextToken().toLowerCase(Locale.ENGLISH))) {
if(debug) {
System.out.println("faild initial test");
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,15 +25,12 @@
package com.sun.media.sound;
-import java.util.Vector;
-
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Control;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException;
-import javax.sound.sampled.Mixer;
/**
@@ -46,13 +43,13 @@
// DEFAULTS
// default format
- protected /*final*/ AudioFormat defaultFormat;
+ private final AudioFormat defaultFormat;
// default buffer size in bytes
- protected /*final*/ int defaultBufferSize;
+ private final int defaultBufferSize;
// the lock for synchronization
- protected Object lock = new Object();
+ protected final Object lock = new Object();
// STATE
@@ -103,7 +100,7 @@
// DATA LINE METHODS
- public void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
+ public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());
@@ -152,7 +149,7 @@
}
- public void open(AudioFormat format) throws LineUnavailableException {
+ public final void open(AudioFormat format) throws LineUnavailableException {
open(format, AudioSystem.NOT_SPECIFIED);
}
@@ -181,7 +178,7 @@
}
- public void start() {
+ public final void start() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".start() - AbstractDataLine");
@@ -205,7 +202,7 @@
}
- public void stop() {
+ public final void stop() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
@@ -249,16 +246,16 @@
// in MixerSourceLine and MixerClip, and I want to touch as little
// code as possible to change isStarted() back to isRunning().
- public boolean isRunning() {
+ public final boolean isRunning() {
return started;
}
- public boolean isActive() {
+ public final boolean isActive() {
return active;
}
- public long getMicrosecondPosition() {
+ public final long getMicrosecondPosition() {
long microseconds = getLongFramePosition();
if (microseconds != AudioSystem.NOT_SPECIFIED) {
@@ -268,26 +265,26 @@
}
- public AudioFormat getFormat() {
+ public final AudioFormat getFormat() {
return format;
}
- public int getBufferSize() {
+ public final int getBufferSize() {
return bufferSize;
}
/**
* This implementation does NOT change the buffer size
*/
- public int setBufferSize(int newSize) {
+ public final int setBufferSize(int newSize) {
return getBufferSize();
}
/**
* This implementation returns AudioSystem.NOT_SPECIFIED.
*/
- public float getLevel() {
+ public final float getLevel() {
return (float)AudioSystem.NOT_SPECIFIED;
}
@@ -304,7 +301,7 @@
// it to isStartedRunning(). This is part of backing out the
// change denied in RFE 4297981.
- protected boolean isStartedRunning() {
+ final boolean isStartedRunning() {
return running;
}
@@ -312,7 +309,7 @@
* This method sets the active state and generates
* events if it changes.
*/
- protected void setActive(boolean active) {
+ final void setActive(boolean active) {
if (Printer.trace) Printer.trace("> AbstractDataLine: setActive(" + active + ")");
@@ -351,7 +348,7 @@
* This method sets the started state and generates
* events if it changes.
*/
- protected void setStarted(boolean started) {
+ final void setStarted(boolean started) {
if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")");
@@ -388,7 +385,7 @@
* This method generates a STOP event and sets the started state to false.
* It is here for historic reasons when an EOM event existed.
*/
- protected void setEOM() {
+ final void setEOM() {
if (Printer.trace) Printer.trace("> AbstractDataLine: setEOM()");
//$$fb 2002-04-21: sometimes, 2 STOP events are generated.
@@ -408,7 +405,7 @@
* line is open, this should return quietly because the values
* requested will match the current ones.
*/
- public void open() throws LineUnavailableException {
+ public final void open() throws LineUnavailableException {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine");
@@ -422,7 +419,7 @@
* This should also stop the line. The closed line should not be running or active.
* After we close the line, we reset the format and buffer size to the defaults.
*/
- public void close() {
+ public final void close() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".close() - in AbstractDataLine.");
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AbstractLine.java
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,11 +25,12 @@
package com.sun.media.sound;
+import java.util.Map;
import java.util.Vector;
+import java.util.WeakHashMap;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Control;
-import javax.sound.sampled.Mixer;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
@@ -43,28 +44,17 @@
*/
abstract class AbstractLine implements Line {
- protected Line.Info info;
+ protected final Line.Info info;
protected Control[] controls;
- protected AbstractMixer mixer;
+ AbstractMixer mixer;
private boolean open = false;
- private Vector listeners = new Vector();
+ private final Vector listeners = new Vector();
/**
- * Global event thread
+ * Contains event dispatcher per thread group.
*/
- private static final EventDispatcher eventDispatcher;
-
- static {
- // create and start the global event thread
-
- // $$kk: 12.21.98:
- // 1) probably don't want a single global event queue
- // 2) need a way to stop this thread when the engine is done
-
- eventDispatcher = new EventDispatcher();
- eventDispatcher.start();
- }
-
+ private static final Map dispatchers =
+ new WeakHashMap<>();
/**
* Constructs a new AbstractLine.
@@ -85,18 +75,17 @@
// LINE METHODS
- public Line.Info getLineInfo() {
+ public final Line.Info getLineInfo() {
return info;
}
- public boolean isOpen() {
+ public final boolean isOpen() {
return open;
}
- public void addLineListener(LineListener listener) {
-
+ public final void addLineListener(LineListener listener) {
synchronized(listeners) {
if ( ! (listeners.contains(listener)) ) {
listeners.addElement(listener);
@@ -109,7 +98,7 @@
* Removes an audio listener.
* @param listener listener to remove
*/
- public void removeLineListener(LineListener listener) {
+ public final void removeLineListener(LineListener listener) {
listeners.removeElement(listener);
}
@@ -120,8 +109,7 @@
* array of length 0.
* @return control set
*/
- public Control[] getControls() {
-
+ public final Control[] getControls() {
Control[] returnedArray = new Control[controls.length];
for (int i = 0; i < controls.length; i++) {
@@ -132,8 +120,7 @@
}
- public boolean isControlSupported(Control.Type controlType) {
-
+ public final boolean isControlSupported(Control.Type controlType) {
// protect against a NullPointerException
if (controlType == null) {
return false;
@@ -149,8 +136,7 @@
}
- public Control getControl(Control.Type controlType) {
-
+ public final Control getControl(Control.Type controlType) {
// protect against a NullPointerException
if (controlType != null) {
@@ -172,7 +158,7 @@
* This method sets the open state and generates
* events if it changes.
*/
- protected void setOpen(boolean open) {
+ final void setOpen(boolean open) {
if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open);
@@ -200,8 +186,8 @@
/**
* Send line events.
*/
- protected void sendEvents(LineEvent event) {
- eventDispatcher.sendAudioEvents(event, listeners);
+ final void sendEvents(LineEvent event) {
+ getEventDispatcher().sendAudioEvents(event, listeners);
}
@@ -227,12 +213,23 @@
// $$kk: 06.03.99: returns the mixer used in construction.
// this is a hold-over from when there was a public method like
// this on line and should be fixed!!
- protected AbstractMixer getMixer() {
+ final AbstractMixer getMixer() {
return mixer;
}
- protected EventDispatcher getEventDispatcher() {
- return eventDispatcher;
+ final EventDispatcher getEventDispatcher() {
+ // create and start the global event thread
+ //TODO need a way to stop this thread when the engine is done
+ final ThreadGroup tg = Thread.currentThread().getThreadGroup();
+ synchronized (dispatchers) {
+ EventDispatcher eventDispatcher = dispatchers.get(tg);
+ if (eventDispatcher == null) {
+ eventDispatcher = new EventDispatcher();
+ dispatchers.put(tg, eventDispatcher);
+ eventDispatcher.start();
+ }
+ return eventDispatcher;
+ }
}
// ABSTRACT METHODS
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -60,12 +60,12 @@
// DEVICE ATTRIBUTES
- private MidiDevice.Info info;
+ private final MidiDevice.Info info;
// DEVICE STATE
- protected /*private*/ boolean open = false;
+ private boolean open = false;
private int openRefCount;
/** List of Receivers and Transmitters that opened the device implicitely.
@@ -102,7 +102,7 @@
// MIDI DEVICE METHODS
- public MidiDevice.Info getDeviceInfo() {
+ public final MidiDevice.Info getDeviceInfo() {
return info;
}
@@ -111,7 +111,7 @@
* opened the the device implicitly from closing it. The only way to close the device after
* this call is a call to close().
*/
- public void open() throws MidiUnavailableException {
+ public final void open() throws MidiUnavailableException {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: open()");
synchronized(this) {
openRefCount = -1;
@@ -159,7 +159,7 @@
}
- public void close() {
+ public final void close() {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: close()");
synchronized (this) {
doClose();
@@ -181,7 +181,7 @@
* @param object The object that might have been opening the device implicitely (for now,
* this may be a Transmitter or receiver).
*/
- public void closeInternal(Object object) {
+ public final void closeInternal(Object object) {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: closeInternal()");
synchronized(this) {
if (getOpenKeepingObjects().remove(object)) {
@@ -197,7 +197,7 @@
}
- public void doClose() {
+ public final void doClose() {
if (Printer.trace) Printer.trace("> AbstractMidiDevice: doClose()");
synchronized(this) {
if (isOpen()) {
@@ -209,7 +209,7 @@
}
- public boolean isOpen() {
+ public final boolean isOpen() {
return open;
}
@@ -329,7 +329,7 @@
// HELPER METHODS
- long getId() {
+ final long getId() {
return id;
}
@@ -339,7 +339,8 @@
/** Retrieve a Receiver and open the device implicitly.
This method is called by MidiSystem.getReceiver().
*/
- public Receiver getReceiverReferenceCounting() throws MidiUnavailableException {
+ public final Receiver getReceiverReferenceCounting()
+ throws MidiUnavailableException {
/* Keep this order of commands! If getReceiver() throws an exception,
openInternal() should not be called!
*/
@@ -355,7 +356,8 @@
/** Retrieve a Transmitter and open the device implicitly.
This method is called by MidiSystem.getTransmitter().
*/
- public Transmitter getTransmitterReferenceCounting() throws MidiUnavailableException {
+ public final Transmitter getTransmitterReferenceCounting()
+ throws MidiUnavailableException {
/* Keep this order of commands! If getTransmitter() throws an exception,
openInternal() should not be called!
*/
@@ -422,7 +424,7 @@
/** Return the internal list of Transmitters, possibly creating it first.
*/
- protected TransmitterList getTransmitterList() {
+ final TransmitterList getTransmitterList() {
synchronized (traRecLock) {
if (transmitterList == null) {
transmitterList = new TransmitterList();
@@ -462,7 +464,7 @@
/**
* close this device if discarded by the garbage collector
*/
- protected void finalize() {
+ protected final void finalize() {
close();
}
@@ -534,7 +536,7 @@
* Also, it has some optimizations regarding sending to the Receivers,
* for known Receivers, and managing itself in the TransmitterList.
*/
- protected class BasicTransmitter implements MidiDeviceTransmitter {
+ class BasicTransmitter implements MidiDeviceTransmitter {
private Receiver receiver = null;
TransmitterList tlist = null;
@@ -546,7 +548,7 @@
this.tlist = tlist;
}
- public void setReceiver(Receiver receiver) {
+ public final void setReceiver(Receiver receiver) {
if (tlist != null && this.receiver != receiver) {
if (Printer.debug) Printer.debug("Transmitter "+toString()+": set receiver "+receiver);
tlist.receiverChanged(this, this.receiver, receiver);
@@ -554,7 +556,7 @@
}
}
- public Receiver getReceiver() {
+ public final Receiver getReceiver() {
return receiver;
}
@@ -564,7 +566,7 @@
* Therefore, subclasses that override this method must call
* 'super.close()'.
*/
- public void close() {
+ public final void close() {
AbstractMidiDevice.this.closeInternal(this);
if (tlist != null) {
tlist.receiverChanged(this, this.receiver, null);
@@ -573,7 +575,7 @@
}
}
- public MidiDevice getMidiDevice() {
+ public final MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
@@ -583,9 +585,9 @@
/**
* a class to manage a list of transmitters
*/
- class TransmitterList {
+ final class TransmitterList {
- private ArrayList transmitters = new ArrayList();
+ private final ArrayList transmitters = new ArrayList();
private MidiOutDevice.MidiOutReceiver midiOutReceiver;
// how many transmitters must be present for optimized
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -36,7 +36,7 @@
*/
public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
- private static boolean enabled;
+ private static final boolean enabled;
/**
* Create objects representing all MIDI output devices on the system.
@@ -52,7 +52,7 @@
}
- synchronized void readDeviceInfos() {
+ final synchronized void readDeviceInfos() {
Info[] infos = getInfoCache();
MidiDevice[] devices = getDeviceCache();
if (!enabled) {
@@ -118,7 +118,7 @@
}
- public MidiDevice.Info[] getDeviceInfo() {
+ public final MidiDevice.Info[] getDeviceInfo() {
readDeviceInfos();
Info[] infos = getInfoCache();
MidiDevice.Info[] localArray = new MidiDevice.Info[infos.length];
@@ -127,7 +127,7 @@
}
- public MidiDevice getDevice(MidiDevice.Info info) {
+ public final MidiDevice getDevice(MidiDevice.Info info) {
if (info instanceof Info) {
readDeviceInfos();
MidiDevice[] devices = getDeviceCache();
@@ -164,7 +164,7 @@
this.index = index;
}
- boolean equalStrings(Info info) {
+ final boolean equalStrings(Info info) {
return (info != null
&& getName().equals(info.getName())
&& getVendor().equals(info.getVendor())
@@ -172,11 +172,11 @@
&& getVersion().equals(info.getVersion()));
}
- int getIndex() {
+ final int getIndex() {
return index;
}
- void setIndex(int index) {
+ final void setIndex(int index) {
this.index = index;
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -27,14 +27,9 @@
import java.util.Vector;
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Control;
-import javax.sound.sampled.DataLine;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.Line;
-import javax.sound.sampled.LineEvent;
-import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
/**
@@ -95,13 +90,13 @@
/**
* Source lines (ports) currently open
*/
- protected Vector sourceLines = new Vector();
+ private final Vector sourceLines = new Vector();
/**
* Target lines currently open.
*/
- protected Vector targetLines = new Vector();
+ private final Vector targetLines = new Vector();
/**
@@ -133,19 +128,19 @@
// MIXER METHODS
- public Mixer.Info getMixerInfo() {
+ public final Mixer.Info getMixerInfo() {
return mixerInfo;
}
- public Line.Info[] getSourceLineInfo() {
+ public final Line.Info[] getSourceLineInfo() {
Line.Info[] localArray = new Line.Info[sourceLineInfo.length];
System.arraycopy(sourceLineInfo, 0, localArray, 0, sourceLineInfo.length);
return localArray;
}
- public Line.Info[] getTargetLineInfo() {
+ public final Line.Info[] getTargetLineInfo() {
Line.Info[] localArray = new Line.Info[targetLineInfo.length];
System.arraycopy(targetLineInfo, 0, localArray, 0, targetLineInfo.length);
@@ -153,7 +148,7 @@
}
- public Line.Info[] getSourceLineInfo(Line.Info info) {
+ public final Line.Info[] getSourceLineInfo(Line.Info info) {
int i;
Vector vec = new Vector();
@@ -174,7 +169,7 @@
}
- public Line.Info[] getTargetLineInfo(Line.Info info) {
+ public final Line.Info[] getTargetLineInfo(Line.Info info) {
int i;
Vector vec = new Vector();
@@ -195,7 +190,7 @@
}
- public boolean isLineSupported(Line.Info info) {
+ public final boolean isLineSupported(Line.Info info) {
int i;
@@ -227,7 +222,7 @@
protected abstract void implClose();
- public Line[] getSourceLines() {
+ public final Line[] getSourceLines() {
Line[] localLines;
@@ -244,7 +239,7 @@
}
- public Line[] getTargetLines() {
+ public final Line[] getTargetLines() {
Line[] localLines;
@@ -264,7 +259,7 @@
/**
* Default implementation always throws an exception.
*/
- public void synchronize(Line[] lines, boolean maintainSync) {
+ public final void synchronize(Line[] lines, boolean maintainSync) {
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
@@ -272,7 +267,7 @@
/**
* Default implementation always throws an exception.
*/
- public void unsynchronize(Line[] lines) {
+ public final void unsynchronize(Line[] lines) {
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
@@ -280,7 +275,8 @@
/**
* Default implementation always returns false.
*/
- public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync) {
+ public final boolean isSynchronizationSupported(Line[] lines,
+ boolean maintainSync) {
return false;
}
@@ -290,14 +286,14 @@
/**
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
- public synchronized void open() throws LineUnavailableException {
+ public final synchronized void open() throws LineUnavailableException {
open(true);
}
/**
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
- protected synchronized void open(boolean manual) throws LineUnavailableException {
+ final synchronized void open(boolean manual) throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> AbstractMixer: open()");
if (!isOpen()) {
implOpen();
@@ -322,7 +318,7 @@
* The mixer may be opened at a format different than the line's
* format if it is a DataLine.
*/
- protected synchronized void open(Line line) throws LineUnavailableException {
+ final synchronized void open(Line line) throws LineUnavailableException {
if (Printer.trace) Printer.trace(">> AbstractMixer: open(line = " + line + ")");
@@ -367,7 +363,7 @@
* open target lines, if it exists in either.
* If the list is now empty, closes the mixer.
*/
- protected synchronized void close(Line line) {
+ final synchronized void close(Line line) {
if (Printer.trace) Printer.trace(">> AbstractMixer: close(" + line + ")");
@@ -396,7 +392,7 @@
/**
* Close all lines and then close this mixer.
*/
- public synchronized void close() {
+ public final synchronized void close() {
if (Printer.trace) Printer.trace(">> AbstractMixer: close()");
if (isOpen()) {
// close all source lines
@@ -423,7 +419,7 @@
/**
* Starts the mixer.
*/
- protected synchronized void start(Line line) {
+ final synchronized void start(Line line) {
if (Printer.trace) Printer.trace(">> AbstractMixer: start(" + line + ")");
@@ -447,7 +443,7 @@
/**
* Stops the mixer if this was the last running line.
*/
- protected synchronized void stop(Line line) {
+ final synchronized void stop(Line line) {
if (Printer.trace) Printer.trace(">> AbstractMixer: stop(" + line + ")");
@@ -501,7 +497,7 @@
* Right now this just checks whether it's supported, but should
* check whether it actually belongs to this mixer....
*/
- boolean isSourceLine(Line.Info info) {
+ final boolean isSourceLine(Line.Info info) {
for (int i = 0; i < sourceLineInfo.length; i++) {
if (info.matches(sourceLineInfo[i])) {
@@ -518,7 +514,7 @@
* Right now this just checks whether it's supported, but should
* check whether it actually belongs to this mixer....
*/
- boolean isTargetLine(Line.Info info) {
+ final boolean isTargetLine(Line.Info info) {
for (int i = 0; i < targetLineInfo.length; i++) {
if (info.matches(targetLineInfo[i])) {
@@ -535,7 +531,7 @@
* matches the one specified, or null if no matching Line.Info
* object is found.
*/
- Line.Info getLineInfo(Line.Info info) {
+ final Line.Info getLineInfo(Line.Info info) {
if (info == null) {
return null;
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java
--- a/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -35,7 +35,7 @@
* @author Jan Borgersen
*/
-class AiffFileFormat extends AudioFileFormat {
+final class AiffFileFormat extends AudioFileFormat {
static final int AIFF_MAGIC = 1179603533;
@@ -62,13 +62,13 @@
//$$fb 2001-07-13: added management of header size in this class
/** header size in bytes */
- private int headerSize=AIFF_HEADERSIZE;
+ private final int headerSize=AIFF_HEADERSIZE;
/** comm chunk size in bytes, inclusive magic and length field */
- private int commChunkSize=26;
+ private final int commChunkSize=26;
/** FVER chunk size in bytes, inclusive magic and length field */
- private int fverChunkSize=0;
+ private final int fverChunkSize=0;
AiffFileFormat( AudioFileFormat aff ) {
this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,28 +25,17 @@
package com.sun.media.sound;
-import java.util.Vector;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.EOFException;
import java.net.URL;
-import java.net.MalformedURLException;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.io.DataOutputStream;
-import java.io.FileOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.SequenceInputStream;
import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -58,19 +47,10 @@
* @author Jan Borgersen
* @author Florian Bomers
*/
-public class AiffFileReader extends SunFileReader {
+public final class AiffFileReader extends SunFileReader {
private static final int MAX_READ_LENGTH = 8;
-
- /**
- * AIFF parser type
- */
- public static final AudioFileFormat.Type types[] = {
- AudioFileFormat.Type.AIFF
- };
-
-
/**
* Constructs a new AiffParser object.
*/
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -50,21 +50,13 @@
*
* @author Jan Borgersen
*/
-public class AiffFileWriter extends SunFileWriter {
-
- /**
- * AIFF type
- */
- private static final AudioFileFormat.Type aiffTypes[] = {
- AudioFileFormat.Type.AIFF
- };
-
+public final class AiffFileWriter extends SunFileWriter {
/**
* Constructs a new AiffFileWriter object.
*/
public AiffFileWriter() {
- super(aiffTypes);
+ super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AIFF});
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AlawCodec.java
--- a/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,14 +25,12 @@
package com.sun.media.sound;
-import java.io.InputStream;
import java.io.IOException;
-
import java.util.Vector;
import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioInputStream;
/**
@@ -40,12 +38,12 @@
*
* @author Kara Kytle
*/
-public class AlawCodec extends SunCodec {
+public final class AlawCodec extends SunCodec {
/* Tables used for A-law decoding */
- final static byte ALAW_TABH[] = new byte[256];
- final static byte ALAW_TABL[] = new byte[256];
+ private static final byte[] ALAW_TABH = new byte[256];
+ private static final byte[] ALAW_TABL = new byte[256];
private static final AudioFormat.Encoding[] alawEncodings = { AudioFormat.Encoding.ALAW, AudioFormat.Encoding.PCM_SIGNED };
@@ -256,7 +254,7 @@
}
- class AlawCodecStream extends AudioInputStream {
+ final class AlawCodecStream extends AudioInputStream {
// tempBuffer required only for encoding (when encode is true)
private static final int tempBufferSize = 64;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java
--- a/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -36,7 +36,7 @@
* @author Jan Borgersen
*/
-class AuFileFormat extends AudioFileFormat {
+final class AuFileFormat extends AudioFileFormat {
// magic numbers
static final int AU_SUN_MAGIC = 0x2e736e64;
@@ -60,7 +60,7 @@
static final int AU_HEADERSIZE = 24;
- int auType;
+ private int auType;
AuFileFormat( AudioFileFormat aff ) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AuFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,28 +25,17 @@
package com.sun.media.sound;
-import java.util.Vector;
+import java.io.BufferedInputStream;
+import java.io.DataInputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.EOFException;
import java.net.URL;
-import java.net.MalformedURLException;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.io.DataOutputStream;
-import java.io.FileOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.SequenceInputStream;
import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -58,16 +47,7 @@
* @author Jan Borgersen
* @author Florian Bomers
*/
-public class AuFileReader extends SunFileReader {
-
- /**
- * AU reader type
- */
-
- public static final AudioFileFormat.Type types[] = {
- AudioFileFormat.Type.AU
- };
-
+public final class AuFileReader extends SunFileReader {
/**
* Constructs a new AuFileReader object.
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -49,28 +49,18 @@
*
* @author Jan Borgersen
*/
-public class AuFileWriter extends SunFileWriter {
+public final class AuFileWriter extends SunFileWriter {
//$$fb value for length field if length is not known
public final static int UNKNOWN_SIZE=-1;
/**
- * AU type
- */
- private static final AudioFileFormat.Type auTypes[] = {
- AudioFileFormat.Type.AU
- };
-
-
- /**
* Constructs a new AuFileWriter object.
*/
public AuFileWriter() {
- super(auTypes);
+ super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
}
-
-
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {
AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -43,7 +43,7 @@
*
* @author Karl Helgason
*/
-public class AudioFileSoundbankReader extends SoundbankReader {
+public final class AudioFileSoundbankReader extends SoundbankReader {
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java
--- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -51,7 +51,7 @@
private static class AudioFloatLSBFilter extends AudioFloatConverter {
- private AudioFloatConverter converter;
+ private final AudioFloatConverter converter;
final private int offset;
@@ -61,8 +61,7 @@
private byte[] mask_buffer;
- public AudioFloatLSBFilter(AudioFloatConverter converter,
- AudioFormat format) {
+ AudioFloatLSBFilter(AudioFloatConverter converter, AudioFormat format) {
int bits = format.getSampleSizeInBits();
boolean bigEndian = format.isBigEndian();
this.converter = converter;
@@ -740,7 +739,7 @@
final int xbytes;
- public AudioFloatConversion32xSL(int xbytes) {
+ AudioFloatConversion32xSL(int xbytes) {
this.xbytes = xbytes;
}
@@ -781,7 +780,7 @@
final int xbytes;
- public AudioFloatConversion32xSB(int xbytes) {
+ AudioFloatConversion32xSB(int xbytes) {
this.xbytes = xbytes;
}
@@ -823,7 +822,7 @@
final int xbytes;
- public AudioFloatConversion32xUL(int xbytes) {
+ AudioFloatConversion32xUL(int xbytes) {
this.xbytes = xbytes;
}
@@ -866,7 +865,7 @@
final int xbytes;
- public AudioFloatConversion32xUB(int xbytes) {
+ AudioFloatConversion32xUB(int xbytes) {
this.xbytes = xbytes;
}
@@ -1008,49 +1007,51 @@
private AudioFormat format;
- public AudioFormat getFormat() {
+ public final AudioFormat getFormat() {
return format;
}
public abstract float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_offset, int out_len);
- public float[] toFloatArray(byte[] in_buff, float[] out_buff,
+ public final float[] toFloatArray(byte[] in_buff, float[] out_buff,
int out_offset, int out_len) {
return toFloatArray(in_buff, 0, out_buff, out_offset, out_len);
}
- public float[] toFloatArray(byte[] in_buff, int in_offset,
+ public final float[] toFloatArray(byte[] in_buff, int in_offset,
float[] out_buff, int out_len) {
return toFloatArray(in_buff, in_offset, out_buff, 0, out_len);
}
- public float[] toFloatArray(byte[] in_buff, float[] out_buff, int out_len) {
+ public final float[] toFloatArray(byte[] in_buff, float[] out_buff,
+ int out_len) {
return toFloatArray(in_buff, 0, out_buff, 0, out_len);
}
- public float[] toFloatArray(byte[] in_buff, float[] out_buff) {
+ public final float[] toFloatArray(byte[] in_buff, float[] out_buff) {
return toFloatArray(in_buff, 0, out_buff, 0, out_buff.length);
}
public abstract byte[] toByteArray(float[] in_buff, int in_offset,
int in_len, byte[] out_buff, int out_offset);
- public byte[] toByteArray(float[] in_buff, int in_len, byte[] out_buff,
- int out_offset) {
+ public final byte[] toByteArray(float[] in_buff, int in_len,
+ byte[] out_buff, int out_offset) {
return toByteArray(in_buff, 0, in_len, out_buff, out_offset);
}
- public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
- byte[] out_buff) {
+ public final byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
+ byte[] out_buff) {
return toByteArray(in_buff, in_offset, in_len, out_buff, 0);
}
- public byte[] toByteArray(float[] in_buff, int in_len, byte[] out_buff) {
+ public final byte[] toByteArray(float[] in_buff, int in_len,
+ byte[] out_buff) {
return toByteArray(in_buff, 0, in_len, out_buff, 0);
}
- public byte[] toByteArray(float[] in_buff, byte[] out_buff) {
+ public final byte[] toByteArray(float[] in_buff, byte[] out_buff) {
return toByteArray(in_buff, 0, in_buff.length, out_buff, 0);
}
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
--- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -42,19 +42,19 @@
*
* @author Karl Helgason
*/
-public class AudioFloatFormatConverter extends FormatConversionProvider {
+public final class AudioFloatFormatConverter extends FormatConversionProvider {
private static class AudioFloatFormatConverterInputStream extends
InputStream {
- private AudioFloatConverter converter;
+ private final AudioFloatConverter converter;
- private AudioFloatInputStream stream;
+ private final AudioFloatInputStream stream;
private float[] readfloatbuffer;
- private int fsize = 0;
+ private final int fsize;
- public AudioFloatFormatConverterInputStream(AudioFormat targetFormat,
+ AudioFloatFormatConverterInputStream(AudioFormat targetFormat,
AudioFloatInputStream stream) {
this.stream = stream;
converter = AudioFloatConverter.getConverter(targetFormat);
@@ -116,17 +116,17 @@
private static class AudioFloatInputStreamChannelMixer extends
AudioFloatInputStream {
- private int targetChannels;
+ private final int targetChannels;
- private int sourceChannels;
+ private final int sourceChannels;
- private AudioFloatInputStream ais;
+ private final AudioFloatInputStream ais;
- private AudioFormat targetFormat;
+ private final AudioFormat targetFormat;
private float[] conversion_buffer;
- public AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais,
+ AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais,
int targetChannels) {
this.sourceChannels = ais.getFormat().getChannels();
this.targetChannels = targetChannels;
@@ -226,37 +226,37 @@
private static class AudioFloatInputStreamResampler extends
AudioFloatInputStream {
- private AudioFloatInputStream ais;
+ private final AudioFloatInputStream ais;
- private AudioFormat targetFormat;
+ private final AudioFormat targetFormat;
private float[] skipbuffer;
private SoftAbstractResampler resampler;
- private float[] pitch = new float[1];
+ private final float[] pitch = new float[1];
- private float[] ibuffer2;
+ private final float[] ibuffer2;
- private float[][] ibuffer;
+ private final float[][] ibuffer;
private float ibuffer_index = 0;
private int ibuffer_len = 0;
- private int nrofchannels = 0;
+ private final int nrofchannels;
private float[][] cbuffer;
- private int buffer_len = 512;
+ private final int buffer_len = 512;
- private int pad;
+ private final int pad;
- private int pad2;
+ private final int pad2;
- private float[] ix = new float[1];
+ private final float[] ix = new float[1];
- private int[] ox = new int[1];
+ private final int[] ox = new int[1];
private float[][] mark_ibuffer = null;
@@ -264,7 +264,7 @@
private int mark_ibuffer_len = 0;
- public AudioFloatInputStreamResampler(AudioFloatInputStream ais,
+ AudioFloatInputStreamResampler(AudioFloatInputStream ais,
AudioFormat format) {
this.ais = ais;
AudioFormat sourceFormat = ais.getFormat();
@@ -468,8 +468,9 @@
}
- private Encoding[] formats = { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
- Encoding.PCM_FLOAT };
+ private final Encoding[] formats = {Encoding.PCM_SIGNED,
+ Encoding.PCM_UNSIGNED,
+ Encoding.PCM_FLOAT};
public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java
--- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -48,14 +48,14 @@
private int pos = 0;
private int markpos = 0;
- private AudioFloatConverter converter;
- private AudioFormat format;
- private byte[] buffer;
- private int buffer_offset;
- private int buffer_len;
- private int framesize_pc;
+ private final AudioFloatConverter converter;
+ private final AudioFormat format;
+ private final byte[] buffer;
+ private final int buffer_offset;
+ private final int buffer_len;
+ private final int framesize_pc;
- public BytaArrayAudioFloatInputStream(AudioFloatConverter converter,
+ BytaArrayAudioFloatInputStream(AudioFloatConverter converter,
byte[] buffer, int offset, int len) {
this.converter = converter;
this.format = converter.getFormat();
@@ -125,12 +125,12 @@
private static class DirectAudioFloatInputStream
extends AudioFloatInputStream {
- private AudioInputStream stream;
+ private final AudioInputStream stream;
private AudioFloatConverter converter;
- private int framesize_pc; // framesize / channels
+ private final int framesize_pc; // framesize / channels
private byte[] buffer;
- public DirectAudioFloatInputStream(AudioInputStream stream) {
+ DirectAudioFloatInputStream(AudioInputStream stream) {
converter = AudioFloatConverter.getConverter(stream.getFormat());
if (converter == null) {
AudioFormat format = stream.getFormat();
@@ -255,11 +255,11 @@
public abstract int read(float[] b, int off, int len) throws IOException;
- public int read(float[] b) throws IOException {
+ public final int read(float[] b) throws IOException {
return read(b, 0, b.length);
}
- public float read() throws IOException {
+ public final float read() throws IOException {
float[] b = new float[1];
int ret = read(b, 0, 1);
if (ret == -1 || ret == 0)
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java
--- a/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class AudioSynthesizerPropertyInfo {
+public final class AudioSynthesizerPropertyInfo {
/**
* Constructs a AudioSynthesizerPropertyInfo
object with a given
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSInfo.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class DLSInfo {
+public final class DLSInfo {
/**
* (INAM) Title or subject.
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -40,15 +40,15 @@
*
* @author Karl Helgason
*/
-public class DLSInstrument extends ModelInstrument {
+public final class DLSInstrument extends ModelInstrument {
- protected int preset = 0;
- protected int bank = 0;
- protected boolean druminstrument = false;
- protected byte[] guid = null;
- protected DLSInfo info = new DLSInfo();
- protected List regions = new ArrayList();
- protected List modulators = new ArrayList();
+ int preset = 0;
+ int bank = 0;
+ boolean druminstrument = false;
+ byte[] guid = null;
+ DLSInfo info = new DLSInfo();
+ List regions = new ArrayList();
+ List modulators = new ArrayList();
public DLSInstrument() {
super(null, null, null, null);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSModulator.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,7 +33,7 @@
*
* @author Karl Helgason
*/
-public class DLSModulator {
+public final class DLSModulator {
// DLS1 Destinations
public static final int CONN_DST_NONE = 0x000; // 0
@@ -102,12 +102,12 @@
public static final int DST_FORMAT_CENT = 1;
public static final int DST_FORMAT_TIMECENT = 2;
public static final int DST_FORMAT_PERCENT = 3;
- protected int source;
- protected int control;
- protected int destination;
- protected int transform;
- protected int scale;
- protected int version = 1;
+ int source;
+ int control;
+ int destination;
+ int transform;
+ int scale;
+ int version = 1;
public int getControl() {
return control;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSRegion.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,21 +36,21 @@
*
* @author Karl Helgason
*/
-public class DLSRegion {
+public final class DLSRegion {
public final static int OPTION_SELFNONEXCLUSIVE = 0x0001;
- protected List modulators = new ArrayList();
- protected int keyfrom;
- protected int keyto;
- protected int velfrom;
- protected int velto;
- protected int options;
- protected int exclusiveClass;
- protected int fusoptions;
- protected int phasegroup;
- protected long channel;
- protected DLSSample sample = null;
- protected DLSSampleOptions sampleoptions;
+ List modulators = new ArrayList();
+ int keyfrom;
+ int keyto;
+ int velfrom;
+ int velto;
+ int options;
+ int exclusiveClass;
+ int fusoptions;
+ int phasegroup;
+ long channel;
+ DLSSample sample = null;
+ DLSSampleOptions sampleoptions;
public List getModulators() {
return modulators;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSSample.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSSample.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSSample.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -40,13 +40,13 @@
*
* @author Karl Helgason
*/
-public class DLSSample extends SoundbankResource {
+public final class DLSSample extends SoundbankResource {
- protected byte[] guid = null;
- protected DLSInfo info = new DLSInfo();
- protected DLSSampleOptions sampleoptions;
- protected ModelByteBuffer data;
- protected AudioFormat format;
+ byte[] guid = null;
+ DLSInfo info = new DLSInfo();
+ DLSSampleOptions sampleoptions;
+ ModelByteBuffer data;
+ AudioFormat format;
public DLSSample(Soundbank soundBank) {
super(soundBank, null, AudioInputStream.class);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,13 +29,13 @@
*
* @author Karl Helgason
*/
-public class DLSSampleLoop {
+public final class DLSSampleLoop {
public final static int LOOP_TYPE_FORWARD = 0;
public final static int LOOP_TYPE_RELEASE = 1;
- protected long type;
- protected long start;
- protected long length;
+ long type;
+ long start;
+ long length;
public long getLength() {
return length;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -34,13 +34,13 @@
*
* @author Karl Helgason
*/
-public class DLSSampleOptions {
+public final class DLSSampleOptions {
- protected int unitynote;
- protected short finetune;
- protected int attenuation;
- protected long options;
- protected List loops = new ArrayList();
+ int unitynote;
+ short finetune;
+ int attenuation;
+ long options;
+ List loops = new ArrayList();
public int getAttenuation() {
return attenuation;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -51,7 +51,7 @@
*
* @author Karl Helgason
*/
-public class DLSSoundbank implements Soundbank {
+public final class DLSSoundbank implements Soundbank {
static private class DLSID {
long i1;
@@ -69,7 +69,7 @@
private DLSID() {
}
- public DLSID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
+ DLSID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
int x5, int x6, int x7, int x8) {
this.i1 = i1;
this.s1 = s1;
@@ -174,10 +174,10 @@
private long major = -1;
private long minor = -1;
- private DLSInfo info = new DLSInfo();
+ private final DLSInfo info = new DLSInfo();
- private List instruments = new ArrayList();
- private List samples = new ArrayList();
+ private final List instruments = new ArrayList();
+ private final List samples = new ArrayList();
private boolean largeFormat = false;
private File sampleFile;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -39,7 +39,7 @@
*
* @author Karl Helgason
*/
-public class DLSSoundbankReader extends SoundbankReader {
+public final class DLSSoundbankReader extends SoundbankReader {
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DataPusher.java
--- a/jdk/src/share/classes/com/sun/media/sound/DataPusher.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DataPusher.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -37,13 +37,13 @@
* @author Florian Bomers
*/
-public class DataPusher implements Runnable {
+public final class DataPusher implements Runnable {
private static final int AUTO_CLOSE_TIME = 5000;
private static final boolean DEBUG = false;
- private SourceDataLine source = null;
- private AudioFormat format = null;
+ private final SourceDataLine source;
+ private final AudioFormat format;
// stream as source data
private AudioInputStream ais = null;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -42,7 +42,7 @@
*
* @author Florian Bomers
*/
-class DirectAudioDevice extends AbstractMixer {
+final class DirectAudioDevice extends AbstractMixer {
// CONSTANTS
private static final int CLIP_BUFFER_TIME = 1000; // in milliseconds
@@ -335,8 +335,8 @@
* but isFormatSupported() also returns true
* for formats with wrong endianness.
*/
- private static class DirectDLI extends DataLine.Info {
- AudioFormat[] hardwareFormats;
+ private static final class DirectDLI extends DataLine.Info {
+ final AudioFormat[] hardwareFormats;
private DirectDLI(Class clazz, AudioFormat[] formatArray,
AudioFormat[] hardwareFormatArray,
@@ -370,12 +370,12 @@
* Private inner class as base class for direct lines
*/
private static class DirectDL extends AbstractDataLine implements EventDispatcher.LineMonitor {
- protected int mixerIndex;
- protected int deviceID;
+ protected final int mixerIndex;
+ protected final int deviceID;
protected long id;
protected int waitTime;
protected volatile boolean flushing = false;
- protected boolean isSource; // true for SourceDataLine, false for TargetDataLine
+ protected final boolean isSource; // true for SourceDataLine, false for TargetDataLine
protected volatile long bytePosition;
protected volatile boolean doIO = false; // true in between start() and stop() calls
protected volatile boolean stoppedWritten = false; // true if a write occured in stopped state
@@ -387,10 +387,10 @@
protected int softwareConversionSize = 0;
protected AudioFormat hardwareFormat;
- private Gain gainControl = new Gain();
- private Mute muteControl = new Mute();
- private Balance balanceControl = new Balance();
- private Pan panControl = new Pan();
+ private final Gain gainControl = new Gain();
+ private final Mute muteControl = new Mute();
+ private final Balance balanceControl = new Balance();
+ private final Pan panControl = new Pan();
private float leftGain, rightGain;
protected volatile boolean noService = false; // do not run the nService method
@@ -829,7 +829,7 @@
/////////////////// CONTROLS /////////////////////////////
- protected class Gain extends FloatControl {
+ protected final class Gain extends FloatControl {
private float linearGain = 1.0f;
@@ -862,7 +862,7 @@
} // class Gain
- private class Mute extends BooleanControl {
+ private final class Mute extends BooleanControl {
private Mute() {
super(BooleanControl.Type.MUTE, false, "True", "False");
@@ -874,7 +874,7 @@
}
} // class Mute
- private class Balance extends FloatControl {
+ private final class Balance extends FloatControl {
private Balance() {
super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1, 0.0f,
@@ -893,7 +893,7 @@
} // class Balance
- private class Pan extends FloatControl {
+ private final class Pan extends FloatControl {
private Pan() {
super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1, 0.0f,
@@ -918,7 +918,8 @@
/**
* Private inner class representing a SourceDataLine
*/
- private static class DirectSDL extends DirectDL implements SourceDataLine {
+ private static final class DirectSDL extends DirectDL
+ implements SourceDataLine {
// CONSTRUCTOR
private DirectSDL(DataLine.Info info,
@@ -934,7 +935,8 @@
/**
* Private inner class representing a TargetDataLine
*/
- private static class DirectTDL extends DirectDL implements TargetDataLine {
+ private static final class DirectTDL extends DirectDL
+ implements TargetDataLine {
// CONSTRUCTOR
private DirectTDL(DataLine.Info info,
@@ -1012,7 +1014,9 @@
* Private inner class representing a Clip
* This clip is realized in software only
*/
- private static class DirectClip extends DirectDL implements Clip, Runnable, AutoClosingClip {
+ private static final class DirectClip extends DirectDL
+ implements Clip, Runnable, AutoClosingClip {
+
private Thread thread;
private byte[] audioData = null;
private int frameSize; // size of one frame in bytes
@@ -1045,7 +1049,7 @@
byte[] newData = new byte[bufferSize];
System.arraycopy(data, offset, newData, 0, bufferSize);
- open(format, data, bufferSize / format.getFrameSize());
+ open(format, newData, bufferSize / format.getFrameSize());
}
// this method does not copy the data array
@@ -1443,7 +1447,7 @@
* which allows retrieval of the internal array
*/
private static class DirectBAOS extends ByteArrayOutputStream {
- public DirectBAOS() {
+ DirectBAOS() {
super();
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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,8 +25,6 @@
package com.sun.media.sound;
-import java.util.Vector;
-
import javax.sound.sampled.Mixer;
import javax.sound.sampled.spi.MixerProvider;
@@ -36,7 +34,7 @@
*
* @author Florian Bomers
*/
-public class DirectAudioDeviceProvider extends MixerProvider {
+public final class DirectAudioDeviceProvider extends MixerProvider {
// STATIC VARIABLES
@@ -66,16 +64,17 @@
* Required public no-arg constructor.
*/
public DirectAudioDeviceProvider() {
- //if (Printer.trace) Printer.trace("DirectAudioDeviceProvider: constructor");
- if (Platform.isDirectAudioEnabled()) {
- init();
- } else {
- infos = new DirectAudioDeviceInfo[0];
- devices = new DirectAudioDevice[0];
+ synchronized (DirectAudioDeviceProvider.class) {
+ if (Platform.isDirectAudioEnabled()) {
+ init();
+ } else {
+ infos = new DirectAudioDeviceInfo[0];
+ devices = new DirectAudioDevice[0];
+ }
}
}
- private synchronized static void init() {
+ private static void init() {
// get the number of input devices
int numDevices = nGetNumDevices();
@@ -94,36 +93,39 @@
}
public Mixer.Info[] getMixerInfo() {
- Mixer.Info[] localArray = new Mixer.Info[infos.length];
- System.arraycopy(infos, 0, localArray, 0, infos.length);
- return localArray;
+ synchronized (DirectAudioDeviceProvider.class) {
+ Mixer.Info[] localArray = new Mixer.Info[infos.length];
+ System.arraycopy(infos, 0, localArray, 0, infos.length);
+ return localArray;
+ }
}
public Mixer getMixer(Mixer.Info info) {
- // if the default device is asked, we provide the mixer
- // with SourceDataLine's
- if (info == null) {
+ synchronized (DirectAudioDeviceProvider.class) {
+ // if the default device is asked, we provide the mixer
+ // with SourceDataLine's
+ if (info == null) {
+ for (int i = 0; i < infos.length; i++) {
+ Mixer mixer = getDevice(infos[i]);
+ if (mixer.getSourceLineInfo().length > 0) {
+ return mixer;
+ }
+ }
+ }
+ // otherwise get the first mixer that matches
+ // the requested info object
for (int i = 0; i < infos.length; i++) {
- Mixer mixer = getDevice(infos[i]);
- if (mixer.getSourceLineInfo().length > 0) {
- return mixer;
+ if (infos[i].equals(info)) {
+ return getDevice(infos[i]);
}
}
}
- // otherwise get the first mixer that matches
- // the requested info object
- for (int i = 0; i < infos.length; i++) {
- if (infos[i].equals(info)) {
- return getDevice(infos[i]);
- }
- }
-
throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider.");
}
- private Mixer getDevice(DirectAudioDeviceInfo info) {
+ private static Mixer getDevice(DirectAudioDeviceInfo info) {
int index = info.getIndex();
if (devices[index] == null) {
devices[index] = new DirectAudioDevice(info);
@@ -139,12 +141,12 @@
* making native references to a particular device.
* This constructor is called from native.
*/
- static class DirectAudioDeviceInfo extends Mixer.Info {
- private int index;
- private int maxSimulLines;
+ static final class DirectAudioDeviceInfo extends Mixer.Info {
+ private final int index;
+ private final int maxSimulLines;
// For ALSA, the deviceID contains the encoded card index, device index, and sub-device-index
- private int deviceID;
+ private final int deviceID;
private DirectAudioDeviceInfo(int index, int deviceID, int maxSimulLines,
String name, String vendor,
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java
--- a/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -35,7 +35,7 @@
*
* @author Karl Helgason
*/
-public class EmergencySoundbank {
+public final class EmergencySoundbank {
private final static String[] general_midi_instruments = {
"Acoustic Grand Piano",
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java
--- a/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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,20 +25,16 @@
package com.sun.media.sound;
-import java.util.EventObject;
import java.util.ArrayList;
import java.util.List;
-import javax.sound.sampled.Clip;
-import javax.sound.sampled.Line;
+import javax.sound.midi.ControllerEventListener;
+import javax.sound.midi.MetaEventListener;
+import javax.sound.midi.MetaMessage;
+import javax.sound.midi.ShortMessage;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
-import javax.sound.midi.MetaMessage;
-import javax.sound.midi.ShortMessage;
-import javax.sound.midi.MetaEventListener;
-import javax.sound.midi.ControllerEventListener;
-
/**
@@ -49,7 +45,7 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-class EventDispatcher implements Runnable {
+final class EventDispatcher implements Runnable {
/**
* time of inactivity until the auto closing clips
@@ -61,7 +57,7 @@
/**
* List of events
*/
- private ArrayList eventQueue = new ArrayList();
+ private final ArrayList eventQueue = new ArrayList();
/**
@@ -73,12 +69,12 @@
/*
* support for auto-closing Clips
*/
- private ArrayList autoClosingClips = new ArrayList();
+ private final ArrayList autoClosingClips = new ArrayList();
/*
* support for monitoring data lines
*/
- private ArrayList lineMonitors = new ArrayList();
+ private final ArrayList lineMonitors = new ArrayList();
/**
* Approximate interval between calls to LineMonitor.checkLine
@@ -105,7 +101,7 @@
* Invoked when there is at least one event in the queue.
* Implement this as a callback to process one event.
*/
- protected void processEvent(EventInfo eventInfo) {
+ void processEvent(EventInfo eventInfo) {
int count = eventInfo.getListenerCount();
// process an LineEvent
@@ -166,7 +162,7 @@
* exclusive access over the code where an event is removed from the
*queue.
*/
- protected void dispatchEvents() {
+ void dispatchEvents() {
EventInfo eventInfo = null;
@@ -388,8 +384,8 @@
*/
private class EventInfo {
- private Object event;
- private Object[] listeners;
+ private final Object event;
+ private final Object[] listeners;
/**
* Create a new instance of this event Info class
@@ -421,8 +417,8 @@
*/
private class ClipInfo {
- private AutoClosingClip clip;
- private long expiration;
+ private final AutoClosingClip clip;
+ private final long expiration;
/**
* Create a new instance of this clip Info class
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/FFT.java
--- a/jdk/src/share/classes/com/sun/media/sound/FFT.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/FFT.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -31,11 +31,11 @@
*/
public final class FFT {
- private double[] w;
- private int fftFrameSize;
- private int sign;
- private int[] bitm_array;
- private int fftFrameSize2;
+ private final double[] w;
+ private final int fftFrameSize;
+ private final int sign;
+ private final int[] bitm_array;
+ private final int fftFrameSize2;
// Sign = -1 is FFT, 1 is IFFT (inverse FFT)
// Data = Interlaced double array to be transformed.
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java
--- a/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -35,13 +35,13 @@
final class FastShortMessage extends ShortMessage {
private int packedMsg;
- public FastShortMessage(int packedMsg) throws InvalidMidiDataException {
+ FastShortMessage(int packedMsg) throws InvalidMidiDataException {
this.packedMsg = packedMsg;
getDataLength(packedMsg & 0xFF); // to check for validity
}
/** Creates a FastShortMessage from this ShortMessage */
- public FastShortMessage(ShortMessage msg) {
+ FastShortMessage(ShortMessage msg) {
this.packedMsg = msg.getStatus()
| (msg.getData1() << 8)
| (msg.getData2() << 16);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,14 +36,16 @@
import javax.sound.midi.Soundbank;
import javax.sound.midi.spi.SoundbankReader;
+import sun.reflect.misc.ReflectUtil;
+
/**
- * JarSoundbankReader is used to read sounbank object from jar files.
+ * JarSoundbankReader is used to read soundbank object from jar files.
*
* @author Karl Helgason
*/
-public class JARSoundbankReader extends SoundbankReader {
+public final class JARSoundbankReader extends SoundbankReader {
- public boolean isZIP(URL url) {
+ private static boolean isZIP(URL url) {
boolean ok = false;
try {
InputStream stream = url.openStream();
@@ -81,14 +83,14 @@
while (line != null) {
if (!line.startsWith("#")) {
try {
- Class c = Class.forName(line.trim(), true, ucl);
- Object o = c.newInstance();
- if (o instanceof Soundbank) {
+ Class> c = Class.forName(line.trim(), false, ucl);
+ if (Soundbank.class.isAssignableFrom(c)) {
+ Object o = ReflectUtil.newInstance(c);
soundbanks.add((Soundbank) o);
}
- } catch (ClassNotFoundException e) {
- } catch (InstantiationException e) {
- } catch (IllegalAccessException e) {
+ } catch (ClassNotFoundException ignored) {
+ } catch (InstantiationException ignored) {
+ } catch (IllegalAccessException ignored) {
}
}
line = r.readLine();
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/JDK13Services.java
--- a/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -31,16 +31,6 @@
import java.util.Map;
import java.util.Properties;
-import javax.sound.sampled.spi.AudioFileReader;
-import javax.sound.sampled.spi.AudioFileWriter;
-import javax.sound.sampled.spi.FormatConversionProvider;
-import javax.sound.sampled.spi.MixerProvider;
-
-import javax.sound.midi.spi.MidiFileReader;
-import javax.sound.midi.spi.MidiFileWriter;
-import javax.sound.midi.spi.SoundbankReader;
-import javax.sound.midi.spi.MidiDeviceProvider;
-
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequencer;
import javax.sound.midi.Synthesizer;
@@ -62,7 +52,7 @@
*
* @author Matthias Pfisterer
*/
-public class JDK13Services {
+public final class JDK13Services {
/** The default for the length of the period to hold the cache.
This value is given in milliseconds. It is equivalent to
@@ -80,7 +70,7 @@
Class objects of the provider type (MixerProvider, MidiDeviceProvider
...) are used as keys. The values are instances of ProviderCache.
*/
- private static Map providersCacheMap = new HashMap();
+ private static final Map providersCacheMap = new HashMap();
/** The length of the period to hold the cache.
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java
--- a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -47,7 +47,7 @@
*
* @author Matthias Pfisterer
*/
-class JSSecurityManager {
+final class JSSecurityManager {
/** Prevent instantiation.
*/
@@ -73,30 +73,6 @@
}
}
-
- static void loadLibrary(final String libName) {
- try {
- if (hasSecurityManager()) {
- if(Printer.debug) Printer.debug("using security manager to load library");
- PrivilegedAction action = new PrivilegedAction() {
- public Void run() {
- System.loadLibrary(libName);
- return null;
- }
- };
- AccessController.doPrivileged(action);
- } else {
- if(Printer.debug) Printer.debug("not using security manager to load library");
- System.loadLibrary(libName);
- }
- if (Printer.debug) Printer.debug("loaded library " + libName);
- } catch (UnsatisfiedLinkError e2) {
- if (Printer.err)Printer.err("UnsatisfiedLinkError loading native library " + libName);
- throw(e2);
- }
- }
-
-
static String getProperty(final String propertyName) {
String propertyValue;
if (hasSecurityManager()) {
@@ -189,83 +165,13 @@
if(Printer.trace)Printer.trace("<< JSSecurityManager: loadPropertiesImpl() completed");
}
-
- private static ThreadGroup getTopmostThreadGroup() {
- ThreadGroup topmostThreadGroup;
- if(hasSecurityManager()) {
- try {
- // invoke the privileged action using 1.2 security
- PrivilegedAction action = new PrivilegedAction() {
- public ThreadGroup run() {
- try {
- return getTopmostThreadGroupImpl();
- } catch (Throwable t) {
- return null;
- }
- }
- };
- topmostThreadGroup = AccessController.doPrivileged(action);
- if(Printer.debug)Printer.debug("Got topmost thread group with JDK 1.2 security");
- } catch (Exception e) {
- if(Printer.debug)Printer.debug("Exception getting topmost thread group with JDK 1.2 security");
- // try without using JDK 1.2 security
- topmostThreadGroup = getTopmostThreadGroupImpl();
- }
- } else {
- // not JDK 1.2 security, assume we already have permission
- topmostThreadGroup = getTopmostThreadGroupImpl();
- }
- return topmostThreadGroup;
- }
-
-
- private static ThreadGroup getTopmostThreadGroupImpl() {
- if(Printer.trace)Printer.trace(">> JSSecurityManager: getTopmostThreadGroupImpl()");
- ThreadGroup g = Thread.currentThread().getThreadGroup();
- while ((g.getParent() != null) && (g.getParent().getParent() != null)) {
- g = g.getParent();
- }
- if(Printer.trace)Printer.trace("<< JSSecurityManager: getTopmostThreadGroupImpl() completed");
- return g;
- }
-
-
- /** Create a Thread in the topmost ThreadGroup.
+ /** Create a Thread in the current ThreadGroup.
*/
static Thread createThread(final Runnable runnable,
final String threadName,
final boolean isDaemon, final int priority,
final boolean doStart) {
- Thread thread = null;
- if(hasSecurityManager()) {
- PrivilegedAction action = new PrivilegedAction() {
- public Thread run() {
- try {
- return createThreadImpl(runnable, threadName,
- isDaemon, priority,
- doStart);
- } catch (Throwable t) {
- return null;
- }
- }
- };
- thread = AccessController.doPrivileged(action);
- if(Printer.debug) Printer.debug("created thread with JDK 1.2 security");
- } else {
- if(Printer.debug)Printer.debug("not using JDK 1.2 security");
- thread = createThreadImpl(runnable, threadName, isDaemon, priority,
- doStart);
- }
- return thread;
- }
-
-
- private static Thread createThreadImpl(Runnable runnable,
- String threadName,
- boolean isDaemon, int priority,
- boolean doStart) {
- ThreadGroup threadGroup = getTopmostThreadGroupImpl();
- Thread thread = new Thread(threadGroup, runnable);
+ Thread thread = new Thread(runnable);
if (threadName != null) {
thread.setName(threadName);
}
@@ -279,7 +185,6 @@
return thread;
}
-
static List getProviders(final Class providerClass) {
List p = new ArrayList<>();
// ServiceLoader creates "lazy" iterator instance, so it doesn't,
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java
--- a/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,25 +28,19 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.applet.AudioClip;
-import java.lang.InterruptedException;
import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.Mixer;
import javax.sound.sampled.Clip;
-import javax.sound.sampled.Control;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
-import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
-
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.MetaMessage;
@@ -63,7 +57,7 @@
* @author Florian Bomers
*/
-public class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
+public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
private static final boolean DEBUG = false;
private static final int BUFFER_SIZE = 16384; // number of bytes written each time to the source data line
@@ -476,7 +470,7 @@
* which allows retrieval of the internal array
*/
private static class DirectBAOS extends ByteArrayOutputStream {
- public DirectBAOS() {
+ DirectBAOS() {
super();
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -33,7 +33,7 @@
*
* @author Alex Menkov
*/
-public class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver {
+public final class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver {
private final MidiDevice device;
private final Receiver receiver;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -33,7 +33,7 @@
*
* @author Alex Menkov
*/
-public class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter {
+public final class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter {
private final MidiDevice device;
private final Transmitter transmitter;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,9 +25,6 @@
package com.sun.media.sound;
-import java.util.ArrayList;
-import java.util.List;
-
import javax.sound.midi.*;
@@ -39,7 +36,7 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-class MidiInDevice extends AbstractMidiDevice implements Runnable {
+final class MidiInDevice extends AbstractMidiDevice implements Runnable {
private Thread midiInThread = null;
@@ -127,7 +124,7 @@
* An own class to distinguish the class name from
* the transmitter of other devices
*/
- private class MidiInTransmitter extends BasicTransmitter {
+ private final class MidiInTransmitter extends BasicTransmitter {
private MidiInTransmitter() {
super();
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -26,7 +26,6 @@
package com.sun.media.sound;
import javax.sound.midi.MidiDevice;
-import javax.sound.midi.spi.MidiDeviceProvider;
/**
@@ -35,15 +34,15 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-public class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
+public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
/** Cache of info objects for all MIDI output devices on the system. */
- static Info[] infos = null;
+ private static Info[] infos = null;
/** Cache of open MIDI input devices on the system. */
- static MidiDevice[] devices = null;
+ private static MidiDevice[] devices = null;
- private static boolean enabled;
+ private static final boolean enabled;
// STATIC
@@ -106,8 +105,8 @@
* previous instance may still exist and be open / in use / etc.,
* the new instance will not reflect that state...
*/
- static class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
- private Class providerClass;
+ static final class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
+ private final Class providerClass;
private MidiInDeviceInfo(int index, Class providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -36,7 +36,7 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-class MidiOutDevice extends AbstractMidiDevice {
+final class MidiOutDevice extends AbstractMidiDevice {
// CONSTRUCTOR
@@ -101,7 +101,7 @@
// INNER CLASSES
- class MidiOutReceiver extends AbstractReceiver {
+ final class MidiOutReceiver extends AbstractReceiver {
void implSend(final MidiMessage message, final long timeStamp) {
final int length = message.getLength();
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -26,7 +26,6 @@
package com.sun.media.sound;
import javax.sound.midi.MidiDevice;
-import javax.sound.midi.spi.MidiDeviceProvider;
/**
@@ -35,15 +34,15 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-public class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
+public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
/** Cache of info objects for all MIDI output devices on the system. */
- static Info[] infos = null;
+ private static Info[] infos = null;
/** Cache of open MIDI output devices on the system. */
- static MidiDevice[] devices = null;
+ private static MidiDevice[] devices = null;
- private static boolean enabled;
+ private final static boolean enabled;
// STATIC
@@ -104,8 +103,8 @@
* previous instance may still exist and be open / in use / etc.,
* the new instance will not reflect that state...
*/
- static class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
- private Class providerClass;
+ static final class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
+ private final Class providerClass;
private MidiOutDeviceInfo(int index, Class providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/MidiUtils.java
--- a/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -36,12 +36,17 @@
*
* @author Florian Bomers
*/
-public class MidiUtils {
+public final class MidiUtils {
public final static int DEFAULT_TEMPO_MPQ = 500000; // 120bpm
public final static int META_END_OF_TRACK_TYPE = 0x2F;
public final static int META_TEMPO_TYPE = 0x51;
+ /**
+ * Suppresses default constructor, ensuring non-instantiability.
+ */
+ private MidiUtils() {
+ }
/** return true if the passed message is Meta End Of Track */
public static boolean isMetaEndOfTrack(MidiMessage midiMsg) {
@@ -262,7 +267,7 @@
}
- public static class TempoCache {
+ public static final class TempoCache {
long[] ticks;
int[] tempos; // in MPQ
// index in ticks/tempos at the snapshot
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -38,7 +38,7 @@
*
* @author Karl Helgason
*/
-public class ModelByteBuffer {
+public final class ModelByteBuffer {
private ModelByteBuffer root = this;
private File file;
@@ -49,12 +49,12 @@
private class RandomFileInputStream extends InputStream {
- private RandomAccessFile raf;
+ private final RandomAccessFile raf;
private long left;
private long mark = 0;
private long markleft = 0;
- public RandomFileInputStream() throws IOException {
+ RandomFileInputStream() throws IOException {
raf = new RandomAccessFile(root.file, "r");
raf.seek(root.fileoffset + arrayOffset());
left = capacity();
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,18 +36,18 @@
*
* @author Karl Helgason
*/
-public class ModelByteBufferWavetable implements ModelWavetable {
+public final class ModelByteBufferWavetable implements ModelWavetable {
private class Buffer8PlusInputStream extends InputStream {
- private boolean bigendian;
- private int framesize_pc;
+ private final boolean bigendian;
+ private final int framesize_pc;
int pos = 0;
int pos2 = 0;
int markpos = 0;
int markpos2 = 0;
- public Buffer8PlusInputStream() {
+ Buffer8PlusInputStream() {
framesize_pc = format.getFrameSize() / format.getChannels();
bigendian = format.isBigEndian();
}
@@ -127,7 +127,7 @@
private float loopStart = -1;
private float loopLength = -1;
- private ModelByteBuffer buffer;
+ private final ModelByteBuffer buffer;
private ModelByteBuffer buffer8 = null;
private AudioFormat format = null;
private float pitchcorrection = 0;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -34,7 +34,7 @@
*
* @author Karl Helgason
*/
-public class ModelConnectionBlock {
+public final class ModelConnectionBlock {
//
// source1 * source2 * scale -> destination
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelDestination.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class ModelDestination {
+public final class ModelDestination {
public static final ModelIdentifier DESTINATION_NONE = null;
public static final ModelIdentifier DESTINATION_KEYNUMBER
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class ModelIdentifier {
+public final class ModelIdentifier {
/*
* Object Variable
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -69,7 +69,7 @@
}
// Get General MIDI 2 Alias patch for this instrument.
- public Patch getPatchAlias() {
+ public final Patch getPatchAlias() {
Patch patch = getPatch();
int program = patch.getProgram();
int bank = patch.getBank();
@@ -87,7 +87,7 @@
// Return name of all the keys.
// This information is generated from ModelPerformer.getName()
// returned from getPerformers().
- public String[] getKeys() {
+ public final String[] getKeys() {
String[] keys = new String[128];
for (ModelPerformer performer : getPerformers()) {
for (int k = performer.getKeyFrom(); k <= performer.getKeyTo(); k++) {
@@ -104,7 +104,7 @@
// Return what channels this instrument will probably response
// on General MIDI synthesizer.
- public boolean[] getChannels() {
+ public final boolean[] getChannels() {
boolean percussion = false;
if (getPatch() instanceof ModelPatch)
percussion = ((ModelPatch)getPatch()).isPercussion();
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -34,7 +34,7 @@
*
* @author Karl Helgason
*/
-public class ModelInstrumentComparator implements Comparator {
+public final class ModelInstrumentComparator implements Comparator {
public int compare(Instrument arg0, Instrument arg1) {
Patch p0 = arg0.getPatch();
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,9 +33,9 @@
*
* @author Karl Helgason
*/
-public class ModelMappedInstrument extends ModelInstrument {
+public final class ModelMappedInstrument extends ModelInstrument {
- private ModelInstrument ins;
+ private final ModelInstrument ins;
public ModelMappedInstrument(ModelInstrument ins, Patch patch) {
super(ins.getSoundbank(), patch, ins.getName(), ins.getDataClass());
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelPatch.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,7 +33,7 @@
*
* @author Karl Helgason
*/
-public class ModelPatch extends Patch {
+public final class ModelPatch extends Patch {
private boolean percussion = false;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,9 +33,9 @@
*
* @author Karl Helgason
*/
-public class ModelPerformer {
+public final class ModelPerformer {
- private List oscillators = new ArrayList();
+ private final List oscillators = new ArrayList();
private List connectionBlocks
= new ArrayList();
private int keyFrom = 0;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelSource.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelSource.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelSource.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class ModelSource {
+public final class ModelSource {
public static final ModelIdentifier SOURCE_NONE = null;
public static final ModelIdentifier SOURCE_NOTEON_KEYNUMBER =
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class ModelStandardDirector implements ModelDirector {
+public final class ModelStandardDirector implements ModelDirector {
ModelPerformer[] performers;
ModelDirectedPlayer player;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class ModelStandardIndexedDirector implements ModelDirector {
+public final class ModelStandardIndexedDirector implements ModelDirector {
ModelPerformer[] performers;
ModelDirectedPlayer player;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java
--- a/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,7 +36,7 @@
*
* @author Karl Helgason
*/
-public class ModelStandardTransform implements ModelTransform {
+public final class ModelStandardTransform implements ModelTransform {
public static final boolean DIRECTION_MIN2MAX = false;
public static final boolean DIRECTION_MAX2MIN = true;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
--- a/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,14 +25,12 @@
package com.sun.media.sound;
-import java.io.InputStream;
import java.io.IOException;
-
import java.util.Vector;
import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.AudioInputStream;
/**
@@ -40,7 +38,7 @@
*
* @author Jan Borgersen
*/
-public class PCMtoPCMCodec extends SunCodec {
+public final class PCMtoPCMCodec extends SunCodec {
private static final AudioFormat.Encoding[] inputEncodings = {
@@ -356,7 +354,7 @@
private final int PCM_UNSIGNED_BE2SIGNED_LE = 7;
private final int PCM_SIGNED_BE2UNSIGNED_LE = 8;
- private int sampleSizeInBytes = 0;
+ private final int sampleSizeInBytes;
private int conversionType = 0;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/Platform.java
--- a/jdk/src/share/classes/com/sun/media/sound/Platform.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/Platform.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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.StringTokenizer;
@@ -35,7 +37,7 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-class Platform {
+final class Platform {
// STATIC FINAL CHARACTERISTICS
@@ -157,7 +159,13 @@
try {
// load the main library
- JSSecurityManager.loadLibrary(libNameMain);
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ System.loadLibrary(libNameMain);
+ return null;
+ }
+ });
// just for the heck of it...
loadedLibs |= LIB_MAIN;
} catch (SecurityException e) {
@@ -171,9 +179,16 @@
// the string is the libraries, separated by white space
StringTokenizer st = new StringTokenizer(extraLibs);
while (st.hasMoreTokens()) {
- String lib = st.nextToken();
+ final String lib = st.nextToken();
try {
- JSSecurityManager.loadLibrary(lib);
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ System.loadLibrary(lib);
+ return null;
+ }
+ });
+
if (lib.equals(libNameALSA)) {
loadedLibs |= LIB_ALSA;
if (Printer.debug) Printer.debug("Loaded ALSA lib successfully.");
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/PortMixer.java
--- a/jdk/src/share/classes/com/sun/media/sound/PortMixer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/PortMixer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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
@@ -41,7 +41,7 @@
*
* @author Florian Bomers
*/
-class PortMixer extends AbstractMixer {
+final class PortMixer extends AbstractMixer {
// CONSTANTS
private static final int SRC_UNKNOWN = 0x01;
@@ -228,8 +228,10 @@
/**
* Private inner class representing a Port for the PortMixer.
*/
- private static class PortMixerPort extends AbstractLine implements Port {
- private int portIndex;
+ private static final class PortMixerPort extends AbstractLine
+ implements Port {
+
+ private final int portIndex;
private long id;
// CONSTRUCTOR
@@ -342,9 +344,9 @@
/**
* Private inner class representing a BooleanControl for PortMixerPort
*/
- private static class BoolCtrl extends BooleanControl {
+ private static final class BoolCtrl extends BooleanControl {
// the handle to the native control function
- private long controlID;
+ private final long controlID;
private boolean closed = false;
private static BooleanControl.Type createType(String name) {
@@ -386,7 +388,7 @@
/**
* inner class for custom types
*/
- private static class BCT extends BooleanControl.Type {
+ private static final class BCT extends BooleanControl.Type {
private BCT(String name) {
super(name);
}
@@ -396,7 +398,7 @@
/**
* Private inner class representing a CompoundControl for PortMixerPort
*/
- private static class CompCtrl extends CompoundControl {
+ private static final class CompCtrl extends CompoundControl {
private CompCtrl(String name, Control[] controls) {
super(new CCT(name), controls);
}
@@ -404,7 +406,7 @@
/**
* inner class for custom compound control types
*/
- private static class CCT extends CompoundControl.Type {
+ private static final class CCT extends CompoundControl.Type {
private CCT(String name) {
super(name);
}
@@ -414,9 +416,9 @@
/**
* Private inner class representing a BooleanControl for PortMixerPort
*/
- private static class FloatCtrl extends FloatControl {
+ private static final class FloatCtrl extends FloatControl {
// the handle to the native control function
- private long controlID;
+ private final long controlID;
private boolean closed = false;
// predefined float control types. See also Ports.h
@@ -462,7 +464,7 @@
/**
* inner class for custom types
*/
- private static class FCT extends FloatControl.Type {
+ private static final class FCT extends FloatControl.Type {
private FCT(String name) {
super(name);
}
@@ -472,7 +474,7 @@
/**
* Private inner class representing a port info
*/
- private static class PortInfo extends Port.Info {
+ private static final class PortInfo extends Port.Info {
private PortInfo(String name, boolean isSource) {
super(Port.class, name, isSource);
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2013, 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,8 +25,6 @@
package com.sun.media.sound;
-import java.util.Vector;
-
import javax.sound.sampled.Mixer;
import javax.sound.sampled.spi.MixerProvider;
@@ -36,7 +34,7 @@
*
* @author Florian Bomers
*/
-public class PortMixerProvider extends MixerProvider {
+public final class PortMixerProvider extends MixerProvider {
// STATIC VARIABLES
@@ -66,16 +64,17 @@
* Required public no-arg constructor.
*/
public PortMixerProvider() {
- //if (Printer.trace) Printer.trace("PortMixerProvider: constructor");
- if (Platform.isPortsEnabled()) {
- init();
- } else {
- infos = new PortMixerInfo[0];
- devices = new PortMixer[0];
+ synchronized (PortMixerProvider.class) {
+ if (Platform.isPortsEnabled()) {
+ init();
+ } else {
+ infos = new PortMixerInfo[0];
+ devices = new PortMixer[0];
+ }
}
}
- private static synchronized void init() {
+ private static void init() {
// get the number of input devices
int numDevices = nGetNumDevices();
@@ -95,23 +94,28 @@
}
public Mixer.Info[] getMixerInfo() {
- Mixer.Info[] localArray = new Mixer.Info[infos.length];
- System.arraycopy(infos, 0, localArray, 0, infos.length);
- return localArray;
+ synchronized (PortMixerProvider.class) {
+ Mixer.Info[] localArray = new Mixer.Info[infos.length];
+ System.arraycopy(infos, 0, localArray, 0, infos.length);
+ return localArray;
+ }
}
public Mixer getMixer(Mixer.Info info) {
- for (int i = 0; i < infos.length; i++) {
- if (infos[i].equals(info)) {
- return getDevice(infos[i]);
+ synchronized (PortMixerProvider.class) {
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].equals(info)) {
+ return getDevice(infos[i]);
+ }
}
}
- throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider.");
+ throw new IllegalArgumentException("Mixer " + info.toString()
+ + " not supported by this provider.");
}
- private Mixer getDevice(PortMixerInfo info) {
+ private static Mixer getDevice(PortMixerInfo info) {
int index = info.getIndex();
if (devices[index] == null) {
devices[index] = new PortMixer(info);
@@ -127,8 +131,8 @@
* making native references to a particular device.
* This constructor is called from native.
*/
- static class PortMixerInfo extends Mixer.Info {
- private int index;
+ static final class PortMixerInfo extends Mixer.Info {
+ private final int index;
private PortMixerInfo(int index, String name, String vendor, String description, String version) {
super("Port " + name, vendor, description, version);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/Printer.java
--- a/jdk/src/share/classes/com/sun/media/sound/Printer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/Printer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -32,7 +32,7 @@
* @author David Rivas
* @author Kara Kytle
*/
-class Printer {
+final class Printer {
static final boolean err = false;
static final boolean debug = false;
@@ -68,6 +68,12 @@
release = on;
}*/
+ /**
+ * Suppresses default constructor, ensuring non-instantiability.
+ */
+ private Printer() {
+ }
+
public static void err(String str) {
if (err)
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java
--- a/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class RIFFInvalidDataException extends InvalidDataException {
+public final class RIFFInvalidDataException extends InvalidDataException {
private static final long serialVersionUID = 1L;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java
--- a/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class RIFFInvalidFormatException extends InvalidFormatException {
+public final class RIFFInvalidFormatException extends InvalidFormatException {
private static final long serialVersionUID = 1L;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/RIFFReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,11 +33,11 @@
*
* @author Karl Helgason
*/
-public class RIFFReader extends InputStream {
+public final class RIFFReader extends InputStream {
- private RIFFReader root;
+ private final RIFFReader root;
private long filepointer = 0;
- private String fourcc;
+ private final String fourcc;
private String riff_type = null;
private long ckSize = 0;
private InputStream stream;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -35,7 +35,7 @@
*
* @author Karl Helgason
*/
-public class RIFFWriter extends OutputStream {
+public final class RIFFWriter extends OutputStream {
private interface RandomAccessWriter {
@@ -60,11 +60,11 @@
RandomAccessFile raf;
- public RandomAccessFileWriter(File file) throws FileNotFoundException {
+ RandomAccessFileWriter(File file) throws FileNotFoundException {
this.raf = new RandomAccessFile(file, "rw");
}
- public RandomAccessFileWriter(String name) throws FileNotFoundException {
+ RandomAccessFileWriter(String name) throws FileNotFoundException {
this.raf = new RandomAccessFile(name, "rw");
}
@@ -107,9 +107,9 @@
int length = 0;
int pos = 0;
byte[] s;
- OutputStream stream;
+ final OutputStream stream;
- public RandomAccessByteWriter(OutputStream stream) {
+ RandomAccessByteWriter(OutputStream stream) {
this.stream = stream;
}
@@ -163,8 +163,8 @@
}
private int chunktype = 0; // 0=RIFF, 1=LIST; 2=CHUNK
private RandomAccessWriter raf;
- private long chunksizepointer;
- private long startpointer;
+ private final long chunksizepointer;
+ private final long startpointer;
private RIFFWriter childchunk = null;
private boolean open = true;
private boolean writeoverride = false;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
--- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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,14 +25,13 @@
package com.sun.media.sound;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.sound.midi.*;
@@ -46,7 +45,8 @@
/* TODO:
* - rename PlayThread to PlayEngine (because isn't a thread)
*/
-class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoConnectSequencer {
+final class RealTimeSequencer extends AbstractMidiDevice
+ implements Sequencer, AutoConnectSequencer {
// STATIC VARIABLES
@@ -58,7 +58,8 @@
* Event Dispatcher thread. Should be using a shared event
* dispatcher instance with a factory in EventDispatcher
*/
- private static final EventDispatcher eventDispatcher;
+ private static final Map dispatchers =
+ new WeakHashMap<>();
/**
* All RealTimeSequencers share this info object.
@@ -66,11 +67,11 @@
static final RealTimeSequencerInfo info = new RealTimeSequencerInfo();
- private static Sequencer.SyncMode[] masterSyncModes = { Sequencer.SyncMode.INTERNAL_CLOCK };
- private static Sequencer.SyncMode[] slaveSyncModes = { Sequencer.SyncMode.NO_SYNC };
+ private static final Sequencer.SyncMode[] masterSyncModes = { Sequencer.SyncMode.INTERNAL_CLOCK };
+ private static final Sequencer.SyncMode[] slaveSyncModes = { Sequencer.SyncMode.NO_SYNC };
- private static Sequencer.SyncMode masterSyncMode = Sequencer.SyncMode.INTERNAL_CLOCK;
- private static Sequencer.SyncMode slaveSyncMode = Sequencer.SyncMode.NO_SYNC;
+ private static final Sequencer.SyncMode masterSyncMode = Sequencer.SyncMode.INTERNAL_CLOCK;
+ private static final Sequencer.SyncMode slaveSyncMode = Sequencer.SyncMode.NO_SYNC;
/**
@@ -100,7 +101,7 @@
private boolean[] trackSolo = null;
/** tempo cache for getMicrosecondPosition */
- private MidiUtils.TempoCache tempoCache = new MidiUtils.TempoCache();
+ private final MidiUtils.TempoCache tempoCache = new MidiUtils.TempoCache();
/**
* True if the sequence is running.
@@ -121,7 +122,7 @@
/**
* List of tracks to which we're recording
*/
- private List recordingTracks = new ArrayList();
+ private final List recordingTracks = new ArrayList();
private long loopStart = 0;
@@ -132,13 +133,13 @@
/**
* Meta event listeners
*/
- private ArrayList metaEventListeners = new ArrayList();
+ private final ArrayList metaEventListeners = new ArrayList();
/**
* Control change listeners
*/
- private ArrayList controllerEventListeners = new ArrayList();
+ private final ArrayList controllerEventListeners = new ArrayList();
/** automatic connection support */
@@ -151,16 +152,9 @@
Receiver autoConnectedReceiver = null;
- static {
- // create and start the global event thread
- eventDispatcher = new EventDispatcher();
- eventDispatcher.start();
- }
-
-
/* ****************************** CONSTRUCTOR ****************************** */
- protected RealTimeSequencer() throws MidiUnavailableException {
+ RealTimeSequencer() throws MidiUnavailableException {
super(info);
if (Printer.trace) Printer.trace(">> RealTimeSequencer CONSTRUCTOR");
@@ -574,7 +568,7 @@
return returnedModes;
}
- protected int getTrackCount() {
+ int getTrackCount() {
Sequence seq = getSequence();
if (seq != null) {
// $$fb wish there was a nicer way to get the number of tracks...
@@ -872,7 +866,7 @@
if (Printer.trace) Printer.trace("<< RealTimeSequencer: implClose() completed");
}
- protected void implStart() {
+ void implStart() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStart()");
if (playThread == null) {
@@ -889,7 +883,7 @@
}
- protected void implStop() {
+ void implStop() {
if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStop()");
if (playThread == null) {
@@ -905,22 +899,36 @@
if (Printer.trace) Printer.trace("<< RealTimeSequencer: implStop() completed");
}
+ private static EventDispatcher getEventDispatcher() {
+ // create and start the global event thread
+ //TODO need a way to stop this thread when the engine is done
+ final ThreadGroup tg = Thread.currentThread().getThreadGroup();
+ synchronized (dispatchers) {
+ EventDispatcher eventDispatcher = dispatchers.get(tg);
+ if (eventDispatcher == null) {
+ eventDispatcher = new EventDispatcher();
+ dispatchers.put(tg, eventDispatcher);
+ eventDispatcher.start();
+ }
+ return eventDispatcher;
+ }
+ }
/**
* Send midi player events.
* must not be synchronized on "this"
*/
- protected void sendMetaEvents(MidiMessage message) {
+ void sendMetaEvents(MidiMessage message) {
if (metaEventListeners.size() == 0) return;
//if (Printer.debug) Printer.debug("sending a meta event");
- eventDispatcher.sendAudioEvents(message, metaEventListeners);
+ getEventDispatcher().sendAudioEvents(message, metaEventListeners);
}
/**
* Send midi player events.
*/
- protected void sendControllerEvents(MidiMessage message) {
+ void sendControllerEvents(MidiMessage message) {
int size = controllerEventListeners.size();
if (size == 0) return;
@@ -942,7 +950,7 @@
}
}
}
- eventDispatcher.sendAudioEvents(message, sendToListeners);
+ getEventDispatcher().sendAudioEvents(message, sendToListeners);
}
@@ -1024,7 +1032,7 @@
}
- class SequencerReceiver extends AbstractReceiver {
+ final class SequencerReceiver extends AbstractReceiver {
void implSend(MidiMessage message, long timeStamp) {
if (recording) {
@@ -1092,7 +1100,7 @@
// easier to deal with than turning all the
// ints into objects to use a Vector
int [] controllers;
- ControllerEventListener listener;
+ final ControllerEventListener listener;
private ControllerListElement(ControllerEventListener listener, int[] controllers) {
@@ -1197,7 +1205,7 @@
static class RecordingTrack {
- private Track track;
+ private final Track track;
private int channel;
RecordingTrack(Track track, int channel) {
@@ -1237,15 +1245,15 @@
}
- class PlayThread implements Runnable {
+ final class PlayThread implements Runnable {
private Thread thread;
- private Object lock = new Object();
+ private final Object lock = new Object();
/** true if playback is interrupted (in close) */
boolean interrupted = false;
boolean isPumping = false;
- private DataPump dataPump = new DataPump();
+ private final DataPump dataPump = new DataPump();
PlayThread() {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -34,7 +34,7 @@
*
* @author Florian Bomers
*/
-public class RealTimeSequencerProvider extends MidiDeviceProvider {
+public final class RealTimeSequencerProvider extends MidiDeviceProvider {
public MidiDevice.Info[] getDeviceInfo() {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,5 +29,5 @@
*
* @author Karl Helgason
*/
-public class SF2GlobalRegion extends SF2Region {
+public final class SF2GlobalRegion extends SF2Region {
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,16 +36,16 @@
*
* @author Karl Helgason
*/
-public class SF2Instrument extends ModelInstrument {
+public final class SF2Instrument extends ModelInstrument {
- protected String name = "";
- protected int preset = 0;
- protected int bank = 0;
- protected long library = 0;
- protected long genre = 0;
- protected long morphology = 0;
- protected SF2GlobalRegion globalregion = null;
- protected List regions
+ String name = "";
+ int preset = 0;
+ int bank = 0;
+ long library = 0;
+ long genre = 0;
+ long morphology = 0;
+ SF2GlobalRegion globalregion = null;
+ List regions
= new ArrayList();
public SF2Instrument() {
@@ -730,7 +730,7 @@
return msrc;
}
- protected static ModelDestination convertDestination(int dst,
+ static ModelDestination convertDestination(int dst,
double[] amountcorrection, ModelSource[] extrasrc) {
ModelIdentifier id = null;
switch (dst) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,9 +29,9 @@
*
* @author Karl Helgason
*/
-public class SF2InstrumentRegion extends SF2Region {
+public final class SF2InstrumentRegion extends SF2Region {
- protected SF2Layer layer;
+ SF2Layer layer;
public SF2Layer getLayer() {
return layer;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2Layer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -34,11 +34,11 @@
*
* @author Karl Helgason
*/
-public class SF2Layer extends SoundbankResource {
+public final class SF2Layer extends SoundbankResource {
- protected String name = "";
- protected SF2GlobalRegion globalregion = null;
- protected List regions = new ArrayList();
+ String name = "";
+ SF2GlobalRegion globalregion = null;
+ List regions = new ArrayList();
public SF2Layer(SF2Soundbank soundBank) {
super(soundBank, null, null);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,9 +29,9 @@
*
* @author Karl Helgason
*/
-public class SF2LayerRegion extends SF2Region {
+public final class SF2LayerRegion extends SF2Region {
- protected SF2Sample sample;
+ SF2Sample sample;
public SF2Sample getSample() {
return sample;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class SF2Modulator {
+public final class SF2Modulator {
public final static int SOURCE_NONE = 0;
public final static int SOURCE_NOTE_ON_VELOCITY = 2;
@@ -49,11 +49,11 @@
public final static int SOURCE_TYPE_SWITCH = 1024 * 3;
public final static int TRANSFORM_LINEAR = 0;
public final static int TRANSFORM_ABSOLUTE = 2;
- protected int sourceOperator;
- protected int destinationOperator;
- protected short amount;
- protected int amountSourceOperator;
- protected int transportOperator;
+ int sourceOperator;
+ int destinationOperator;
+ short amount;
+ int amountSourceOperator;
+ int transportOperator;
public short getAmount() {
return amount;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2Sample.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,18 +36,18 @@
*
* @author Karl Helgason
*/
-public class SF2Sample extends SoundbankResource {
+public final class SF2Sample extends SoundbankResource {
- protected String name = "";
- protected long startLoop = 0;
- protected long endLoop = 0;
- protected long sampleRate = 44100;
- protected int originalPitch = 60;
- protected byte pitchCorrection = 0;
- protected int sampleLink = 0;
- protected int sampleType = 0;
- protected ModelByteBuffer data;
- protected ModelByteBuffer data24;
+ String name = "";
+ long startLoop = 0;
+ long endLoop = 0;
+ long sampleRate = 44100;
+ int originalPitch = 60;
+ byte pitchCorrection = 0;
+ int sampleLink = 0;
+ int sampleType = 0;
+ ModelByteBuffer data;
+ ModelByteBuffer data24;
public SF2Sample(Soundbank soundBank) {
super(soundBank, null, AudioInputStream.class);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -50,40 +50,40 @@
*
* @author Karl Helgason
*/
-public class SF2Soundbank implements Soundbank {
+public final class SF2Soundbank implements Soundbank {
// version of the Sound Font RIFF file
- protected int major = 2;
- protected int minor = 1;
+ int major = 2;
+ int minor = 1;
// target Sound Engine
- protected String targetEngine = "EMU8000";
+ String targetEngine = "EMU8000";
// Sound Font Bank Name
- protected String name = "untitled";
+ String name = "untitled";
// Sound ROM Name
- protected String romName = null;
+ String romName = null;
// Sound ROM Version
- protected int romVersionMajor = -1;
- protected int romVersionMinor = -1;
+ int romVersionMajor = -1;
+ int romVersionMinor = -1;
// Date of Creation of the Bank
- protected String creationDate = null;
+ String creationDate = null;
// Sound Designers and Engineers for the Bank
- protected String engineers = null;
+ String engineers = null;
// Product for which the Bank was intended
- protected String product = null;
+ String product = null;
// Copyright message
- protected String copyright = null;
+ String copyright = null;
// Comments
- protected String comments = null;
+ String comments = null;
// The SoundFont tools used to create and alter the bank
- protected String tools = null;
+ String tools = null;
// The Sample Data loaded from the SoundFont
private ModelByteBuffer sampleData = null;
private ModelByteBuffer sampleData24 = null;
private File sampleFile = null;
private boolean largeFormat = false;
- private List instruments = new ArrayList();
- private List layers = new ArrayList();
- private List samples = new ArrayList();
+ private final List instruments = new ArrayList();
+ private final List layers = new ArrayList();
+ private final List samples = new ArrayList();
public SF2Soundbank() {
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -38,7 +38,7 @@
*
* @author Karl Helgason
*/
-public class SF2SoundbankReader extends SoundbankReader {
+public final class SF2SoundbankReader extends SoundbankReader {
public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -67,7 +67,7 @@
float samplerateconv = 1;
float pitchcorrection = 0;
- public ModelAbstractResamplerStream() {
+ ModelAbstractResamplerStream() {
pad = getPadding();
pad2 = getPadding() * 2;
ibuffer = new float[2][sector_size + pad2];
@@ -384,7 +384,7 @@
float in_end, float[] pitch, float pitchstep, float[] out,
int[] out_offset, int out_end);
- public SoftResamplerStreamer openStreamer() {
+ public final SoftResamplerStreamer openStreamer() {
return new ModelAbstractResamplerStream();
}
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,7 +33,7 @@
*
* @author Karl Helgason
*/
-public class SoftAudioBuffer {
+public final class SoftAudioBuffer {
private int size;
private float[] buffer;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -34,13 +34,13 @@
*
* @author Karl Helgason
*/
-public class SoftAudioPusher implements Runnable {
+public final class SoftAudioPusher implements Runnable {
private volatile boolean active = false;
private SourceDataLine sourceDataLine = null;
private Thread audiothread;
- private AudioInputStream ais;
- private byte[] buffer;
+ private final AudioInputStream ais;
+ private final byte[] buffer;
public SoftAudioPusher(SourceDataLine sourceDataLine, AudioInputStream ais,
int workbuffersizer) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftChannel.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -39,7 +39,7 @@
*
* @author Karl Helgason
*/
-public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
+public final class SoftChannel implements MidiChannel, ModelDirectedPlayer {
private static boolean[] dontResetControls = new boolean[128];
static {
@@ -90,15 +90,15 @@
private static final int RPN_NULL_VALUE = (127 << 7) + 127;
private int rpn_control = RPN_NULL_VALUE;
private int nrpn_control = RPN_NULL_VALUE;
- protected double portamento_time = 1; // keyschanges per control buffer time
- protected int[] portamento_lastnote = new int[128];
- protected int portamento_lastnote_ix = 0;
+ double portamento_time = 1; // keyschanges per control buffer time
+ int[] portamento_lastnote = new int[128];
+ int portamento_lastnote_ix = 0;
private boolean portamento = false;
private boolean mono = false;
private boolean mute = false;
private boolean solo = false;
private boolean solomute = false;
- private Object control_mutex;
+ private final Object control_mutex;
private int channel;
private SoftVoice[] voices;
private int bank;
@@ -111,21 +111,21 @@
private int pitchbend;
private double[] co_midi_pitch = new double[1];
private double[] co_midi_channel_pressure = new double[1];
- protected SoftTuning tuning = new SoftTuning();
- protected int tuning_bank = 0;
- protected int tuning_program = 0;
- protected SoftInstrument current_instrument = null;
- protected ModelChannelMixer current_mixer = null;
- protected ModelDirector current_director = null;
+ SoftTuning tuning = new SoftTuning();
+ int tuning_bank = 0;
+ int tuning_program = 0;
+ SoftInstrument current_instrument = null;
+ ModelChannelMixer current_mixer = null;
+ ModelDirector current_director = null;
// Controller Destination Settings
- protected int cds_control_number = -1;
- protected ModelConnectionBlock[] cds_control_connections = null;
- protected ModelConnectionBlock[] cds_channelpressure_connections = null;
- protected ModelConnectionBlock[] cds_polypressure_connections = null;
- protected boolean sustain = false;
- protected boolean[][] keybasedcontroller_active = null;
- protected double[][] keybasedcontroller_value = null;
+ int cds_control_number = -1;
+ ModelConnectionBlock[] cds_control_connections = null;
+ ModelConnectionBlock[] cds_channelpressure_connections = null;
+ ModelConnectionBlock[] cds_polypressure_connections = null;
+ boolean sustain = false;
+ boolean[][] keybasedcontroller_active = null;
+ double[][] keybasedcontroller_value = null;
private class MidiControlObject implements SoftControl {
double[] pitch = co_midi_pitch;
@@ -336,7 +336,7 @@
}
- protected void initVoice(SoftVoice voice, SoftPerformer p, int voiceID,
+ void initVoice(SoftVoice voice, SoftPerformer p, int voiceID,
int noteNumber, int velocity, int delay, ModelConnectionBlock[] connectionBlocks,
ModelChannelMixer channelmixer, boolean releaseTriggered) {
if (voice.active) {
@@ -414,7 +414,7 @@
/* A special noteOn with delay parameter, which is used to
* start note within control buffers.
*/
- protected void noteOn(int noteNumber, int velocity, int delay) {
+ void noteOn(int noteNumber, int velocity, int delay) {
noteNumber = restrict7Bit(noteNumber);
velocity = restrict7Bit(velocity);
noteOn_internal(noteNumber, velocity, delay);
@@ -707,7 +707,7 @@
}
}
- protected void applyInstrumentCustomization() {
+ void applyInstrumentCustomization() {
if (cds_control_connections == null
&& cds_channelpressure_connections == null
&& cds_polypressure_connections == null) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -32,7 +32,7 @@
*
* @author Karl Helgason
*/
-public class SoftChannelProxy implements MidiChannel {
+public final class SoftChannelProxy implements MidiChannel {
private MidiChannel channel = null;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftChorus.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -32,11 +32,11 @@
*
* @author Karl Helgason
*/
-public class SoftChorus implements SoftAudioProcessor {
+public final class SoftChorus implements SoftAudioProcessor {
private static class VariableDelay {
- private float[] delaybuffer;
+ private final float[] delaybuffer;
private int rovepos = 0;
private float gain = 1;
private float rgain = 0;
@@ -44,7 +44,7 @@
private float lastdelay = 0;
private float feedback = 0;
- public VariableDelay(int maxbuffersize) {
+ VariableDelay(int maxbuffersize) {
delaybuffer = new float[maxbuffersize];
}
@@ -119,10 +119,10 @@
private double phase_step = 0;
private double depth = 0;
private VariableDelay vdelay;
- private double samplerate;
- private double controlrate;
+ private final double samplerate;
+ private final double controlrate;
- public LFODelay(double samplerate, double controlrate) {
+ LFODelay(double samplerate, double controlrate) {
this.samplerate = samplerate;
this.controlrate = controlrate;
// vdelay = new VariableDelay((int)(samplerate*4));
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class SoftCubicResampler extends SoftAbstractResampler {
+public final class SoftCubicResampler extends SoftAbstractResampler {
public int getPadding() {
return 3;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class SoftEnvelopeGenerator implements SoftProcess {
+public final class SoftEnvelopeGenerator implements SoftProcess {
public final static int EG_OFF = 0;
public final static int EG_DELAY = 1;
@@ -42,23 +42,23 @@
public final static int EG_END = 8;
int max_count = 10;
int used_count = 0;
- private int[] stage = new int[max_count];
- private int[] stage_ix = new int[max_count];
- private double[] stage_v = new double[max_count];
- private int[] stage_count = new int[max_count];
- private double[][] on = new double[max_count][1];
- private double[][] active = new double[max_count][1];
- private double[][] out = new double[max_count][1];
- private double[][] delay = new double[max_count][1];
- private double[][] attack = new double[max_count][1];
- private double[][] hold = new double[max_count][1];
- private double[][] decay = new double[max_count][1];
- private double[][] sustain = new double[max_count][1];
- private double[][] release = new double[max_count][1];
- private double[][] shutdown = new double[max_count][1];
- private double[][] release2 = new double[max_count][1];
- private double[][] attack2 = new double[max_count][1];
- private double[][] decay2 = new double[max_count][1];
+ private final int[] stage = new int[max_count];
+ private final int[] stage_ix = new int[max_count];
+ private final double[] stage_v = new double[max_count];
+ private final int[] stage_count = new int[max_count];
+ private final double[][] on = new double[max_count][1];
+ private final double[][] active = new double[max_count][1];
+ private final double[][] out = new double[max_count][1];
+ private final double[][] delay = new double[max_count][1];
+ private final double[][] attack = new double[max_count][1];
+ private final double[][] hold = new double[max_count][1];
+ private final double[][] decay = new double[max_count][1];
+ private final double[][] sustain = new double[max_count][1];
+ private final double[][] release = new double[max_count][1];
+ private final double[][] shutdown = new double[max_count][1];
+ private final double[][] release2 = new double[max_count][1];
+ private final double[][] attack2 = new double[max_count][1];
+ private final double[][] decay2 = new double[max_count][1];
private double control_time = 0;
public void reset() {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftFilter.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,7 +33,7 @@
*
* @author Karl Helgason
*/
-public class SoftFilter {
+public final class SoftFilter {
public final static int FILTERTYPE_LP6 = 0x00;
public final static int FILTERTYPE_LP12 = 0x01;
@@ -55,7 +55,7 @@
// 0x30 = NP, Notch or Band Elimination Filter
//
private int filtertype = FILTERTYPE_LP6;
- private float samplerate;
+ private final float samplerate;
private float x1;
private float x2;
private float y1;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -32,12 +32,12 @@
*
* @author Karl Helgason
*/
-public class SoftInstrument extends Instrument {
+public final class SoftInstrument extends Instrument {
private SoftPerformer[] performers;
private ModelPerformer[] modelperformers;
- private Object data;
- private ModelInstrument ins;
+ private final Object data;
+ private final ModelInstrument ins;
public SoftInstrument(ModelInstrument ins) {
super(ins.getSoundbank(), ins.getPatch(), ins.getName(),
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,7 +36,7 @@
*
* @author Karl Helgason
*/
-public class SoftJitterCorrector extends AudioInputStream {
+public final class SoftJitterCorrector extends AudioInputStream {
private static class JitterStream extends InputStream {
@@ -48,7 +48,7 @@
int writepos = 0;
int readpos = 0;
byte[][] buffers;
- Object buffers_mutex = new Object();
+ private final Object buffers_mutex = new Object();
// Adapative Drift Statistics
int w_count = 1000;
@@ -112,7 +112,7 @@
}
}
- public JitterStream(AudioInputStream s, int buffersize,
+ JitterStream(AudioInputStream s, int buffersize,
int smallbuffersize) {
this.w_count = 10 * (buffersize / smallbuffersize);
if (w_count < 100)
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class SoftLanczosResampler extends SoftAbstractResampler {
+public final class SoftLanczosResampler extends SoftAbstractResampler {
float[][] sinc_table;
int sinc_table_fsize = 2000;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -30,7 +30,7 @@
*
* @author Karl Helgason
*/
-public class SoftLimiter implements SoftAudioProcessor {
+public final class SoftLimiter implements SoftAudioProcessor {
float lastmax = 0;
float gain = 1;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class SoftLinearResampler extends SoftAbstractResampler {
+public final class SoftLinearResampler extends SoftAbstractResampler {
public int getPadding() {
return 2;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -31,7 +31,7 @@
*
* @author Karl Helgason
*/
-public class SoftLinearResampler2 extends SoftAbstractResampler {
+public final class SoftLinearResampler2 extends SoftAbstractResampler {
public int getPadding() {
return 2;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,21 +29,21 @@
*
* @author Karl Helgason
*/
-public class SoftLowFrequencyOscillator implements SoftProcess {
+public final class SoftLowFrequencyOscillator implements SoftProcess {
- private int max_count = 10;
+ private final int max_count = 10;
private int used_count = 0;
- private double[][] out = new double[max_count][1];
- private double[][] delay = new double[max_count][1];
- private double[][] delay2 = new double[max_count][1];
- private double[][] freq = new double[max_count][1];
- private int[] delay_counter = new int[max_count];
- private double[] sin_phase = new double[max_count];
- private double[] sin_stepfreq = new double[max_count];
- private double[] sin_step = new double[max_count];
+ private final double[][] out = new double[max_count][1];
+ private final double[][] delay = new double[max_count][1];
+ private final double[][] delay2 = new double[max_count][1];
+ private final double[][] freq = new double[max_count][1];
+ private final int[] delay_counter = new int[max_count];
+ private final double[] sin_phase = new double[max_count];
+ private final double[] sin_stepfreq = new double[max_count];
+ private final double[] sin_step = new double[max_count];
private double control_time = 0;
private double sin_factor = 0;
- private static double PI2 = 2.0 * Math.PI;
+ private static final double PI2 = 2.0 * Math.PI;
public SoftLowFrequencyOscillator() {
// If sin_step is 0 then sin_stepfreq must be -INF
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -43,7 +43,7 @@
*
* @author Karl Helgason
*/
-public class SoftMainMixer {
+public final class SoftMainMixer {
// A private class thats contains a ModelChannelMixer and it's private buffers.
// This becomes necessary when we want to have separate delay buffers for each channel mixer.
@@ -67,13 +67,13 @@
public final static int CHANNEL_RIGHT_DRY = 11;
public final static int CHANNEL_SCRATCH1 = 12;
public final static int CHANNEL_SCRATCH2 = 13;
- protected boolean active_sensing_on = false;
+ boolean active_sensing_on = false;
private long msec_last_activity = -1;
private boolean pusher_silent = false;
private int pusher_silent_count = 0;
private long sample_pos = 0;
- protected boolean readfully = true;
- private Object control_mutex;
+ boolean readfully = true;
+ private final Object control_mutex;
private SoftSynthesizer synth;
private float samplerate = 44100;
private int nrofchannels = 2;
@@ -84,7 +84,7 @@
private SoftAudioProcessor agc;
private long msec_buffer_len = 0;
private int buffer_len = 0;
- protected TreeMap midimessages = new TreeMap();
+ TreeMap midimessages = new TreeMap();
private int delay_midievent = 0;
private int max_delay_midievent = 0;
double last_volume_left = 1.0;
@@ -97,7 +97,7 @@
private Set registeredMixers = null;
private Set stoppedMixers = null;
private SoftChannelMixerContainer[] cur_registeredMixers = null;
- protected SoftControl co_master = new SoftControl() {
+ SoftControl co_master = new SoftControl() {
double[] balance = co_master_balance;
double[] volume = co_master_volume;
@@ -438,7 +438,7 @@
delay_midievent = 0;
}
- protected void processAudioBuffers() {
+ void processAudioBuffers() {
if(synth.weakstream != null && synth.weakstream.silent_samples != 0)
{
@@ -859,16 +859,16 @@
InputStream in = new InputStream() {
- private SoftAudioBuffer[] buffers = SoftMainMixer.this.buffers;
- private int nrofchannels
+ private final SoftAudioBuffer[] buffers = SoftMainMixer.this.buffers;
+ private final int nrofchannels
= SoftMainMixer.this.synth.getFormat().getChannels();
- private int buffersize = buffers[0].getSize();
- private byte[] bbuffer = new byte[buffersize
+ private final int buffersize = buffers[0].getSize();
+ private final byte[] bbuffer = new byte[buffersize
* (SoftMainMixer.this.synth.getFormat()
.getSampleSizeInBits() / 8)
* nrofchannels];
private int bbuffer_pos = 0;
- private byte[] single = new byte[1];
+ private final byte[] single = new byte[1];
public void fillBuffer() {
/*
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -50,7 +50,7 @@
*
* @author Karl Helgason
*/
-public class SoftMidiAudioFileReader extends AudioFileReader {
+public final class SoftMidiAudioFileReader extends AudioFileReader {
public static final Type MIDI = new Type("MIDI", "mid");
private static AudioFormat format = new AudioFormat(44100, 16, 2, true, false);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -42,7 +42,7 @@
*
* @author Karl Helgason
*/
-public class SoftMixingClip extends SoftMixingDataLine implements Clip {
+public final class SoftMixingClip extends SoftMixingDataLine implements Clip {
private AudioFormat format;
@@ -50,7 +50,7 @@
private byte[] data;
- private InputStream datastream = new InputStream() {
+ private final InputStream datastream = new InputStream() {
public int read() throws IOException {
byte[] b = new byte[1];
@@ -162,7 +162,7 @@
private AudioFloatInputStream afis;
- protected SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) {
+ SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) {
super(mixer, info);
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -50,22 +50,22 @@
"Chorus Send") {
};
- protected static class AudioFloatInputStreamResampler extends
+ protected static final class AudioFloatInputStreamResampler extends
AudioFloatInputStream {
- private AudioFloatInputStream ais;
+ private final AudioFloatInputStream ais;
- private AudioFormat targetFormat;
+ private final AudioFormat targetFormat;
private float[] skipbuffer;
private SoftAbstractResampler resampler;
- private float[] pitch = new float[1];
+ private final float[] pitch = new float[1];
- private float[] ibuffer2;
+ private final float[] ibuffer2;
- private float[][] ibuffer;
+ private final float[][] ibuffer;
private float ibuffer_index = 0;
@@ -75,15 +75,15 @@
private float[][] cbuffer;
- private int buffer_len = 512;
+ private final int buffer_len = 512;
- private int pad;
+ private final int pad;
- private int pad2;
+ private final int pad2;
- private float[] ix = new float[1];
+ private final float[] ix = new float[1];
- private int[] ox = new int[1];
+ private final int[] ox = new int[1];
private float[][] mark_ibuffer = null;
@@ -294,7 +294,7 @@
}
- private class Gain extends FloatControl {
+ private final class Gain extends FloatControl {
private Gain() {
@@ -308,7 +308,7 @@
}
}
- private class Mute extends BooleanControl {
+ private final class Mute extends BooleanControl {
private Mute() {
super(BooleanControl.Type.MUTE, false, "True", "False");
@@ -320,7 +320,7 @@
}
}
- private class ApplyReverb extends BooleanControl {
+ private final class ApplyReverb extends BooleanControl {
private ApplyReverb() {
super(BooleanControl.Type.APPLY_REVERB, false, "True", "False");
@@ -333,7 +333,7 @@
}
- private class Balance extends FloatControl {
+ private final class Balance extends FloatControl {
private Balance() {
super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1,
@@ -347,7 +347,7 @@
}
- private class Pan extends FloatControl {
+ private final class Pan extends FloatControl {
private Pan() {
super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1,
@@ -365,7 +365,7 @@
}
- private class ReverbSend extends FloatControl {
+ private final class ReverbSend extends FloatControl {
private ReverbSend() {
super(FloatControl.Type.REVERB_SEND, -80f, 6.0206f, 80f / 128.0f,
@@ -379,7 +379,7 @@
}
- private class ChorusSend extends FloatControl {
+ private final class ChorusSend extends FloatControl {
private ChorusSend() {
super(CHORUS_SEND, -80f, 6.0206f, 80f / 128.0f, -1, -80f, "dB",
@@ -393,43 +393,43 @@
}
- private Gain gain_control = new Gain();
+ private final Gain gain_control = new Gain();
- private Mute mute_control = new Mute();
+ private final Mute mute_control = new Mute();
- private Balance balance_control = new Balance();
+ private final Balance balance_control = new Balance();
- private Pan pan_control = new Pan();
+ private final Pan pan_control = new Pan();
- private ReverbSend reverbsend_control = new ReverbSend();
+ private final ReverbSend reverbsend_control = new ReverbSend();
- private ChorusSend chorussend_control = new ChorusSend();
+ private final ChorusSend chorussend_control = new ChorusSend();
- private ApplyReverb apply_reverb = new ApplyReverb();
+ private final ApplyReverb apply_reverb = new ApplyReverb();
- private Control[] controls;
+ private final Control[] controls;
- protected float leftgain = 1;
+ float leftgain = 1;
- protected float rightgain = 1;
+ float rightgain = 1;
- protected float eff1gain = 0;
+ float eff1gain = 0;
- protected float eff2gain = 0;
+ float eff2gain = 0;
- protected List listeners = new ArrayList();
+ List listeners = new ArrayList();
- protected Object control_mutex;
+ final Object control_mutex;
- protected SoftMixingMixer mixer;
+ SoftMixingMixer mixer;
- protected DataLine.Info info;
+ DataLine.Info info;
protected abstract void processControlLogic();
protected abstract void processAudioLogic(SoftAudioBuffer[] buffers);
- protected SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) {
+ SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) {
this.mixer = mixer;
this.info = info;
this.control_mutex = mixer.control_mutex;
@@ -440,7 +440,7 @@
calcVolume();
}
- protected void calcVolume() {
+ final void calcVolume() {
synchronized (control_mutex) {
double gain = Math.pow(10.0, gain_control.getValue() / 20.0);
if (mute_control.getValue())
@@ -466,7 +466,7 @@
}
}
- protected void sendEvent(LineEvent event) {
+ final void sendEvent(LineEvent event) {
if (listeners.size() == 0)
return;
LineListener[] listener_array = listeners
@@ -476,23 +476,23 @@
}
}
- public void addLineListener(LineListener listener) {
+ public final void addLineListener(LineListener listener) {
synchronized (control_mutex) {
listeners.add(listener);
}
}
- public void removeLineListener(LineListener listener) {
+ public final void removeLineListener(LineListener listener) {
synchronized (control_mutex) {
listeners.add(listener);
}
}
- public javax.sound.sampled.Line.Info getLineInfo() {
+ public final javax.sound.sampled.Line.Info getLineInfo() {
return info;
}
- public Control getControl(Type control) {
+ public final Control getControl(Type control) {
if (control != null) {
for (int i = 0; i < controls.length; i++) {
if (controls[i].getType() == control) {
@@ -504,11 +504,11 @@
+ control);
}
- public Control[] getControls() {
+ public final Control[] getControls() {
return Arrays.copyOf(controls, controls.length);
}
- public boolean isControlSupported(Type control) {
+ public final boolean isControlSupported(Type control) {
if (control != null) {
for (int i = 0; i < controls.length; i++) {
if (controls[i].getType() == control) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -37,7 +37,7 @@
*
* @author Karl Helgason
*/
-public class SoftMixingMainMixer {
+public final class SoftMixingMainMixer {
public final static int CHANNEL_LEFT = 0;
@@ -63,23 +63,23 @@
public final static int CHANNEL_CHANNELMIXER_RIGHT = 15;
- private SoftMixingMixer mixer;
+ private final SoftMixingMixer mixer;
- private AudioInputStream ais;
+ private final AudioInputStream ais;
- private SoftAudioBuffer[] buffers;
+ private final SoftAudioBuffer[] buffers;
- private SoftAudioProcessor reverb;
+ private final SoftAudioProcessor reverb;
- private SoftAudioProcessor chorus;
+ private final SoftAudioProcessor chorus;
- private SoftAudioProcessor agc;
+ private final SoftAudioProcessor agc;
- private int nrofchannels;
+ private final int nrofchannels;
- private Object control_mutex;
+ private final Object control_mutex;
- private List openLinesList = new ArrayList();
+ private final List openLinesList = new ArrayList();
private SoftMixingDataLine[] openLines = new SoftMixingDataLine[0];
@@ -87,7 +87,7 @@
return ais;
}
- protected void processAudioBuffers() {
+ void processAudioBuffers() {
for (int i = 0; i < buffers.length; i++) {
buffers[i].clear();
}
@@ -162,20 +162,20 @@
InputStream in = new InputStream() {
- private SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers;
+ private final SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers;
- private int nrofchannels = SoftMixingMainMixer.this.mixer
+ private final int nrofchannels = SoftMixingMainMixer.this.mixer
.getFormat().getChannels();
- private int buffersize = buffers[0].getSize();
+ private final int buffersize = buffers[0].getSize();
- private byte[] bbuffer = new byte[buffersize
+ private final byte[] bbuffer = new byte[buffersize
* (SoftMixingMainMixer.this.mixer.getFormat()
.getSampleSizeInBits() / 8) * nrofchannels];
private int bbuffer_pos = 0;
- private byte[] single = new byte[1];
+ private final byte[] single = new byte[1];
public void fillBuffer() {
processAudioBuffers();
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -48,27 +48,27 @@
*
* @author Karl Helgason
*/
-public class SoftMixingMixer implements Mixer {
+public final class SoftMixingMixer implements Mixer {
private static class Info extends Mixer.Info {
- public Info() {
+ Info() {
super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION);
}
}
- protected static final String INFO_NAME = "Gervill Sound Mixer";
+ static final String INFO_NAME = "Gervill Sound Mixer";
- protected static final String INFO_VENDOR = "OpenJDK Proposal";
+ static final String INFO_VENDOR = "OpenJDK Proposal";
- protected static final String INFO_DESCRIPTION = "Software Sound Mixer";
+ static final String INFO_DESCRIPTION = "Software Sound Mixer";
- protected static final String INFO_VERSION = "1.0";
+ static final String INFO_VERSION = "1.0";
- protected final static Mixer.Info info = new Info();
+ static final Mixer.Info info = new Info();
- protected Object control_mutex = this;
+ final Object control_mutex = this;
- protected boolean implicitOpen = false;
+ boolean implicitOpen = false;
private boolean open = false;
@@ -82,15 +82,15 @@
private AudioInputStream pusher_stream = null;
- private float controlrate = 147f;
+ private final float controlrate = 147f;
- private long latency = 100000; // 100 msec
+ private final long latency = 100000; // 100 msec
- private boolean jitter_correction = false;
+ private final boolean jitter_correction = false;
- private List listeners = new ArrayList();
+ private final List listeners = new ArrayList();
- private javax.sound.sampled.Line.Info[] sourceLineInfo;
+ private final javax.sound.sampled.Line.Info[] sourceLineInfo;
public SoftMixingMixer() {
@@ -516,11 +516,11 @@
}
}
- protected float getControlRate() {
+ float getControlRate() {
return controlrate;
}
- protected SoftMixingMainMixer getMainMixer() {
+ SoftMixingMainMixer getMainMixer() {
if (!isOpen())
return null;
return mainmixer;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -33,13 +33,13 @@
*
* @author Karl Helgason
*/
-public class SoftMixingMixerProvider extends MixerProvider {
+public final class SoftMixingMixerProvider extends MixerProvider {
static SoftMixingMixer globalmixer = null;
static Thread lockthread = null;
- protected final static Object mutex = new Object();
+ static final Object mutex = new Object();
public Mixer getMixer(Info info) {
if (!(info == null || info == SoftMixingMixer.info)) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -41,8 +41,8 @@
*
* @author Karl Helgason
*/
-public class SoftMixingSourceDataLine extends SoftMixingDataLine implements
- SourceDataLine {
+public final class SoftMixingSourceDataLine extends SoftMixingDataLine
+ implements SourceDataLine {
private boolean open = false;
@@ -72,7 +72,7 @@
AudioFloatInputStream {
AudioFloatInputStream ais;
- public NonBlockingFloatInputStream(AudioFloatInputStream ais) {
+ NonBlockingFloatInputStream(AudioFloatInputStream ais) {
this.ais = ais;
}
@@ -120,7 +120,7 @@
}
- protected SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) {
+ SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) {
super(mixer, info);
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -37,7 +37,7 @@
*
* @author Karl Helgason
*/
-public class SoftPerformer {
+public final class SoftPerformer {
static ModelConnectionBlock[] defaultconnections
= new ModelConnectionBlock[42];
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -29,7 +29,7 @@
*
* @author Karl Helgason
*/
-public class SoftPointResampler extends SoftAbstractResampler {
+public final class SoftPointResampler extends SoftAbstractResampler {
public int getPadding() {
return 100;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftProvider.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -34,10 +34,10 @@
*
* @author Karl Helgason
*/
-public class SoftProvider extends MidiDeviceProvider {
+public final class SoftProvider extends MidiDeviceProvider {
- protected final static Info softinfo = SoftSynthesizer.info;
- private static Info[] softinfos = {softinfo};
+ static final Info softinfo = SoftSynthesizer.info;
+ private static final Info[] softinfos = {softinfo};
public MidiDevice.Info[] getDeviceInfo() {
return Arrays.copyOf(softinfos, softinfos.length);
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,13 +36,13 @@
*
* @author Karl Helgason
*/
-public class SoftReceiver implements MidiDeviceReceiver {
+public final class SoftReceiver implements MidiDeviceReceiver {
- protected boolean open = true;
- private Object control_mutex;
- private SoftSynthesizer synth;
- protected TreeMap midimessages;
- protected SoftMainMixer mainmixer;
+ boolean open = true;
+ private final Object control_mutex;
+ private final SoftSynthesizer synth;
+ TreeMap midimessages;
+ SoftMainMixer mainmixer;
public SoftReceiver(SoftSynthesizer synth) {
this.control_mutex = synth.control_mutex;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftReverb.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -33,14 +33,14 @@
*
* @author Karl Helgason
*/
-public class SoftReverb implements SoftAudioProcessor {
+public final class SoftReverb implements SoftAudioProcessor {
private final static class Delay {
private float[] delaybuffer;
private int rovepos = 0;
- public Delay() {
+ Delay() {
delaybuffer = null;
}
@@ -77,7 +77,7 @@
private int rovepos = 0;
private float feedback;
- public AllPass(int size) {
+ AllPass(int size) {
delaybuffer = new float[size];
delaybuffersize = size;
}
@@ -127,7 +127,7 @@
private float filtercoeff1 = 0;
private float filtercoeff2 = 1;
- public Comb(int size) {
+ Comb(int size) {
delaybuffer = new float[size];
delaybuffersize = size;
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -32,7 +32,7 @@
*
* @author Karl Helgason
*/
-public class SoftShortMessage extends ShortMessage {
+public final class SoftShortMessage extends ShortMessage {
int channel = 0;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -31,7 +31,7 @@
*
* @author Karl Helgason
*/
-public class SoftSincResampler extends SoftAbstractResampler {
+public final class SoftSincResampler extends SoftAbstractResampler {
float[][][] sinc_table;
int sinc_scale_size = 100;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -66,10 +66,10 @@
*
* @author Karl Helgason
*/
-public class SoftSynthesizer implements AudioSynthesizer,
+public final class SoftSynthesizer implements AudioSynthesizer,
ReferenceCountingDevice {
- protected static class WeakAudioStream extends InputStream
+ protected static final class WeakAudioStream extends InputStream
{
private volatile AudioInputStream stream;
public SoftAudioPusher pusher = null;
@@ -166,39 +166,39 @@
}
private static class Info extends MidiDevice.Info {
- public Info() {
+ Info() {
super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION);
}
}
- protected static final String INFO_NAME = "Gervill";
- protected static final String INFO_VENDOR = "OpenJDK";
- protected static final String INFO_DESCRIPTION = "Software MIDI Synthesizer";
- protected static final String INFO_VERSION = "1.0";
- protected final static MidiDevice.Info info = new Info();
+ static final String INFO_NAME = "Gervill";
+ static final String INFO_VENDOR = "OpenJDK";
+ static final String INFO_DESCRIPTION = "Software MIDI Synthesizer";
+ static final String INFO_VERSION = "1.0";
+ final static MidiDevice.Info info = new Info();
private static SourceDataLine testline = null;
private static Soundbank defaultSoundBank = null;
- protected WeakAudioStream weakstream = null;
+ WeakAudioStream weakstream = null;
- protected Object control_mutex = this;
+ final Object control_mutex = this;
- protected int voiceIDCounter = 0;
+ int voiceIDCounter = 0;
// 0: default
// 1: DLS Voice Allocation
- protected int voice_allocation_mode = 0;
+ int voice_allocation_mode = 0;
- protected boolean load_default_soundbank = false;
- protected boolean reverb_light = true;
- protected boolean reverb_on = true;
- protected boolean chorus_on = true;
- protected boolean agc_on = true;
+ boolean load_default_soundbank = false;
+ boolean reverb_light = true;
+ boolean reverb_on = true;
+ boolean chorus_on = true;
+ boolean agc_on = true;
- protected SoftChannel[] channels;
- protected SoftChannelProxy[] external_channels = null;
+ SoftChannel[] channels;
+ SoftChannelProxy[] external_channels = null;
private boolean largemode = false;
@@ -371,7 +371,7 @@
this.format = format;
}
- protected void removeReceiver(Receiver recv) {
+ void removeReceiver(Receiver recv) {
boolean perform_close = false;
synchronized (control_mutex) {
if (recvslist.remove(recv)) {
@@ -383,13 +383,13 @@
close();
}
- protected SoftMainMixer getMainMixer() {
+ SoftMainMixer getMainMixer() {
if (!isOpen())
return null;
return mainmixer;
}
- protected SoftInstrument findInstrument(int program, int bank, int channel) {
+ SoftInstrument findInstrument(int program, int bank, int channel) {
// Add support for GM2 banks 0x78 and 0x79
// as specified in DLS 2.2 in Section 1.4.6
@@ -450,31 +450,31 @@
return null;
}
- protected int getVoiceAllocationMode() {
+ int getVoiceAllocationMode() {
return voice_allocation_mode;
}
- protected int getGeneralMidiMode() {
+ int getGeneralMidiMode() {
return gmmode;
}
- protected void setGeneralMidiMode(int gmmode) {
+ void setGeneralMidiMode(int gmmode) {
this.gmmode = gmmode;
}
- protected int getDeviceID() {
+ int getDeviceID() {
return deviceid;
}
- protected float getControlRate() {
+ float getControlRate() {
return controlrate;
}
- protected SoftVoice[] getVoices() {
+ SoftVoice[] getVoices() {
return voices;
}
- protected SoftTuning getTuning(Patch patch) {
+ SoftTuning getTuning(Patch patch) {
String t_id = patchToString(patch);
SoftTuning tuning = tunings.get(t_id);
if (tuning == null) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftTuning.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -35,10 +35,10 @@
*
* @author Karl Helgason
*/
-public class SoftTuning {
+public final class SoftTuning {
private String name = null;
- private double[] tuning = new double[128];
+ private final double[] tuning = new double[128];
private Patch patch = null;
public SoftTuning() {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SoftVoice.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -36,7 +36,7 @@
*
* @author Karl Helgason
*/
-public class SoftVoice extends VoiceStatus {
+public final class SoftVoice extends VoiceStatus {
public int exclusiveClass = 0;
public boolean releaseTriggered = false;
@@ -44,32 +44,32 @@
private int noteOn_velocity = 0;
private int noteOff_velocity = 0;
private int delay = 0;
- protected ModelChannelMixer channelmixer = null;
- protected double tunedKey = 0;
- protected SoftTuning tuning = null;
- protected SoftChannel stealer_channel = null;
- protected ModelConnectionBlock[] stealer_extendedConnectionBlocks = null;
- protected SoftPerformer stealer_performer = null;
- protected ModelChannelMixer stealer_channelmixer = null;
- protected int stealer_voiceID = -1;
- protected int stealer_noteNumber = 0;
- protected int stealer_velocity = 0;
- protected boolean stealer_releaseTriggered = false;
- protected int voiceID = -1;
- protected boolean sustain = false;
- protected boolean sostenuto = false;
- protected boolean portamento = false;
- private SoftFilter filter_left;
- private SoftFilter filter_right;
- private SoftProcess eg = new SoftEnvelopeGenerator();
- private SoftProcess lfo = new SoftLowFrequencyOscillator();
- protected Map objects =
+ ModelChannelMixer channelmixer = null;
+ double tunedKey = 0;
+ SoftTuning tuning = null;
+ SoftChannel stealer_channel = null;
+ ModelConnectionBlock[] stealer_extendedConnectionBlocks = null;
+ SoftPerformer stealer_performer = null;
+ ModelChannelMixer stealer_channelmixer = null;
+ int stealer_voiceID = -1;
+ int stealer_noteNumber = 0;
+ int stealer_velocity = 0;
+ boolean stealer_releaseTriggered = false;
+ int voiceID = -1;
+ boolean sustain = false;
+ boolean sostenuto = false;
+ boolean portamento = false;
+ private final SoftFilter filter_left;
+ private final SoftFilter filter_right;
+ private final SoftProcess eg = new SoftEnvelopeGenerator();
+ private final SoftProcess lfo = new SoftLowFrequencyOscillator();
+ Map objects =
new HashMap();
- protected SoftSynthesizer synthesizer;
- protected SoftInstrument instrument;
- protected SoftPerformer performer;
- protected SoftChannel softchannel = null;
- protected boolean on = false;
+ SoftSynthesizer synthesizer;
+ SoftInstrument instrument;
+ SoftPerformer performer;
+ SoftChannel softchannel = null;
+ boolean on = false;
private boolean audiostarted = false;
private boolean started = false;
private boolean stopping = false;
@@ -87,7 +87,7 @@
private float last_out_mixer_right = 0;
private float last_out_mixer_effect1 = 0;
private float last_out_mixer_effect2 = 0;
- protected ModelConnectionBlock[] extendedConnectionBlocks = null;
+ ModelConnectionBlock[] extendedConnectionBlocks = null;
private ModelConnectionBlock[] connections;
// Last value added to destination
private double[] connections_last = new double[50];
@@ -100,10 +100,10 @@
private boolean soundoff = false;
private float lastMuteValue = 0;
private float lastSoloMuteValue = 0;
- protected double[] co_noteon_keynumber = new double[1];
- protected double[] co_noteon_velocity = new double[1];
- protected double[] co_noteon_on = new double[1];
- private SoftControl co_noteon = new SoftControl() {
+ double[] co_noteon_keynumber = new double[1];
+ double[] co_noteon_velocity = new double[1];
+ double[] co_noteon_on = new double[1];
+ private final SoftControl co_noteon = new SoftControl() {
double[] keynumber = co_noteon_keynumber;
double[] velocity = co_noteon_velocity;
double[] on = co_noteon_on;
@@ -119,13 +119,13 @@
return null;
}
};
- private double[] co_mixer_active = new double[1];
- private double[] co_mixer_gain = new double[1];
- private double[] co_mixer_pan = new double[1];
- private double[] co_mixer_balance = new double[1];
- private double[] co_mixer_reverb = new double[1];
- private double[] co_mixer_chorus = new double[1];
- private SoftControl co_mixer = new SoftControl() {
+ private final double[] co_mixer_active = new double[1];
+ private final double[] co_mixer_gain = new double[1];
+ private final double[] co_mixer_pan = new double[1];
+ private final double[] co_mixer_balance = new double[1];
+ private final double[] co_mixer_reverb = new double[1];
+ private final double[] co_mixer_chorus = new double[1];
+ private final SoftControl co_mixer = new SoftControl() {
double[] active = co_mixer_active;
double[] gain = co_mixer_gain;
double[] pan = co_mixer_pan;
@@ -150,8 +150,8 @@
return null;
}
};
- private double[] co_osc_pitch = new double[1];
- private SoftControl co_osc = new SoftControl() {
+ private final double[] co_osc_pitch = new double[1];
+ private final SoftControl co_osc = new SoftControl() {
double[] pitch = co_osc_pitch;
public double[] get(int instance, String name) {
if (name == null)
@@ -161,10 +161,10 @@
return null;
}
};
- private double[] co_filter_freq = new double[1];
- private double[] co_filter_type = new double[1];
- private double[] co_filter_q = new double[1];
- private SoftControl co_filter = new SoftControl() {
+ private final double[] co_filter_freq = new double[1];
+ private final double[] co_filter_type = new double[1];
+ private final double[] co_filter_q = new double[1];
+ private final SoftControl co_filter = new SoftControl() {
double[] freq = co_filter_freq;
double[] ftype = co_filter_type;
double[] q = co_filter_q;
@@ -180,8 +180,8 @@
return null;
}
};
- protected SoftResamplerStreamer resampler;
- private int nrofchannels;
+ SoftResamplerStreamer resampler;
+ private final int nrofchannels;
public SoftVoice(SoftSynthesizer synth) {
synthesizer = synth;
@@ -278,7 +278,7 @@
// co_mixer_gain[0] = 0;
}
- protected void updateTuning(SoftTuning newtuning) {
+ void updateTuning(SoftTuning newtuning) {
tuning = newtuning;
tunedKey = tuning.getTuning(note) / 100.0;
if (!portamento) {
@@ -293,12 +293,12 @@
}
}
- protected void setNote(int noteNumber) {
+ void setNote(int noteNumber) {
note = noteNumber;
tunedKey = tuning.getTuning(noteNumber) / 100.0;
}
- protected void noteOn(int noteNumber, int velocity, int delay) {
+ void noteOn(int noteNumber, int velocity, int delay) {
sustain = false;
sostenuto = false;
@@ -435,7 +435,7 @@
}
- protected void setPolyPressure(int pressure) {
+ void setPolyPressure(int pressure) {
if(performer == null)
return;
int[] c = performer.midi_connections[2];
@@ -445,7 +445,7 @@
processConnection(c[i]);
}
- protected void setChannelPressure(int pressure) {
+ void setChannelPressure(int pressure) {
if(performer == null)
return;
int[] c = performer.midi_connections[1];
@@ -455,7 +455,7 @@
processConnection(c[i]);
}
- protected void controlChange(int controller, int value) {
+ void controlChange(int controller, int value) {
if(performer == null)
return;
int[] c = performer.midi_ctrl_connections[controller];
@@ -465,7 +465,7 @@
processConnection(c[i]);
}
- protected void nrpnChange(int controller, int value) {
+ void nrpnChange(int controller, int value) {
if(performer == null)
return;
int[] c = performer.midi_nrpn_connections.get(controller);
@@ -475,7 +475,7 @@
processConnection(c[i]);
}
- protected void rpnChange(int controller, int value) {
+ void rpnChange(int controller, int value) {
if(performer == null)
return;
int[] c = performer.midi_rpn_connections.get(controller);
@@ -485,7 +485,7 @@
processConnection(c[i]);
}
- protected void setPitchBend(int bend) {
+ void setPitchBend(int bend) {
if(performer == null)
return;
int[] c = performer.midi_connections[0];
@@ -495,19 +495,19 @@
processConnection(c[i]);
}
- protected void setMute(boolean mute) {
+ void setMute(boolean mute) {
co_mixer_gain[0] -= lastMuteValue;
lastMuteValue = mute ? -960 : 0;
co_mixer_gain[0] += lastMuteValue;
}
- protected void setSoloMute(boolean mute) {
+ void setSoloMute(boolean mute) {
co_mixer_gain[0] -= lastSoloMuteValue;
lastSoloMuteValue = mute ? -960 : 0;
co_mixer_gain[0] += lastSoloMuteValue;
}
- protected void shutdown() {
+ void shutdown() {
if (co_noteon_on[0] < -0.5)
return;
on = false;
@@ -523,12 +523,12 @@
processConnection(c[i]);
}
- protected void soundOff() {
+ void soundOff() {
on = false;
soundoff = true;
}
- protected void noteOff(int velocity) {
+ void noteOff(int velocity) {
if (!on)
return;
on = false;
@@ -553,7 +553,7 @@
processConnection(c[i]);
}
- protected void redamp() {
+ void redamp() {
if (co_noteon_on[0] > 0.5)
return;
if (co_noteon_on[0] < -0.5)
@@ -571,7 +571,7 @@
processConnection(c[i]);
}
- protected void processControlLogic() {
+ void processControlLogic() {
if (stopping) {
active = false;
stopping = false;
@@ -760,9 +760,9 @@
}
- protected void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out,
- SoftAudioBuffer dout,
- float amp_from, float amp_to) {
+ void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out,
+ SoftAudioBuffer dout, float amp_from,
+ float amp_to) {
int bufferlen = in.getSize();
if (amp_from < 0.000000001 && amp_to < 0.000000001)
return;
@@ -815,7 +815,7 @@
}
- protected void processAudioLogic(SoftAudioBuffer[] buffer) {
+ void processAudioLogic(SoftAudioBuffer[] buffer) {
if (!audiostarted)
return;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -26,22 +26,13 @@
package com.sun.media.sound;
import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.SequenceInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.EOFException;
-import java.io.OutputStream;
-import java.io.RandomAccessFile;
import java.io.BufferedInputStream;
import java.net.URL;
-import java.net.MalformedURLException;
import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.InvalidMidiDataException;
@@ -49,7 +40,6 @@
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.Sequence;
-import javax.sound.midi.ShortMessage;
import javax.sound.midi.SysexMessage;
import javax.sound.midi.Track;
import javax.sound.midi.spi.MidiFileReader;
@@ -64,23 +54,12 @@
* @author Florian Bomers
*/
-public class StandardMidiFileReader extends MidiFileReader {
+public final class StandardMidiFileReader extends MidiFileReader {
private static final int MThd_MAGIC = 0x4d546864; // 'MThd'
- private static final int MIDI_TYPE_0 = 0;
- private static final int MIDI_TYPE_1 = 1;
-
private static final int bisBufferSize = 1024; // buffer size in buffered input streams
- /**
- * MIDI parser types
- */
- private static final int types[] = {
- MIDI_TYPE_0,
- MIDI_TYPE_1
- };
-
public MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException {
return getMidiFileFormatFromStream(stream, MidiFileFormat.UNKNOWN_LENGTH, null);
}
@@ -253,7 +232,7 @@
/**
* State variables during parsing of a MIDI file
*/
-class SMFParser {
+final class SMFParser {
private static final int MTrk_MAGIC = 0x4d54726b; // 'MTrk'
// set to true to not allow corrupt MIDI files tombe loaded
@@ -268,7 +247,7 @@
private byte[] trackData = null;
private int pos = 0;
- public SMFParser() {
+ SMFParser() {
}
private int readUnsigned() throws IOException {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,7 +25,6 @@
package com.sun.media.sound;
-import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
@@ -34,18 +33,13 @@
import java.io.SequenceInputStream;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.IOException;
-import java.lang.IllegalArgumentException;
import java.io.OutputStream;
-import java.util.Vector;
-import javax.sound.midi.MidiFileFormat;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MetaMessage;
-import javax.sound.midi.MidiMessage;
import javax.sound.midi.Sequence;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.SysexMessage;
@@ -59,7 +53,7 @@
* @author Kara Kytle
* @author Jan Borgersen
*/
-public class StandardMidiFileWriter extends MidiFileWriter {
+public final class StandardMidiFileWriter extends MidiFileWriter {
private static final int MThd_MAGIC = 0x4d546864; // 'MThd'
private static final int MTrk_MAGIC = 0x4d54726b; // 'MTrk'
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SunCodec.java
--- a/jdk/src/share/classes/com/sun/media/sound/SunCodec.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SunCodec.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,8 +25,6 @@
package com.sun.media.sound;
-import java.io.InputStream;
-
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
@@ -48,14 +46,14 @@
*/
abstract class SunCodec extends FormatConversionProvider {
- AudioFormat.Encoding[] inputEncodings;
- AudioFormat.Encoding[] outputEncodings;
+ private final AudioFormat.Encoding[] inputEncodings;
+ private final AudioFormat.Encoding[] outputEncodings;
/**
* Constructs a new codec object.
*/
- protected SunCodec(AudioFormat.Encoding[] inputEncodings, AudioFormat.Encoding[] outputEncodings) {
-
+ SunCodec(final AudioFormat.Encoding[] inputEncodings,
+ final AudioFormat.Encoding[] outputEncodings) {
this.inputEncodings = inputEncodings;
this.outputEncodings = outputEncodings;
}
@@ -63,16 +61,14 @@
/**
*/
- public AudioFormat.Encoding[] getSourceEncodings() {
-
+ public final AudioFormat.Encoding[] getSourceEncodings() {
AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[inputEncodings.length];
System.arraycopy(inputEncodings, 0, encodings, 0, inputEncodings.length);
return encodings;
}
/**
*/
- public AudioFormat.Encoding[] getTargetEncodings() {
-
+ public final AudioFormat.Encoding[] getTargetEncodings() {
AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[outputEncodings.length];
System.arraycopy(outputEncodings, 0, encodings, 0, outputEncodings.length);
return encodings;
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SunFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -27,7 +27,6 @@
import java.io.File;
import java.io.InputStream;
-import java.io.OutputStream;
import java.io.IOException;
import java.io.DataInputStream;
import java.net.URL;
@@ -52,7 +51,7 @@
/**
* Constructs a new SunFileReader object.
*/
- public SunFileReader() {
+ SunFileReader() {
}
@@ -167,7 +166,7 @@
* @return 32 bits swapped value.
* @exception IOException
*/
- protected int rllong(DataInputStream dis) throws IOException {
+ final int rllong(DataInputStream dis) throws IOException {
int b1, b2, b3, b4 ;
int i = 0;
@@ -190,7 +189,7 @@
* @param int
* @return 32 bits swapped value
*/
- protected int big2little(int i) {
+ final int big2little(int i) {
int b1, b2, b3, b4 ;
@@ -211,7 +210,7 @@
* @return the swapped value.
* @exception IOException
*/
- protected short rlshort(DataInputStream dis) throws IOException {
+ final short rlshort(DataInputStream dis) throws IOException {
short s=0;
short high, low;
@@ -232,7 +231,7 @@
* @param int
* @return 16 bits swapped value
*/
- protected short big2littleShort(short i) {
+ final short big2littleShort(short i) {
short high, low;
@@ -244,16 +243,14 @@
return i;
}
-
- /** Calculates the frame size for PCM frames.
- * Note that this method is appropriate for non-packed samples.
- * For instance, 12 bit, 2 channels will return 4 bytes, not 3.
- * @param sampleSizeInBits the size of a single sample in bits
- * @param channels the number of channels
- * @return the size of a PCM frame in bytes.
- */
- protected static int calculatePCMFrameSize(int sampleSizeInBits,
- int channels) {
- return ((sampleSizeInBits + 7) / 8) * channels;
- }
+ /** Calculates the frame size for PCM frames.
+ * Note that this method is appropriate for non-packed samples.
+ * For instance, 12 bit, 2 channels will return 4 bytes, not 3.
+ * @param sampleSizeInBits the size of a single sample in bits
+ * @param channels the number of channels
+ * @return the size of a PCM frame in bytes.
+ */
+ static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) {
+ return ((sampleSizeInBits + 7) / 8) * channels;
+ }
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -69,8 +69,7 @@
// new, 10.27.99
- public AudioFileFormat.Type[] getAudioFileTypes(){
-
+ public final AudioFileFormat.Type[] getAudioFileTypes(){
AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length];
System.arraycopy(types, 0, localArray, 0, types.length);
return localArray;
@@ -95,7 +94,7 @@
* @return 32 bits swapped value.
* @exception IOException
*/
- protected int rllong(DataInputStream dis) throws IOException {
+ final int rllong(DataInputStream dis) throws IOException {
int b1, b2, b3, b4 ;
int i = 0;
@@ -118,7 +117,7 @@
* @param int
* @return 32 bits swapped value
*/
- protected int big2little(int i) {
+ final int big2little(int i) {
int b1, b2, b3, b4 ;
@@ -139,7 +138,7 @@
* @return the swapped value.
* @exception IOException
*/
- protected short rlshort(DataInputStream dis) throws IOException {
+ final short rlshort(DataInputStream dis) throws IOException {
short s=0;
short high, low;
@@ -160,7 +159,7 @@
* @param int
* @return 16 bits swapped value
*/
- protected short big2littleShort(short i) {
+ final short big2littleShort(short i) {
short high, low;
@@ -177,10 +176,10 @@
* The class is usefull for use with SequenceInputStream to prevent
* closing of the source input streams.
*/
- protected class NoCloseInputStream extends InputStream {
+ final class NoCloseInputStream extends InputStream {
private final InputStream in;
- public NoCloseInputStream(InputStream in) {
+ NoCloseInputStream(InputStream in) {
this.in = in;
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/Toolkit.java
--- a/jdk/src/share/classes/com/sun/media/sound/Toolkit.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/Toolkit.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -35,8 +35,13 @@
* @author Kara Kytle
* @author Florian Bomers
*/
-public class Toolkit {
+public final class Toolkit {
+ /**
+ * Suppresses default constructor, ensuring non-instantiability.
+ */
+ private Toolkit() {
+ }
/**
* Converts bytes from signed to unsigned.
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/UlawCodec.java
--- a/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,7 +25,6 @@
package com.sun.media.sound;
-import java.io.InputStream;
import java.io.IOException;
import java.util.Vector;
@@ -40,12 +39,12 @@
*
* @author Kara Kytle
*/
-public class UlawCodec extends SunCodec {
+public final class UlawCodec extends SunCodec {
/* Tables used for U-law decoding */
- final static byte ULAW_TABH[] = new byte[256];
- final static byte ULAW_TABL[] = new byte[256];
+ private final static byte[] ULAW_TABH = new byte[256];
+ private final static byte[] ULAW_TABL = new byte[256];
private static final AudioFormat.Encoding[] ulawEncodings = {AudioFormat.Encoding.ULAW,
AudioFormat.Encoding.PCM_SIGNED};
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -46,7 +46,7 @@
*
* @author Karl Helgason
*/
-public class WaveExtensibleFileReader extends AudioFileReader {
+public final class WaveExtensibleFileReader extends AudioFileReader {
static private class GUID {
long i1;
@@ -74,7 +74,7 @@
private GUID() {
}
- public GUID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
+ GUID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
int x5, int x6, int x7, int x8) {
this.i1 = i1;
this.s1 = s1;
@@ -140,13 +140,13 @@
}
- private static String[] channelnames = { "FL", "FR", "FC", "LF",
+ private static final String[] channelnames = { "FL", "FR", "FC", "LF",
"BL",
"BR", // 5.1
"FLC", "FLR", "BC", "SL", "SR", "TC", "TFL", "TFC", "TFR", "TBL",
"TBC", "TBR" };
- private static String[] allchannelnames = { "w1", "w2", "w3", "w4", "w5",
+ private static final String[] allchannelnames = { "w1", "w2", "w3", "w4", "w5",
"w6", "w7", "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15",
"w16", "w17", "w18", "w19", "w20", "w21", "w22", "w23", "w24",
"w25", "w26", "w27", "w28", "w29", "w30", "w31", "w32", "w33",
@@ -155,10 +155,10 @@
"w52", "w53", "w54", "w55", "w56", "w57", "w58", "w59", "w60",
"w61", "w62", "w63", "w64" };
- private static GUID SUBTYPE_PCM = new GUID(0x00000001, 0x0000, 0x0010,
+ private static final GUID SUBTYPE_PCM = new GUID(0x00000001, 0x0000, 0x0010,
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
- private static GUID SUBTYPE_IEEE_FLOAT = new GUID(0x00000003, 0x0000,
+ private static final GUID SUBTYPE_IEEE_FLOAT = new GUID(0x00000003, 0x0000,
0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
private String decodeChannelMask(long channelmask) {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,24 +25,8 @@
package com.sun.media.sound;
-import java.util.Vector;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.lang.IllegalArgumentException;
-
-import java.io.BufferedOutputStream;
-import java.io.DataOutputStream;
-import java.io.FileOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.SequenceInputStream;
-
import javax.sound.sampled.AudioFileFormat;
-import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.AudioSystem;
/**
@@ -51,12 +35,12 @@
* @author Jan Borgersen
*/
-class WaveFileFormat extends AudioFileFormat {
+final class WaveFileFormat extends AudioFileFormat {
/**
* Wave format type.
*/
- private int waveType;
+ private final int waveType;
//$$fb 2001-07-13: added management of header size in this class
//$$fb 2002-04-16: Fix for 4636355: RIFF audio headers could be _more_ spec compliant
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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,28 +25,17 @@
package com.sun.media.sound;
-import java.util.Vector;
+import java.io.DataInputStream;
+import java.io.EOFException;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.EOFException;
import java.net.URL;
-import java.net.MalformedURLException;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.FileInputStream;
-import java.io.DataOutputStream;
-import java.io.FileOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.SequenceInputStream;
import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -59,20 +48,11 @@
* @author Jan Borgersen
* @author Florian Bomers
*/
-public class WaveFileReader extends SunFileReader {
+public final class WaveFileReader extends SunFileReader {
private static final int MAX_READ_LENGTH = 12;
/**
- * WAVE reader type
- */
-
- public static final AudioFileFormat.Type types[] = {
- AudioFileFormat.Type.WAVE
- };
-
-
- /**
* Constructs a new WaveFileReader object.
*/
public WaveFileReader() {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -50,7 +50,7 @@
*
* @author Jan Borgersen
*/
-public class WaveFileWriter extends SunFileWriter {
+public final class WaveFileWriter extends SunFileWriter {
// magic numbers
static final int RIFF_MAGIC = 1380533830;
@@ -74,18 +74,10 @@
static final int WAVE_FORMAT_SX7383 = 0x1C07;
/**
- * WAVE type
- */
- private static final AudioFileFormat.Type waveTypes[] = {
- AudioFileFormat.Type.WAVE
- };
-
-
- /**
* Constructs a new WaveFileWriter object.
*/
public WaveFileWriter() {
- super(waveTypes);
+ super(new AudioFileFormat.Type[]{AudioFileFormat.Type.WAVE});
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -44,7 +44,7 @@
*
* @author Karl Helgason
*/
-public class WaveFloatFileReader extends AudioFileReader {
+public final class WaveFloatFileReader extends AudioFileReader {
public AudioFileFormat getAudioFileFormat(InputStream stream)
throws UnsupportedAudioFileException, IOException {
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java Wed Jun 19 11:04:39 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
@@ -41,7 +41,7 @@
*
* @author Karl Helgason
*/
-public class WaveFloatFileWriter extends AudioFileWriter {
+public final class WaveFloatFileWriter extends AudioFileWriter {
public Type[] getAudioFileTypes() {
return new Type[] { Type.WAVE };
@@ -86,9 +86,9 @@
}
private static class NoCloseOutputStream extends OutputStream {
- OutputStream out;
+ final OutputStream out;
- public NoCloseOutputStream(OutputStream out) {
+ NoCloseOutputStream(OutputStream out) {
this.out = out;
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java Wed Jun 19 11:04:39 2013 +0100
@@ -2,38 +2,43 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package com.sun.org.apache.xml.internal.security;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
-import com.sun.org.apache.xml.internal.security.keys.KeyInfo;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver;
import com.sun.org.apache.xml.internal.security.transforms.Transform;
+import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
import com.sun.org.apache.xml.internal.security.utils.I18n;
-//import com.sun.org.apache.xml.internal.security.utils.PRNG;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
import org.w3c.dom.Attr;
@@ -47,367 +52,317 @@
* the mapping of Canonicalization and Transform algorithms. Initialization is
* done by calling {@link Init#init} which should be done in any static block
* of the files of this library. We ensure that this call is only executed once.
- *
- * @author $Author: mullan $
*/
-public final class Init {
+public class Init {
- /** {@link java.util.logging} logging facility */
- static java.util.logging.Logger log =
+ /** The namespace for CONF file **/
+ public static final String CONF_NS = "http://www.xmlsecurity.org/NS/#configuration";
+
+ /** {@link org.apache.commons.logging} logging facility */
+ private static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(Init.class.getName());
- /** Field _initialized */
- private static boolean _alreadyInitialized = false;
+ /** Field alreadyInitialized */
+ private static boolean alreadyInitialized = false;
- /** The namespace for CONF file **/
- public static final String CONF_NS="http://www.xmlsecurity.org/NS/#configuration";
+ /**
+ * Method isInitialized
+ * @return true if the library is already initialized.
+ */
+ public static synchronized final boolean isInitialized() {
+ return Init.alreadyInitialized;
+ }
+
+ /**
+ * Method init
+ *
+ */
+ public static synchronized void init() {
+ if (alreadyInitialized) {
+ return;
+ }
- /**
- * Method isInitialized
- * @return true if the librairy is already initialized.
- *
- */
- public static final boolean isInitialized() {
- return Init._alreadyInitialized;
- }
+ InputStream is =
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public InputStream run() {
+ String cfile =
+ System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
+ if (cfile == null) {
+ return null;
+ }
+ return getClass().getResourceAsStream(cfile);
+ }
+ });
+ if (is == null) {
+ dynamicInit();
+ } else {
+ fileInit(is);
+ }
- /**
- * Method init
- *
- */
- public synchronized static void init() {
+ alreadyInitialized = true;
+ }
+
+ /**
+ * Dynamically initialise the library by registering the default algorithms/implementations
+ */
+ private static void dynamicInit() {
+ //
+ // Load the Resource Bundle - the default is the English resource bundle.
+ // To load another resource bundle, call I18n.init(...) before calling this
+ // method.
+ //
+ I18n.init("en", "US");
- if (_alreadyInitialized) {
- return;
- }
- long XX_configure_i18n_end=0;
- long XX_configure_reg_c14n_start=0;
- long XX_configure_reg_c14n_end=0;
- long XX_configure_reg_jcemapper_end=0;
- long XX_configure_reg_keyInfo_start=0;
- long XX_configure_reg_keyResolver_end=0;
- long XX_configure_reg_prefixes_start=0;
- long XX_configure_reg_resourceresolver_start=0;
- long XX_configure_reg_sigalgos_end=0;
- long XX_configure_reg_transforms_end=0;
- long XX_configure_reg_keyInfo_end=0;
- long XX_configure_reg_keyResolver_start=0;
- _alreadyInitialized = true;
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Registering default algorithms");
+ }
+ try {
+ //
+ // Bind the default prefixes
+ //
+ ElementProxy.registerDefaultPrefixes();
+
+ //
+ // Set the default Transforms
+ //
+ Transform.registerDefaultAlgorithms();
+
+ //
+ // Set the default signature algorithms
+ //
+ SignatureAlgorithm.registerDefaultAlgorithms();
+
+ //
+ // Set the default JCE algorithms
+ //
+ JCEMapper.registerDefaultAlgorithms();
- try {
- long XX_init_start = System.currentTimeMillis();
- long XX_prng_start = System.currentTimeMillis();
+ //
+ // Set the default c14n algorithms
+ //
+ Canonicalizer.registerDefaultAlgorithms();
- //PRNG.init(new java.security.SecureRandom());
+ //
+ // Register the default resolvers
+ //
+ ResourceResolver.registerDefaultResolvers();
- long XX_prng_end = System.currentTimeMillis();
+ //
+ // Register the default key resolvers
+ //
+ KeyResolver.registerDefaultResolvers();
+ } catch (Exception ex) {
+ log.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
+ ex.printStackTrace();
+ }
+ }
+ /**
+ * Initialise the library from a configuration file
+ */
+ private static void fileInit(InputStream is) {
+ try {
/* read library configuration file */
- long XX_parsing_start = System.currentTimeMillis();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
dbf.setNamespaceAware(true);
dbf.setValidating(false);
DocumentBuilder db = dbf.newDocumentBuilder();
- // We don't allow users to override the Apache XML Security
- // configuration in the JRE. Users should use the standard security
- // provider mechanism instead if implementing their own
- // transform or canonicalization algorithms.
- // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
- InputStream is = AccessController.doPrivileged(
- new PrivilegedAction() {
- public InputStream run() {
-// String cfile = System.getProperty
-// ("com.sun.org.apache.xml.internal.security.resource.config");
- return getClass().getResourceAsStream
-// (cfile != null ? cfile : "resource/config.xml");
- ("resource/config.xml");
- }
- });
-
Document doc = db.parse(is);
- long XX_parsing_end = System.currentTimeMillis();
- long XX_configure_i18n_start = 0;
-
- {
- XX_configure_reg_keyInfo_start = System.currentTimeMillis();
- try {
- KeyInfo.init();
- } catch (Exception e) {
- e.printStackTrace();
-
- throw e;
- }
- XX_configure_reg_keyInfo_end = System.currentTimeMillis();
- }
-
- long XX_configure_reg_transforms_start=0;
- long XX_configure_reg_jcemapper_start=0;
- long XX_configure_reg_sigalgos_start=0;
- long XX_configure_reg_resourceresolver_end=0;
- long XX_configure_reg_prefixes_end=0;
- Node config=doc.getFirstChild();
- for (;config!=null;config=config.getNextSibling()) {
+ Node config = doc.getFirstChild();
+ for (; config != null; config = config.getNextSibling()) {
if ("Configuration".equals(config.getLocalName())) {
- break;
+ break;
}
}
- for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
- if (el.getNodeType() != Node.ELEMENT_NODE) {
- continue;
+ if (config == null) {
+ log.log(java.util.logging.Level.SEVERE, "Error in reading configuration file - Configuration element not found");
+ return;
+ }
+ for (Node el = config.getFirstChild(); el != null; el = el.getNextSibling()) {
+ if (Node.ELEMENT_NODE != el.getNodeType()) {
+ continue;
+ }
+ String tag = el.getLocalName();
+ if (tag.equals("ResourceBundles")) {
+ Element resource = (Element)el;
+ /* configure internationalization */
+ Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
+ Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
+ String languageCode =
+ (langAttr == null) ? null : langAttr.getNodeValue();
+ String countryCode =
+ (countryAttr == null) ? null : countryAttr.getNodeValue();
+ I18n.init(languageCode, countryCode);
}
- String tag=el.getLocalName();
-//
-// Commented out: not supported in the JDK. We use the default locale.
-//
-// if (tag.equals("ResourceBundles")){
-// XX_configure_i18n_start = System.currentTimeMillis();
-// Element resource=(Element)el;
-// /* configure internationalization */
-// Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
-// Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
-// String languageCode = (langAttr == null)
-// ? null
-// : langAttr.getNodeValue();
-// String countryCode = (countryAttr == null)
-// ? null
-// : countryAttr.getNodeValue();
-//
-// I18n.init(languageCode, countryCode);
-// XX_configure_i18n_end = System.currentTimeMillis();
-// }
+
+ if (tag.equals("CanonicalizationMethods")) {
+ Element[] list =
+ XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "CanonicalizationMethod");
+
+ for (int i = 0; i < list.length; i++) {
+ String uri = list[i].getAttributeNS(null, "URI");
+ String javaClass =
+ list[i].getAttributeNS(null, "JAVACLASS");
+ try {
+ Canonicalizer.register(uri, javaClass);
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + uri + ", " + javaClass + ")");
+ }
+ } catch (ClassNotFoundException e) {
+ Object exArgs[] = { uri, javaClass };
+ log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
+ }
+ }
+ }
+
+ if (tag.equals("TransformAlgorithms")) {
+ Element[] tranElem =
+ XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "TransformAlgorithm");
- if (tag.equals("CanonicalizationMethods")){
- XX_configure_reg_c14n_start = System.currentTimeMillis();
- Canonicalizer.init();
- Element[] list=XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,"CanonicalizationMethod");
+ for (int i = 0; i < tranElem.length; i++) {
+ String uri = tranElem[i].getAttributeNS(null, "URI");
+ String javaClass =
+ tranElem[i].getAttributeNS(null, "JAVACLASS");
+ try {
+ Transform.register(uri, javaClass);
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Transform.register(" + uri + ", " + javaClass + ")");
+ }
+ } catch (ClassNotFoundException e) {
+ Object exArgs[] = { uri, javaClass };
- for (int i = 0; i < list.length; i++) {
- String URI = list[i].getAttributeNS(null,
- "URI");
- String JAVACLASS =
- list[i].getAttributeNS(null,
- "JAVACLASS");
- try {
- Class.forName(JAVACLASS);
-/* Method methods[] = c.getMethods();
+ log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
+ } catch (NoClassDefFoundError ex) {
+ log.log(java.util.logging.Level.WARNING, "Not able to found dependencies for algorithm, I'll keep working.");
+ }
+ }
+ }
- for (int j = 0; j < methods.length; j++) {
- Method currMeth = methods[j];
-
- if (currMeth.getDeclaringClass().getName()
- .equals(JAVACLASS)) {
- log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
+ if ("JCEAlgorithmMappings".equals(tag)) {
+ Node algorithmsNode = ((Element)el).getElementsByTagName("Algorithms").item(0);
+ if (algorithmsNode != null) {
+ Element[] algorithms =
+ XMLUtils.selectNodes(algorithmsNode.getFirstChild(), CONF_NS, "Algorithm");
+ for (int i = 0; i < algorithms.length; i++) {
+ Element element = algorithms[i];
+ String id = element.getAttribute("URI");
+ JCEMapper.register(id, new JCEMapper.Algorithm(element));
}
- }*/
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
- + JAVACLASS + ")");
- Canonicalizer.register(URI, JAVACLASS);
- } catch (ClassNotFoundException e) {
- Object exArgs[] = { URI, JAVACLASS };
+ }
+ }
+
+ if (tag.equals("SignatureAlgorithms")) {
+ Element[] sigElems =
+ XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "SignatureAlgorithm");
+
+ for (int i = 0; i < sigElems.length; i++) {
+ String uri = sigElems[i].getAttributeNS(null, "URI");
+ String javaClass =
+ sigElems[i].getAttributeNS(null, "JAVACLASS");
+
+ /** $todo$ handle registering */
- log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
- exArgs));
- }
- }
- XX_configure_reg_c14n_end = System.currentTimeMillis();
- }
+ try {
+ SignatureAlgorithm.register(uri, javaClass);
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + uri + ", "
+ + javaClass + ")");
+ }
+ } catch (ClassNotFoundException e) {
+ Object exArgs[] = { uri, javaClass };
- if (tag.equals("TransformAlgorithms")){
- XX_configure_reg_transforms_start = System.currentTimeMillis();
- Transform.init();
+ log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
+ }
+ }
+ }
- Element[] tranElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,"TransformAlgorithm");
+ if (tag.equals("ResourceResolvers")) {
+ Element[]resolverElem =
+ XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
+
+ for (int i = 0; i < resolverElem.length; i++) {
+ String javaClass =
+ resolverElem[i].getAttributeNS(null, "JAVACLASS");
+ String description =
+ resolverElem[i].getAttributeNS(null, "DESCRIPTION");
- for (int i = 0; i < tranElem.length; i++) {
- String URI = tranElem[i].getAttributeNS(null,
- "URI");
- String JAVACLASS =
- tranElem[i].getAttributeNS(null,
- "JAVACLASS");
- try {
- Class.forName(JAVACLASS);
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS + ")");
- Transform.register(URI, JAVACLASS);
- } catch (ClassNotFoundException e) {
- Object exArgs[] = { URI, JAVACLASS };
+ if ((description != null) && (description.length() > 0)) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass + ": "
+ + description);
+ }
+ } else {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass
+ + ": For unknown purposes");
+ }
+ }
+ try {
+ ResourceResolver.register(javaClass);
+ } catch (Throwable e) {
+ log.log(java.util.logging.Level.WARNING,
+ "Cannot register:" + javaClass
+ + " perhaps some needed jars are not installed",
+ e
+ );
+ }
+ }
+ }
- log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
- exArgs));
+ if (tag.equals("KeyResolver")){
+ Element[] resolverElem =
+ XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
+ List classNames = new ArrayList(resolverElem.length);
+ for (int i = 0; i < resolverElem.length; i++) {
+ String javaClass =
+ resolverElem[i].getAttributeNS(null, "JAVACLASS");
+ String description =
+ resolverElem[i].getAttributeNS(null, "DESCRIPTION");
- } catch (NoClassDefFoundError ex) {
- log.log(java.util.logging.Level.WARNING, "Not able to found dependecies for algorithm, I'm keep working.");
- }
- }
- XX_configure_reg_transforms_end = System.currentTimeMillis();
- }
-
-
- if ("JCEAlgorithmMappings".equals(tag)){
- XX_configure_reg_jcemapper_start = System.currentTimeMillis();
- JCEMapper.init((Element)el);
- XX_configure_reg_jcemapper_end = System.currentTimeMillis();
- }
-
+ if ((description != null) && (description.length() > 0)) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass + ": "
+ + description);
+ }
+ } else {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass
+ + ": For unknown purposes");
+ }
+ }
+ classNames.add(javaClass);
+ }
+ KeyResolver.registerClassNames(classNames);
+ }
- if (tag.equals("SignatureAlgorithms")){
- XX_configure_reg_sigalgos_start = System.currentTimeMillis();
- SignatureAlgorithm.providerInit();
-
- Element[] sigElems = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,
- "SignatureAlgorithm");
-
- for (int i = 0; i < sigElems.length; i++) {
- String URI = sigElems[i].getAttributeNS(null,
- "URI");
- String JAVACLASS =
- sigElems[i].getAttributeNS(null,
- "JAVACLASS");
-
- /** $todo$ handle registering */
-
- try {
- Class.forName(JAVACLASS);
- // Method methods[] = c.getMethods();
-
-// for (int j = 0; j < methods.length; j++) {
-// Method currMeth = methods[j];
-//
-// if (currMeth.getDeclaringClass().getName()
-// .equals(JAVACLASS)) {
-// log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
-// }
-// }
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", " + JAVACLASS + ")");
- SignatureAlgorithm.register(URI, JAVACLASS);
- } catch (ClassNotFoundException e) {
- Object exArgs[] = { URI, JAVACLASS };
-
- log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
- exArgs));
+ if (tag.equals("PrefixMappings")){
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
+ }
- }
- }
- XX_configure_reg_sigalgos_end = System.currentTimeMillis();
- }
-
-
-
- if (tag.equals("ResourceResolvers")){
- XX_configure_reg_resourceresolver_start = System.currentTimeMillis();
- ResourceResolver.init();
-
- Element[]resolverElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,
- "Resolver");
-
- for (int i = 0; i < resolverElem.length; i++) {
- String JAVACLASS =
- resolverElem[i].getAttributeNS(null,
- "JAVACLASS");
- String Description =
- resolverElem[i].getAttributeNS(null,
- "DESCRIPTION");
-
- if ((Description != null) && (Description.length() > 0)) {
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
- } else {
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
- }
- try {
- ResourceResolver.register(JAVACLASS);
- } catch (Throwable e) {
- log.log(java.util.logging.Level.WARNING, "Cannot register:"+JAVACLASS+" perhaps some needed jars are not installed",e);
- }
- XX_configure_reg_resourceresolver_end =
- System.currentTimeMillis();
- }
+ Element[] nl =
+ XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "PrefixMapping");
- }
-
-
-
-
-
-
- if (tag.equals("KeyResolver")){
- XX_configure_reg_keyResolver_start =System.currentTimeMillis();
- KeyResolver.init();
-
- Element[] resolverElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"Resolver");
-
- for (int i = 0; i < resolverElem.length; i++) {
- String JAVACLASS =
- resolverElem[i].getAttributeNS(null,
- "JAVACLASS");
- String Description =
- resolverElem[i].getAttributeNS(null,
- "DESCRIPTION");
-
- if ((Description != null) && (Description.length() > 0)) {
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
- } else {
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
- }
-
- KeyResolver.register(JAVACLASS);
- }
- XX_configure_reg_keyResolver_end = System.currentTimeMillis();
+ for (int i = 0; i < nl.length; i++) {
+ String namespace = nl[i].getAttributeNS(null, "namespace");
+ String prefix = nl[i].getAttributeNS(null, "prefix");
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
+ }
+ ElementProxy.setDefaultPrefix(namespace, prefix);
+ }
+ }
}
-
-
- if (tag.equals("PrefixMappings")){
- XX_configure_reg_prefixes_start = System.currentTimeMillis();
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
-
- Element[] nl = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"PrefixMapping");
-
- for (int i = 0; i < nl.length; i++) {
- String namespace = nl[i].getAttributeNS(null,
- "namespace");
- String prefix = nl[i].getAttributeNS(null,
- "prefix");
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
- com.sun.org.apache.xml.internal.security.utils.ElementProxy
- .setDefaultPrefix(namespace, prefix);
- }
- XX_configure_reg_prefixes_end = System.currentTimeMillis();
- }
- }
-
- long XX_init_end = System.currentTimeMillis();
-
- //J-
- if (log.isLoggable(java.util.logging.Level.FINE)) {
- log.log(java.util.logging.Level.FINE, "XX_init " + ((int)(XX_init_end - XX_init_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_prng " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_parsing " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_i18n " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_c14n " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_jcemapper " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_keyInfo " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_keyResolver " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_prefixes " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_sigalgos " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
- log.log(java.util.logging.Level.FINE, " XX_configure_reg_transforms " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
- }
- } catch (Exception e) {
+ } catch (Exception e) {
log.log(java.util.logging.Level.SEVERE, "Bad: ", e);
e.printStackTrace();
- }
-
- }
-
+ }
+ }
}
+
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/ClassLoaderUtils.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/ClassLoaderUtils.java Wed Jun 19 11:04:39 2013 +0100
@@ -0,0 +1,280 @@
+/*
+ * reserved comment block
+ * DO NOT REMOVE OR ALTER!
+ */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.sun.org.apache.xml.internal.security.algorithms;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * This class is extremely useful for loading resources and classes in a fault
+ * tolerant manner that works across different applications servers. Do not
+ * touch this unless you're a grizzled classloading guru veteran who is going to
+ * verify any change on 6 different application servers.
+ */
+// NOTE! This is a duplicate of utils.ClassLoaderUtils with public
+// modifiers changed to package-private. Make sure to integrate any future
+// changes to utils.ClassLoaderUtils to this file.
+final class ClassLoaderUtils {
+
+ /** {@link org.apache.commons.logging} logging facility */
+ private static final java.util.logging.Logger log =
+ java.util.logging.Logger.getLogger(ClassLoaderUtils.class.getName());
+
+ private ClassLoaderUtils() {
+ }
+
+ /**
+ * Load a given resource. This method will try to load the resource
+ * using the following methods (in order):
+ *
+ * - From Thread.currentThread().getContextClassLoader()
+ *
- From ClassLoaderUtil.class.getClassLoader()
+ *
- callingClass.getClassLoader()
+ *
+ *
+ * @param resourceName The name of the resource to load
+ * @param callingClass The Class object of the calling object
+ */
+ static URL getResource(String resourceName, Class> callingClass) {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
+ if (url == null && resourceName.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ url =
+ Thread.currentThread().getContextClassLoader().getResource(
+ resourceName.substring(1)
+ );
+ }
+
+ ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
+ if (cluClassloader == null) {
+ cluClassloader = ClassLoader.getSystemClassLoader();
+ }
+ if (url == null) {
+ url = cluClassloader.getResource(resourceName);
+ }
+ if (url == null && resourceName.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ url = cluClassloader.getResource(resourceName.substring(1));
+ }
+
+ if (url == null) {
+ ClassLoader cl = callingClass.getClassLoader();
+
+ if (cl != null) {
+ url = cl.getResource(resourceName);
+ }
+ }
+
+ if (url == null) {
+ url = callingClass.getResource(resourceName);
+ }
+
+ if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
+ return getResource('/' + resourceName, callingClass);
+ }
+
+ return url;
+ }
+
+ /**
+ * Load a given resources. This method will try to load the resources
+ * using the following methods (in order):
+ *
+ * - From Thread.currentThread().getContextClassLoader()
+ *
- From ClassLoaderUtil.class.getClassLoader()
+ *
- callingClass.getClassLoader()
+ *
+ *
+ * @param resourceName The name of the resource to load
+ * @param callingClass The Class object of the calling object
+ */
+ static List getResources(String resourceName, Class> callingClass) {
+ List ret = new ArrayList();
+ Enumeration urls = new Enumeration() {
+ public boolean hasMoreElements() {
+ return false;
+ }
+ public URL nextElement() {
+ return null;
+ }
+
+ };
+ try {
+ urls = Thread.currentThread().getContextClassLoader().getResources(resourceName);
+ } catch (IOException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ //ignore
+ }
+ if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ try {
+ urls =
+ Thread.currentThread().getContextClassLoader().getResources(
+ resourceName.substring(1)
+ );
+ } catch (IOException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ // ignore
+ }
+ }
+
+ ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
+ if (cluClassloader == null) {
+ cluClassloader = ClassLoader.getSystemClassLoader();
+ }
+ if (!urls.hasMoreElements()) {
+ try {
+ urls = cluClassloader.getResources(resourceName);
+ } catch (IOException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ // ignore
+ }
+ }
+ if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
+ //certain classloaders need it without the leading /
+ try {
+ urls = cluClassloader.getResources(resourceName.substring(1));
+ } catch (IOException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ // ignore
+ }
+ }
+
+ if (!urls.hasMoreElements()) {
+ ClassLoader cl = callingClass.getClassLoader();
+
+ if (cl != null) {
+ try {
+ urls = cl.getResources(resourceName);
+ } catch (IOException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ // ignore
+ }
+ }
+ }
+
+ if (!urls.hasMoreElements()) {
+ URL url = callingClass.getResource(resourceName);
+ if (url != null) {
+ ret.add(url);
+ }
+ }
+ while (urls.hasMoreElements()) {
+ ret.add(urls.nextElement());
+ }
+
+
+ if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) {
+ return getResources('/' + resourceName, callingClass);
+ }
+ return ret;
+ }
+
+
+ /**
+ * This is a convenience method to load a resource as a stream. The
+ * algorithm used to find the resource is given in getResource()
+ *
+ * @param resourceName The name of the resource to load
+ * @param callingClass The Class object of the calling object
+ */
+ static InputStream getResourceAsStream(String resourceName, Class> callingClass) {
+ URL url = getResource(resourceName, callingClass);
+
+ try {
+ return (url != null) ? url.openStream() : null;
+ } catch (IOException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Load a class with a given name. It will try to load the class in the
+ * following order:
+ *
+ * - From Thread.currentThread().getContextClassLoader()
+ *
- Using the basic Class.forName()
+ *
- From ClassLoaderUtil.class.getClassLoader()
+ *
- From the callingClass.getClassLoader()
+ *
+ *
+ * @param className The name of the class to load
+ * @param callingClass The Class object of the calling object
+ * @throws ClassNotFoundException If the class cannot be found anywhere.
+ */
+ static Class> loadClass(String className, Class> callingClass)
+ throws ClassNotFoundException {
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ if (cl != null) {
+ return cl.loadClass(className);
+ }
+ } catch (ClassNotFoundException e) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+ }
+ //ignore
+ }
+ return loadClass2(className, callingClass);
+ }
+
+ private static Class> loadClass2(String className, Class> callingClass)
+ throws ClassNotFoundException {
+ try {
+ return Class.forName(className);
+ } catch (ClassNotFoundException ex) {
+ try {
+ if (ClassLoaderUtils.class.getClassLoader() != null) {
+ return ClassLoaderUtils.class.getClassLoader().loadClass(className);
+ }
+ } catch (ClassNotFoundException exc) {
+ if (callingClass != null && callingClass.getClassLoader() != null) {
+ return callingClass.getClassLoader().loadClass(className);
+ }
+ }
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, ex.getMessage(), ex);
+ }
+ throw ex;
+ }
+ }
+}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java Wed Jun 19 11:04:39 2013 +0100
@@ -2,167 +2,316 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
-
-
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
-
-import com.sun.org.apache.xml.internal.security.Init;
-import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+import com.sun.org.apache.xml.internal.security.encryption.XMLCipher;
+import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import org.w3c.dom.Element;
-
/**
* This class maps algorithm identifier URIs to JAVA JCE class names.
- *
- * @author $Author: mullan $
*/
public class JCEMapper {
- /** {@link java.util.logging} logging facility */
- static java.util.logging.Logger log =
+ /** {@link org.apache.commons.logging} logging facility */
+ private static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(JCEMapper.class.getName());
-
-
- private static Map uriToJCEName;
-
- private static Map algorithmsMap;
+ private static Map algorithmsMap =
+ new ConcurrentHashMap();
- private static String providerName = null;
- /**
- * Method init
- *
- * @param mappingElement
- * @throws Exception
- */
- public static void init(Element mappingElement) throws Exception {
-
- loadAlgorithms((Element)mappingElement.getElementsByTagName("Algorithms").item(0));
- }
+ private static String providerName = null;
- static void loadAlgorithms( Element algorithmsEl) {
- Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
- uriToJCEName = new HashMap( algorithms.length * 2);
- algorithmsMap = new HashMap( algorithms.length * 2);
- for (int i = 0 ;i < algorithms.length ;i ++) {
- Element el = algorithms[i];
- String id = el.getAttribute("URI");
- String jceName = el.getAttribute("JCEName");
- uriToJCEName.put(id, jceName);
- algorithmsMap.put(id, new Algorithm(el));
- }
-
- }
-
- static Algorithm getAlgorithmMapping(String algoURI) {
- return algorithmsMap.get(algoURI);
- }
-
- /**
- * Method translateURItoJCEID
- *
- * @param AlgorithmURI
- * @return the JCE standard name corresponding to the given URI
- *
- */
- public static String translateURItoJCEID(String AlgorithmURI) {
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
-
- String jceName = uriToJCEName.get(AlgorithmURI);
- return jceName;
- }
+ /**
+ * Method register
+ *
+ * @param id
+ * @param algorithm
+ */
+ public static void register(String id, Algorithm algorithm) {
+ algorithmsMap.put(id, algorithm);
+ }
- /**
- * Method getAlgorithmClassFromURI
- * NOTE(Raul Benito) It seems a buggy function the loop doesn't do
- * anything??
- * @param AlgorithmURI
- * @return the class name that implements this algorithm
- *
- */
- public static String getAlgorithmClassFromURI(String AlgorithmURI) {
- if (log.isLoggable(java.util.logging.Level.FINE))
- log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
-
- return (algorithmsMap.get(AlgorithmURI)).algorithmClass;
- }
-
- /**
- * Returns the keylength in bit for a particular algorithm.
- *
- * @param AlgorithmURI
- * @return The length of the key used in the alogrithm
- */
- public static int getKeyLengthFromURI(String AlgorithmURI) {
- return Integer.parseInt((algorithmsMap.get(AlgorithmURI)).keyLength);
- }
+ /**
+ * This method registers the default algorithms.
+ */
+ public static void registerDefaultAlgorithms() {
+ algorithmsMap.put(
+ MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5,
+ new Algorithm("", "MD5", "MessageDigest")
+ );
+ algorithmsMap.put(
+ MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160,
+ new Algorithm("", "RIPEMD160", "MessageDigest")
+ );
+ algorithmsMap.put(
+ MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1,
+ new Algorithm("", "SHA-1", "MessageDigest")
+ );
+ algorithmsMap.put(
+ MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256,
+ new Algorithm("", "SHA-256", "MessageDigest")
+ );
+ algorithmsMap.put(
+ MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA384,
+ new Algorithm("", "SHA-384", "MessageDigest")
+ );
+ algorithmsMap.put(
+ MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512,
+ new Algorithm("", "SHA-512", "MessageDigest")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_DSA,
+ new Algorithm("", "SHA1withDSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5,
+ new Algorithm("", "MD5withRSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160,
+ new Algorithm("", "RIPEMD160withRSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1,
+ new Algorithm("", "SHA1withRSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256,
+ new Algorithm("", "SHA256withRSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384,
+ new Algorithm("", "SHA384withRSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512,
+ new Algorithm("", "SHA512withRSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1,
+ new Algorithm("", "SHA1withECDSA", "Signature")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5,
+ new Algorithm("", "HmacMD5", "Mac")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160,
+ new Algorithm("", "HMACRIPEMD160", "Mac")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
+ new Algorithm("", "HmacSHA1", "Mac")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_MAC_HMAC_SHA256,
+ new Algorithm("", "HmacSHA256", "Mac")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_MAC_HMAC_SHA384,
+ new Algorithm("", "HmacSHA384", "Mac")
+ );
+ algorithmsMap.put(
+ XMLSignature.ALGO_ID_MAC_HMAC_SHA512,
+ new Algorithm("", "HmacSHA512", "Mac")
+ );
+ algorithmsMap.put(
+ XMLCipher.TRIPLEDES,
+ new Algorithm("DESede", "DESede/CBC/ISO10126Padding", "BlockEncryption", 192)
+ );
+ algorithmsMap.put(
+ XMLCipher.AES_128,
+ new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 128)
+ );
+ algorithmsMap.put(
+ XMLCipher.AES_192,
+ new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 192)
+ );
+ algorithmsMap.put(
+ XMLCipher.AES_256,
+ new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 256)
+ );
+ algorithmsMap.put(
+ XMLCipher.RSA_v1dot5,
+ new Algorithm("RSA", "RSA/ECB/PKCS1Padding", "KeyTransport")
+ );
+ algorithmsMap.put(
+ XMLCipher.RSA_OAEP,
+ new Algorithm("RSA", "RSA/ECB/OAEPPadding", "KeyTransport")
+ );
+ algorithmsMap.put(
+ XMLCipher.DIFFIE_HELLMAN,
+ new Algorithm("", "", "KeyAgreement")
+ );
+ algorithmsMap.put(
+ XMLCipher.TRIPLEDES_KeyWrap,
+ new Algorithm("DESede", "DESedeWrap", "SymmetricKeyWrap", 192)
+ );
+ algorithmsMap.put(
+ XMLCipher.AES_128_KeyWrap,
+ new Algorithm("AES", "AESWrap", "SymmetricKeyWrap", 128)
+ );
+ algorithmsMap.put(
+ XMLCipher.AES_192_KeyWrap,
+ new Algorithm("AES", "AESWrap", "SymmetricKeyWrap", 192)
+ );
+ algorithmsMap.put(
+ XMLCipher.AES_256_KeyWrap,
+ new Algorithm("AES", "AESWrap", "SymmetricKeyWrap", 256)
+ );
+ }
- /**
- * Method getJCEKeyAlgorithmFromURI
- *
- * @param AlgorithmURI
- * @return The KeyAlgorithm for the given URI.
- *
- */
- public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) {
+ /**
+ * Method translateURItoJCEID
+ *
+ * @param algorithmURI
+ * @return the JCE standard name corresponding to the given URI
+ */
+ public static String translateURItoJCEID(String algorithmURI) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
+ }
- return (algorithmsMap.get(AlgorithmURI)).requiredKey;
+ Algorithm algorithm = algorithmsMap.get(algorithmURI);
+ if (algorithm != null) {
+ return algorithm.jceName;
+ }
+ return null;
+ }
- }
+ /**
+ * Method getAlgorithmClassFromURI
+ * @param algorithmURI
+ * @return the class name that implements this algorithm
+ */
+ public static String getAlgorithmClassFromURI(String algorithmURI) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
+ }
+
+ Algorithm algorithm = algorithmsMap.get(algorithmURI);
+ if (algorithm != null) {
+ return algorithm.algorithmClass;
+ }
+ return null;
+ }
- /**
- * Gets the default Provider for obtaining the security algorithms
- * @return the default providerId.
- */
- public static String getProviderId() {
- return providerName;
- }
+ /**
+ * Returns the keylength in bits for a particular algorithm.
+ *
+ * @param algorithmURI
+ * @return The length of the key used in the algorithm
+ */
+ public static int getKeyLengthFromURI(String algorithmURI) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
+ }
+ Algorithm algorithm = algorithmsMap.get(algorithmURI);
+ if (algorithm != null) {
+ return algorithm.keyLength;
+ }
+ return 0;
+ }
- /**
- * Sets the default Provider for obtaining the security algorithms
- * @param provider the default providerId.
- */
- public static void setProviderId(String provider) {
- providerName=provider;
- }
+ /**
+ * Method getJCEKeyAlgorithmFromURI
+ *
+ * @param algorithmURI
+ * @return The KeyAlgorithm for the given URI.
+ */
+ public static String getJCEKeyAlgorithmFromURI(String algorithmURI) {
+ if (log.isLoggable(java.util.logging.Level.FINE)) {
+ log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
+ }
+ Algorithm algorithm = algorithmsMap.get(algorithmURI);
+ if (algorithm != null) {
+ return algorithm.requiredKey;
+ }
+ return null;
+ }
- /**
- * Represents the Algorithm xml element
- */
- public static class Algorithm {
- String algorithmClass;
- String keyLength;
- String requiredKey;
+ /**
+ * Gets the default Provider for obtaining the security algorithms
+ * @return the default providerId.
+ */
+ public static String getProviderId() {
+ return providerName;
+ }
+
+ /**
+ * Sets the default Provider for obtaining the security algorithms
+ * @param provider the default providerId.
+ */
+ public static void setProviderId(String provider) {
+ providerName = provider;
+ }
+
+ /**
+ * Represents the Algorithm xml element
+ */
+ public static class Algorithm {
+
+ final String requiredKey;
+ final String jceName;
+ final String algorithmClass;
+ final int keyLength;
+
/**
* Gets data from element
* @param el
*/
public Algorithm(Element el) {
- algorithmClass=el.getAttribute("AlgorithmClass");
- keyLength=el.getAttribute("KeyLength");
- requiredKey=el.getAttribute("RequiredKey");
+ requiredKey = el.getAttribute("RequiredKey");
+ jceName = el.getAttribute("JCEName");
+ algorithmClass = el.getAttribute("AlgorithmClass");
+ if (el.hasAttribute("KeyLength")) {
+ keyLength = Integer.parseInt(el.getAttribute("KeyLength"));
+ } else {
+ keyLength = 0;
+ }
+ }
+
+ public Algorithm(String requiredKey, String jceName) {
+ this(requiredKey, jceName, null, 0);
}
- }
+
+ public Algorithm(String requiredKey, String jceName, String algorithmClass) {
+ this(requiredKey, jceName, algorithmClass, 0);
+ }
+
+ public Algorithm(String requiredKey, String jceName, int keyLength) {
+ this(requiredKey, jceName, null, keyLength);
+ }
+
+ public Algorithm(String requiredKey, String jceName, String algorithmClass, int keyLength) {
+ this.requiredKey = requiredKey;
+ this.jceName = jceName;
+ this.algorithmClass = algorithmClass;
+ this.keyLength = keyLength;
+ }
+ }
+
}
diff -r 5e467681e781 -r 47cb0bfa2f0d jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java Fri Jun 14 07:26:49 2013 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java Wed Jun 19 11:04:39 2013 +0100
@@ -2,460 +2,445 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
-
import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureDSA;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
/**
- * Allows selection of digital signature's algorithm, private keys, other security parameters, and algorithm's ID.
+ * Allows selection of digital signature's algorithm, private keys, other
+ * security parameters, and algorithm's ID.
*
* @author Christian Geuer-Pollmann
*/
public class SignatureAlgorithm extends Algorithm {
- /** {@link java.util.logging} logging facility */
- static java.util.logging.Logger log =
+ /** {@link org.apache.commons.logging} logging facility */
+ private static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SignatureAlgorithm.class.getName());
- /** Field _alreadyInitialized */
- static boolean _alreadyInitialized = false;
+ /** All available algorithm classes are registered here */
+ private static Map> algorithmHash =
+ new ConcurrentHashMap>();
- /** All available algorithm classes are registered here */
- static Map> _algorithmHash = null;
+ /** Field signatureAlgorithm */
+ private final SignatureAlgorithmSpi signatureAlgorithm;
+
+ private final String algorithmURI;
- static ThreadLocal