mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Remove dependency on Java 1.6
This commit is contained in:
@@ -180,9 +180,9 @@ public class BitcoinSerializer {
|
||||
System.arraycopy(hash, 0, header, 4 + COMMAND_LEN + 4, 4);
|
||||
}
|
||||
} else {
|
||||
assert Arrays.equals(checksum, Arrays.copyOf(doubleDigest(payload), 4))
|
||||
assert Arrays.equals(checksum, Utils.copyOf(doubleDigest(payload), 4))
|
||||
: "Checksum match failure on serialization. Cached: " + Arrays.toString(checksum)
|
||||
+ " Calculated: " + Arrays.toString(Arrays.copyOf(doubleDigest(payload), 4));
|
||||
+ " Calculated: " + Arrays.toString(Utils.copyOf(doubleDigest(payload), 4));
|
||||
System.arraycopy(checksum, 0, header, 4 + COMMAND_LEN + 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.google.bitcoin.core;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* An unsynchronized implementation of ByteArrayOutputStream that will return the backing byte array if its length == size().
|
||||
@@ -33,7 +32,7 @@ public class UnsafeByteArrayOutputStream extends ByteArrayOutputStream {
|
||||
public void write(int b) {
|
||||
int newcount = count + 1;
|
||||
if (newcount > buf.length) {
|
||||
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
|
||||
buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
|
||||
}
|
||||
buf[count] = (byte) b;
|
||||
count = newcount;
|
||||
@@ -56,7 +55,7 @@ public class UnsafeByteArrayOutputStream extends ByteArrayOutputStream {
|
||||
}
|
||||
int newcount = count + len;
|
||||
if (newcount > buf.length) {
|
||||
buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
|
||||
buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
|
||||
}
|
||||
System.arraycopy(b, off, buf, count, len);
|
||||
count = newcount;
|
||||
@@ -95,7 +94,7 @@ public class UnsafeByteArrayOutputStream extends ByteArrayOutputStream {
|
||||
* @see java.io.ByteArrayOutputStream#size()
|
||||
*/
|
||||
public byte toByteArray()[] {
|
||||
return count == buf.length ? buf : Arrays.copyOf(buf, count);
|
||||
return count == buf.length ? buf : Utils.copyOf(buf, count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.Date;
|
||||
* A collection of various utility methods that are helpful for working with the BitCoin protocol.
|
||||
* To enable debug logging from the library, run with -Dbitcoinj.logging=true on your command line.
|
||||
*/
|
||||
@SuppressWarnings({"SameParameterValue"})
|
||||
public class Utils {
|
||||
// TODO: Replace this nanocoins business with something better.
|
||||
|
||||
@@ -284,4 +283,10 @@ public class Utils {
|
||||
else
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public static byte[] copyOf(byte[] in, int length) {
|
||||
byte[] out = new byte[length];
|
||||
System.arraycopy(in, 0, out, 0, length);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user