mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
Merge branch 'master' of ssh://git.ecovate.com/avian
This commit is contained in:
commit
21c1ea53ae
@ -26,8 +26,6 @@ public class Classes {
|
||||
public static native VMClass defineVMClass
|
||||
(ClassLoader loader, byte[] b, int offset, int length);
|
||||
|
||||
public static native VMClass vmClass(Object o);
|
||||
|
||||
public static native VMClass primitiveClass(char name);
|
||||
|
||||
public static native void initialize(VMClass vmClass);
|
||||
|
@ -50,7 +50,7 @@ import java.util.concurrent.Callable;
|
||||
* frames from within that context.
|
||||
*
|
||||
* <p>Calling a continuation (i.e. feeding it a result or exception)
|
||||
* causes the current continuation to be replaced with the calling
|
||||
* causes the current continuation to be replaced with the called
|
||||
* continuation. When the last method in this new continuation
|
||||
* returns, it returns to the native frame which created the current
|
||||
* context, which may or may not be the same as the context in which
|
||||
|
26
classpath/avian/Iso88591.java
Normal file
26
classpath/avian/Iso88591.java
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
/* Copyright (c) 2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package avian;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class Iso88591 {
|
||||
|
||||
public static byte[] encode(char[] s16, int offset, int length) {
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
for (int i = offset; i < offset+length; ++i) {
|
||||
// ISO-88591-1/Latin-1 is the same as UTF-16 under 0x100
|
||||
buf.write(s16[i]);
|
||||
}
|
||||
return buf.toByteArray();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -314,10 +314,29 @@ Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path)
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_java_io_File_toAbsolutePath(JNIEnv* /*e*/, jclass, jstring path)
|
||||
Java_java_io_File_toAbsolutePath(JNIEnv* e UNUSED, jclass, jstring path)
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
// todo
|
||||
return path;
|
||||
#else
|
||||
jstring result = path;
|
||||
string_t chars = getChars(e, path);
|
||||
if (chars) {
|
||||
if (chars[0] != '/') {
|
||||
char* cwd = getcwd(NULL, 0);
|
||||
if (cwd) {
|
||||
unsigned size = strlen(cwd) + strlen(chars) + 2;
|
||||
RUNTIME_ARRAY(char, buffer, size);
|
||||
snprintf(RUNTIME_ARRAY_BODY(buffer), size, "%s/%s", cwd, chars);
|
||||
result = e->NewStringUTF(RUNTIME_ARRAY_BODY(buffer));
|
||||
free(cwd);
|
||||
}
|
||||
}
|
||||
releaseChars(e, path, chars);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -48,6 +48,7 @@
|
||||
# define SO_SUFFIX ".so"
|
||||
# endif
|
||||
# include "unistd.h"
|
||||
# include "limits.h"
|
||||
# include "sys/time.h"
|
||||
# include "sys/sysctl.h"
|
||||
# include "sys/utsname.h"
|
||||
@ -410,8 +411,8 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
||||
execvp(argv[0], argv);
|
||||
|
||||
// Error if here
|
||||
char c = errno;
|
||||
ssize_t rv UNUSED = write(msg[1], &c, 1);
|
||||
int val = errno;
|
||||
ssize_t rv UNUSED = write(msg[1], &val, sizeof(val));
|
||||
exit(127);
|
||||
} break;
|
||||
|
||||
@ -424,12 +425,13 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
||||
safeClose(err[1]);
|
||||
safeClose(msg[1]);
|
||||
|
||||
char c;
|
||||
int r = read(msg[0], &c, 1);
|
||||
int val;
|
||||
int r = read(msg[0], &val, sizeof(val));
|
||||
if(r == -1) {
|
||||
throwNewErrno(e, "java/io/IOException");
|
||||
return;
|
||||
} else if(r) {
|
||||
errno = val;
|
||||
throwNewErrno(e, "java/io/IOException");
|
||||
return;
|
||||
}
|
||||
@ -590,7 +592,8 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
|
||||
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
|
||||
r = e->NewStringUTF("/tmp");
|
||||
} else if (strcmp(chars, "user.dir") == 0) {
|
||||
r = e->NewStringUTF(getenv("PWD"));
|
||||
char buffer[PATH_MAX];
|
||||
r = e->NewStringUTF(getcwd(buffer, PATH_MAX));
|
||||
} else if (strcmp(chars, "user.home") == 0) {
|
||||
r = e->NewStringUTF(getenv("HOME"));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -42,7 +42,14 @@ public class BufferedReader extends Reader {
|
||||
}
|
||||
|
||||
for (int i = position; i < limit; ++i) {
|
||||
if (buffer[i] == '\n') {
|
||||
if(buffer[i] == '\r') {
|
||||
sb.append(buffer, position, i - position);
|
||||
position = i + 1;
|
||||
if(i+1 < limit && buffer[i+1] == '\n') {
|
||||
position = i + 2;
|
||||
}
|
||||
return sb.toString();
|
||||
} else if (buffer[i] == '\n') {
|
||||
sb.append(buffer, position, i - position);
|
||||
position = i + 1;
|
||||
return sb.toString();
|
||||
|
@ -98,6 +98,10 @@ public class ByteArrayOutputStream extends OutputStream {
|
||||
return array;
|
||||
}
|
||||
|
||||
public String toString(String encoding) throws UnsupportedEncodingException {
|
||||
return new String(toByteArray(), encoding);
|
||||
}
|
||||
|
||||
private static class Cell {
|
||||
public byte[] array;
|
||||
public int offset;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
package java.io;
|
||||
|
||||
public class File {
|
||||
public class File implements Serializable {
|
||||
private static final String FileSeparator
|
||||
= System.getProperty("file.separator");
|
||||
|
||||
@ -120,6 +120,10 @@ public class File {
|
||||
return toAbsolutePath(path);
|
||||
}
|
||||
|
||||
public File getAbsoluteFile() {
|
||||
return new File(getAbsolutePath());
|
||||
}
|
||||
|
||||
private static native long length(String path);
|
||||
|
||||
public long length() {
|
||||
|
40
classpath/java/io/FilterOutputStream.java
Normal file
40
classpath/java/io/FilterOutputStream.java
Normal file
@ -0,0 +1,40 @@
|
||||
/* Copyright (c) 2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.io;
|
||||
|
||||
public class FilterOutputStream extends OutputStream {
|
||||
protected OutputStream out;
|
||||
|
||||
public FilterOutputStream(OutputStream out) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
out.close();
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
out.flush();
|
||||
}
|
||||
|
||||
public void write(byte[] b) throws IOException {
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
out.write(b, off, len);
|
||||
}
|
||||
|
||||
public void write(int b) throws IOException {
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,8 @@
|
||||
|
||||
package java.io;
|
||||
|
||||
import avian.VMClass;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
@ -110,7 +112,7 @@ public class ObjectInputStream extends InputStream {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int c;
|
||||
while ((c = r.read()) != -1 && ! Character.isWhitespace((char) c)) {
|
||||
while ((c = r.read()) != -1 && ! Character.isWhitespace((char) c) && c != ')') {
|
||||
sb.append((char) c);
|
||||
}
|
||||
if (c != -1) {
|
||||
@ -149,7 +151,6 @@ public class ObjectInputStream extends InputStream {
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
skipSpace();
|
||||
|
||||
switch (r.read()) {
|
||||
case 'a':
|
||||
return deserializeArray(map);
|
||||
@ -160,7 +161,7 @@ public class ObjectInputStream extends InputStream {
|
||||
case 'n':
|
||||
return null;
|
||||
case 'z':
|
||||
return (readLongToken() == 0);
|
||||
return (readLongToken() != 0);
|
||||
case 'b':
|
||||
return (byte) readLongToken();
|
||||
case 'c':
|
||||
@ -203,7 +204,7 @@ public class ObjectInputStream extends InputStream {
|
||||
return o;
|
||||
}
|
||||
|
||||
private static native Object makeInstance(Class c);
|
||||
private static native Object makeInstance(VMClass c);
|
||||
|
||||
private Object deserializeObject(HashMap<Integer, Object> map)
|
||||
throws IOException, ClassNotFoundException
|
||||
@ -211,11 +212,11 @@ public class ObjectInputStream extends InputStream {
|
||||
read('(');
|
||||
int id = (int) readLongToken();
|
||||
Class c = Class.forName(readStringToken());
|
||||
Object o = makeInstance(c);
|
||||
Object o = makeInstance(c.vmClass);
|
||||
|
||||
map.put(id, o);
|
||||
|
||||
for (Field f: c.getFields()) {
|
||||
|
||||
for (Field f: c.getAllFields()) {
|
||||
int modifiers = f.getModifiers();
|
||||
if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) {
|
||||
try {
|
||||
|
@ -39,7 +39,7 @@ public class ObjectOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
public void writeObject(Object o) throws IOException {
|
||||
writeObject(o, new IdentityHashMap(), 0);
|
||||
writeObject(o, new IdentityHashMap(), new int[] {0});
|
||||
}
|
||||
|
||||
public void writeBoolean(boolean v) {
|
||||
@ -87,7 +87,7 @@ public class ObjectOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
private void writeObject(Object o, IdentityHashMap<Object, Integer> map,
|
||||
int nextId)
|
||||
int[] nextId)
|
||||
throws IOException
|
||||
{
|
||||
if (o == null) {
|
||||
@ -95,7 +95,7 @@ public class ObjectOutputStream extends OutputStream {
|
||||
} else {
|
||||
Integer id = map.get(o);
|
||||
if (id == null) {
|
||||
map.put(o, nextId);
|
||||
map.put(o, nextId[0]);
|
||||
|
||||
Class c = o.getClass();
|
||||
if (c.isArray()) {
|
||||
@ -113,7 +113,7 @@ public class ObjectOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
private void serializeArray(Object o, IdentityHashMap<Object, Integer> map,
|
||||
int nextId)
|
||||
int[] nextId)
|
||||
throws IOException
|
||||
{
|
||||
Class c = o.getClass();
|
||||
@ -121,7 +121,7 @@ public class ObjectOutputStream extends OutputStream {
|
||||
int length = Array.getLength(o);
|
||||
|
||||
out.print("a(");
|
||||
out.print(nextId++);
|
||||
out.print(nextId[0]++);
|
||||
out.print(" ");
|
||||
out.print(c.getName());
|
||||
out.print(" ");
|
||||
@ -155,17 +155,17 @@ public class ObjectOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
private void serializeObject(Object o, IdentityHashMap<Object, Integer> map,
|
||||
int nextId)
|
||||
int[] nextId)
|
||||
throws IOException
|
||||
{
|
||||
Class c = o.getClass();
|
||||
|
||||
out.print("l(");
|
||||
out.print(nextId++);
|
||||
out.print(nextId[0]++);
|
||||
out.print(" ");
|
||||
out.print(c.getName());
|
||||
|
||||
for (Field f: c.getFields()) {
|
||||
for (Field f: c.getAllFields()) {
|
||||
int modifiers = f.getModifiers();
|
||||
if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) {
|
||||
out.print(" ");
|
||||
|
21
classpath/java/lang/AbstractMethodError.java
Normal file
21
classpath/java/lang/AbstractMethodError.java
Normal file
@ -0,0 +1,21 @@
|
||||
/* Copyright (c) 2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.lang;
|
||||
|
||||
public class AbstractMethodError extends IncompatibleClassChangeError {
|
||||
public AbstractMethodError() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractMethodError(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.security.ProtectionDomain;
|
||||
@ -424,6 +425,25 @@ public final class Class <T> implements Type, AnnotatedElement {
|
||||
return array;
|
||||
}
|
||||
|
||||
private static void getAllFields(VMClass vmClass, ArrayList<Field> fields) {
|
||||
if (vmClass.super_ != null) {
|
||||
getAllFields(vmClass.super_, fields);
|
||||
}
|
||||
if (vmClass.fieldTable != null) {
|
||||
Classes.link(vmClass);
|
||||
|
||||
for (int i = 0; i < vmClass.fieldTable.length; ++i) {
|
||||
fields.add(new Field(vmClass.fieldTable[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Field[] getAllFields() {
|
||||
ArrayList<Field> fields = new ArrayList<Field>();
|
||||
getAllFields(vmClass, fields);
|
||||
return fields.toArray(new Field[fields.size()]);
|
||||
}
|
||||
|
||||
private int countMethods(boolean publicOnly) {
|
||||
int count = 0;
|
||||
if (vmClass.methodTable != null) {
|
||||
@ -515,7 +535,7 @@ public final class Class <T> implements Type, AnnotatedElement {
|
||||
}
|
||||
|
||||
public Class getSuperclass() {
|
||||
return SystemClassLoader.getClass(vmClass.super_);
|
||||
return (vmClass.super_ == null ? null : SystemClassLoader.getClass(vmClass.super_));
|
||||
}
|
||||
|
||||
public boolean isArray() {
|
||||
|
@ -103,7 +103,8 @@ public class Runtime {
|
||||
|
||||
if (exception[0] != null) {
|
||||
if (exception[0] instanceof IOException) {
|
||||
throw new IOException(exception[0]);
|
||||
String message = "Failed to run \"" + command[0] + "\": " + exception[0].getMessage();
|
||||
throw new IOException(message);
|
||||
} else {
|
||||
throw new RuntimeException(exception[0]);
|
||||
}
|
||||
|
@ -16,10 +16,16 @@ import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.io.Serializable;
|
||||
import avian.Utf8;
|
||||
import avian.Iso88591;
|
||||
|
||||
public final class String
|
||||
implements Comparable<String>, CharSequence, Serializable
|
||||
{
|
||||
private static final String UTF_8_ENCODING = "UTF-8";
|
||||
private static final String ISO_8859_1_ENCODING = "ISO-8859-1";
|
||||
private static final String LATIN_1_ENCODING = "LATIN-1";
|
||||
private static final String DEFAULT_ENCODING = UTF_8_ENCODING;
|
||||
|
||||
public static Comparator<String> CASE_INSENSITIVE_ORDER
|
||||
= new Comparator<String>() {
|
||||
public int compare(String a, String b) {
|
||||
@ -52,8 +58,8 @@ public final class String
|
||||
throws UnsupportedEncodingException
|
||||
{
|
||||
this(bytes, offset, length);
|
||||
if (! (charsetName.equalsIgnoreCase("UTF-8")
|
||||
|| charsetName.equalsIgnoreCase("ISO-8859-1")))
|
||||
if (! (charsetName.equalsIgnoreCase(UTF_8_ENCODING)
|
||||
|| charsetName.equalsIgnoreCase(ISO_8859_1_ENCODING)))
|
||||
{
|
||||
throw new UnsupportedEncodingException(charsetName);
|
||||
}
|
||||
@ -421,18 +427,31 @@ public final class String
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
if(data instanceof byte[]) {
|
||||
byte[] b = new byte[length];
|
||||
getBytes(0, length, b, 0);
|
||||
return b;
|
||||
try {
|
||||
return getBytes(DEFAULT_ENCODING);
|
||||
} catch (java.io.UnsupportedEncodingException ex) {
|
||||
throw new RuntimeException(
|
||||
"Default '" + DEFAULT_ENCODING + "' encoding not handled", ex);
|
||||
}
|
||||
return Utf8.encode((char[])data, offset, length);
|
||||
}
|
||||
|
||||
public byte[] getBytes(String format)
|
||||
throws java.io.UnsupportedEncodingException
|
||||
{
|
||||
return getBytes();
|
||||
if(data instanceof byte[]) {
|
||||
byte[] b = new byte[length];
|
||||
getBytes(0, length, b, 0);
|
||||
return b;
|
||||
}
|
||||
String fmt = format.trim().toUpperCase();
|
||||
if (DEFAULT_ENCODING.equals(fmt)) {
|
||||
return Utf8.encode((char[])data, offset, length);
|
||||
} else if (ISO_8859_1_ENCODING.equals(fmt) || LATIN_1_ENCODING.equals(fmt)) {
|
||||
return Iso88591.encode((char[])data, offset, length);
|
||||
} else {
|
||||
throw new java.io.UnsupportedEncodingException(
|
||||
"Encoding " + format + " not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public void getChars(int srcOffset, int srcEnd,
|
||||
|
@ -139,9 +139,17 @@ public class Thread implements Runnable {
|
||||
|
||||
public static native Thread currentThread();
|
||||
|
||||
public native void interrupt();
|
||||
public void interrupt() {
|
||||
interrupt(peer);
|
||||
}
|
||||
|
||||
public native boolean interrupted();
|
||||
private static native boolean interrupt(long peer);
|
||||
|
||||
public boolean interrupted() {
|
||||
return interrupted(peer);
|
||||
}
|
||||
|
||||
private static native boolean interrupted(long peer);
|
||||
|
||||
public static boolean isInterrupted() {
|
||||
return currentThread().interrupted;
|
||||
|
@ -205,7 +205,7 @@ public class Field<T> extends AccessibleObject {
|
||||
} else {
|
||||
throw new IllegalArgumentException
|
||||
("needed " + getType() + ", got "
|
||||
+ Class.getName(Classes.vmClass(target)) +
|
||||
+ value.getClass().getName() +
|
||||
" when setting " + Class.getName(vmField.class_) + "." + getName());
|
||||
}
|
||||
break;
|
||||
|
@ -11,5 +11,5 @@
|
||||
package java.lang.reflect;
|
||||
|
||||
public interface InvocationHandler {
|
||||
public Object invoke(Object proxy, Method method, Object[] arguments);
|
||||
public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable;
|
||||
}
|
||||
|
@ -20,4 +20,8 @@ public class ProtectionDomain {
|
||||
this.codeSource = codeSource;
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public CodeSource getCodeSource() {
|
||||
return codeSource;
|
||||
}
|
||||
}
|
||||
|
@ -12,4 +12,14 @@ package java.util;
|
||||
|
||||
public abstract class AbstractList<T> extends AbstractCollection<T>
|
||||
implements List<T>
|
||||
{ }
|
||||
{
|
||||
protected int modCount;
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return listIterator();
|
||||
}
|
||||
|
||||
public ListIterator<T> listIterator() {
|
||||
return new Collections.ArrayListIterator(this);
|
||||
}
|
||||
}
|
||||
|
13
classpath/java/util/AbstractMap.java
Normal file
13
classpath/java/util/AbstractMap.java
Normal file
@ -0,0 +1,13 @@
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.util;
|
||||
|
||||
public abstract class AbstractMap<K,V> extends Object implements Map<K,V> { }
|
@ -10,7 +10,7 @@
|
||||
|
||||
package java.util;
|
||||
|
||||
public class ArrayList<T> extends AbstractList<T> {
|
||||
public class ArrayList<T> extends AbstractList<T> implements java.io.Serializable {
|
||||
private static final int MinimumCapacity = 16;
|
||||
|
||||
private Object[] array;
|
||||
|
@ -52,6 +52,23 @@ public class Collections {
|
||||
return array;
|
||||
}
|
||||
|
||||
public static final List EMPTY_LIST
|
||||
= new UnmodifiableList<Object>(new ArrayList<Object>(0));
|
||||
|
||||
public static final <E> List<E> emptyList() {
|
||||
return EMPTY_LIST;
|
||||
}
|
||||
|
||||
public static final <K,V> Map<K,V> emptyMap() {
|
||||
return (Map<K, V>) new UnmodifiableMap<Object, Object>(
|
||||
new HashMap<Object, Object>(0));
|
||||
}
|
||||
|
||||
public static final <T> Set<T> emptySet() {
|
||||
return (Set<T>) new UnmodifiableSet<Object>(
|
||||
new HashSet<Object>(0));
|
||||
}
|
||||
|
||||
static String toString(Collection c) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[");
|
||||
@ -293,8 +310,153 @@ public class Collections {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> unmodifiableList(List<T> list) {
|
||||
return new UnmodifiableList<T>(list);
|
||||
}
|
||||
|
||||
static class UnmodifiableList<T> implements List<T> {
|
||||
|
||||
private List<T> inner;
|
||||
|
||||
UnmodifiableList(List<T> l) {
|
||||
this.inner = l;
|
||||
}
|
||||
|
||||
public T get(int index) {
|
||||
return inner.get(index);
|
||||
}
|
||||
|
||||
public T set(int index, T value) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public T remove(int index) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public boolean remove(Object o) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public boolean add(T element) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public void add(int index, T element) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return inner.iterator();
|
||||
}
|
||||
|
||||
public int indexOf(Object value) {
|
||||
return inner.indexOf(value);
|
||||
}
|
||||
|
||||
public int lastIndexOf(Object value) {
|
||||
return inner.lastIndexOf(value);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return inner.isEmpty();
|
||||
}
|
||||
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
return inner.listIterator(index);
|
||||
}
|
||||
|
||||
public ListIterator<T> listIterator() {
|
||||
return inner.listIterator();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return inner.size();
|
||||
}
|
||||
|
||||
public boolean contains(Object element) {
|
||||
return inner.contains(element);
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends T> collection) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
return inner.toArray();
|
||||
}
|
||||
|
||||
public <S> S[] toArray(S[] array) {
|
||||
return inner.toArray(array);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static <K,V> Map<K,V> unmodifiableMap(Map<K,V> m) {
|
||||
return new UnmodifiableMap<K, V>(m);
|
||||
}
|
||||
|
||||
static class UnmodifiableMap<K, V> implements Map<K, V> {
|
||||
private Map<K, V> inner;
|
||||
|
||||
UnmodifiableMap(Map<K, V> m) {
|
||||
this.inner = m;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return inner.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return inner.containsValue(value);
|
||||
}
|
||||
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
return unmodifiableSet(inner.entrySet());
|
||||
}
|
||||
|
||||
public V get(Object key) {
|
||||
return inner.get(key);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return inner.isEmpty();
|
||||
}
|
||||
|
||||
public Set<K> keySet() {
|
||||
return unmodifiableSet(inner.keySet());
|
||||
}
|
||||
|
||||
public V put(K key, V value) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public void putAll(Map<? extends K, ? extends V> t) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return inner.size();
|
||||
}
|
||||
|
||||
public Collection<V> values() {
|
||||
return unmodifiableSet((Set<V>)inner.values());
|
||||
}
|
||||
}
|
||||
|
||||
static class UnmodifiableSet<T> implements Set<T> {
|
||||
Set<T> inner;
|
||||
private Set<T> inner;
|
||||
|
||||
UnmodifiableSet(Set<T> inner) {
|
||||
this.inner = inner;
|
||||
@ -396,7 +558,5 @@ public class Collections {
|
||||
public int compare(T o1, T o2) {
|
||||
return - cmp.compare(o1, o2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
14
classpath/java/util/RandomAccess.java
Normal file
14
classpath/java/util/RandomAccess.java
Normal file
@ -0,0 +1,14 @@
|
||||
/* Copyright (c) 2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.util;
|
||||
|
||||
public interface RandomAccess {
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
|
||||
package java.util;
|
||||
|
||||
public class Vector<T> extends AbstractList<T> {
|
||||
public class Vector<T> extends AbstractList<T> implements java.io.Serializable {
|
||||
private final ArrayList<T> list;
|
||||
|
||||
public Vector(int capacity) {
|
||||
@ -81,6 +81,10 @@ public class Vector<T> extends AbstractList<T> {
|
||||
remove(index);
|
||||
}
|
||||
|
||||
public synchronized void removeAllElements() {
|
||||
list.clear();
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Object element) {
|
||||
return list.remove(element);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class CRC32 {
|
||||
private static final int Width = 32;
|
||||
private static final int Top = 1 << (Width - 1);
|
||||
private static final int InitialRemainder = 0xFFFFFFFF;
|
||||
private static final int ResultXor = 0xFFFFFFFF;
|
||||
private static final long ResultXor = 0xFFFFFFFFL;
|
||||
|
||||
private static final int[] table = new int[256];
|
||||
|
||||
@ -53,7 +53,7 @@ public class CRC32 {
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return reflect(remainder, Width) ^ ResultXor;
|
||||
return (reflect(remainder, Width) ^ ResultXor) & 0xFFFFFFFFL;
|
||||
}
|
||||
|
||||
private static int reflect(int x, int n) {
|
||||
|
@ -147,6 +147,10 @@ public class Deflater {
|
||||
boolean finish,
|
||||
int[] results);
|
||||
|
||||
public void end() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (peer != 0) {
|
||||
dispose(peer);
|
||||
|
@ -127,6 +127,10 @@ public class Inflater {
|
||||
byte[] output, int outputOffset, int outputLength,
|
||||
int[] results);
|
||||
|
||||
public void end() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (peer != 0) {
|
||||
dispose(peer);
|
||||
|
@ -74,6 +74,9 @@ public class ZipFile {
|
||||
}
|
||||
|
||||
protected ZipEntry getEntry(EntryFactory factory, String name) {
|
||||
while (name.startsWith("/")) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
Integer pointer = index.get(name);
|
||||
return (pointer == null ? null : factory.makeEntry(window, pointer));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2008-2010, Avian Contributors
|
||||
Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
63
makefile
Normal file → Executable file
63
makefile
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
MAKEFLAGS = -s
|
||||
|
||||
name = avian
|
||||
version = 0.4
|
||||
version = 0.5
|
||||
|
||||
build-arch := $(shell uname -m \
|
||||
| sed 's/^i.86$$/i386/' \
|
||||
@ -94,12 +94,12 @@ ifneq ($(openjdk),)
|
||||
lib/security/java.policy lib/security/cacerts
|
||||
|
||||
local-policy = lib/security/local_policy.jar
|
||||
ifeq ($(shell test -e $(openjdk)/$(local-policy) && echo found),found)
|
||||
ifeq ($(shell test -e "$(openjdk)/$(local-policy)" && echo found),found)
|
||||
javahome-files += $(local-policy)
|
||||
endif
|
||||
|
||||
export-policy = lib/security/US_export_policy.jar
|
||||
ifeq ($(shell test -e $(openjdk)/$(export-policy) && echo found),found)
|
||||
ifeq ($(shell test -e "$(openjdk)/$(export-policy)" && echo found),found)
|
||||
javahome-files += $(export-policy)
|
||||
endif
|
||||
|
||||
@ -181,7 +181,8 @@ endif
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
||||
"-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
|
||||
|
||||
converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject
|
||||
converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject \
|
||||
-fno-rtti -fno-exceptions
|
||||
|
||||
cflags = $(build-cflags)
|
||||
|
||||
@ -240,17 +241,24 @@ ifeq ($(arch),arm)
|
||||
endif
|
||||
|
||||
ifeq ($(platform),darwin)
|
||||
ifeq (${OSX_SDK_SYSROOT},)
|
||||
OSX_SDK_SYSROOT = 10.4u
|
||||
endif
|
||||
ifeq (${OSX_SDK_VERSION},)
|
||||
OSX_SDK_VERSION = 10.4
|
||||
endif
|
||||
ifneq ($(build-platform),darwin)
|
||||
cxx = i686-apple-darwin8-g++ $(mflag)
|
||||
cc = i686-apple-darwin8-gcc $(mflag)
|
||||
ar = i686-apple-darwin8-ar
|
||||
ranlib = i686-apple-darwin8-ranlib
|
||||
strip = i686-apple-darwin8-strip
|
||||
sysroot = /opt/mac/SDKs/MacOSX10.4u.sdk
|
||||
sysroot = /opt/mac/SDKs/MacOSX${OSX_SDK_SYSROOT}.sdk
|
||||
cflags = -I$(sysroot)/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/ \
|
||||
$(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
||||
else
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
||||
cflags += -I/System/Library/Frameworks/JavaVM.framework/Headers/
|
||||
build-lflags += -framework CoreFoundation
|
||||
endif
|
||||
|
||||
@ -269,20 +277,20 @@ ifeq ($(platform),darwin)
|
||||
ifneq (,$(filter i386 x86_64 arm,$(build-arch)))
|
||||
converter-cflags += -DOPPOSITE_ENDIAN
|
||||
endif
|
||||
openjdk-extra-cflags += -arch ppc -mmacosx-version-min=10.4
|
||||
cflags += -arch ppc -mmacosx-version-min=10.4
|
||||
asmflags += -arch ppc -mmacosx-version-min=10.4
|
||||
lflags += -arch ppc -mmacosx-version-min=10.4
|
||||
openjdk-extra-cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
asmflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
lflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
endif
|
||||
|
||||
ifeq ($(arch),i386)
|
||||
ifeq ($(build-arch),powerpc)
|
||||
converter-cflags += -DOPPOSITE_ENDIAN
|
||||
endif
|
||||
openjdk-extra-cflags += -arch i386 -mmacosx-version-min=10.4
|
||||
cflags += -arch i386 -mmacosx-version-min=10.4
|
||||
asmflags += -arch i386 -mmacosx-version-min=10.4
|
||||
lflags += -arch i386 -mmacosx-version-min=10.4
|
||||
openjdk-extra-cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
|
||||
endif
|
||||
|
||||
ifeq ($(arch),x86_64)
|
||||
@ -326,15 +334,20 @@ ifeq ($(platform),windows)
|
||||
openjdk-extra-cflags =
|
||||
build-lflags = -L$(lib) $(common-lflags)
|
||||
ifeq ($(build-platform),cygwin)
|
||||
build-lflags += -mno-cygwin
|
||||
build-cflags += -mno-cygwin
|
||||
openjdk-extra-cflags += -mno-cygwin
|
||||
lflags += -mno-cygwin
|
||||
cflags += -mno-cygwin
|
||||
build-cxx = i686-w64-mingw32-g++
|
||||
build-cc = i686-w64-mingw32-gcc
|
||||
dlltool = i686-w64-mingw32-dlltool
|
||||
ar = i686-w64-mingw32-ar
|
||||
ranlib = i686-w64-mingw32-ranlib
|
||||
strip = i686-w64-mingw32-strip
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(arch),x86_64)
|
||||
ifeq ($(build-platform),cygwin)
|
||||
build-cxx = x86_64-w64-mingw32-g++
|
||||
build-cc = x86_64-w64-mingw32-gcc
|
||||
endif
|
||||
cxx = x86_64-w64-mingw32-g++ $(mflag)
|
||||
cc = x86_64-w64-mingw32-gcc $(mflag)
|
||||
dlltool = x86_64-w64-mingw32-dlltool
|
||||
@ -751,7 +764,7 @@ $(boot-javahome-object): $(src)/boot-javahome.cpp
|
||||
$(compile-object)
|
||||
|
||||
$(build)/binaryToObject-main.o: $(src)/binaryToObject/main.cpp
|
||||
$(build-cxx) -c $(^) -o $(@)
|
||||
$(build-cxx) $(converter-cflags) -c $(^) -o $(@)
|
||||
|
||||
$(build)/binaryToObject-elf64.o: $(src)/binaryToObject/elf.cpp
|
||||
$(build-cxx) $(converter-cflags) -DBITS_PER_WORD=64 -c $(^) -o $(@)
|
||||
@ -769,7 +782,7 @@ $(build)/binaryToObject-pe.o: $(src)/binaryToObject/pe.cpp
|
||||
$(build-cxx) $(converter-cflags) -c $(^) -o $(@)
|
||||
|
||||
$(converter): $(converter-objects)
|
||||
$(build-cxx) $(^) -o $(@)
|
||||
$(build-cc) $(^) -o $(@)
|
||||
|
||||
$(build)/classpath.jar: $(classpath-dep) $(classpath-jar-dep)
|
||||
@echo "creating $(@)"
|
||||
@ -923,8 +936,14 @@ ifeq ($(platform),windows)
|
||||
sed 's/^#ifdef _WIN64/#if 1/' \
|
||||
< "$(openjdk-src)/windows/native/java/net/net_util_md.h" \
|
||||
> $(build)/openjdk/net_util_md.h
|
||||
cp "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \
|
||||
$(build)/openjdk/NetworkInterface.h
|
||||
sed \
|
||||
-e 's/IpPrefix/hide_IpPrefix/' \
|
||||
-e 's/IpSuffix/hide_IpSuffix/' \
|
||||
-e 's/IpDad/hide_IpDad/' \
|
||||
-e 's/ScopeLevel/hide_ScopeLevel/' \
|
||||
-e 's/SCOPE_LEVEL/hide_SCOPE_LEVEL/' \
|
||||
< "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \
|
||||
> $(build)/openjdk/NetworkInterface.h
|
||||
echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h
|
||||
endif
|
||||
@touch $(@)
|
||||
|
@ -48,6 +48,7 @@ openjdk-sources = \
|
||||
$(openjdk-src)/share/native/java/util/zip/ZipEntry.c \
|
||||
$(openjdk-src)/share/native/java/util/zip/ZipFile.c \
|
||||
$(openjdk-src)/share/native/java/util/zip/zip_util.c \
|
||||
$(openjdk-src)/share/native/sun/management/VMManagementImpl.c \
|
||||
$(openjdk-src)/share/native/sun/misc/GC.c \
|
||||
$(openjdk-src)/share/native/sun/misc/MessageUtils.c \
|
||||
$(openjdk-src)/share/native/sun/misc/NativeSignalHandler.c \
|
||||
@ -112,6 +113,7 @@ openjdk-headers-classes = \
|
||||
java.util.zip.Inflater \
|
||||
java.util.zip.ZipEntry \
|
||||
java.util.zip.ZipFile \
|
||||
sun.management.VMManagementImpl \
|
||||
sun.misc.GC \
|
||||
sun.misc.MessageUtils \
|
||||
sun.misc.NativeSignalHandler \
|
||||
@ -151,6 +153,7 @@ openjdk-cflags = \
|
||||
"-I$(openjdk-src)/share/native/java/lang/fdlibm/include" \
|
||||
"-I$(openjdk-src)/share/native/java/net" \
|
||||
"-I$(openjdk-src)/share/native/java/util/zip" \
|
||||
"-I$(openjdk-src)/share/native/sun/management" \
|
||||
"-I$(openjdk-src)/share/native/sun/nio/ch" \
|
||||
"-I$(openjdk-src)/share/javavm/include" \
|
||||
-D_LITTLE_ENDIAN \
|
||||
@ -184,6 +187,7 @@ ifeq ($(platform),windows)
|
||||
$(openjdk-src)/windows/native/java/lang/ProcessEnvironment_md.c \
|
||||
$(openjdk-src)/windows/native/java/lang/ProcessImpl_md.c \
|
||||
$(openjdk-src)/windows/native/java/net/net_util_md.c \
|
||||
$(openjdk-src)/windows/native/java/net/DualStackPlainSocketImpl.c \
|
||||
$(openjdk-src)/windows/native/java/net/InetAddressImplFactory.c \
|
||||
$(openjdk-src)/windows/native/java/net/Inet4AddressImpl.c \
|
||||
$(openjdk-src)/windows/native/java/net/Inet6AddressImpl.c \
|
||||
@ -210,6 +214,7 @@ ifeq ($(platform),windows)
|
||||
$(openjdk-src)/windows/native/sun/security/provider/WinCAPISeedGenerator.c
|
||||
|
||||
openjdk-headers-classes += \
|
||||
java.net.DualStackPlainSocketImpl \
|
||||
java.lang.ProcessImpl \
|
||||
sun.io.Win32ErrorMode \
|
||||
sun.nio.ch.WindowsSelectorImpl \
|
||||
@ -225,7 +230,6 @@ ifeq ($(platform),windows)
|
||||
"-I$(root)/win32/include" \
|
||||
-D_JNI_IMPLEMENTATION_ \
|
||||
-D_JAVASOFT_WIN32_TYPEDEF_MD_H_ \
|
||||
-D_WINSOCK2API_ \
|
||||
-Ds6_words=_s6_words \
|
||||
-Ds6_bytes=_s6_bytes
|
||||
else
|
||||
@ -290,13 +294,15 @@ else
|
||||
"-I$(openjdk-src)/solaris/native/java/lang" \
|
||||
"-I$(openjdk-src)/solaris/native/java/net" \
|
||||
"-I$(openjdk-src)/solaris/native/java/util" \
|
||||
"-I$(openjdk-src)/solaris/native/sun/management" \
|
||||
"-I$(openjdk-src)/solaris/native/sun/nio/ch" \
|
||||
"-I$(openjdk-src)/solaris/javavm/include" \
|
||||
"-I$(openjdk-src)/solaris/hpi/include"
|
||||
endif
|
||||
|
||||
openjdk-local-sources = \
|
||||
$(src)/openjdk/my_net_util.c
|
||||
$(src)/openjdk/my_net_util.c \
|
||||
$(src)/openjdk/my_management.c
|
||||
|
||||
c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-openjdk.o,$(x)))
|
||||
|
||||
|
@ -162,8 +162,8 @@ Installing MSYS:
|
||||
Installing Cygwin:
|
||||
|
||||
1. Download and run setup.exe from cygwin.com, installing the base
|
||||
system and these packages: make, gcc-mingw-g++, and (optionally)
|
||||
git.
|
||||
system and these packages: make, gcc-mingw-g++,
|
||||
mingw64-i686-gcc-g++, mingw64-x86_64-gcc-g++, and (optionally) git.
|
||||
|
||||
You may also find our win32 repository useful: (run this from the
|
||||
directory containing the avian directory)
|
||||
@ -308,7 +308,7 @@ it on various OSes:
|
||||
# http://download.java.net/openjdk/jdk6/promoted/, e.g.:
|
||||
wget http://download.java.net/openjdk/jdk6/promoted/b21/openjdk-6-src-b21-20_jan_2011.tar.gz
|
||||
mkdir openjdk
|
||||
(cd openjdk && tar xzf openjdk-6-src-b21-20_jan_2011.tar.gz)
|
||||
(cd openjdk && tar xzf ../openjdk-6-src-b21-20_jan_2011.tar.gz)
|
||||
make openjdk=/cygdrive/c/OpenSCG/openjdk-6.21 \
|
||||
openjdk-src=$(pwd)/openjdk/jdk/src \
|
||||
test
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -22,6 +22,39 @@ class Allocator {
|
||||
virtual void free(const void* p, unsigned size) = 0;
|
||||
};
|
||||
|
||||
inline const char*
|
||||
append(Allocator* allocator, const char* a, const char* b, const char* c)
|
||||
{
|
||||
unsigned al = strlen(a);
|
||||
unsigned bl = strlen(b);
|
||||
unsigned cl = strlen(c);
|
||||
char* p = static_cast<char*>(allocator->allocate((al + bl + cl) + 1));
|
||||
memcpy(p, a, al);
|
||||
memcpy(p + al, b, bl);
|
||||
memcpy(p + al + bl, c, cl + 1);
|
||||
return p;
|
||||
}
|
||||
|
||||
inline const char*
|
||||
append(Allocator* allocator, const char* a, const char* b)
|
||||
{
|
||||
unsigned al = strlen(a);
|
||||
unsigned bl = strlen(b);
|
||||
char* p = static_cast<char*>(allocator->allocate((al + bl) + 1));
|
||||
memcpy(p, a, al);
|
||||
memcpy(p + al, b, bl + 1);
|
||||
return p;
|
||||
}
|
||||
|
||||
inline const char*
|
||||
copy(Allocator* allocator, const char* a)
|
||||
{
|
||||
unsigned al = strlen(a);
|
||||
char* p = static_cast<char*>(allocator->allocate(al + 1));
|
||||
memcpy(p, a, al + 1);
|
||||
return p;
|
||||
}
|
||||
|
||||
} // namespace vm
|
||||
|
||||
#endif//ALLOCATOR_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* arm.S: JNI gluecode for ARM/Linux
|
||||
Copyright (c) 2008-2010, Avian Contributors
|
||||
Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, Avian Contributors
|
||||
/* Copyright (c) 2010-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2010, Avian Contributors
|
||||
/* Copyright (c) 2009-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -23,7 +23,7 @@ using namespace vm;
|
||||
|
||||
namespace {
|
||||
|
||||
const unsigned HeapCapacity = 128 * 1024 * 1024;
|
||||
const unsigned HeapCapacity = 256 * 1024 * 1024;
|
||||
|
||||
// Notes on immutable references in the heap image:
|
||||
//
|
||||
@ -572,7 +572,7 @@ main(int ac, const char** av)
|
||||
p->initialize(&image, code, CodeCapacity);
|
||||
|
||||
Machine* m = new (h->allocate(sizeof(Machine))) Machine
|
||||
(s, h, f, 0, p, c, 0, 0);
|
||||
(s, h, f, 0, p, c, 0, 0, 0, 0);
|
||||
Thread* t = p->makeThread(m, 0, 0);
|
||||
|
||||
enter(t, Thread::ActiveState);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, Avian Contributors
|
||||
/* Copyright (c) 2010-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -554,6 +554,15 @@ Avian_java_lang_Thread_interrupt
|
||||
interrupt(t, reinterpret_cast<Thread*>(peer));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_java_lang_Thread_interrupted
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
int64_t peer; memcpy(&peer, arguments, 8);
|
||||
|
||||
return getAndClearInterrupted(t, reinterpret_cast<Thread*>(peer));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_java_lang_Thread_getStackTrace
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, Avian Contributors
|
||||
/* Copyright (c) 2010-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, Avian Contributors
|
||||
/* Copyright (c) 2010-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -355,7 +355,7 @@ class MyClasspath : public Classpath {
|
||||
|
||||
MyClasspath(System* s, Allocator* allocator, const char* javaHome,
|
||||
const char* embedPrefix):
|
||||
allocator(allocator), ranNetOnLoad(0)
|
||||
allocator(allocator), ranNetOnLoad(0), ranManagementOnLoad(0)
|
||||
{
|
||||
class StringBuilder {
|
||||
public:
|
||||
@ -613,6 +613,7 @@ class MyClasspath : public Classpath {
|
||||
unsigned zipEntryCsizeField;
|
||||
unsigned zipEntryMethodField;
|
||||
bool ranNetOnLoad;
|
||||
bool ranManagementOnLoad;
|
||||
char buffer[BufferSize];
|
||||
JmmInterface jmmInterface;
|
||||
};
|
||||
@ -1615,6 +1616,9 @@ getBootstrapResources(Thread* t, object, uintptr_t* arguments)
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
net_JNI_OnLoad(JavaVM*, void*);
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
management_JNI_OnLoad(JavaVM*, void*);
|
||||
|
||||
void JNICALL
|
||||
loadLibrary(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
@ -1643,6 +1647,23 @@ loadLibrary(Thread* t, object, uintptr_t* arguments)
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (strcmp(n, "management") == 0) {
|
||||
bool ran;
|
||||
|
||||
{ ACQUIRE(t, t->m->classLock);
|
||||
|
||||
local::MyClasspath* c = static_cast<local::MyClasspath*>
|
||||
(t->m->classpath);
|
||||
|
||||
ran = c->ranManagementOnLoad;
|
||||
c->ranManagementOnLoad = true;
|
||||
}
|
||||
|
||||
if (not ran) {
|
||||
management_JNI_OnLoad(t->m, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (strcmp(n, "zip") == 0
|
||||
or strcmp(n, "nio") == 0)
|
||||
{
|
||||
@ -2627,6 +2648,16 @@ Avian_sun_misc_Unsafe_putByte__JB
|
||||
*reinterpret_cast<int8_t*>(p) = v;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_putShort__JS
|
||||
(Thread*, object, uintptr_t* arguments)
|
||||
{
|
||||
int64_t p; memcpy(&p, arguments + 1, 8);
|
||||
int16_t v = arguments[3];
|
||||
|
||||
*reinterpret_cast<int16_t*>(p) = v;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_putLong__JJ
|
||||
(Thread*, object, uintptr_t* arguments)
|
||||
@ -2665,6 +2696,15 @@ Avian_sun_misc_Unsafe_getInt__J
|
||||
return *reinterpret_cast<int32_t*>(p);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_getLong__J
|
||||
(Thread*, object, uintptr_t* arguments)
|
||||
{
|
||||
int64_t p; memcpy(&p, arguments + 1, 8);
|
||||
|
||||
return *reinterpret_cast<int64_t*>(p);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_getFloat__J
|
||||
(Thread*, object, uintptr_t* arguments)
|
||||
@ -5099,6 +5139,27 @@ GetVersion(Thread*)
|
||||
return JMM_VERSION_1_0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getInputArgumentArray(Thread* t, uintptr_t*)
|
||||
{
|
||||
object array = makeObjectArray
|
||||
(t, type(t, Machine::StringType), t->m->argumentCount);
|
||||
PROTECT(t, array);
|
||||
|
||||
for (unsigned i = 0; i < t->m->argumentCount; ++i) {
|
||||
object argument = makeString(t, t->m->arguments[i]);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), argument);
|
||||
}
|
||||
|
||||
return reinterpret_cast<uintptr_t>(makeLocalReference(t, array));
|
||||
}
|
||||
|
||||
jobjectArray JNICALL
|
||||
GetInputArgumentArray(Thread* t)
|
||||
{
|
||||
return reinterpret_cast<jobjectArray>(run(t, getInputArgumentArray, 0));
|
||||
}
|
||||
|
||||
jint JNICALL
|
||||
GetOptionalSupport(Thread*, jmmOptionalSupport* support)
|
||||
{
|
||||
@ -5184,6 +5245,7 @@ EXPORT(JVM_GetManagement)(jint version)
|
||||
interface->GetBoolAttribute = GetBoolAttribute;
|
||||
interface->GetMemoryManagers = GetMemoryManagers;
|
||||
interface->GetMemoryPools = GetMemoryPools;
|
||||
interface->GetInputArgumentArray = GetInputArgumentArray;
|
||||
|
||||
return interface;
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, Avian Contributors
|
||||
/* Copyright (c) 2010-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2010, Avian Contributors
|
||||
/* Copyright (c) 2009-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
123
src/compile.cpp
123
src/compile.cpp
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -2190,6 +2190,9 @@ unwind(MyThread* t)
|
||||
object continuation;
|
||||
findUnwindTarget(t, &ip, &frame, &stack, &continuation);
|
||||
|
||||
t->trace->targetMethod = 0;
|
||||
t->trace->nativeMethod = 0;
|
||||
|
||||
transition(t, ip, stack, continuation, t->trace);
|
||||
|
||||
vmJump(ip, frame, stack, t, 0, 0);
|
||||
@ -2263,19 +2266,34 @@ resolveMethod(Thread* t, object pair)
|
||||
findMethodInClass, Machine::NoSuchMethodErrorType);
|
||||
}
|
||||
|
||||
bool
|
||||
methodAbstract(Thread* t, object method)
|
||||
{
|
||||
return methodCode(t, method) == 0
|
||||
and (methodFlags(t, method) & ACC_NATIVE) == 0;
|
||||
}
|
||||
|
||||
int64_t
|
||||
prepareMethodForCall(MyThread* t, object target)
|
||||
{
|
||||
if (unresolved(t, methodAddress(t, target))) {
|
||||
PROTECT(t, target);
|
||||
if (methodAbstract(t, target)) {
|
||||
throwNew(t, Machine::AbstractMethodErrorType, "%s.%s%s",
|
||||
&byteArrayBody(t, className(t, methodClass(t, target)), 0),
|
||||
&byteArrayBody(t, methodName(t, target), 0),
|
||||
&byteArrayBody(t, methodSpec(t, target), 0));
|
||||
} else {
|
||||
if (unresolved(t, methodAddress(t, target))) {
|
||||
PROTECT(t, target);
|
||||
|
||||
compile(t, codeAllocator(t), 0, target);
|
||||
}
|
||||
|
||||
compile(t, codeAllocator(t), 0, target);
|
||||
}
|
||||
if (methodFlags(t, target) & ACC_NATIVE) {
|
||||
t->trace->nativeMethod = target;
|
||||
}
|
||||
|
||||
if (methodFlags(t, target) & ACC_NATIVE) {
|
||||
t->trace->nativeMethod = target;
|
||||
return methodAddress(t, target);
|
||||
}
|
||||
return methodAddress(t, target);
|
||||
}
|
||||
|
||||
int64_t
|
||||
@ -2341,6 +2359,12 @@ findVirtualMethodFromReference(MyThread* t, object pair, object instance)
|
||||
return prepareMethodForCall(t, target);
|
||||
}
|
||||
|
||||
int64_t
|
||||
getMethodAddress(MyThread* t, object target)
|
||||
{
|
||||
return prepareMethodForCall(t, target);
|
||||
}
|
||||
|
||||
int64_t
|
||||
getJClassFromReference(MyThread* t, object pair)
|
||||
{
|
||||
@ -3437,6 +3461,48 @@ compileDirectReferenceInvoke(MyThread* t, Frame* frame, Thunk thunk,
|
||||
reference, isStatic, tailCall);
|
||||
}
|
||||
|
||||
void
|
||||
compileAbstractInvoke(MyThread* t, Frame* frame, Compiler::Operand* method,
|
||||
object target, bool tailCall)
|
||||
{
|
||||
unsigned parameterFootprint = methodParameterFootprint(t, target);
|
||||
|
||||
int returnCode = methodReturnCode(t, target);
|
||||
|
||||
unsigned rSize = resultSize(t, returnCode);
|
||||
|
||||
Compiler::Operand* result = frame->c->stackCall
|
||||
(method,
|
||||
tailCall ? Compiler::TailJump : 0,
|
||||
frame->trace(0, 0),
|
||||
rSize,
|
||||
operandTypeForFieldCode(t, returnCode),
|
||||
parameterFootprint);
|
||||
|
||||
frame->pop(parameterFootprint);
|
||||
|
||||
if (rSize) {
|
||||
pushReturnValue(t, frame, returnCode, result);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
compileDirectAbstractInvoke(MyThread* t, Frame* frame, Thunk thunk,
|
||||
object target, bool tailCall)
|
||||
{
|
||||
Compiler* c = frame->c;
|
||||
|
||||
compileAbstractInvoke
|
||||
(t, frame, c->call
|
||||
(c->constant(getThunk(t, thunk), Compiler::AddressType),
|
||||
0,
|
||||
frame->trace(0, 0),
|
||||
BytesPerWord,
|
||||
Compiler::AddressType,
|
||||
2, c->register_(t->arch->thread()), frame->append(target)),
|
||||
target, tailCall);
|
||||
}
|
||||
|
||||
void
|
||||
handleMonitorEvent(MyThread* t, Frame* frame, intptr_t function)
|
||||
{
|
||||
@ -4841,7 +4907,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
||||
|
||||
bool tailCall = isTailCall(t, code, ip, context->method, target);
|
||||
|
||||
compileDirectInvoke(t, frame, target, tailCall);
|
||||
if (UNLIKELY(methodAbstract(t, target))) {
|
||||
compileDirectAbstractInvoke
|
||||
(t, frame, getMethodAddressThunk, target, tailCall);
|
||||
} else {
|
||||
compileDirectInvoke(t, frame, target, tailCall);
|
||||
}
|
||||
} else {
|
||||
compileDirectReferenceInvoke
|
||||
(t, frame, findSpecialMethodFromReferenceThunk, reference, false,
|
||||
@ -5521,18 +5592,6 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
||||
}
|
||||
}
|
||||
|
||||
Compiler::Operand* value = popField(t, frame, fieldCode);
|
||||
|
||||
Compiler::Operand* table;
|
||||
|
||||
if (instruction == putstatic) {
|
||||
PROTECT(t, field);
|
||||
|
||||
table = frame->append(staticTable);
|
||||
} else {
|
||||
table = frame->popObject();
|
||||
}
|
||||
|
||||
if (fieldFlags(t, field) & ACC_VOLATILE) {
|
||||
if (BytesPerWord == 4
|
||||
and (fieldCode == DoubleField or fieldCode == LongField))
|
||||
@ -5550,6 +5609,18 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
||||
}
|
||||
}
|
||||
|
||||
Compiler::Operand* value = popField(t, frame, fieldCode);
|
||||
|
||||
Compiler::Operand* table;
|
||||
|
||||
if (instruction == putstatic) {
|
||||
PROTECT(t, field);
|
||||
|
||||
table = frame->append(staticTable);
|
||||
} else {
|
||||
table = frame->popObject();
|
||||
}
|
||||
|
||||
switch (fieldCode) {
|
||||
case ByteField:
|
||||
case BooleanField:
|
||||
@ -7328,11 +7399,6 @@ invokeNative(MyThread* t)
|
||||
uint64_t result = 0;
|
||||
|
||||
t->trace->targetMethod = t->trace->nativeMethod;
|
||||
|
||||
THREAD_RESOURCE0(t, {
|
||||
static_cast<MyThread*>(t)->trace->targetMethod = 0;
|
||||
static_cast<MyThread*>(t)->trace->nativeMethod = 0;
|
||||
});
|
||||
|
||||
t->m->classpath->resolveNative(t, t->trace->nativeMethod);
|
||||
|
||||
@ -7355,6 +7421,9 @@ invokeNative(MyThread* t)
|
||||
|
||||
transition(t, getIp(t), stack, t->continuation, t->trace);
|
||||
|
||||
t->trace->targetMethod = 0;
|
||||
t->trace->nativeMethod = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -8143,7 +8212,7 @@ class SignalHandler: public System::SignalHandler {
|
||||
t->exception = vm::root(t, root);
|
||||
}
|
||||
|
||||
printTrace(t, t->exception);
|
||||
//printTrace(t, t->exception);
|
||||
|
||||
object continuation;
|
||||
findUnwindTarget(t, ip, frame, stack, &continuation);
|
||||
|
@ -4815,7 +4815,11 @@ class BranchEvent: public Event {
|
||||
ConstantSite* secondConstant = findConstantSite(c, second);
|
||||
|
||||
if (not unreachable(this)) {
|
||||
if (firstConstant and secondConstant) {
|
||||
if (firstConstant
|
||||
and secondConstant
|
||||
and firstConstant->value->resolved()
|
||||
and secondConstant->value->resolved())
|
||||
{
|
||||
int64_t firstValue = firstConstant->value->value();
|
||||
int64_t secondValue = secondConstant->value->value();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2010, Avian Contributors
|
||||
/* Copyright (c) 2009-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -18,39 +18,7 @@ using namespace vm;
|
||||
namespace {
|
||||
|
||||
const bool DebugFind = false;
|
||||
|
||||
const char*
|
||||
append(Allocator* allocator, const char* a, const char* b, const char* c)
|
||||
{
|
||||
unsigned al = strlen(a);
|
||||
unsigned bl = strlen(b);
|
||||
unsigned cl = strlen(c);
|
||||
char* p = static_cast<char*>(allocator->allocate((al + bl + cl) + 1));
|
||||
memcpy(p, a, al);
|
||||
memcpy(p + al, b, bl);
|
||||
memcpy(p + al + bl, c, cl + 1);
|
||||
return p;
|
||||
}
|
||||
|
||||
const char*
|
||||
append(Allocator* allocator, const char* a, const char* b)
|
||||
{
|
||||
unsigned al = strlen(a);
|
||||
unsigned bl = strlen(b);
|
||||
char* p = static_cast<char*>(allocator->allocate((al + bl) + 1));
|
||||
memcpy(p, a, al);
|
||||
memcpy(p + al, b, bl + 1);
|
||||
return p;
|
||||
}
|
||||
|
||||
const char*
|
||||
copy(Allocator* allocator, const char* a)
|
||||
{
|
||||
unsigned al = strlen(a);
|
||||
char* p = static_cast<char*>(allocator->allocate(al + 1));
|
||||
memcpy(p, a, al + 1);
|
||||
return p;
|
||||
}
|
||||
const bool DebugStat = false;
|
||||
|
||||
class Element {
|
||||
public:
|
||||
@ -136,9 +104,12 @@ class DirectoryElement: public Element {
|
||||
};
|
||||
|
||||
DirectoryElement(System* s, Allocator* allocator, const char* name):
|
||||
s(s), allocator(allocator), name(name),
|
||||
urlPrefix_(append(allocator, "file:", name, "/")),
|
||||
sourceUrl_(append(allocator, "file:", name))
|
||||
s(s),
|
||||
allocator(allocator),
|
||||
originalName(name),
|
||||
name(s->toAbsolutePath(allocator, name)),
|
||||
urlPrefix_(append(allocator, "file:", this->name, "/")),
|
||||
sourceUrl_(append(allocator, "file:", this->name))
|
||||
{ }
|
||||
|
||||
virtual Element::Iterator* iterator() {
|
||||
@ -168,6 +139,9 @@ class DirectoryElement: public Element {
|
||||
virtual System::FileType stat(const char* name, unsigned* length, bool) {
|
||||
const char* file = append(allocator, this->name, "/", name);
|
||||
System::FileType type = s->stat(file, length);
|
||||
if (DebugStat) {
|
||||
fprintf(stderr, "stat %s in %s: %d\n", name, this->name, type);
|
||||
}
|
||||
allocator->free(file, strlen(file) + 1);
|
||||
return type;
|
||||
}
|
||||
@ -181,6 +155,7 @@ class DirectoryElement: public Element {
|
||||
}
|
||||
|
||||
virtual void dispose() {
|
||||
allocator->free(originalName, strlen(originalName) + 1);
|
||||
allocator->free(name, strlen(name) + 1);
|
||||
allocator->free(urlPrefix_, strlen(urlPrefix_) + 1);
|
||||
allocator->free(sourceUrl_, strlen(sourceUrl_) + 1);
|
||||
@ -189,6 +164,7 @@ class DirectoryElement: public Element {
|
||||
|
||||
System* s;
|
||||
Allocator* allocator;
|
||||
const char* originalName;
|
||||
const char* name;
|
||||
const char* urlPrefix_;
|
||||
const char* sourceUrl_;
|
||||
@ -454,10 +430,17 @@ class JarElement: public Element {
|
||||
unsigned position;
|
||||
};
|
||||
|
||||
JarElement(System* s, Allocator* allocator, const char* name):
|
||||
s(s), allocator(allocator), name(name),
|
||||
urlPrefix_(name ? append(allocator, "jar:file:", name, "!/") : 0),
|
||||
sourceUrl_(name ? append(allocator, "file:", name) : 0),
|
||||
JarElement(System* s, Allocator* allocator, const char* name,
|
||||
bool canonicalizePath = true):
|
||||
s(s),
|
||||
allocator(allocator),
|
||||
originalName(name),
|
||||
name(name and canonicalizePath
|
||||
? s->toAbsolutePath(allocator, name) : name),
|
||||
urlPrefix_(this->name
|
||||
? append(allocator, "jar:file:", this->name, "!/") : 0),
|
||||
sourceUrl_(this->name
|
||||
? append(allocator, "file:", this->name) : 0),
|
||||
region(0), index(0)
|
||||
{ }
|
||||
|
||||
@ -513,8 +496,12 @@ class JarElement: public Element {
|
||||
|
||||
while (*name == '/') name++;
|
||||
|
||||
return (index ? index->stat(name, length, tryDirectory)
|
||||
: System::TypeDoesNotExist);
|
||||
System::FileType type = (index ? index->stat(name, length, tryDirectory)
|
||||
: System::TypeDoesNotExist);
|
||||
if (DebugStat) {
|
||||
fprintf(stderr, "stat %s in %s: %d\n", name, this->name, type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
virtual const char* urlPrefix() {
|
||||
@ -530,6 +517,9 @@ class JarElement: public Element {
|
||||
}
|
||||
|
||||
virtual void dispose(unsigned size) {
|
||||
if (originalName != name) {
|
||||
allocator->free(originalName, strlen(originalName) + 1);
|
||||
}
|
||||
allocator->free(name, strlen(name) + 1);
|
||||
allocator->free(urlPrefix_, strlen(urlPrefix_) + 1);
|
||||
allocator->free(sourceUrl_, strlen(sourceUrl_) + 1);
|
||||
@ -544,6 +534,7 @@ class JarElement: public Element {
|
||||
|
||||
System* s;
|
||||
Allocator* allocator;
|
||||
const char* originalName;
|
||||
const char* name;
|
||||
const char* urlPrefix_;
|
||||
const char* sourceUrl_;
|
||||
@ -555,7 +546,7 @@ class BuiltinElement: public JarElement {
|
||||
public:
|
||||
BuiltinElement(System* s, Allocator* allocator, const char* name,
|
||||
const char* libraryName):
|
||||
JarElement(s, allocator, name),
|
||||
JarElement(s, allocator, name, false),
|
||||
libraryName(libraryName ? copy(allocator, libraryName) : 0)
|
||||
{ }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010 Avian Contributors
|
||||
/* Copyright (c) 2008-2011 Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -1631,7 +1631,7 @@ setDoubleField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject o = reinterpret_cast<jobject>(arguments[0]);
|
||||
object field = getField(t, arguments[1]);
|
||||
jdouble v = bitsToDouble(arguments[2]);
|
||||
jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble));
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
@ -1644,9 +1644,10 @@ setDoubleField(Thread* t, uintptr_t* arguments)
|
||||
void JNICALL
|
||||
SetDoubleField(Thread* t, jobject o, jfieldID field, jdouble v)
|
||||
{
|
||||
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o),
|
||||
field,
|
||||
doubleToBits(v) };
|
||||
uintptr_t arguments[2 + (sizeof(jdouble) / BytesPerWord)];
|
||||
arguments[0] = reinterpret_cast<uintptr_t>(o);
|
||||
arguments[1] = field;
|
||||
memcpy(arguments + 2, &v, sizeof(jdouble));
|
||||
|
||||
run(t, setDoubleField, arguments);
|
||||
}
|
||||
@ -1667,6 +1668,9 @@ uint64_t
|
||||
getStaticObjectField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1691,6 +1695,9 @@ uint64_t
|
||||
getStaticBooleanField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1713,6 +1720,9 @@ uint64_t
|
||||
getStaticByteField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1735,6 +1745,9 @@ uint64_t
|
||||
getStaticCharField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1757,6 +1770,9 @@ uint64_t
|
||||
getStaticShortField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1779,6 +1795,9 @@ uint64_t
|
||||
getStaticIntField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1801,6 +1820,9 @@ uint64_t
|
||||
getStaticLongField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1823,6 +1845,9 @@ uint64_t
|
||||
getStaticFloatField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1846,6 +1871,9 @@ uint64_t
|
||||
getStaticDoubleField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
|
||||
PROTECT(t, field);
|
||||
@ -1869,6 +1897,9 @@ uint64_t
|
||||
setStaticObjectField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jobject v = reinterpret_cast<jobject>(arguments[2]);
|
||||
|
||||
@ -1895,6 +1926,9 @@ uint64_t
|
||||
setStaticBooleanField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jboolean v = arguments[2];
|
||||
|
||||
@ -1921,6 +1955,9 @@ uint64_t
|
||||
setStaticByteField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jbyte v = arguments[2];
|
||||
|
||||
@ -1947,6 +1984,9 @@ uint64_t
|
||||
setStaticCharField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jchar v = arguments[2];
|
||||
|
||||
@ -1973,6 +2013,9 @@ uint64_t
|
||||
setStaticShortField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jshort v = arguments[2];
|
||||
|
||||
@ -1999,6 +2042,9 @@ uint64_t
|
||||
setStaticIntField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jint v = arguments[2];
|
||||
|
||||
@ -2025,6 +2071,9 @@ uint64_t
|
||||
setStaticLongField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jlong v; memcpy(&v, arguments + 2, sizeof(jlong));
|
||||
|
||||
@ -2052,6 +2101,9 @@ uint64_t
|
||||
setStaticFloatField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jfloat v = bitsToFloat(arguments[2]);
|
||||
|
||||
@ -2078,8 +2130,11 @@ uint64_t
|
||||
setStaticDoubleField(Thread* t, uintptr_t* arguments)
|
||||
{
|
||||
jobject c = reinterpret_cast<jobject>(arguments[0]);
|
||||
|
||||
initClass(t, jclassVmClass(t, *c));
|
||||
|
||||
object field = getStaticField(t, arguments[1]);
|
||||
jdouble v = bitsToDouble(arguments[2]);
|
||||
jdouble v; memcpy(&v, arguments + 2, sizeof(jdouble));
|
||||
|
||||
PROTECT(t, field);
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, field);
|
||||
@ -2093,9 +2148,10 @@ setStaticDoubleField(Thread* t, uintptr_t* arguments)
|
||||
void JNICALL
|
||||
SetStaticDoubleField(Thread* t, jobject c, jfieldID field, jdouble v)
|
||||
{
|
||||
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c),
|
||||
field,
|
||||
doubleToBits(v) };
|
||||
uintptr_t arguments[2 + (sizeof(jdouble) / BytesPerWord)];
|
||||
arguments[0] = reinterpret_cast<uintptr_t>(c);
|
||||
arguments[1] = field;
|
||||
memcpy(arguments + 2, &v, sizeof(jdouble));
|
||||
|
||||
run(t, setStaticDoubleField, arguments);
|
||||
}
|
||||
@ -3281,15 +3337,24 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
||||
|
||||
const char** properties = static_cast<const char**>
|
||||
(h->allocate(sizeof(const char*) * propertyCount));
|
||||
|
||||
const char** propertyPointer = properties;
|
||||
|
||||
const char** arguments = static_cast<const char**>
|
||||
(h->allocate(sizeof(const char*) * a->nOptions));
|
||||
|
||||
const char** argumentPointer = arguments;
|
||||
|
||||
for (int i = 0; i < a->nOptions; ++i) {
|
||||
if (strncmp(a->options[i].optionString, "-D", 2) == 0) {
|
||||
*(propertyPointer++) = a->options[i].optionString + 2;
|
||||
}
|
||||
*(argumentPointer++) = a->options[i].optionString;
|
||||
}
|
||||
|
||||
*m = new (h->allocate(sizeof(Machine)))
|
||||
Machine(s, h, bf, af, p, c, properties, propertyCount);
|
||||
Machine
|
||||
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions);
|
||||
|
||||
*t = p->makeThread(*m, 0, 0);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -974,6 +974,8 @@ getClassAddendum(Thread* t, object class_, object pool)
|
||||
{
|
||||
object addendum = classAddendum(t, class_);
|
||||
if (addendum == 0) {
|
||||
PROTECT(t, class_);
|
||||
|
||||
addendum = makeClassAddendum(t, pool, 0, 0, 0, 0, 0);
|
||||
set(t, class_, ClassAddendum, addendum);
|
||||
}
|
||||
@ -1879,6 +1881,8 @@ makeArrayClass(Thread* t, object loader, unsigned dimensions, object spec,
|
||||
loader,
|
||||
arrayLength(t, vtable));
|
||||
|
||||
PROTECT(t, c);
|
||||
|
||||
t->m->processor->initVtable(t, c);
|
||||
|
||||
return c;
|
||||
@ -2395,7 +2399,8 @@ namespace vm {
|
||||
|
||||
Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
||||
Finder* appFinder, Processor* processor, Classpath* classpath,
|
||||
const char** properties, unsigned propertyCount):
|
||||
const char** properties, unsigned propertyCount,
|
||||
const char** arguments, unsigned argumentCount):
|
||||
vtable(&javaVMVTable),
|
||||
system(system),
|
||||
heapClient(new (heap->allocate(sizeof(HeapClient)))
|
||||
@ -2411,6 +2416,8 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
||||
jniReferences(0),
|
||||
properties(properties),
|
||||
propertyCount(propertyCount),
|
||||
arguments(arguments),
|
||||
argumentCount(argumentCount),
|
||||
activeCount(0),
|
||||
liveCount(0),
|
||||
daemonCount(0),
|
||||
@ -2477,6 +2484,8 @@ Machine::dispose()
|
||||
heap->free(heapPool[i], ThreadHeapSizeInBytes);
|
||||
}
|
||||
|
||||
heap->free(arguments, sizeof(const char*) * argumentCount);
|
||||
|
||||
heap->free(properties, sizeof(const char*) * propertyCount);
|
||||
|
||||
static_cast<HeapClient*>(heapClient)->dispose();
|
||||
@ -3016,16 +3025,20 @@ popResources(Thread* t)
|
||||
object
|
||||
makeByteArray(Thread* t, const char* format, va_list a)
|
||||
{
|
||||
const int Size = 256;
|
||||
char buffer[Size];
|
||||
int size = 256;
|
||||
while (true) {
|
||||
THREAD_RUNTIME_ARRAY(t, char, buffer, size);
|
||||
|
||||
int r = vm::vsnprintf(buffer, Size - 1, format, a);
|
||||
expect(t, r >= 0 and r < Size - 1);
|
||||
|
||||
object s = makeByteArray(t, strlen(buffer) + 1);
|
||||
memcpy(&byteArrayBody(t, s, 0), buffer, byteArrayLength(t, s));
|
||||
|
||||
return s;
|
||||
int r = vm::vsnprintf(RUNTIME_ARRAY_BODY(buffer), size - 1, format, a);
|
||||
if (r >= 0 and r < size - 1) {
|
||||
object s = makeByteArray(t, strlen(RUNTIME_ARRAY_BODY(buffer)) + 1);
|
||||
memcpy(&byteArrayBody(t, s, 0), RUNTIME_ARRAY_BODY(buffer),
|
||||
byteArrayLength(t, s));
|
||||
return s;
|
||||
} else {
|
||||
size *= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object
|
||||
@ -3215,14 +3228,17 @@ instanceOf(Thread* t, object class_, object o)
|
||||
object
|
||||
classInitializer(Thread* t, object class_)
|
||||
{
|
||||
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, class_)); ++i) {
|
||||
object o = arrayBody(t, classMethodTable(t, class_), i);
|
||||
|
||||
if (vm::strcmp(reinterpret_cast<const int8_t*>("<clinit>"),
|
||||
&byteArrayBody(t, methodName(t, o), 0)) == 0)
|
||||
if (classMethodTable(t, class_)) {
|
||||
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, class_)); ++i)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
object o = arrayBody(t, classMethodTable(t, class_), i);
|
||||
|
||||
if (vm::strcmp(reinterpret_cast<const int8_t*>("<clinit>"),
|
||||
&byteArrayBody(t, methodName(t, o), 0)) == 0)
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -1273,7 +1273,8 @@ class Machine {
|
||||
|
||||
Machine(System* system, Heap* heap, Finder* bootFinder, Finder* appFinder,
|
||||
Processor* processor, Classpath* classpath, const char** properties,
|
||||
unsigned propertyCount);
|
||||
unsigned propertyCount, const char** arguments,
|
||||
unsigned argumentCount);
|
||||
|
||||
~Machine() {
|
||||
dispose();
|
||||
@ -1295,6 +1296,8 @@ class Machine {
|
||||
Reference* jniReferences;
|
||||
const char** properties;
|
||||
unsigned propertyCount;
|
||||
const char** arguments;
|
||||
unsigned argumentCount;
|
||||
unsigned activeCount;
|
||||
unsigned liveCount;
|
||||
unsigned daemonCount;
|
||||
@ -3036,7 +3039,7 @@ monitorWait(Thread* t, object monitor, int64_t time)
|
||||
|
||||
ENTER(t, Thread::IdleState);
|
||||
|
||||
interrupted = t->lock->wait(t->systemThread, time);
|
||||
interrupted = t->lock->waitAndClearInterrupted(t->systemThread, time);
|
||||
}
|
||||
|
||||
monitorAcquire(t, monitor, monitorNode);
|
||||
@ -3236,6 +3239,18 @@ interrupt(Thread* t, Thread* target)
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
getAndClearInterrupted(Thread* t, Thread* target)
|
||||
{
|
||||
if (acquireSystem(t, target)) {
|
||||
bool result = target->systemThread->getAndClearInterrupted();
|
||||
releaseSystem(t, target);
|
||||
return result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
object
|
||||
intern(Thread* t, object s);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -179,6 +179,10 @@ main(int ac, const char** av)
|
||||
or strncmp(av[i], "-D", 2) == 0)
|
||||
{
|
||||
++ vmArgs.nOptions;
|
||||
} else if (strcmp(av[i], "-client") == 0
|
||||
or strcmp(av[i], "-server") == 0)
|
||||
{
|
||||
// ignore
|
||||
} else {
|
||||
if (jar == 0) {
|
||||
class_ = av[i++];
|
||||
|
2
src/openjdk/my_management.c
Normal file
2
src/openjdk/my_management.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define JNI_OnLoad management_JNI_OnLoad
|
||||
#include "management.c"
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -151,6 +151,16 @@ class MySystem: public System {
|
||||
expect(s, rv == 0);
|
||||
}
|
||||
|
||||
virtual bool getAndClearInterrupted() {
|
||||
ACQUIRE(mutex);
|
||||
|
||||
bool interrupted = r->interrupted();
|
||||
|
||||
r->setInterrupted(false);
|
||||
|
||||
return interrupted;
|
||||
}
|
||||
|
||||
virtual void join() {
|
||||
int rv UNUSED = pthread_join(thread, 0);
|
||||
expect(s, rv == 0);
|
||||
@ -276,7 +286,16 @@ class MySystem: public System {
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool wait(System::Thread* context, int64_t time) {
|
||||
virtual void wait(System::Thread* context, int64_t time) {
|
||||
wait(context, time, false);
|
||||
}
|
||||
|
||||
virtual bool waitAndClearInterrupted(System::Thread* context, int64_t time)
|
||||
{
|
||||
return wait(context, time, true);
|
||||
}
|
||||
|
||||
bool wait(System::Thread* context, int64_t time, bool clearInterrupted) {
|
||||
Thread* t = static_cast<Thread*>(context);
|
||||
|
||||
if (owner_ == t) {
|
||||
@ -288,7 +307,9 @@ class MySystem: public System {
|
||||
{ ACQUIRE(t->mutex);
|
||||
|
||||
if (t->r->interrupted()) {
|
||||
t->r->setInterrupted(false);
|
||||
if (clearInterrupted) {
|
||||
t->r->setInterrupted(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -319,7 +340,7 @@ class MySystem: public System {
|
||||
t->flags = 0;
|
||||
|
||||
interrupted = t->r->interrupted();
|
||||
if (interrupted) {
|
||||
if (interrupted and clearInterrupted) {
|
||||
t->r->setInterrupted(false);
|
||||
}
|
||||
}
|
||||
@ -776,6 +797,15 @@ class MySystem: public System {
|
||||
return SO_SUFFIX;
|
||||
}
|
||||
|
||||
virtual const char* toAbsolutePath(Allocator* allocator, const char* name) {
|
||||
if (name[0] == '/') {
|
||||
return copy(allocator, name);
|
||||
} else {
|
||||
char buffer[PATH_MAX];
|
||||
return append(allocator, getcwd(buffer, PATH_MAX), "/", name);
|
||||
}
|
||||
}
|
||||
|
||||
virtual Status load(System::Library** lib,
|
||||
const char* name)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2010, Avian Contributors
|
||||
/* Copyright (c) 2009-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -2439,16 +2439,16 @@ class MyAssembler: public Assembler {
|
||||
return arch_;
|
||||
}
|
||||
|
||||
virtual void checkStackOverflow(uintptr_t /*handler*/,
|
||||
unsigned /*stackLimitOffsetFromThread*/)
|
||||
virtual void checkStackOverflow(uintptr_t handler,
|
||||
unsigned stackLimitOffsetFromThread)
|
||||
{
|
||||
/*Register stack(StackRegister);
|
||||
Register stack(StackRegister);
|
||||
Memory stackLimit(ThreadRegister, stackLimitOffsetFromThread);
|
||||
Constant handlerConstant
|
||||
(new (c.zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(handler));
|
||||
branchRM(&c, JumpIfGreaterOrEqual, BytesPerWord, &stack, &stackLimit,
|
||||
&handlerConstant);*/
|
||||
&handlerConstant);
|
||||
}
|
||||
|
||||
virtual void saveFrame(unsigned stackOffset, unsigned) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -12,6 +12,7 @@
|
||||
#define SYSTEM_H
|
||||
|
||||
#include "common.h"
|
||||
#include "allocator.h"
|
||||
|
||||
namespace vm {
|
||||
|
||||
@ -29,6 +30,7 @@ class System {
|
||||
class Thread {
|
||||
public:
|
||||
virtual void interrupt() = 0;
|
||||
virtual bool getAndClearInterrupted() = 0;
|
||||
virtual void join() = 0;
|
||||
virtual void dispose() = 0;
|
||||
};
|
||||
@ -58,7 +60,8 @@ class System {
|
||||
virtual bool tryAcquire(Thread* context) = 0;
|
||||
virtual void acquire(Thread* context) = 0;
|
||||
virtual void release(Thread* context) = 0;
|
||||
virtual bool wait(Thread* context, int64_t time) = 0;
|
||||
virtual void wait(Thread* context, int64_t time) = 0;
|
||||
virtual bool waitAndClearInterrupted(Thread* context, int64_t time) = 0;
|
||||
virtual void notify(Thread* context) = 0;
|
||||
virtual void notifyAll(Thread* context) = 0;
|
||||
virtual Thread* owner() = 0;
|
||||
@ -140,6 +143,8 @@ class System {
|
||||
virtual Status load(Library**, const char* name) = 0;
|
||||
virtual char pathSeparator() = 0;
|
||||
virtual char fileSeparator() = 0;
|
||||
virtual const char* toAbsolutePath(Allocator* allocator,
|
||||
const char* name) = 0;
|
||||
virtual int64_t now() = 0;
|
||||
virtual void yield() = 0;
|
||||
virtual void exit(int code) = 0;
|
||||
|
@ -4,6 +4,7 @@ THUNK(findInterfaceMethodFromInstanceAndReference)
|
||||
THUNK(findSpecialMethodFromReference)
|
||||
THUNK(findStaticMethodFromReference)
|
||||
THUNK(findVirtualMethodFromReference)
|
||||
THUNK(getMethodAddress)
|
||||
THUNK(compareDoublesG)
|
||||
THUNK(compareDoublesL)
|
||||
THUNK(compareFloatsG)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010, Avian Contributors
|
||||
/* Copyright (c) 2010-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -1911,7 +1911,7 @@ writeConstructors(Output* out, Object* declarations)
|
||||
|
||||
out->write(")\n{\n");
|
||||
|
||||
bool hasObjectMask = false;
|
||||
bool hasObjectMask = strcmp(typeName(o), "singleton") == 0;
|
||||
for (MemberIterator it(o); it.hasMore();) {
|
||||
Object* m = it.next();
|
||||
if (m->type == Object::Scalar
|
||||
|
@ -249,6 +249,8 @@
|
||||
|
||||
(type incompatibleClassChangeError java/lang/IncompatibleClassChangeError)
|
||||
|
||||
(type abstractMethodError java/lang/AbstractMethodError)
|
||||
|
||||
(type noSuchFieldError java/lang/NoSuchFieldError)
|
||||
|
||||
(type noSuchMethodError java/lang/NoSuchMethodError)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -100,6 +100,16 @@ class MySystem: public System {
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool getAndClearInterrupted() {
|
||||
ACQUIRE(s, mutex);
|
||||
|
||||
bool interrupted = r->interrupted();
|
||||
|
||||
r->setInterrupted(false);
|
||||
|
||||
return interrupted;
|
||||
}
|
||||
|
||||
virtual void join() {
|
||||
int r UNUSED = WaitForSingleObject(thread, INFINITE);
|
||||
assert(s, r == WAIT_OBJECT_0);
|
||||
@ -237,7 +247,16 @@ class MySystem: public System {
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool wait(System::Thread* context, int64_t time) {
|
||||
virtual void wait(System::Thread* context, int64_t time) {
|
||||
wait(context, time, false);
|
||||
}
|
||||
|
||||
virtual bool waitAndClearInterrupted(System::Thread* context, int64_t time)
|
||||
{
|
||||
return wait(context, time, true);
|
||||
}
|
||||
|
||||
bool wait(System::Thread* context, int64_t time, bool clearInterrupted) {
|
||||
Thread* t = static_cast<Thread*>(context);
|
||||
assert(s, t);
|
||||
|
||||
@ -252,7 +271,9 @@ class MySystem: public System {
|
||||
{ ACQUIRE(s, t->mutex);
|
||||
|
||||
if (t->r->interrupted()) {
|
||||
t->r->setInterrupted(false);
|
||||
if (clearInterrupted) {
|
||||
t->r->setInterrupted(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -284,7 +305,7 @@ class MySystem: public System {
|
||||
t->flags = 0;
|
||||
|
||||
interrupted = t->r->interrupted();
|
||||
if (interrupted) {
|
||||
if (interrupted and clearInterrupted) {
|
||||
t->r->setInterrupted(false);
|
||||
}
|
||||
}
|
||||
@ -752,6 +773,20 @@ class MySystem: public System {
|
||||
return SO_SUFFIX;
|
||||
}
|
||||
|
||||
virtual const char* toAbsolutePath(Allocator* allocator, const char* name) {
|
||||
if (strncmp(name, "//", 2) == 0
|
||||
or strncmp(name, "\\\\", 2) == 0
|
||||
or strncmp(name + 1, ":/", 2) == 0
|
||||
or strncmp(name + 1, ":\\", 2) == 0)
|
||||
{
|
||||
return copy(allocator, name);
|
||||
} else {
|
||||
TCHAR buffer[MAX_PATH];
|
||||
GetCurrentDirectory(MAX_PATH, buffer);
|
||||
return append(allocator, buffer, "\\", name);
|
||||
}
|
||||
}
|
||||
|
||||
virtual Status load(System::Library** lib,
|
||||
const char* name)
|
||||
{
|
||||
@ -939,13 +974,11 @@ handleException(LPEXCEPTION_POINTERS e)
|
||||
|
||||
if (jump) {
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
} else if (system->crashDumpDirectory) {
|
||||
dump(e, system->crashDumpDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
if (system->crashDumpDirectory) {
|
||||
dump(e, system->crashDumpDirectory);
|
||||
}
|
||||
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
44
src/x86.cpp
44
src/x86.cpp
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -238,7 +238,7 @@ codePromise(Context* c, unsigned offset)
|
||||
class Offset: public Promise {
|
||||
public:
|
||||
Offset(Context* c, MyBlock* block, unsigned offset, AlignmentPadding* limit):
|
||||
c(c), block(block), offset(offset), limit(limit)
|
||||
c(c), block(block), offset(offset), limit(limit), value_(-1)
|
||||
{ }
|
||||
|
||||
virtual bool resolved() {
|
||||
@ -248,14 +248,19 @@ class Offset: public Promise {
|
||||
virtual int64_t value() {
|
||||
assert(c, resolved());
|
||||
|
||||
return block->start + (offset - block->offset)
|
||||
+ padding(block->firstPadding, block->start, block->offset, limit);
|
||||
if (value_ == -1) {
|
||||
value_ = block->start + (offset - block->offset)
|
||||
+ padding(block->firstPadding, block->start, block->offset, limit);
|
||||
}
|
||||
|
||||
return value_;
|
||||
}
|
||||
|
||||
Context* c;
|
||||
MyBlock* block;
|
||||
unsigned offset;
|
||||
AlignmentPadding* limit;
|
||||
int value_;
|
||||
};
|
||||
|
||||
Promise*
|
||||
@ -419,7 +424,8 @@ class AlignmentPadding {
|
||||
offset(c->code.length()),
|
||||
instructionOffset(instructionOffset),
|
||||
alignment(alignment),
|
||||
next(0)
|
||||
next(0),
|
||||
padding(-1)
|
||||
{
|
||||
if (c->lastBlock->firstPadding) {
|
||||
c->lastBlock->lastPadding->next = this;
|
||||
@ -433,6 +439,7 @@ class AlignmentPadding {
|
||||
unsigned instructionOffset;
|
||||
unsigned alignment;
|
||||
AlignmentPadding* next;
|
||||
int padding;
|
||||
};
|
||||
|
||||
unsigned
|
||||
@ -441,14 +448,25 @@ padding(AlignmentPadding* p, unsigned start, unsigned offset,
|
||||
{
|
||||
unsigned padding = 0;
|
||||
if (limit) {
|
||||
unsigned index = 0;
|
||||
for (; p; p = p->next) {
|
||||
index = p->offset - offset;
|
||||
while ((start + index + padding + p->instructionOffset) % p->alignment) {
|
||||
++ padding;
|
||||
}
|
||||
if (limit->padding == -1) {
|
||||
for (; p; p = p->next) {
|
||||
if (p->padding == -1) {
|
||||
unsigned index = p->offset - offset;
|
||||
while ((start + index + padding + p->instructionOffset)
|
||||
% p->alignment)
|
||||
{
|
||||
++ padding;
|
||||
}
|
||||
|
||||
if (p == limit) break;
|
||||
p->padding = padding;
|
||||
|
||||
if (p == limit) break;
|
||||
} else {
|
||||
padding = p->padding;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
padding = limit->padding;
|
||||
}
|
||||
}
|
||||
return padding;
|
||||
@ -969,7 +987,7 @@ sseMoveRR(Context* c, unsigned aSize, Assembler::Register* a,
|
||||
modrm(c, 0xc0, a, b);
|
||||
} else {
|
||||
opcode(c, 0xf2);
|
||||
maybeRex(c, 4, a, b);
|
||||
maybeRex(c, 4, b, a);
|
||||
opcode(c, 0x0f, 0x10);
|
||||
modrm(c, 0xc0, a, b);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, Avian Contributors
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -33,7 +33,91 @@ public class Floats {
|
||||
return f.field * a;
|
||||
}
|
||||
|
||||
private static void subdivide(double src[], int srcoff,
|
||||
double left[], int leftoff,
|
||||
double right[], int rightoff)
|
||||
{
|
||||
double x1 = src[srcoff + 0];
|
||||
double y1 = src[srcoff + 1];
|
||||
double ctrlx1 = src[srcoff + 2];
|
||||
double ctrly1 = src[srcoff + 3];
|
||||
double ctrlx2 = src[srcoff + 4];
|
||||
double ctrly2 = src[srcoff + 5];
|
||||
double x2 = src[srcoff + 6];
|
||||
double y2 = src[srcoff + 7];
|
||||
if (left != null) {
|
||||
left[leftoff + 0] = x1;
|
||||
left[leftoff + 1] = y1;
|
||||
}
|
||||
if (right != null) {
|
||||
right[rightoff + 6] = x2;
|
||||
right[rightoff + 7] = y2;
|
||||
}
|
||||
x1 = (x1 + ctrlx1) / 2.0;
|
||||
y1 = (y1 + ctrly1) / 2.0;
|
||||
x2 = (x2 + ctrlx2) / 2.0;
|
||||
y2 = (y2 + ctrly2) / 2.0;
|
||||
double centerx = (ctrlx1 + ctrlx2) / 2.0;
|
||||
double centery = (ctrly1 + ctrly2) / 2.0;
|
||||
ctrlx1 = (x1 + centerx) / 2.0;
|
||||
ctrly1 = (y1 + centery) / 2.0;
|
||||
ctrlx2 = (x2 + centerx) / 2.0;
|
||||
ctrly2 = (y2 + centery) / 2.0;
|
||||
centerx = (ctrlx1 + ctrlx2) / 2.0;
|
||||
centery = (ctrly1 + ctrly2) / 2.0;
|
||||
if (left != null) {
|
||||
left[leftoff + 2] = x1;
|
||||
left[leftoff + 3] = y1;
|
||||
left[leftoff + 4] = ctrlx1;
|
||||
left[leftoff + 5] = ctrly1;
|
||||
left[leftoff + 6] = centerx;
|
||||
left[leftoff + 7] = centery;
|
||||
}
|
||||
if (right != null) {
|
||||
right[rightoff + 0] = centerx;
|
||||
right[rightoff + 1] = centery;
|
||||
right[rightoff + 2] = ctrlx2;
|
||||
right[rightoff + 3] = ctrly2;
|
||||
right[rightoff + 4] = x2;
|
||||
right[rightoff + 5] = y2;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
{ double input[] = new double[8];
|
||||
double left[] = new double[8];
|
||||
double right[] = new double[8];
|
||||
|
||||
input[0] = 732.0;
|
||||
input[1] = 952.0;
|
||||
input[2] = 761.0;
|
||||
input[3] = 942.0;
|
||||
input[4] = 786.0;
|
||||
input[5] = 944.0;
|
||||
input[6] = 813.0;
|
||||
input[7] = 939.0;
|
||||
|
||||
subdivide(input, 0, left, 0, right, 0);
|
||||
|
||||
expect(left[0] == 732.0);
|
||||
expect(left[1] == 952.0);
|
||||
expect(left[2] == 746.5);
|
||||
expect(left[3] == 947.0);
|
||||
expect(left[4] == 760.0);
|
||||
expect(left[5] == 945.0);
|
||||
expect(left[6] == 773.25);
|
||||
expect(left[7] == 943.625);
|
||||
|
||||
expect(right[0] == 773.25);
|
||||
expect(right[1] == 943.625);
|
||||
expect(right[2] == 786.5);
|
||||
expect(right[3] == 942.25);
|
||||
expect(right[4] == 799.5);
|
||||
expect(right[5] == 941.5);
|
||||
expect(right[6] == 813.0);
|
||||
expect(right[7] == 939.0);
|
||||
}
|
||||
|
||||
expect(multiply(0.5d, 0.5d) == 0.25d);
|
||||
expect(multiply(0.5f, 0.5f) == 0.25f);
|
||||
|
||||
|
@ -49,8 +49,12 @@ public class Logging {
|
||||
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());
|
||||
String methodName = r.getSourceMethodName();
|
||||
if (methodName == null) {
|
||||
methodName = "<unknown>";
|
||||
}
|
||||
sb.append(methodName);
|
||||
indent(sb, METHOD_WIDTH - methodName.length());
|
||||
sb.append(r.getLevel().getName());
|
||||
indent(sb, LEVEL_WIDTH - r.getLevel().getName().length());
|
||||
sb.append(r.getMessage());
|
||||
|
@ -1,4 +1,10 @@
|
||||
public class Longs {
|
||||
public class Longs {
|
||||
private static volatile long volatileLong = getConstant();
|
||||
|
||||
private static long getConstant() {
|
||||
return 0x123456789ABCDEFL;
|
||||
}
|
||||
|
||||
private static void expect(boolean v) {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
@ -60,6 +66,8 @@ public class Longs {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
expect(volatileLong == getConstant());
|
||||
|
||||
{ long a = 0x1FFFFFFFFL;
|
||||
long b = -1;
|
||||
expect(a != b);
|
||||
|
@ -1,15 +1,36 @@
|
||||
public class Threads implements Runnable {
|
||||
public static void main(String[] args) {
|
||||
Threads test = new Threads();
|
||||
Thread thread = new Thread(test);
|
||||
{ Threads test = new Threads();
|
||||
Thread thread = new Thread(test);
|
||||
|
||||
try {
|
||||
synchronized (test) {
|
||||
thread.start();
|
||||
test.wait();
|
||||
try {
|
||||
synchronized (test) {
|
||||
thread.start();
|
||||
test.wait();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
{ Thread thread = new Thread() {
|
||||
public void run() {
|
||||
while (true) {
|
||||
System.out.print(".");
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (Exception e) {
|
||||
System.out.println("thread interrupted? " + interrupted());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
||||
System.out.println("\nAbout to interrupt...");
|
||||
thread.interrupt();
|
||||
System.out.println("\nInterrupted!");
|
||||
}
|
||||
|
||||
System.out.println("finished");
|
||||
|
1
vm.pro
1
vm.pro
@ -62,6 +62,7 @@
|
||||
-keep public class java.lang.StackOverflowError
|
||||
-keep public class java.lang.NoSuchFieldError
|
||||
-keep public class java.lang.NoSuchMethodError
|
||||
-keep public class java.lang.AbstractMethodError
|
||||
-keep public class java.lang.UnsatisfiedLinkError
|
||||
-keep public class java.lang.ExceptionInInitializerError
|
||||
-keep public class java.lang.OutOfMemoryError
|
||||
|
Loading…
Reference in New Issue
Block a user