Fix java warnings (#1005)

This commit is contained in:
Allen Byrne
2021-09-15 08:26:25 -05:00
committed by GitHub
parent cd2ca91875
commit 1c892fb41f
3 changed files with 37 additions and 47 deletions

View File

@@ -46,10 +46,10 @@ public class HDFArray {
* *
* @param anArray * @param anArray
* The array object. * The array object.
* @exception hdf.hdf5lib.exceptions.HDF5Exception * @exception hdf.hdf5lib.exceptions.HDF5JavaException
* object is not an array. * object is not an array.
*/ */
public HDFArray(Object anArray) throws HDF5Exception public HDFArray(Object anArray) throws HDF5JavaException
{ {
if (anArray == null) { if (anArray == null) {
HDF5JavaException ex = new HDF5JavaException("HDFArray: array is null?: "); HDF5JavaException ex = new HDF5JavaException("HDFArray: array is null?: ");
@@ -76,16 +76,14 @@ public class HDFArray {
* @return A one-D array of bytes, filled with zeroes. The bytes are sufficient to hold the data of the Array passed * @return A one-D array of bytes, filled with zeroes. The bytes are sufficient to hold the data of the Array passed
* to the constructor. * to the constructor.
* @exception hdf.hdf5lib.exceptions.HDF5JavaException * @exception hdf.hdf5lib.exceptions.HDF5JavaException
* Allocation failed. * Allocation failed.
*/ */
public byte[] emptyBytes() public byte[] emptyBytes() throws HDF5JavaException
throws HDF5JavaException
{ {
byte[] b = null; byte[] b = null;
if ((ArrayDescriptor.dims == 1) if ((ArrayDescriptor.dims == 1) && (ArrayDescriptor.NT == 'B')) {
&& (ArrayDescriptor.NT == 'B')) {
b = (byte[]) _theArray; b = (byte[]) _theArray;
} }
else { else {
@@ -103,10 +101,9 @@ public class HDFArray {
* *
* @return A one-D array of bytes, constructed from the Array passed to the constructor. * @return A one-D array of bytes, constructed from the Array passed to the constructor.
* @exception hdf.hdf5lib.exceptions.HDF5JavaException * @exception hdf.hdf5lib.exceptions.HDF5JavaException
* the object not an array or other internal error. * the object not an array or other internal error.
*/ */
public byte[] byteify() public byte[] byteify() throws HDF5JavaException
throws HDF5JavaException
{ {
if (_barray != null) { if (_barray != null) {
return _barray; return _barray;
@@ -224,8 +221,6 @@ public class HDFArray {
if (ArrayDescriptor.NT == 'J') { if (ArrayDescriptor.NT == 'J') {
arow = HDFNativeData.longToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims], arow = HDFNativeData.longToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
(long[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]); (long[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
arow = HDFNativeData.longToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
(long[]) ArrayDescriptor.objs[ArrayDescriptor.dims - 1]);
} }
else if (ArrayDescriptor.NT == 'I') { else if (ArrayDescriptor.NT == 'I') {
arow = HDFNativeData.intToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims], arow = HDFNativeData.intToByte(0, ArrayDescriptor.dimlen[ArrayDescriptor.dims],
@@ -552,8 +547,7 @@ public class HDFArray {
+ "?")); + "?"));
} }
} }
if (ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1] != ArrayDescriptor.dimlen[ArrayDescriptor.dims if (ArrayDescriptor.currentindex[ArrayDescriptor.dims - 1] != ArrayDescriptor.dimlen[ArrayDescriptor.dims - 1]) {
- 1]) {
throw new java.lang.InternalError( throw new java.lang.InternalError(
new String("HDFArray::arrayify Panic didn't complete all data: currentindex[" + i + "] = " new String("HDFArray::arrayify Panic didn't complete all data: currentindex[" + i + "] = "
+ ArrayDescriptor.currentindex[i] + " (should be " + (ArrayDescriptor.dimlen[i]) + "?")); + ArrayDescriptor.currentindex[i] + " (should be " + (ArrayDescriptor.dimlen[i]) + "?"));
@@ -580,7 +574,7 @@ public class HDFArray {
Integer[] out = new Integer[nelems]; Integer[] out = new Integer[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Integer(in[i]); out[i] = Integer.valueOf(in[i]);
} }
return out; return out;
} }
@@ -592,7 +586,7 @@ public class HDFArray {
Integer[] out = new Integer[nelems]; Integer[] out = new Integer[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Integer(in[i]); out[i] = Integer.valueOf(in[i]);
} }
return out; return out;
} }
@@ -615,7 +609,7 @@ public class HDFArray {
Short[] out = new Short[nelems]; Short[] out = new Short[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Short(in[i]); out[i] = Short.valueOf(in[i]);
} }
return out; return out;
} }
@@ -627,7 +621,7 @@ public class HDFArray {
Short[] out = new Short[nelems]; Short[] out = new Short[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Short(in[i]); out[i] = Short.valueOf(in[i]);
} }
return out; return out;
} }
@@ -649,7 +643,7 @@ public class HDFArray {
Byte[] out = new Byte[nelems]; Byte[] out = new Byte[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Byte(bin[i]); out[i] = Byte.valueOf(bin[i]);
} }
return out; return out;
} }
@@ -659,7 +653,7 @@ public class HDFArray {
Byte[] out = new Byte[len]; Byte[] out = new Byte[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
out[i] = new Byte(bin[i]); out[i] = Byte.valueOf(bin[i]);
} }
return out; return out;
} }
@@ -682,7 +676,7 @@ public class HDFArray {
Float[] out = new Float[nelems]; Float[] out = new Float[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Float(in[i]); out[i] = Float.valueOf(in[i]);
} }
return out; return out;
} }
@@ -694,7 +688,7 @@ public class HDFArray {
Float[] out = new Float[nelems]; Float[] out = new Float[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Float(in[i]); out[i] = Float.valueOf(in[i]);
} }
return out; return out;
} }
@@ -717,7 +711,7 @@ public class HDFArray {
Double[] out = new Double[nelems]; Double[] out = new Double[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Double(in[i]); out[i] = Double.valueOf(in[i]);
} }
return out; return out;
} }
@@ -729,7 +723,7 @@ public class HDFArray {
Double[] out = new Double[nelems]; Double[] out = new Double[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Double(in[i]); out[i] = Double.valueOf(in[i]);
} }
return out; return out;
} }
@@ -752,7 +746,7 @@ public class HDFArray {
Long[] out = new Long[nelems]; Long[] out = new Long[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Long(in[i]); out[i] = Long.valueOf(in[i]);
} }
return out; return out;
} }
@@ -764,7 +758,7 @@ public class HDFArray {
Long[] out = new Long[nelems]; Long[] out = new Long[nelems];
for (int i = 0; i < nelems; i++) { for (int i = 0; i < nelems; i++) {
out[i] = new Long(in[i]); out[i] = Long.valueOf(in[i]);
} }
return out; return out;
} }
@@ -790,12 +784,12 @@ class ArrayDescriptor {
static int dims = 0; static int dims = 0;
static String className; static String className;
public ArrayDescriptor(Object anArray) throws HDF5Exception public ArrayDescriptor(Object anArray) throws HDF5JavaException
{ {
Class tc = anArray.getClass(); Class tc = anArray.getClass();
if (tc.isArray() == false) { if (tc.isArray() == false) {
/* exception: not an array */ /* exception: not an array */
HDF5Exception ex = new HDF5JavaException("ArrayDescriptor: not an array?: "); HDF5JavaException ex = new HDF5JavaException("ArrayDescriptor: not an array?: ");
throw (ex); throw (ex);
} }

View File

@@ -153,8 +153,7 @@ public class HDFNativeData {
* The input array of bytes * The input array of bytes
* @return an array of 'len' float * @return an array of 'len' float
*/ */
public synchronized static native float[] byteToFloat(int start, int len, public synchronized static native float[] byteToFloat(int start, int len, byte[] data);
byte[] data);
/** /**
* Convert 4 bytes from an array of bytes into a single float * Convert 4 bytes from an array of bytes into a single float
@@ -437,41 +436,38 @@ public class HDFNativeData {
* - Error unsupported type. * - Error unsupported type.
*/ */
public synchronized static Object byteToNumber(byte[] barray, Object obj) public synchronized static Object byteToNumber(byte[] barray, Object obj)
throws HDF5Exception { throws HDF5Exception
{
Class theClass = obj.getClass(); Class theClass = obj.getClass();
String type = theClass.getName(); String type = theClass.getName();
Object retobj = null; Object retobj = null;
if (type.equals("java.lang.Integer")) { if (type.equals("java.lang.Integer")) {
int[] i = hdf.hdf5lib.HDFNativeData.byteToInt(0, 1, barray); int[] i = hdf.hdf5lib.HDFNativeData.byteToInt(0, 1, barray);
retobj = new Integer(i[0]); retobj = Integer.valueOf(i[0]);
} }
else if (type.equals("java.lang.Byte")) { else if (type.equals("java.lang.Byte")) {
retobj = new Byte(barray[0]); retobj = Byte.valueOf(barray[0]);
} }
else if (type.equals("java.lang.Short")) { else if (type.equals("java.lang.Short")) {
short[] f = hdf.hdf5lib.HDFNativeData short[] f = hdf.hdf5lib.HDFNativeData.byteToShort(0, 1, barray);
.byteToShort(0, 1, barray); retobj = Short.valueOf(f[0]);
retobj = new Short(f[0]);
} }
else if (type.equals("java.lang.Float")) { else if (type.equals("java.lang.Float")) {
float[] f = hdf.hdf5lib.HDFNativeData float[] f = hdf.hdf5lib.HDFNativeData.byteToFloat(0, 1, barray);
.byteToFloat(0, 1, barray); retobj = Float.valueOf(f[0]);
retobj = new Float(f[0]);
} }
else if (type.equals("java.lang.Long")) { else if (type.equals("java.lang.Long")) {
long[] f = hdf.hdf5lib.HDFNativeData.byteToLong(0, 1, barray); long[] f = hdf.hdf5lib.HDFNativeData.byteToLong(0, 1, barray);
retobj = new Long(f[0]); retobj = Long.valueOf(f[0]);
} }
else if (type.equals("java.lang.Double")) { else if (type.equals("java.lang.Double")) {
double[] f = hdf.hdf5lib.HDFNativeData.byteToDouble(0, 1, double[] f = hdf.hdf5lib.HDFNativeData.byteToDouble(0, 1, barray);
barray); retobj = Double.valueOf(f[0]);
retobj = new Double(f[0]);
} }
else { else {
/* exception: unsupported type */ /* exception: unsupported type */
HDF5Exception ex = new HDF5JavaException( HDF5Exception ex = new HDF5JavaException("byteToNumber: setfield bad type: " + obj + " " + type);
"byteToNumber: setfield bad type: " + obj + " " + type);
throw (ex); throw (ex);
} }
return (retobj); return (retobj);

View File

@@ -102,7 +102,7 @@ public class TestH5Pfapl {
for(int indx = 0; ;indx++) { for(int indx = 0; ;indx++) {
java.text.DecimalFormat myFormat = new java.text.DecimalFormat("00000"); java.text.DecimalFormat myFormat = new java.text.DecimalFormat("00000");
try { try {
file = new File("test"+myFormat.format(new Integer(indx))+".h5"); file = new File("test"+myFormat.format(Integer.valueOf(indx))+".h5");
} }
catch (Throwable err) {} catch (Throwable err) {}