提交 a3ba31ae 编写于 作者: S serb

8006085: [findbugs] a warning on javax.sound.sampled.DataLine$Info constructor

Reviewed-by: art, prr
上级 61b4665d
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package javax.sound.sampled; package javax.sound.sampled;
import java.util.Arrays;
/** /**
* <code>DataLine</code> adds media-related functionality to its * <code>DataLine</code> adds media-related functionality to its
* superinterface, <code>{@link Line}</code>. This functionality includes * superinterface, <code>{@link Line}</code>. This functionality includes
...@@ -282,9 +284,9 @@ public interface DataLine extends Line { ...@@ -282,9 +284,9 @@ public interface DataLine extends Line {
*/ */
public static class Info extends Line.Info { public static class Info extends Line.Info {
private AudioFormat[] formats; private final AudioFormat[] formats;
private int minBufferSize; private final int minBufferSize;
private int maxBufferSize; private final int maxBufferSize;
/** /**
* Constructs a data line's info object from the specified information, * Constructs a data line's info object from the specified information,
...@@ -304,7 +306,7 @@ public interface DataLine extends Line { ...@@ -304,7 +306,7 @@ public interface DataLine extends Line {
if (formats == null) { if (formats == null) {
this.formats = new AudioFormat[0]; this.formats = new AudioFormat[0];
} else { } else {
this.formats = formats; this.formats = Arrays.copyOf(formats, formats.length);
} }
this.minBufferSize = minBufferSize; this.minBufferSize = minBufferSize;
...@@ -329,8 +331,7 @@ public interface DataLine extends Line { ...@@ -329,8 +331,7 @@ public interface DataLine extends Line {
if (format == null) { if (format == null) {
this.formats = new AudioFormat[0]; this.formats = new AudioFormat[0];
} else { } else {
AudioFormat[] formats = { format }; this.formats = new AudioFormat[]{format};
this.formats = formats;
} }
this.minBufferSize = bufferSize; this.minBufferSize = bufferSize;
...@@ -373,10 +374,7 @@ public interface DataLine extends Line { ...@@ -373,10 +374,7 @@ public interface DataLine extends Line {
* @see #isFormatSupported(AudioFormat) * @see #isFormatSupported(AudioFormat)
*/ */
public AudioFormat[] getFormats() { public AudioFormat[] getFormats() {
return Arrays.copyOf(formats, formats.length);
AudioFormat[] returnedArray = new AudioFormat[formats.length];
System.arraycopy(formats, 0, returnedArray, 0, formats.length);
return returnedArray;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册