mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
Merge branch 'master' of dice:git/vm
This commit is contained in:
commit
37ccb6cb46
@ -23,7 +23,7 @@ public class PrintStream extends OutputStream {
|
||||
}
|
||||
|
||||
public void print(Object o) {
|
||||
print(o.toString());
|
||||
print(String.valueOf(o));
|
||||
}
|
||||
|
||||
public void print(char c) {
|
||||
@ -46,7 +46,7 @@ public class PrintStream extends OutputStream {
|
||||
}
|
||||
|
||||
public void println(Object o) {
|
||||
println(o.toString());
|
||||
println(String.valueOf(o));
|
||||
}
|
||||
|
||||
public void println(char c) {
|
||||
|
@ -379,7 +379,7 @@ public final class String implements Comparable<String> {
|
||||
public native String intern();
|
||||
|
||||
public static String valueOf(Object s) {
|
||||
return s.toString();
|
||||
return s == null ? "null" : s.toString();
|
||||
}
|
||||
|
||||
public static String valueOf(boolean v) {
|
||||
|
@ -70,7 +70,7 @@ public class ArrayList<T> implements List<T> {
|
||||
public void add(int index, T element) {
|
||||
size = Math.max(size+1, index+1);
|
||||
grow();
|
||||
System.arraycopy(array, index, array, index+1, size-index);
|
||||
System.arraycopy(array, index, array, index+1, size-index-1);
|
||||
array[index] = element;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,11 @@ import java.util.List;
|
||||
|
||||
public class Logger {
|
||||
private final String name;
|
||||
private static final ArrayList<Handler> handlers = new ArrayList<Handler>();
|
||||
private static final ArrayList<Handler> handlers;
|
||||
static {
|
||||
handlers = new ArrayList<Handler>();
|
||||
handlers.add(new DefaultHandler());
|
||||
}
|
||||
|
||||
public static Logger getLogger(String name) {
|
||||
return new Logger(name);
|
||||
@ -17,7 +21,7 @@ public class Logger {
|
||||
}
|
||||
|
||||
public List<Handler> getHandlers() {
|
||||
return handlers;
|
||||
return new ArrayList<Handler>(handlers);
|
||||
}
|
||||
|
||||
public void addHandler(Handler handler) {
|
||||
@ -64,4 +68,57 @@ public class Logger {
|
||||
public void setLevel(Level level) {
|
||||
// Currently ignored
|
||||
}
|
||||
|
||||
private static class DefaultHandler extends Handler {
|
||||
private static final int NAME_WIDTH = 14;
|
||||
private static final int METHOD_WIDTH = 15;
|
||||
private static final int LEVEL_WIDTH = 8;
|
||||
|
||||
public Object clone() { return this; }
|
||||
public void close() { }
|
||||
public void flush() { }
|
||||
|
||||
private void maybeLogThrown(StringBuilder sb, Throwable t) {
|
||||
if (t != null) {
|
||||
sb.append("\nCaused by: ");
|
||||
sb.append(t.getClass().getName());
|
||||
sb.append(": ");
|
||||
sb.append(t.getMessage());
|
||||
sb.append('\n');
|
||||
|
||||
for (StackTraceElement elt : t.getStackTrace()) {
|
||||
sb.append('\t');
|
||||
sb.append(elt.getClassName());
|
||||
sb.append('.');
|
||||
sb.append(elt.getMethodName());
|
||||
sb.append("(line");
|
||||
sb.append(':');
|
||||
sb.append(elt.getLineNumber());
|
||||
sb.append(')');
|
||||
sb.append('\n');
|
||||
}
|
||||
maybeLogThrown(sb, t.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void indent(StringBuilder sb, int amount) {
|
||||
do {
|
||||
sb.append(' ');
|
||||
} while (--amount > 0);
|
||||
}
|
||||
|
||||
public void publish(LogRecord r) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(r.getLoggerName());
|
||||
indent(sb, NAME_WIDTH - r.getLoggerName().length());
|
||||
sb.append(r.getSourceMethodName());
|
||||
indent(sb, METHOD_WIDTH - r.getSourceMethodName().length());
|
||||
sb.append(r.getLevel().getName());
|
||||
indent(sb, LEVEL_WIDTH - r.getLevel().getName().length());
|
||||
sb.append(r.getMessage());
|
||||
maybeLogThrown(sb, r.getThrown());
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ Java_java_lang_System_arraycopy
|
||||
{
|
||||
uint8_t* sbody = &cast<uint8_t>(s, 2 * BytesPerWord);
|
||||
uint8_t* dbody = &cast<uint8_t>(d, 2 * BytesPerWord);
|
||||
if (src == dst) {
|
||||
if (s == d) {
|
||||
memmove(dbody + (dstOffset * elementSize),
|
||||
sbody + (srcOffset * elementSize),
|
||||
length * elementSize);
|
||||
|
@ -92,11 +92,15 @@ public class Logging {
|
||||
throw new Exception("Started here");
|
||||
}
|
||||
|
||||
private static final boolean useCustomHandler = true;
|
||||
public static void main(String args[]) {
|
||||
Logger root = Logger.getLogger("");
|
||||
root.addHandler(new MyHandler());
|
||||
for (Handler h : root.getHandlers()) root.removeHandler(h);
|
||||
root.addHandler(new MyHandler());
|
||||
if (useCustomHandler) {
|
||||
Logger root = Logger.getLogger("");
|
||||
root.addHandler(new MyHandler());
|
||||
for (Handler h : root.getHandlers()) root.removeHandler(h);
|
||||
root.addHandler(new MyHandler());
|
||||
}
|
||||
|
||||
Logging me = new Logging();
|
||||
me.run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user