mirror of
https://github.com/corda/corda.git
synced 2025-02-09 04:11:50 +00:00
Merge branch 'master' of git:avian into git-master
Conflicts: makefile src/machine.cpp
This commit is contained in:
commit
312a4cc985
@ -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) 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) 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) 2009, Avian Contributors
|
||||
/* Copyright (c) 2009-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -10,8 +10,16 @@
|
||||
|
||||
package avian;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public abstract class Machine {
|
||||
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
|
||||
public static native void dumpHeap(String outputFile);
|
||||
|
||||
public static Unsafe getUnsafe() {
|
||||
return unsafe;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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) 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, 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-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
|
||||
|
@ -24,4 +24,8 @@ public class VMMethod {
|
||||
public MethodAddendum addendum;
|
||||
public VMClass class_;
|
||||
public Object code;
|
||||
|
||||
public boolean hasAnnotations() {
|
||||
return addendum != null && addendum.annotationTable != null;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -48,7 +48,6 @@
|
||||
# define R_OK 4
|
||||
# else
|
||||
# define OPEN _wopen
|
||||
# define CREAT _wcreat
|
||||
# endif
|
||||
|
||||
# define GET_CHARS GetStringChars
|
||||
@ -71,7 +70,6 @@ typedef wchar_t char_t;
|
||||
# define STRUCT_STAT struct stat
|
||||
# define MKDIR mkdir
|
||||
# define CHMOD chmod
|
||||
# define CREAT creat
|
||||
# define UNLINK unlink
|
||||
# define RENAME rename
|
||||
# define OPEN_MASK 0
|
||||
@ -102,12 +100,6 @@ OPEN(string_t path, int mask, int mode)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
inline int
|
||||
CREAT(string_t path, int mode)
|
||||
{
|
||||
return OPEN(path, _O_CREAT, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline bool
|
||||
@ -407,21 +399,26 @@ Java_java_io_File_mkdir(JNIEnv* e, jclass, jstring path)
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_java_io_File_createNewFile(JNIEnv* e, jclass, jstring path)
|
||||
{
|
||||
bool result = false;
|
||||
string_t chars = getChars(e, path);
|
||||
if (chars) {
|
||||
if (not exists(chars)) {
|
||||
int fd = CREAT(chars, 0600);
|
||||
int fd = OPEN(chars, O_CREAT | O_WRONLY | O_EXCL, 0600);
|
||||
if (fd == -1) {
|
||||
throwNewErrno(e, "java/io/IOException");
|
||||
if (errno != EEXIST) {
|
||||
throwNewErrno(e, "java/io/IOException");
|
||||
}
|
||||
} else {
|
||||
result = true;
|
||||
doClose(e, fd);
|
||||
}
|
||||
}
|
||||
releaseChars(e, path, chars);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2011, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -631,6 +631,36 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
|
||||
return r;
|
||||
}
|
||||
|
||||
// System.getEnvironment() implementation
|
||||
// TODO: For Win32, replace usage of deprecated _environ and add Unicode
|
||||
// support (neither of which is likely to be of great importance).
|
||||
#ifdef AVIAN_IOS
|
||||
namespace {
|
||||
const char* environ[] = { 0 };
|
||||
}
|
||||
#elif defined __APPLE__
|
||||
# include <crt_externs.h>
|
||||
# define environ (*_NSGetEnviron())
|
||||
#else
|
||||
extern char** environ;
|
||||
#endif
|
||||
extern "C" JNIEXPORT jobjectArray JNICALL
|
||||
Java_java_lang_System_getEnvironment(JNIEnv* env, jclass) {
|
||||
int length;
|
||||
for (length = 0; environ[length] != 0; ++length) ;
|
||||
|
||||
jobjectArray stringArray =
|
||||
env->NewObjectArray(length, env->FindClass("java/lang/String"),
|
||||
env->NewStringUTF(""));
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
jobject varString = env->NewStringUTF(environ[i]);
|
||||
env->SetObjectArrayElement(stringArray, i, varString);
|
||||
}
|
||||
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
|
||||
{
|
||||
|
@ -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-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
|
||||
@ -76,7 +76,9 @@ Java_java_util_zip_Inflater_inflate
|
||||
|
||||
int r = inflate(s, Z_SYNC_FLUSH);
|
||||
jint resultArray[3]
|
||||
= { r, inputLength - s->avail_in, outputLength - s->avail_out };
|
||||
= { r,
|
||||
static_cast<jint>(inputLength - s->avail_in),
|
||||
static_cast<jint>(outputLength - s->avail_out) };
|
||||
|
||||
free(in);
|
||||
|
||||
@ -147,7 +149,9 @@ Java_java_util_zip_Deflater_deflate
|
||||
|
||||
int r = deflate(s, finish ? Z_FINISH : Z_NO_FLUSH);
|
||||
jint resultArray[3]
|
||||
= { r, inputLength - s->avail_in, outputLength - s->avail_out };
|
||||
= { r,
|
||||
static_cast<jint>(inputLength - s->avail_in),
|
||||
static_cast<jint>(outputLength - s->avail_out) };
|
||||
|
||||
free(in);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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, 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-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -35,11 +35,16 @@ public class File implements Serializable {
|
||||
this(parent.getPath() + FileSeparator + child);
|
||||
}
|
||||
|
||||
public static File createTempFile(String prefix, String suffix) {
|
||||
public static File createTempFile(String prefix, String suffix)
|
||||
throws IOException
|
||||
{
|
||||
return createTempFile(prefix, suffix, null);
|
||||
}
|
||||
|
||||
public static File createTempFile(String prefix, String suffix, File directory) {
|
||||
public static File createTempFile(String prefix, String suffix,
|
||||
File directory)
|
||||
throws IOException
|
||||
{
|
||||
if(directory == null) {
|
||||
directory = new File(System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
@ -199,15 +204,10 @@ public class File implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private static native void createNewFile(String path) throws IOException;
|
||||
private static native boolean createNewFile(String path) throws IOException;
|
||||
|
||||
public boolean createNewFile() {
|
||||
try {
|
||||
createNewFile(path);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
public boolean createNewFile() throws IOException {
|
||||
return createNewFile(path);
|
||||
}
|
||||
|
||||
public static native void delete(String path) throws IOException;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -16,6 +16,7 @@ public class FileInputStream extends InputStream {
|
||||
// }
|
||||
|
||||
private int fd;
|
||||
private int remaining;
|
||||
|
||||
public FileInputStream(FileDescriptor fd) {
|
||||
this.fd = fd.value;
|
||||
@ -23,12 +24,17 @@ public class FileInputStream extends InputStream {
|
||||
|
||||
public FileInputStream(String path) throws IOException {
|
||||
fd = open(path);
|
||||
remaining = (int) new File(path).length();
|
||||
}
|
||||
|
||||
public FileInputStream(File file) throws IOException {
|
||||
this(file.getPath());
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
return remaining;
|
||||
}
|
||||
|
||||
private static native int open(String path) throws IOException;
|
||||
|
||||
private static native int read(int fd) throws IOException;
|
||||
@ -39,7 +45,11 @@ public class FileInputStream extends InputStream {
|
||||
public static native void close(int fd) throws IOException;
|
||||
|
||||
public int read() throws IOException {
|
||||
return read(fd);
|
||||
int c = read(fd);
|
||||
if (c >= 0 && remaining > 0) {
|
||||
-- remaining;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public int read(byte[] b, int offset, int length) throws IOException {
|
||||
@ -51,7 +61,11 @@ public class FileInputStream extends InputStream {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
return read(fd, b, offset, length);
|
||||
int c = read(fd, b, offset, length);
|
||||
if (c > 0 && remaining > 0) {
|
||||
remaining -= c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
|
@ -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, 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
|
||||
|
@ -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-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
|
||||
|
@ -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, 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
|
||||
|
13
classpath/java/lang/ReflectiveOperationException.java
Normal file
13
classpath/java/lang/ReflectiveOperationException.java
Normal file
@ -0,0 +1,13 @@
|
||||
/* Copyright (c) 2012, 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 ReflectiveOperationException extends Exception { }
|
@ -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
|
||||
|
21
classpath/java/lang/RuntimePermission.java
Normal file
21
classpath/java/lang/RuntimePermission.java
Normal file
@ -0,0 +1,21 @@
|
||||
/* Copyright (c) 2012, 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;
|
||||
|
||||
import java.security.BasicPermission;
|
||||
|
||||
public class RuntimePermission extends BasicPermission {
|
||||
|
||||
public RuntimePermission(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
}
|
@ -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-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -17,12 +17,15 @@ import java.io.BufferedOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileDescriptor;
|
||||
import java.util.Map;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class System {
|
||||
private static final long NanoTimeBaseInMillis = currentTimeMillis();
|
||||
|
||||
private static Property properties;
|
||||
private static Map<String, String> environment;
|
||||
|
||||
private static SecurityManager securityManager;
|
||||
// static {
|
||||
@ -145,4 +148,37 @@ public abstract class System {
|
||||
this.next = next;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getenv(String name) throws NullPointerException,
|
||||
SecurityException {
|
||||
if (getSecurityManager() != null) { // is this allowed?
|
||||
getSecurityManager().
|
||||
checkPermission(new RuntimePermission("getenv." + name));
|
||||
}
|
||||
return getenv().get(name);
|
||||
}
|
||||
|
||||
public static Map<String, String> getenv() throws SecurityException {
|
||||
if (getSecurityManager() != null) { // is this allowed?
|
||||
getSecurityManager().checkPermission(new RuntimePermission("getenv.*"));
|
||||
}
|
||||
|
||||
if (environment == null) { // build environment table
|
||||
String[] vars = getEnvironment();
|
||||
environment = new Hashtable<String, String>(vars.length);
|
||||
for (String var : vars) { // parse name-value pairs
|
||||
int equalsIndex = var.indexOf('=');
|
||||
// null names and values are forbidden
|
||||
if (equalsIndex != -1 && equalsIndex < var.length() - 1) {
|
||||
environment.put(var.substring(0, equalsIndex),
|
||||
var.substring(equalsIndex + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return environment;
|
||||
}
|
||||
|
||||
/** Returns the native process environment. */
|
||||
private static native String[] getEnvironment();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -145,8 +145,8 @@ public class Thread implements Runnable {
|
||||
|
||||
private static native boolean interrupt(long peer);
|
||||
|
||||
public boolean interrupted() {
|
||||
return interrupted(peer);
|
||||
public static boolean interrupted() {
|
||||
return interrupted(currentThread().peer);
|
||||
}
|
||||
|
||||
private static native boolean interrupted(long peer);
|
||||
|
22
classpath/java/lang/annotation/ElementType.java
Normal file
22
classpath/java/lang/annotation/ElementType.java
Normal file
@ -0,0 +1,22 @@
|
||||
/* Copyright (c) 2012, 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.annotation;
|
||||
|
||||
public enum ElementType {
|
||||
ANNOTATION_TYPE,
|
||||
CONSTRUCTOR,
|
||||
FIELD,
|
||||
LOCAL_VARIABLE,
|
||||
METHOD,
|
||||
PACKAGE,
|
||||
PARAMETER,
|
||||
TYPE
|
||||
}
|
17
classpath/java/lang/annotation/Target.java
Normal file
17
classpath/java/lang/annotation/Target.java
Normal file
@ -0,0 +1,17 @@
|
||||
/* Copyright (c) 2012, 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.annotation;
|
||||
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
@Target(value=ElementType.ANNOTATION_TYPE)
|
||||
public @interface Target {
|
||||
public ElementType[] 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, 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-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
@ -170,7 +170,7 @@ public class Method<T> extends AccessibleObject implements Member {
|
||||
}
|
||||
|
||||
public <T extends Annotation> T getAnnotation(Class<T> class_) {
|
||||
if (vmMethod.addendum.annotationTable != null) {
|
||||
if (vmMethod.hasAnnotations()) {
|
||||
Object[] table = (Object[]) vmMethod.addendum.annotationTable;
|
||||
for (int i = 0; i < table.length; ++i) {
|
||||
Object[] a = (Object[]) table[i];
|
||||
@ -183,7 +183,7 @@ public class Method<T> extends AccessibleObject implements Member {
|
||||
}
|
||||
|
||||
public Annotation[] getAnnotations() {
|
||||
if (vmMethod.addendum.annotationTable != null) {
|
||||
if (vmMethod.hasAnnotations()) {
|
||||
Object[] table = (Object[]) vmMethod.addendum.annotationTable;
|
||||
Annotation[] array = new Annotation[table.length];
|
||||
for (int i = 0; i < table.length; ++i) {
|
||||
|
@ -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
|
||||
@ -358,7 +358,7 @@ public class Proxy {
|
||||
int[] interfaceIndexes = new int[interfaces.length];
|
||||
for (int i = 0; i < interfaces.length; ++i) {
|
||||
interfaceIndexes[i] = ConstantPool.addClass
|
||||
(pool, interfaces[i].getName());
|
||||
(pool, interfaces[i].getName().replace('.', '/'));
|
||||
}
|
||||
|
||||
Map<String,avian.VMMethod> virtualMap = new HashMap();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, 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
|
||||
|
@ -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) 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) 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-2012, 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, 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) 2009, 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-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
60
classpath/java/util/AbstractQueue.java
Normal file
60
classpath/java/util/AbstractQueue.java
Normal file
@ -0,0 +1,60 @@
|
||||
/* Copyright (c) 2012, 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 AbstractQueue<T> extends AbstractCollection<T> implements Queue<T> {
|
||||
|
||||
protected AbstractQueue() {
|
||||
super();
|
||||
}
|
||||
|
||||
public boolean add(T element) {
|
||||
if (offer(element)) {
|
||||
return true;
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAll(Collection <? extends T> collection) {
|
||||
if (collection == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
for (T element : collection) {
|
||||
add(element);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
while (size() > 0) {
|
||||
poll();
|
||||
}
|
||||
}
|
||||
|
||||
public T element() {
|
||||
emptyCheck();
|
||||
return peek();
|
||||
}
|
||||
|
||||
public T remove() {
|
||||
emptyCheck();
|
||||
return poll();
|
||||
}
|
||||
|
||||
private void emptyCheck() {
|
||||
if (size() == 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -29,14 +29,15 @@ public class ArrayList<T> extends AbstractList<T> implements java.io.Serializabl
|
||||
addAll(source);
|
||||
}
|
||||
|
||||
private void grow() {
|
||||
if (array == null || size >= array.length) {
|
||||
resize(array == null ? MinimumCapacity : array.length * 2);
|
||||
private void grow(int newSize) {
|
||||
if (array == null || newSize > array.length) {
|
||||
resize(Math.max(newSize, array == null
|
||||
? MinimumCapacity : array.length * 2));
|
||||
}
|
||||
}
|
||||
|
||||
private void shrink() {
|
||||
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
||||
private void shrink(int newSize) {
|
||||
if (array.length / 2 >= MinimumCapacity && newSize <= array.length / 3) {
|
||||
resize(array.length / 2);
|
||||
}
|
||||
}
|
||||
@ -74,16 +75,15 @@ public class ArrayList<T> extends AbstractList<T> implements java.io.Serializabl
|
||||
}
|
||||
|
||||
public void add(int index, T element) {
|
||||
size = Math.max(size+1, index+1);
|
||||
grow();
|
||||
int newSize = Math.max(size+1, index+1);
|
||||
grow(newSize);
|
||||
size = newSize;
|
||||
System.arraycopy(array, index, array, index+1, size-index-1);
|
||||
array[index] = element;
|
||||
}
|
||||
|
||||
public boolean add(T element) {
|
||||
++ size;
|
||||
grow();
|
||||
array[size - 1] = element;
|
||||
add(size, element);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -137,8 +137,9 @@ public class ArrayList<T> extends AbstractList<T> implements java.io.Serializabl
|
||||
System.arraycopy(array, index + 1, array, index, size - index);
|
||||
}
|
||||
|
||||
-- size;
|
||||
shrink();
|
||||
int newSize = size - 1;
|
||||
shrink(newSize);
|
||||
size = newSize;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -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-2010, 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
|
||||
|
20
classpath/java/util/Queue.java
Normal file
20
classpath/java/util/Queue.java
Normal file
@ -0,0 +1,20 @@
|
||||
/* Copyright (c) 2012, 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 Queue<T> extends Collection<T>, Iterable<T> {
|
||||
public boolean add(T element);
|
||||
public T element();
|
||||
public boolean offer(T element);
|
||||
public T peek();
|
||||
public T poll();
|
||||
public T remove();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, Avian Contributors
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
|
20
classpath/java/util/SortedSet.java
Normal file
20
classpath/java/util/SortedSet.java
Normal file
@ -0,0 +1,20 @@
|
||||
/* Copyright (c) 2012, 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 SortedSet<T> extends Collection<T>, Iterable<T>, Set<T> {
|
||||
public Comparator<? super T> comparator();
|
||||
public T first();
|
||||
public SortedSet<T> headSet(T toElement);
|
||||
public T last();
|
||||
public SortedSet<T> subSet(T fromElement, T toElement);
|
||||
public SortedSet<T> tailSet(T fromElement);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009, 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
|
||||
@ -15,7 +15,6 @@ import avian.Cell;
|
||||
|
||||
public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
private PersistentSet<Cell<T>> set;
|
||||
private int size;
|
||||
|
||||
public TreeSet(final Comparator<T> comparator) {
|
||||
set = new PersistentSet(new Comparator<Cell<T>>() {
|
||||
@ -23,7 +22,6 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
return comparator.compare(a.value, b.value);
|
||||
}
|
||||
});
|
||||
size = 0;
|
||||
}
|
||||
|
||||
public TreeSet() {
|
||||
@ -66,7 +64,6 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null));
|
||||
if (p.fresh()) {
|
||||
set = p.add();
|
||||
++size;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -76,7 +73,6 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null));
|
||||
if (p.fresh()) {
|
||||
set = p.add();
|
||||
++size;
|
||||
return null;
|
||||
} else {
|
||||
T old = p.value().value;
|
||||
@ -100,8 +96,6 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
if (p.fresh()) {
|
||||
return null;
|
||||
} else {
|
||||
--size;
|
||||
|
||||
Cell<T> old = p.value();
|
||||
|
||||
if (p.value().next != null) {
|
||||
@ -119,11 +113,11 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
return set.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return size == 0;
|
||||
return set.size() != 0;
|
||||
}
|
||||
|
||||
public boolean contains(Object value) {
|
||||
@ -132,7 +126,6 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
|
||||
public void clear() {
|
||||
set = new PersistentSet(set.comparator());
|
||||
size = 0;
|
||||
}
|
||||
|
||||
private class MyIterator<T> implements java.util.Iterator<T> {
|
||||
@ -180,8 +173,6 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
public void remove() {
|
||||
if (! canRemove) throw new IllegalStateException();
|
||||
|
||||
--size;
|
||||
|
||||
if (prevPrevCell != null && prevPrevCell.next == prevCell) {
|
||||
// cell to remove is not the first in the list.
|
||||
prevPrevCell.next = prevCell.next;
|
||||
|
@ -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-2009, Avian Contributors
|
||||
/* Copyright (c) 2008-2010, 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, 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) 2009, 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, 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-2012, 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-2012, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -86,7 +86,7 @@ public class ZipFile {
|
||||
}
|
||||
|
||||
public InputStream getInputStream(ZipEntry entry) throws IOException {
|
||||
int pointer = ((MyEntry) entry).pointer();
|
||||
final int pointer = ((MyEntry) entry).pointer();
|
||||
int method = compressionMethod(window, pointer);
|
||||
int size = compressedSize(window, pointer);
|
||||
InputStream in = new MyInputStream(file, fileData(window, pointer), size);
|
||||
@ -99,7 +99,35 @@ public class ZipFile {
|
||||
return in;
|
||||
|
||||
case Deflated:
|
||||
return new InflaterInputStream(in, new Inflater(true));
|
||||
return new InflaterInputStream(in, new Inflater(true)) {
|
||||
int remaining = uncompressedSize(window, pointer);
|
||||
|
||||
public int read() throws IOException {
|
||||
int c = super.read();
|
||||
if (c >= 0) {
|
||||
-- remaining;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public int read(byte[] buffer) throws IOException {
|
||||
return read(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
public int read(byte[] buffer, int offset, int length)
|
||||
throws IOException
|
||||
{
|
||||
int c = super.read(buffer, offset, length);
|
||||
if (c > 0) {
|
||||
remaining -= c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public int available() {
|
||||
return remaining;
|
||||
}
|
||||
};
|
||||
|
||||
default:
|
||||
throw new IOException();
|
||||
|
@ -73,8 +73,6 @@ typedef unsigned __int64 uint64_t;
|
||||
|
||||
#endif // not _MSC_VER
|
||||
|
||||
namespace {
|
||||
|
||||
inline void
|
||||
throwNew(JNIEnv* e, const char* class_, const char* message, ...)
|
||||
{
|
||||
@ -149,7 +147,4 @@ class RuntimeArray {
|
||||
|
||||
#endif // not _MSC_VER
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif//JNI_UTIL
|
||||
|
50
classpath/sun/misc/Unsafe.java
Normal file
50
classpath/sun/misc/Unsafe.java
Normal file
@ -0,0 +1,50 @@
|
||||
package sun.misc;
|
||||
|
||||
public final class Unsafe {
|
||||
private void Unsafe() { }
|
||||
|
||||
private static final Unsafe Instance = new Unsafe();
|
||||
|
||||
public static Unsafe getUnsafe() {
|
||||
return Instance;
|
||||
}
|
||||
|
||||
public native long allocateMemory(long bytes);
|
||||
|
||||
public native void setMemory
|
||||
(Object base, long offset, long count, byte value);
|
||||
|
||||
public native void freeMemory(long address);
|
||||
|
||||
public native byte getByte(long address);
|
||||
|
||||
public native void putByte(long address, byte x);
|
||||
|
||||
public native short getShort(long address);
|
||||
|
||||
public native void putShort(long address, short x);
|
||||
|
||||
public native char getChar(long address);
|
||||
|
||||
public native void putChar(long address, char x);
|
||||
|
||||
public native int getInt(long address);
|
||||
|
||||
public native void putInt(long address, int x);
|
||||
|
||||
public native long getLong(long address);
|
||||
|
||||
public native void putLong(long address, long x);
|
||||
|
||||
public native float getFloat(long address);
|
||||
|
||||
public native void putFloat(long address, float x);
|
||||
|
||||
public native double getDouble(long address);
|
||||
|
||||
public native void putDouble(long address, double x);
|
||||
|
||||
public native long getAddress(long address);
|
||||
|
||||
public native void putAddress(long address, long x);
|
||||
}
|
5
hello/Hello.java
Normal file
5
hello/Hello.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class Hello {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("hello, world!");
|
||||
}
|
||||
}
|
BIN
hello/LzmaDec.o
Normal file
BIN
hello/LzmaDec.o
Normal file
Binary file not shown.
BIN
hello/bootimage-bin.o
Normal file
BIN
hello/bootimage-bin.o
Normal file
Binary file not shown.
91
hello/bootimage-main.cpp
Normal file
91
hello/bootimage-main.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "stdint.h"
|
||||
#include "jni.h"
|
||||
|
||||
#if (defined __MINGW32__) || (defined _MSC_VER)
|
||||
# define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define EXPORT __attribute__ ((visibility("default")))
|
||||
#endif
|
||||
|
||||
#if (! defined __x86_64__) && ((defined __MINGW32__) || (defined _MSC_VER))
|
||||
# define BOOTIMAGE_BIN(x) binary_bootimage_bin_##x
|
||||
# define CODEIMAGE_BIN(x) binary_codeimage_bin_##x
|
||||
#else
|
||||
# define BOOTIMAGE_BIN(x) _binary_bootimage_bin_##x
|
||||
# define CODEIMAGE_BIN(x) _binary_codeimage_bin_##x
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern const uint8_t BOOTIMAGE_BIN(start)[];
|
||||
extern const uint8_t BOOTIMAGE_BIN(end)[];
|
||||
|
||||
EXPORT const uint8_t*
|
||||
bootimageBin(unsigned* size)
|
||||
{
|
||||
*size = BOOTIMAGE_BIN(end) - BOOTIMAGE_BIN(start);
|
||||
return BOOTIMAGE_BIN(start);
|
||||
}
|
||||
|
||||
extern const uint8_t CODEIMAGE_BIN(start)[];
|
||||
extern const uint8_t CODEIMAGE_BIN(end)[];
|
||||
|
||||
EXPORT const uint8_t*
|
||||
codeimageBin(unsigned* size)
|
||||
{
|
||||
*size = CODEIMAGE_BIN(end) - CODEIMAGE_BIN(start);
|
||||
return CODEIMAGE_BIN(start);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
int
|
||||
main(int ac, const char** av)
|
||||
{
|
||||
JavaVMInitArgs vmArgs;
|
||||
vmArgs.version = JNI_VERSION_1_2;
|
||||
vmArgs.nOptions = 2;
|
||||
vmArgs.ignoreUnrecognized = JNI_TRUE;
|
||||
|
||||
JavaVMOption options[vmArgs.nOptions];
|
||||
vmArgs.options = options;
|
||||
|
||||
options[0].optionString
|
||||
= const_cast<char*>("-Davian.bootimage=lzma:bootimageBin");
|
||||
|
||||
options[1].optionString
|
||||
= const_cast<char*>("-Davian.codeimage=codeimageBin");
|
||||
|
||||
JavaVM* vm;
|
||||
void* env;
|
||||
JNI_CreateJavaVM(&vm, &env, &vmArgs);
|
||||
JNIEnv* e = static_cast<JNIEnv*>(env);
|
||||
|
||||
jclass c = e->FindClass("Hello");
|
||||
if (not e->ExceptionCheck()) {
|
||||
jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
|
||||
if (not e->ExceptionCheck()) {
|
||||
jclass stringClass = e->FindClass("java/lang/String");
|
||||
if (not e->ExceptionCheck()) {
|
||||
jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
|
||||
if (not e->ExceptionCheck()) {
|
||||
for (int i = 1; i < ac; ++i) {
|
||||
e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
|
||||
}
|
||||
|
||||
e->CallStaticVoidMethod(c, m, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int exitCode = 0;
|
||||
if (e->ExceptionCheck()) {
|
||||
exitCode = -1;
|
||||
e->ExceptionDescribe();
|
||||
}
|
||||
|
||||
vm->DestroyJavaVM();
|
||||
|
||||
return exitCode;
|
||||
}
|
BIN
hello/builtin.o
Normal file
BIN
hello/builtin.o
Normal file
Binary file not shown.
BIN
hello/classpath-avian.o
Normal file
BIN
hello/classpath-avian.o
Normal file
Binary file not shown.
BIN
hello/codeimage-bin.o
Normal file
BIN
hello/codeimage-bin.o
Normal file
Binary file not shown.
BIN
hello/compile-x86-asm.o
Normal file
BIN
hello/compile-x86-asm.o
Normal file
Binary file not shown.
BIN
hello/compile.o
Normal file
BIN
hello/compile.o
Normal file
Binary file not shown.
BIN
hello/compiler.o
Normal file
BIN
hello/compiler.o
Normal file
Binary file not shown.
BIN
hello/finder.o
Normal file
BIN
hello/finder.o
Normal file
Binary file not shown.
BIN
hello/heap.o
Normal file
BIN
hello/heap.o
Normal file
Binary file not shown.
BIN
hello/hello
Executable file
BIN
hello/hello
Executable file
Binary file not shown.
BIN
hello/java-io.o
Normal file
BIN
hello/java-io.o
Normal file
Binary file not shown.
BIN
hello/java-lang.o
Normal file
BIN
hello/java-lang.o
Normal file
Binary file not shown.
BIN
hello/java-net.o
Normal file
BIN
hello/java-net.o
Normal file
Binary file not shown.
BIN
hello/java-nio.o
Normal file
BIN
hello/java-nio.o
Normal file
Binary file not shown.
BIN
hello/java-util-zip.o
Normal file
BIN
hello/java-util-zip.o
Normal file
Binary file not shown.
BIN
hello/java-util.o
Normal file
BIN
hello/java-util.o
Normal file
Binary file not shown.
BIN
hello/jnienv.o
Normal file
BIN
hello/jnienv.o
Normal file
Binary file not shown.
BIN
hello/lzma-decode.o
Normal file
BIN
hello/lzma-decode.o
Normal file
Binary file not shown.
BIN
hello/machine.o
Normal file
BIN
hello/machine.o
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user