8042256: Fix raw and unchecked lint warnings in com.sun.media.sound
authordarcy
Mon, 05 May 2014 23:19:00 -0700
changeset 24548 9c007a986347
parent 24547 1b3cb0c1ac87
child 24549 147a5c8b7793
8042256: Fix raw and unchecked lint warnings in com.sun.media.sound Reviewed-by: prr
jdk/src/share/classes/com/sun/media/sound/AbstractLine.java
jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java
jdk/src/share/classes/com/sun/media/sound/AlawCodec.java
jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java
jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java
jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java
jdk/src/share/classes/com/sun/media/sound/JDK13Services.java
jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java
jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java
jdk/src/share/classes/com/sun/media/sound/MidiUtils.java
jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
jdk/src/share/classes/com/sun/media/sound/PortMixer.java
jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
jdk/src/share/classes/com/sun/media/sound/UlawCodec.java
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java	Mon May 05 23:19:00 2014 -0700
@@ -48,7 +48,7 @@
     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.
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java	Mon May 05 23:19:00 2014 -0700
@@ -70,7 +70,7 @@
 
     /** 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 @@
     }
 
 
+    @SuppressWarnings("unchecked") // Cast of result of clone
     public final List<Receiver> getReceivers() {
         List<Receiver> recs;
         synchronized (traRecLock) {
@@ -313,6 +314,7 @@
     }
 
 
+    @SuppressWarnings("unchecked") // Cast of result of clone
     public final List<Transmitter> getTransmitters() {
         List<Transmitter> tras;
         synchronized (traRecLock) {
@@ -372,9 +374,9 @@
 
     /** 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;
     }
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java	Mon May 05 23:19:00 2014 -0700
@@ -90,13 +90,13 @@
     /**
      * 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 @@
     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 @@
 
         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 @@
     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 @@
 
         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 @@
             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 @@
             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 @@
             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 @@
             }
         }
 
-        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
--- a/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java	Mon May 05 23:19:00 2014 -0700
@@ -213,7 +213,7 @@
     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 @@
 
         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;
     }
--- a/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java	Mon May 05 23:19:00 2014 -0700
@@ -68,7 +68,7 @@
      * 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
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Mon May 05 23:19:00 2014 -0700
@@ -94,7 +94,7 @@
     }
 
     private DirectDLI createDataLineInfo(boolean isSource) {
-        Vector formats = new Vector();
+        Vector<AudioFormat> formats = new Vector<>();
         AudioFormat[] hardwareFormatArray = null;
         AudioFormat[] formatArray = null;
 
@@ -107,7 +107,7 @@
                 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 @@
         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 @@
     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 @@
 
     } // class DirectBAOS
 
-
+    @SuppressWarnings("rawtypes")
     private static native void nGetFormats(int mixerIndex, int deviceID,
                                            boolean isSource, Vector formats);
 
--- a/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java	Mon May 05 23:19:00 2014 -0700
@@ -57,7 +57,7 @@
     /**
      * List of events
      */
-    private final ArrayList eventQueue = new ArrayList();
+    private final ArrayList<EventInfo> eventQueue = new ArrayList<>();
 
 
     /**
@@ -186,7 +186,7 @@
             }
             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 @@
     /**
      * 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 @@
          * @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();
         }
--- a/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java	Mon May 05 23:19:00 2014 -0700
@@ -118,7 +118,7 @@
         (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 @@
         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 @@
         @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)
--- a/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java	Mon May 05 23:19:00 2014 -0700
@@ -106,9 +106,9 @@
      * 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;
         }
--- a/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java	Mon May 05 23:19:00 2014 -0700
@@ -104,9 +104,9 @@
      * 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;
         }
--- a/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java	Mon May 05 23:19:00 2014 -0700
@@ -295,7 +295,7 @@
 
 
         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 @@
             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 @@
                 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());
             }
--- a/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java	Mon May 05 23:19:00 2014 -0700
@@ -91,7 +91,7 @@
         // 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 @@
         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 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 @@
 
             for (int i = 0; i < formatArray.length; i++) {
 
-                formatArray[i] = (AudioFormat)(formats.elementAt(i));
+                formatArray[i] = formats.elementAt(i);
             }
         }
 
--- a/jdk/src/share/classes/com/sun/media/sound/PortMixer.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/PortMixer.java	Mon May 05 23:19:00 2014 -0700
@@ -253,12 +253,12 @@
             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 @@
     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
--- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java	Mon May 05 23:19:00 2014 -0700
@@ -122,7 +122,7 @@
     /**
      * 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 @@
     /**
      * 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 @@
             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 @@
             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 @@
         }
         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 @@
             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 @@
             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;
                     }
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java	Mon May 05 23:19:00 2014 -0700
@@ -949,7 +949,7 @@
             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) {
--- a/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java	Mon May 05 12:49:13 2014 -0700
+++ b/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java	Mon May 05 23:19:00 2014 -0700
@@ -198,7 +198,7 @@
     /*  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 @@
 
         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;
     }