8042256: Fix raw and unchecked lint warnings in com.sun.media.sound

Reviewed-by: prr
This commit is contained in:
Joe Darcy 2014-05-05 23:19:00 -07:00
parent 835658f99d
commit 1a24f81c1b
16 changed files with 61 additions and 56 deletions

View File

@ -48,7 +48,7 @@ abstract class AbstractLine implements Line {
protected Control[] controls;
AbstractMixer mixer;
private boolean open = false;
private final Vector listeners = new Vector();
private final Vector<Object> listeners = new Vector<>();
/**
* Contains event dispatcher per thread group.

View File

@ -70,7 +70,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
/** List of Receivers and Transmitters that opened the device implicitely.
*/
private List openKeepingObjects;
private List<Object> openKeepingObjects;
/**
* This is the device handle returned from native code
@ -284,6 +284,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Receiver> getReceivers() {
List<Receiver> recs;
synchronized (traRecLock) {
@ -313,6 +314,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Transmitter> getTransmitters() {
List<Transmitter> tras;
synchronized (traRecLock) {
@ -372,9 +374,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
/** Return the list of objects that have opened the device implicitely.
*/
private synchronized List getOpenKeepingObjects() {
private synchronized List<Object> getOpenKeepingObjects() {
if (openKeepingObjects == null) {
openKeepingObjects = new ArrayList();
openKeepingObjects = new ArrayList<>();
}
return openKeepingObjects;
}

View File

@ -90,13 +90,13 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
/**
* Source lines (ports) currently open
*/
private final Vector sourceLines = new Vector();
private final Vector<Line> sourceLines = new Vector<>();
/**
* Target lines currently open.
*/
private final Vector targetLines = new Vector();
private final Vector<Line> targetLines = new Vector<>();
/**
@ -151,7 +151,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
public final Line.Info[] getSourceLineInfo(Line.Info info) {
int i;
Vector vec = new Vector();
Vector<Line.Info> vec = new Vector<>();
for (i = 0; i < sourceLineInfo.length; i++) {
@ -162,7 +162,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
returnedArray[i] = (Line.Info)vec.elementAt(i);
returnedArray[i] = vec.elementAt(i);
}
return returnedArray;
@ -172,7 +172,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
public final Line.Info[] getTargetLineInfo(Line.Info info) {
int i;
Vector vec = new Vector();
Vector<Line.Info> vec = new Vector<>();
for (i = 0; i < targetLineInfo.length; i++) {
@ -183,7 +183,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
returnedArray[i] = (Line.Info)vec.elementAt(i);
returnedArray[i] = vec.elementAt(i);
}
return returnedArray;
@ -231,7 +231,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
localLines = new Line[sourceLines.size()];
for (int i = 0; i < localLines.length; i++) {
localLines[i] = (Line)sourceLines.elementAt(i);
localLines[i] = sourceLines.elementAt(i);
}
}
@ -248,7 +248,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
localLines = new Line[targetLines.size()];
for (int i = 0; i < localLines.length; i++) {
localLines[i] = (Line)targetLines.elementAt(i);
localLines[i] = targetLines.elementAt(i);
}
}
@ -453,7 +453,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return;
}
Vector localSourceLines = (Vector)sourceLines.clone();
@SuppressWarnings("unchecked")
Vector<Line> localSourceLines = (Vector<Line>)sourceLines.clone();
for (int i = 0; i < localSourceLines.size(); i++) {
// if any other open line is running, return
@ -468,7 +469,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
}
}
Vector localTargetLines = (Vector)targetLines.clone();
@SuppressWarnings("unchecked")
Vector<Line> localTargetLines = (Vector<Line>)targetLines.clone();
for (int i = 0; i < localTargetLines.size(); i++) {
// if any other open line is running, return

View File

@ -213,7 +213,7 @@ public final class AlawCodec extends SunCodec {
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
if ( AudioFormat.Encoding.PCM_SIGNED.equals(inputFormat.getEncoding())) {
@ -248,7 +248,7 @@ public final class AlawCodec extends SunCodec {
AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(formats.elementAt(i));
formatArray[i] = formats.elementAt(i);
}
return formatArray;
}

View File

@ -68,7 +68,7 @@ public final class AudioSynthesizerPropertyInfo {
* The <code>valueClass</code> field specifies class
* used in <code>value</code> field.
*/
public Class valueClass = null;
public Class<?> valueClass = null;
/**
* An array of possible values if the value for the field
* <code>AudioSynthesizerPropertyInfo.value</code> may be selected

View File

@ -94,7 +94,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
private DirectDLI createDataLineInfo(boolean isSource) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat[] hardwareFormatArray = null;
AudioFormat[] formatArray = null;
@ -107,7 +107,7 @@ final class DirectAudioDevice extends AbstractMixer {
int formatArraySize = size;
hardwareFormatArray = new AudioFormat[size];
for (int i = 0; i < size; i++) {
AudioFormat format = (AudioFormat)formats.elementAt(i);
AudioFormat format = formats.elementAt(i);
hardwareFormatArray[i] = format;
int bits = format.getSampleSizeInBits();
boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
@ -265,7 +265,7 @@ final class DirectAudioDevice extends AbstractMixer {
return ((DirectAudioDeviceProvider.DirectAudioDeviceInfo) getMixerInfo()).getMaxSimulLines();
}
private static void addFormat(Vector v, int bits, int frameSizeInBytes, int channels, float sampleRate,
private static void addFormat(Vector<AudioFormat> v, int bits, int frameSizeInBytes, int channels, float sampleRate,
int encoding, boolean signed, boolean bigEndian) {
AudioFormat.Encoding enc = null;
switch (encoding) {
@ -338,7 +338,7 @@ final class DirectAudioDevice extends AbstractMixer {
private static final class DirectDLI extends DataLine.Info {
final AudioFormat[] hardwareFormats;
private DirectDLI(Class clazz, AudioFormat[] formatArray,
private DirectDLI(Class<?> clazz, AudioFormat[] formatArray,
AudioFormat[] hardwareFormatArray,
int minBuffer, int maxBuffer) {
super(clazz, formatArray, minBuffer, maxBuffer);
@ -1457,7 +1457,7 @@ final class DirectAudioDevice extends AbstractMixer {
} // class DirectBAOS
@SuppressWarnings("rawtypes")
private static native void nGetFormats(int mixerIndex, int deviceID,
boolean isSource, Vector formats);

View File

@ -57,7 +57,7 @@ final class EventDispatcher implements Runnable {
/**
* List of events
*/
private final ArrayList eventQueue = new ArrayList();
private final ArrayList<EventInfo> eventQueue = new ArrayList<>();
/**
@ -186,7 +186,7 @@ final class EventDispatcher implements Runnable {
}
if (eventQueue.size() > 0) {
// Remove the event from the queue and dispatch it to the listeners.
eventInfo = (EventInfo) eventQueue.remove(0);
eventInfo = eventQueue.remove(0);
}
} // end of synchronized
@ -230,7 +230,7 @@ final class EventDispatcher implements Runnable {
/**
* Send audio and MIDI events.
*/
void sendAudioEvents(Object event, List listeners) {
void sendAudioEvents(Object event, List<Object> listeners) {
if ((listeners == null)
|| (listeners.size() == 0)) {
// nothing to do
@ -392,7 +392,7 @@ final class EventDispatcher implements Runnable {
* @param event the event to be dispatched
* @param listeners listener list; will be copied
*/
EventInfo(Object event, List listeners) {
EventInfo(Object event, List<Object> listeners) {
this.event = event;
this.listeners = listeners.toArray();
}

View File

@ -118,7 +118,7 @@ public final class JDK13Services {
(the part before the hash sign), if available. If the property is
not set or the value has no provider class name part, null is returned.
*/
public static synchronized String getDefaultProviderClassName(Class typeClass) {
public static synchronized String getDefaultProviderClassName(Class<?> typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
@ -144,7 +144,7 @@ public final class JDK13Services {
part after the hash sign), if available. If the property is not set
or the value has no instance name part, null is returned.
*/
public static synchronized String getDefaultInstanceName(Class typeClass) {
public static synchronized String getDefaultInstanceName(Class<?> typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
@ -165,7 +165,7 @@ public final class JDK13Services {
@return The complete value of the property, if available.
If the property is not set, null is returned.
*/
private static synchronized String getDefaultProvider(Class typeClass) {
private static synchronized String getDefaultProvider(Class<?> typeClass) {
if (!SourceDataLine.class.equals(typeClass)
&& !TargetDataLine.class.equals(typeClass)
&& !Clip.class.equals(typeClass)

View File

@ -106,9 +106,9 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
* the new instance will not reflect that state...
*/
static final class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
private final Class providerClass;
private final Class<?> providerClass;
private MidiInDeviceInfo(int index, Class providerClass) {
private MidiInDeviceInfo(int index, Class<?> providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
this.providerClass = providerClass;
}

View File

@ -104,9 +104,9 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
* the new instance will not reflect that state...
*/
static final class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
private final Class providerClass;
private final Class<?> providerClass;
private MidiOutDeviceInfo(int index, Class providerClass) {
private MidiOutDeviceInfo(int index, Class<?> providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
this.providerClass = providerClass;
}

View File

@ -295,7 +295,7 @@ public final class MidiUtils {
public synchronized void refresh(Sequence seq) {
ArrayList list = new ArrayList();
ArrayList<MidiEvent> list = new ArrayList<>();
Track[] tracks = seq.getTracks();
if (tracks.length > 0) {
// tempo events only occur in track 0
@ -313,7 +313,7 @@ public final class MidiUtils {
int size = list.size() + 1;
firstTempoIsFake = true;
if ((size > 1)
&& (((MidiEvent) list.get(0)).getTick() == 0)) {
&& (list.get(0).getTick() == 0)) {
// do not need to add an initial tempo event at the beginning
size--;
firstTempoIsFake = false;
@ -328,7 +328,7 @@ public final class MidiUtils {
e++;
}
for (int i = 0; i < list.size(); i++, e++) {
MidiEvent evt = (MidiEvent) list.get(i);
MidiEvent evt = list.get(i);
ticks[e] = evt.getTick();
tempos[e] = getTempoMPQ(evt.getMessage());
}

View File

@ -91,7 +91,7 @@ public final class PCMtoPCMCodec extends SunCodec {
// filter out targetEncoding from the old getOutputFormats( sourceFormat ) method
AudioFormat[] formats = getOutputFormats( sourceFormat );
Vector newFormats = new Vector();
Vector<AudioFormat> newFormats = new Vector<>();
for(int i=0; i<formats.length; i++ ) {
if( formats[i].getEncoding().equals( targetEncoding ) ) {
newFormats.addElement( formats[i] );
@ -101,7 +101,7 @@ public final class PCMtoPCMCodec extends SunCodec {
AudioFormat[] formatArray = new AudioFormat[newFormats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(newFormats.elementAt(i));
formatArray[i] = newFormats.elementAt(i);
}
return formatArray;
@ -181,7 +181,7 @@ public final class PCMtoPCMCodec extends SunCodec {
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
int sampleSize = inputFormat.getSampleSizeInBits();
@ -335,7 +335,7 @@ public final class PCMtoPCMCodec extends SunCodec {
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(formats.elementAt(i));
formatArray[i] = formats.elementAt(i);
}
}

View File

@ -253,12 +253,12 @@ final class PortMixer extends AbstractMixer {
long newID = ((PortMixer) mixer).getID();
if ((id == 0) || (newID != id) || (controls.length == 0)) {
id = newID;
Vector vector = new Vector();
Vector<Control> vector = new Vector<>();
synchronized (vector) {
nGetControls(id, portIndex, vector);
controls = new Control[vector.size()];
for (int i = 0; i < controls.length; i++) {
controls[i] = (Control) vector.elementAt(i);
controls[i] = vector.elementAt(i);
}
}
} else {
@ -494,6 +494,7 @@ final class PortMixer extends AbstractMixer {
private static native String nGetPortName(long id, int portIndex);
// fills the vector with the controls for this port
@SuppressWarnings("rawtypes")
private static native void nGetControls(long id, int portIndex, Vector vector);
// getters/setters for controls

View File

@ -122,7 +122,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
/**
* List of tracks to which we're recording
*/
private final List recordingTracks = new ArrayList();
private final List<RecordingTrack> recordingTracks = new ArrayList<>();
private long loopStart = 0;
@ -133,13 +133,13 @@ final class RealTimeSequencer extends AbstractMidiDevice
/**
* Meta event listeners
*/
private final ArrayList metaEventListeners = new ArrayList();
private final ArrayList<Object> metaEventListeners = new ArrayList<>();
/**
* Control change listeners
*/
private final ArrayList controllerEventListeners = new ArrayList();
private final ArrayList<ControllerListElement> controllerEventListeners = new ArrayList<>();
/** automatic connection support */
@ -645,7 +645,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
boolean flag = false;
for(int i=0; i < controllerEventListeners.size(); i++) {
cve = (ControllerListElement) controllerEventListeners.get(i);
cve = controllerEventListeners.get(i);
if (cve.listener.equals(listener)) {
cve.addControllers(controllers);
@ -669,7 +669,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
ControllerListElement cve = null;
boolean flag = false;
for (int i=0; i < controllerEventListeners.size(); i++) {
cve = (ControllerListElement) controllerEventListeners.get(i);
cve = controllerEventListeners.get(i);
if (cve.listener.equals(listener)) {
cve.removeControllers(controllers);
flag = true;
@ -940,9 +940,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
ShortMessage msg = (ShortMessage) message;
int controller = msg.getData1();
List sendToListeners = new ArrayList();
List<Object> sendToListeners = new ArrayList<>();
for (int i = 0; i < size; i++) {
ControllerListElement cve = (ControllerListElement) controllerEventListeners.get(i);
ControllerListElement cve = controllerEventListeners.get(i);
for(int j = 0; j < cve.controllers.length; j++) {
if (cve.controllers[j] == controller) {
sendToListeners.add(cve.listener);
@ -1213,13 +1213,13 @@ final class RealTimeSequencer extends AbstractMidiDevice
this.channel = channel;
}
static RecordingTrack get(List recordingTracks, Track track) {
static RecordingTrack get(List<RecordingTrack> recordingTracks, Track track) {
synchronized(recordingTracks) {
int size = recordingTracks.size();
for (int i = 0; i < size; i++) {
RecordingTrack current = (RecordingTrack)recordingTracks.get(i);
RecordingTrack current = recordingTracks.get(i);
if (current.track == track) {
return current;
}
@ -1228,12 +1228,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
return null;
}
static Track get(List recordingTracks, int channel) {
static Track get(List<RecordingTrack> recordingTracks, int channel) {
synchronized(recordingTracks) {
int size = recordingTracks.size();
for (int i = 0; i < size; i++) {
RecordingTrack current = (RecordingTrack)recordingTracks.get(i);
RecordingTrack current = recordingTracks.get(i);
if ((current.channel == channel) || (current.channel == -1)) {
return current.track;
}

View File

@ -949,7 +949,7 @@ public final class SoftSynthesizer implements AudioSynthesizer,
Object v = (info == null) ? null : info.get(item2.name);
v = (v != null) ? v : storedProperties.getProperty(item2.name);
if (v != null) {
Class c = (item2.valueClass);
Class<?> c = (item2.valueClass);
if (c.isInstance(v))
item2.value = v;
else if (v instanceof String) {

View File

@ -198,7 +198,7 @@ public final class UlawCodec extends SunCodec {
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
if ((inputFormat.getSampleSizeInBits() == 16)
@ -235,7 +235,7 @@ public final class UlawCodec extends SunCodec {
AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(formats.elementAt(i));
formatArray[i] = formats.elementAt(i);
}
return formatArray;
}