mirror of
https://github.com/corda/corda.git
synced 2025-06-15 21:58:17 +00:00
heap o' bugfixes
This commit is contained in:
@ -25,6 +25,10 @@ public final class Class <T> {
|
||||
|
||||
private Class() { }
|
||||
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return new String(name, 0, name.length - 1, false);
|
||||
}
|
||||
@ -73,7 +77,7 @@ public final class Class <T> {
|
||||
|
||||
public Class getComponentType() {
|
||||
if (isArray()) {
|
||||
return forCanonicalName(new String(name, 1, name.length - 2, false));
|
||||
return (Class) (Object) staticTable;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -258,12 +262,14 @@ public final class Class <T> {
|
||||
|
||||
private int countMethods(boolean publicOnly) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < methodTable.length; ++i) {
|
||||
if (((! publicOnly)
|
||||
|| ((methodTable[i].getModifiers() & Modifier.PUBLIC)) != 0)
|
||||
&& (! methodTable[i].getName().startsWith("<")))
|
||||
{
|
||||
++ count;
|
||||
if (methodTable != null) {
|
||||
for (int i = 0; i < methodTable.length; ++i) {
|
||||
if (((! publicOnly)
|
||||
|| ((methodTable[i].getModifiers() & Modifier.PUBLIC)) != 0)
|
||||
&& (! methodTable[i].getName().startsWith("<")))
|
||||
{
|
||||
++ count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
@ -31,7 +31,7 @@ public final class Double extends Number {
|
||||
}
|
||||
|
||||
public static String toString(double v) {
|
||||
return "todo";
|
||||
return "Double.toString: todo";
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
@ -60,7 +60,7 @@ public final class Double extends Number {
|
||||
|
||||
public static double parseDouble(String s) {
|
||||
// todo
|
||||
return 0.0;
|
||||
throw new NumberFormatException(s);
|
||||
}
|
||||
|
||||
public static native long doubleToRawLongBits(double value);
|
||||
|
@ -26,7 +26,7 @@ public final class Float extends Number {
|
||||
}
|
||||
|
||||
public static String toString(float v) {
|
||||
return "todo";
|
||||
return "Float.toString: todo";
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
|
@ -34,7 +34,10 @@ public final class Long extends Number {
|
||||
return "0";
|
||||
}
|
||||
|
||||
int size = (v < 0 ? 1 : 0);
|
||||
boolean negative = v < 0;
|
||||
if (negative) v = -v;
|
||||
|
||||
int size = (negative ? 1 : 0);
|
||||
for (long n = v; n > 0; n /= radix) ++size;
|
||||
|
||||
char[] array = new char[size];
|
||||
@ -50,7 +53,7 @@ public final class Long extends Number {
|
||||
--i;
|
||||
}
|
||||
|
||||
if (v < 0) {
|
||||
if (negative) {
|
||||
array[i] = '-';
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public final class String implements Comparable<String> {
|
||||
}
|
||||
|
||||
public int indexOf(int c) {
|
||||
for (int i = 0; i < length - 1; ++i) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (charAt(i) == c) {
|
||||
return i;
|
||||
}
|
||||
@ -144,7 +144,7 @@ public final class String implements Comparable<String> {
|
||||
public int indexOf(String s) {
|
||||
if (s.length == 0) return 0;
|
||||
|
||||
for (int i = 0; i < length - s.length; ++i) {
|
||||
for (int i = 0; i < length - s.length + 1; ++i) {
|
||||
int j = 0;
|
||||
for (; j < s.length; ++j) {
|
||||
if (charAt(i + j) != s.charAt(j)) {
|
||||
|
@ -36,7 +36,12 @@ public class Throwable {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + message;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getName());
|
||||
if (message != null) {
|
||||
sb.append(": ").append(message);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static native Object trace(int skipCount);
|
||||
@ -69,11 +74,7 @@ public class Throwable {
|
||||
}
|
||||
|
||||
private void printStackTrace(StringBuilder sb, String nl) {
|
||||
sb.append(getClass().getName());
|
||||
if (message != null) {
|
||||
sb.append(": ").append(message);
|
||||
}
|
||||
sb.append(nl);
|
||||
sb.append(toString()).append(nl);
|
||||
|
||||
StackTraceElement[] trace = resolveTrace();
|
||||
for (int i = 0; i < trace.length; ++i) {
|
||||
|
@ -28,15 +28,13 @@ public final class Array {
|
||||
return Boolean.valueOf(((boolean[]) array)[index]);
|
||||
case 'L':
|
||||
case '[':
|
||||
return getObject(array, index);
|
||||
return ((Object[]) array)[index];
|
||||
|
||||
default:
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
|
||||
private static native Object getObject(Object array, int index);
|
||||
|
||||
public static void set(Object array, int index, Object value) {
|
||||
String className = array.getClass().getName();
|
||||
if (! className.startsWith("[")) {
|
||||
@ -71,7 +69,7 @@ public final class Array {
|
||||
case 'L':
|
||||
case '[':
|
||||
if (array.getClass().getComponentType().isInstance(value)) {
|
||||
setObject(array, index, value);
|
||||
((Object[]) array)[index] = value;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -82,8 +80,6 @@ public final class Array {
|
||||
}
|
||||
}
|
||||
|
||||
private static native void setObject(Object array, int index, Object value);
|
||||
|
||||
public static native int getLength(Object array);
|
||||
|
||||
private static native Object makeObjectArray(Class elementType, int length);
|
||||
|
@ -73,11 +73,11 @@ public class Method<T> extends AccessibleObject implements Member {
|
||||
types[index++] = Class.forName(name);
|
||||
} else {
|
||||
String name = spec.substring(start, i + 1);
|
||||
types[index++] = Class.forName(name);
|
||||
types[index++] = Class.forCanonicalName(name);
|
||||
}
|
||||
} else {
|
||||
String name = spec.substring(i, i + 1);
|
||||
types[index++] = Class.forName(name);
|
||||
types[index++] = Class.forCanonicalName(name);
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
Reference in New Issue
Block a user