mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
bugfixes
This commit is contained in:
parent
e2f3e80bdf
commit
27c8511c5e
@ -97,6 +97,13 @@ doWrite(JNIEnv* e, jint fd, const jbyte* data, jint length)
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path)
|
||||
{
|
||||
// todo
|
||||
return path;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_java_io_File_toAbsolutePath(JNIEnv* /*e*/, jclass, jstring path)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
package java.lang;
|
||||
|
||||
public class StackTraceElement {
|
||||
private static int NativeLine = -2;
|
||||
private static int NativeLine = -1;
|
||||
|
||||
private String class_;
|
||||
private String method;
|
||||
|
@ -1,24 +1,30 @@
|
||||
package java.util;
|
||||
|
||||
public class ArrayList<T> implements List<T> {
|
||||
private static final int MinimumCapacity = 16;
|
||||
|
||||
private Object[] array;
|
||||
private int size;
|
||||
|
||||
public ArrayList(int capacity) {
|
||||
if (capacity != 0) {
|
||||
array = new Object[capacity];
|
||||
}
|
||||
resize(capacity);
|
||||
}
|
||||
|
||||
public ArrayList() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
private void grow() {
|
||||
if (array == null || size >= array.length) {
|
||||
resize(array == null ? MinimumCapacity : array.length * 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void resize() {
|
||||
if (array == null || size >= array.length - 1) {
|
||||
resize(array == null ? 16 : array.length * 2);
|
||||
} else if (size <= array.length / 3) {
|
||||
private void shrink() {
|
||||
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
||||
resize(array.length / 2);
|
||||
} else if (size == 0) {
|
||||
resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +61,9 @@ public class ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
public boolean add(T element) {
|
||||
resize();
|
||||
array[size++] = element;
|
||||
++ size;
|
||||
grow();
|
||||
array[size - 1] = element;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -78,7 +85,7 @@ public class ArrayList<T> implements List<T> {
|
||||
}
|
||||
|
||||
-- size;
|
||||
resize();
|
||||
shrink();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package java.util;
|
||||
|
||||
public class HashMap<K, V> implements Map<K, V> {
|
||||
private static final int MinimumCapacity = 16;
|
||||
|
||||
private int size;
|
||||
private Cell[] array;
|
||||
private final Helper helper;
|
||||
@ -46,11 +48,17 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
return size;
|
||||
}
|
||||
|
||||
private void resize() {
|
||||
private void grow() {
|
||||
if (array == null || size >= array.length * 2) {
|
||||
resize(array == null ? 16 : array.length * 2);
|
||||
} else if (size <= array.length / 3) {
|
||||
resize(array == null ? MinimumCapacity : array.length * 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void shrink() {
|
||||
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
||||
resize(array.length / 2);
|
||||
} else if (size == 0) {
|
||||
resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +102,7 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
private void insert(Cell<K, V> cell) {
|
||||
++ size;
|
||||
|
||||
resize();
|
||||
grow();
|
||||
|
||||
int index = cell.hashCode() & (array.length - 1);
|
||||
cell.setNext(array[index]);
|
||||
@ -116,7 +124,7 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
resize();
|
||||
shrink();
|
||||
}
|
||||
|
||||
private Cell<K, V> putCell(K key, V value) {
|
||||
@ -161,7 +169,7 @@ public class HashMap<K, V> implements Map<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
resize();
|
||||
shrink();
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
2
makefile
2
makefile
@ -1,4 +1,4 @@
|
||||
#MAKEFLAGS = -s
|
||||
MAKEFLAGS = -s
|
||||
|
||||
arch = $(shell uname -m)
|
||||
ifeq ($(arch),i586)
|
||||
|
32
src/run.cpp
32
src/run.cpp
@ -616,7 +616,7 @@ run(Thread* t)
|
||||
{
|
||||
pushObject(t, objectArrayBody(t, array, index));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
objectArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -638,7 +638,7 @@ run(Thread* t)
|
||||
{
|
||||
set(t, objectArrayBody(t, array, index), value);
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
objectArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -748,7 +748,7 @@ run(Thread* t)
|
||||
{
|
||||
pushInt(t, byteArrayBody(t, array, index));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
byteArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -770,7 +770,7 @@ run(Thread* t)
|
||||
{
|
||||
byteArrayBody(t, array, index) = value;
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
byteArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -795,7 +795,7 @@ run(Thread* t)
|
||||
{
|
||||
pushInt(t, charArrayBody(t, array, index));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
charArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -817,7 +817,7 @@ run(Thread* t)
|
||||
{
|
||||
charArrayBody(t, array, index) = value;
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
charArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -878,7 +878,7 @@ run(Thread* t)
|
||||
memcpy(&d, &doubleArrayBody(t, array, index), sizeof(double));
|
||||
pushDouble(t, d);
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
doubleArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -900,7 +900,7 @@ run(Thread* t)
|
||||
{
|
||||
memcpy(&doubleArrayBody(t, array, index), &value, sizeof(uint64_t));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
doubleArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -1063,7 +1063,7 @@ run(Thread* t)
|
||||
float f; memcpy(&f, &floatArrayBody(t, array, index), sizeof(float));
|
||||
pushFloat(t, f);
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
floatArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -1085,7 +1085,7 @@ run(Thread* t)
|
||||
{
|
||||
memcpy(&floatArrayBody(t, array, index), &value, sizeof(uint32_t));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
floatArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -1276,7 +1276,7 @@ run(Thread* t)
|
||||
{
|
||||
pushInt(t, intArrayBody(t, array, index));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
intArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -1305,7 +1305,7 @@ run(Thread* t)
|
||||
{
|
||||
intArrayBody(t, array, index) = value;
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
intArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -1803,7 +1803,7 @@ run(Thread* t)
|
||||
{
|
||||
pushLong(t, longArrayBody(t, array, index));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
longArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -1832,7 +1832,7 @@ run(Thread* t)
|
||||
{
|
||||
longArrayBody(t, array, index) = value;
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
longArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -2287,7 +2287,7 @@ run(Thread* t)
|
||||
{
|
||||
pushInt(t, shortArrayBody(t, array, index));
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
shortArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
@ -2309,7 +2309,7 @@ run(Thread* t)
|
||||
{
|
||||
shortArrayBody(t, array, index) = value;
|
||||
} else {
|
||||
object message = makeString(t, "%d not in [0,%d]", index,
|
||||
object message = makeString(t, "%d not in [0,%d)", index,
|
||||
shortArrayLength(t, array));
|
||||
exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||
goto throw_;
|
||||
|
Loading…
Reference in New Issue
Block a user