mirror of
https://github.com/corda/corda.git
synced 2025-02-02 01:08:09 +00:00
Merge commit 'origin/master' into arm
This commit is contained in:
commit
cfc09f8fdb
@ -128,7 +128,7 @@ public class Continuations {
|
|||||||
* <code>receiver.receive(Callback)</code>, propagate the exception
|
* <code>receiver.receive(Callback)</code>, propagate the exception
|
||||||
* thrown by that method, return the result passed to the
|
* thrown by that method, return the result passed to the
|
||||||
* handleResult(T) method of the continuation, or throw the
|
* handleResult(T) method of the continuation, or throw the
|
||||||
* exception passed to the handleException(Throwable) of the
|
* exception passed to the handleException(Throwable) method of the
|
||||||
* continuation.
|
* continuation.
|
||||||
*/
|
*/
|
||||||
public static native <T> T callWithCurrentContinuation
|
public static native <T> T callWithCurrentContinuation
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
# include <share.h>
|
# include <share.h>
|
||||||
|
|
||||||
|
# define ACCESS _waccess
|
||||||
# define CLOSE _close
|
# define CLOSE _close
|
||||||
# define READ _read
|
# define READ _read
|
||||||
# define WRITE _write
|
# define WRITE _write
|
||||||
@ -56,6 +57,7 @@ typedef wchar_t char_t;
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include "sys/mman.h"
|
# include "sys/mman.h"
|
||||||
|
|
||||||
|
# define ACCESS access
|
||||||
# define OPEN open
|
# define OPEN open
|
||||||
# define CLOSE close
|
# define CLOSE close
|
||||||
# define READ read
|
# define READ read
|
||||||
@ -377,6 +379,31 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jboolean JNICALL
|
||||||
|
Java_java_io_File_canRead(JNIEnv* e, jclass, jstring path)
|
||||||
|
{
|
||||||
|
string_t chars = getChars(e, path);
|
||||||
|
if (chars) {
|
||||||
|
int r = ACCESS(chars, R_OK);
|
||||||
|
releaseChars(e, path, chars);
|
||||||
|
return (r == 0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jboolean JNICALL
|
||||||
|
Java_java_io_File_canWrite(JNIEnv* e, jclass, jstring path)
|
||||||
|
{
|
||||||
|
string_t chars = getChars(e, path);
|
||||||
|
if (chars) {
|
||||||
|
int r = ACCESS(chars, W_OK);
|
||||||
|
releaseChars(e, path, chars);
|
||||||
|
return (r == 0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT jboolean JNICALL
|
extern "C" JNIEXPORT jboolean JNICALL
|
||||||
Java_java_io_File_rename(JNIEnv* e, jclass, jstring old, jstring new_)
|
Java_java_io_File_rename(JNIEnv* e, jclass, jstring old, jstring new_)
|
||||||
{
|
{
|
||||||
|
@ -36,9 +36,6 @@
|
|||||||
# define isnan _isnan
|
# define isnan _isnan
|
||||||
# define isfinite _finite
|
# define isfinite _finite
|
||||||
# define strtof strtod
|
# define strtof strtod
|
||||||
# define FTIME _ftime_s
|
|
||||||
# else
|
|
||||||
# define FTIME _ftime
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else // not PLATFORM_WINDOWS
|
#else // not PLATFORM_WINDOWS
|
||||||
@ -234,7 +231,8 @@ extern "C" JNIEXPORT void JNICALL
|
|||||||
Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
||||||
jobjectArray command, jlongArray process)
|
jobjectArray command, jlongArray process)
|
||||||
{
|
{
|
||||||
char** argv = static_cast<char**>(malloc((e->GetArrayLength(command) + 1) * sizeof(char*)));
|
char** argv = static_cast<char**>
|
||||||
|
(malloc((e->GetArrayLength(command) + 1) * sizeof(char*)));
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < e->GetArrayLength(command); i++){
|
for(i = 0; i < e->GetArrayLength(command); i++){
|
||||||
jstring element = (jstring) e->GetObjectArrayElement(command, i);
|
jstring element = (jstring) e->GetObjectArrayElement(command, i);
|
||||||
@ -255,11 +253,11 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
|
|||||||
makePipe(e, out);
|
makePipe(e, out);
|
||||||
if(e->ExceptionCheck()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
jlong outDescriptor = static_cast<jlong>(out[1]);
|
jlong outDescriptor = static_cast<jlong>(out[1]);
|
||||||
e->SetLongArrayRegion(process, 1, 1, &outDescriptor);
|
e->SetLongArrayRegion(process, 2, 1, &outDescriptor);
|
||||||
makePipe(e, err);
|
makePipe(e, err);
|
||||||
if(e->ExceptionCheck()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
jlong errDescriptor = static_cast<jlong>(err[0]);
|
jlong errDescriptor = static_cast<jlong>(err[0]);
|
||||||
e->SetLongArrayRegion(process, 1, 1, &errDescriptor);
|
e->SetLongArrayRegion(process, 3, 1, &errDescriptor);
|
||||||
makePipe(e, msg);
|
makePipe(e, msg);
|
||||||
if(e->ExceptionCheck()) return;
|
if(e->ExceptionCheck()) return;
|
||||||
if(fcntl(msg[1], F_SETFD, FD_CLOEXEC) != 0) {
|
if(fcntl(msg[1], F_SETFD, FD_CLOEXEC) != 0) {
|
||||||
@ -468,9 +466,13 @@ extern "C" JNIEXPORT jlong JNICALL
|
|||||||
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
|
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
_timeb tb;
|
// We used to use _ftime here, but that only gives us 1-second
|
||||||
FTIME(&tb);
|
// resolution on Windows 7. _ftime_s might work better, but MinGW
|
||||||
return (static_cast<jlong>(tb.time) * 1000) + static_cast<jlong>(tb.millitm);
|
// doesn't have it as of this writing. So we use this mess instead:
|
||||||
|
FILETIME time;
|
||||||
|
GetSystemTimeAsFileTime(&time);
|
||||||
|
return (((static_cast<jlong>(time.dwHighDateTime) << 32)
|
||||||
|
| time.dwLowDateTime) / 10000) - 11644473600000LL;
|
||||||
#else
|
#else
|
||||||
timeval tv = { 0, 0 };
|
timeval tv = { 0, 0 };
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
|
@ -60,7 +60,19 @@ public class File {
|
|||||||
public boolean isFile() {
|
public boolean isFile() {
|
||||||
return isFile(path);
|
return isFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static native boolean canRead(String path);
|
||||||
|
|
||||||
|
public boolean canRead() {
|
||||||
|
return canRead(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native boolean canWrite(String path);
|
||||||
|
|
||||||
|
public boolean canWrite() {
|
||||||
|
return canWrite(path);
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
int index = path.lastIndexOf(FileSeparator);
|
int index = path.lastIndexOf(FileSeparator);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -79,6 +79,10 @@ public class ObjectInputStream extends InputStream {
|
|||||||
read('d');
|
read('d');
|
||||||
return readDoubleToken();
|
return readDoubleToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void defaultReadObject() throws IOException {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
private void skipSpace() throws IOException {
|
private void skipSpace() throws IOException {
|
||||||
int c;
|
int c;
|
||||||
|
@ -82,6 +82,10 @@ public class ObjectOutputStream extends OutputStream {
|
|||||||
out.print(v);
|
out.print(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void defaultWriteObject() throws IOException {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
private void writeObject(Object o, IdentityHashMap<Object, Integer> map,
|
private void writeObject(Object o, IdentityHashMap<Object, Integer> map,
|
||||||
int nextId)
|
int nextId)
|
||||||
throws IOException
|
throws IOException
|
||||||
|
@ -31,6 +31,7 @@ public class PrintStream extends OutputStream {
|
|||||||
public synchronized void print(String s) {
|
public synchronized void print(String s) {
|
||||||
try {
|
try {
|
||||||
out.write(s.getBytes());
|
out.write(s.getBytes());
|
||||||
|
if (autoFlush) flush();
|
||||||
} catch (IOException e) { }
|
} catch (IOException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
classpath/java/lang/SecurityManager.java
Normal file
30
classpath/java/lang/SecurityManager.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright (c) 2010, 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.AccessController;
|
||||||
|
import java.security.Permission;
|
||||||
|
import java.security.SecurityPermission;
|
||||||
|
|
||||||
|
public class SecurityManager {
|
||||||
|
|
||||||
|
public SecurityManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkPermission(Permission perm) {
|
||||||
|
AccessController.checkPermission(perm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkSecurityAccess(String target) {
|
||||||
|
checkPermission(new SecurityPermission(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -236,19 +236,31 @@ public final class String
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toLowerCase() {
|
public String toLowerCase() {
|
||||||
char[] b = new char[length];
|
for (int j = 0; j < length; ++j) {
|
||||||
for (int i = 0; i < length; ++i) {
|
char ch = charAt(j);
|
||||||
b[i] = Character.toLowerCase(charAt(i));
|
if (Character.toLowerCase(ch) != ch) {
|
||||||
|
char[] b = new char[length];
|
||||||
|
for (int i = 0; i < length; ++i) {
|
||||||
|
b[i] = Character.toLowerCase(charAt(i));
|
||||||
|
}
|
||||||
|
return new String(b, 0, length, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new String(b, 0, length, false);
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toUpperCase() {
|
public String toUpperCase() {
|
||||||
char[] b = new char[length];
|
for (int j = 0; j < length; ++j) {
|
||||||
for (int i = 0; i < length; ++i) {
|
char ch = charAt(j);
|
||||||
b[i] = Character.toUpperCase(charAt(i));
|
if (Character.toUpperCase(ch) != ch) {
|
||||||
|
char[] b = new char[length];
|
||||||
|
for (int i = 0; i < length; ++i) {
|
||||||
|
b[i] = Character.toUpperCase(charAt(i));
|
||||||
|
}
|
||||||
|
return new String(b, 0, length, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new String(b, 0, length, false);
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int indexOf(int c) {
|
public int indexOf(int c) {
|
||||||
@ -581,11 +593,19 @@ public final class String
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toUpperCase(Locale locale) {
|
public String toUpperCase(Locale locale) {
|
||||||
throw new UnsupportedOperationException();
|
if (locale == Locale.ENGLISH) {
|
||||||
|
return toUpperCase();
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException("toUpperCase("+locale+')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toLowerCase(Locale locale) {
|
public String toLowerCase(Locale locale) {
|
||||||
throw new UnsupportedOperationException();
|
if (locale == Locale.ENGLISH) {
|
||||||
|
return toLowerCase();
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException("toLowerCase("+locale+')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(Locale locale, String format, Object ... args) {
|
public static String format(Locale locale, String format, Object ... args) {
|
||||||
|
@ -22,6 +22,7 @@ import java.util.Properties;
|
|||||||
public abstract class System {
|
public abstract class System {
|
||||||
private static Property properties;
|
private static Property properties;
|
||||||
|
|
||||||
|
private static SecurityManager securityManager;
|
||||||
// static {
|
// static {
|
||||||
// loadLibrary("natives");
|
// loadLibrary("natives");
|
||||||
// }
|
// }
|
||||||
@ -118,6 +119,14 @@ public abstract class System {
|
|||||||
public static void exit(int code) {
|
public static void exit(int code) {
|
||||||
Runtime.getRuntime().exit(code);
|
Runtime.getRuntime().exit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SecurityManager getSecurityManager() {
|
||||||
|
return securityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setSecurityManager(SecurityManager securityManager) {
|
||||||
|
System.securityManager = securityManager;
|
||||||
|
}
|
||||||
|
|
||||||
private static class Property {
|
private static class Property {
|
||||||
public final String name;
|
public final String name;
|
||||||
|
@ -40,7 +40,7 @@ public class ServerSocketChannel extends SelectableChannel {
|
|||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SocketChannel accept() throws Exception {
|
public SocketChannel accept() throws IOException {
|
||||||
SocketChannel c = new SocketChannel();
|
SocketChannel c = new SocketChannel();
|
||||||
c.socket = doAccept();
|
c.socket = doAccept();
|
||||||
c.connected = true;
|
c.connected = true;
|
||||||
|
@ -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
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
for any purpose with or without fee is hereby granted, provided
|
for any purpose with or without fee is hereby granted, provided
|
||||||
@ -21,5 +21,9 @@ public class AccessController {
|
|||||||
public static Object doPrivileged (PrivilegedAction action) {
|
public static Object doPrivileged (PrivilegedAction action) {
|
||||||
return action.run();
|
return action.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkPermission(Permission perm) throws AccessControlException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,10 @@
|
|||||||
|
|
||||||
package java.security;
|
package java.security;
|
||||||
|
|
||||||
public class AllPermission extends Permission { }
|
public class AllPermission extends Permission {
|
||||||
|
public AllPermission() {
|
||||||
|
super("<all>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
19
classpath/java/security/BasicPermission.java
Normal file
19
classpath/java/security/BasicPermission.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* Copyright (c) 2010, 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.security;
|
||||||
|
|
||||||
|
public class BasicPermission extends Permission {
|
||||||
|
|
||||||
|
public BasicPermission(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,22 @@
|
|||||||
package java.security;
|
package java.security;
|
||||||
|
|
||||||
public abstract class Permission {
|
public abstract class Permission {
|
||||||
|
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
public Permission(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName() + '['+name+']';
|
||||||
|
}
|
||||||
|
|
||||||
public PermissionCollection newPermissionCollection() {
|
public PermissionCollection newPermissionCollection() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
19
classpath/java/security/SecurityPermission.java
Normal file
19
classpath/java/security/SecurityPermission.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* Copyright (c) 2010, 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.security;
|
||||||
|
|
||||||
|
public class SecurityPermission extends BasicPermission {
|
||||||
|
|
||||||
|
public SecurityPermission(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -148,5 +148,11 @@ public class Arrays {
|
|||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> void fill(T[] array, T value) {
|
||||||
|
for (int i=0;i<array.length;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
package java.util;
|
package java.util;
|
||||||
|
|
||||||
public class Collections {
|
public class Collections {
|
||||||
|
|
||||||
private Collections() { }
|
private Collections() { }
|
||||||
|
|
||||||
public static void shuffle(List list, Random random) {
|
public static void shuffle(List list, Random random) {
|
||||||
@ -84,6 +85,10 @@ public class Collections {
|
|||||||
return new IteratorEnumeration<T> (c.iterator());
|
return new IteratorEnumeration<T> (c.iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {
|
||||||
|
return new ReverseComparator<T>(cmp);
|
||||||
|
}
|
||||||
|
|
||||||
static class IteratorEnumeration<T> implements Enumeration<T> {
|
static class IteratorEnumeration<T> implements Enumeration<T> {
|
||||||
private final Iterator<T> it;
|
private final Iterator<T> it;
|
||||||
|
|
||||||
@ -379,4 +384,20 @@ public class Collections {
|
|||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class ReverseComparator<T> implements Comparator<T> {
|
||||||
|
|
||||||
|
Comparator<T> cmp;
|
||||||
|
|
||||||
|
public ReverseComparator(Comparator<T> cmp) {
|
||||||
|
this.cmp = cmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(T o1, T o2) {
|
||||||
|
return - cmp.compare(o1, o2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
47
classpath/java/util/ConcurrentModificationException.java
Normal file
47
classpath/java/util/ConcurrentModificationException.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* Copyright (c) 2010, 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zsombor
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConcurrentModificationException extends RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public ConcurrentModificationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public ConcurrentModificationException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cause
|
||||||
|
*/
|
||||||
|
public ConcurrentModificationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ConcurrentModificationException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -269,8 +269,10 @@ public class HashMap<K, V> implements Map<K, V> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(V value) {
|
public V setValue(V value) {
|
||||||
|
V old = this.value;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap.Cell<K, V> next() {
|
public HashMap.Cell<K, V> next() {
|
||||||
|
@ -40,6 +40,6 @@ public interface Map<K, V> {
|
|||||||
|
|
||||||
public V getValue();
|
public V getValue();
|
||||||
|
|
||||||
public void setValue(V value);
|
public V setValue(V value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,15 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
public class Properties extends Hashtable {
|
public class Properties extends Hashtable {
|
||||||
public void load(InputStream in) throws IOException {
|
public void load(InputStream in) throws IOException {
|
||||||
new Parser().parse(in, this);
|
new InputStreamParser(in).parse(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load(Reader reader) throws IOException {
|
||||||
|
new ReaderParser(reader).parse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void store(OutputStream out, String comment) throws IOException {
|
public void store(OutputStream out, String comment) throws IOException {
|
||||||
@ -53,7 +58,7 @@ public class Properties extends Hashtable {
|
|||||||
return keys();
|
return keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Parser {
|
private abstract static class Parser {
|
||||||
private StringBuilder key = null;
|
private StringBuilder key = null;
|
||||||
private StringBuilder value = null;
|
private StringBuilder value = null;
|
||||||
private StringBuilder current = null;
|
private StringBuilder current = null;
|
||||||
@ -79,13 +84,15 @@ public class Properties extends Hashtable {
|
|||||||
key = value = current = null;
|
key = value = current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parse(InputStream in, Map map)
|
abstract int readCharacter() throws IOException;
|
||||||
|
|
||||||
|
void parse(Map map)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
boolean escaped = false;
|
boolean escaped = false;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = in.read()) != -1) {
|
while ((c = readCharacter()) != -1) {
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
escaped = false;
|
escaped = false;
|
||||||
@ -98,7 +105,7 @@ public class Properties extends Hashtable {
|
|||||||
case '#':
|
case '#':
|
||||||
case '!':
|
case '!':
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
while ((c = in.read()) != -1 && c != '\n');
|
while ((c = readCharacter()) != -1 && c != '\n');
|
||||||
} else {
|
} else {
|
||||||
append(c);
|
append(c);
|
||||||
}
|
}
|
||||||
@ -153,4 +160,32 @@ public class Properties extends Hashtable {
|
|||||||
finishLine(map);
|
finishLine(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class InputStreamParser extends Parser {
|
||||||
|
InputStream in;
|
||||||
|
|
||||||
|
|
||||||
|
public InputStreamParser(InputStream in) {
|
||||||
|
this.in = in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int readCharacter() throws IOException {
|
||||||
|
return in.read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ReaderParser extends Parser {
|
||||||
|
Reader in;
|
||||||
|
|
||||||
|
public ReaderParser(Reader in) {
|
||||||
|
this.in = in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int readCharacter() throws IOException {
|
||||||
|
return in.read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,12 @@ public class TreeMap<K,V> implements Map<K,V> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(V value) {
|
public V setValue(V value) {
|
||||||
|
V old = this.value;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class KeySet implements Set<K> {
|
private class KeySet implements Set<K> {
|
||||||
|
@ -114,8 +114,10 @@ public class WeakHashMap<K, V> implements Map<K, V> {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(V value) {
|
public V setValue(V value) {
|
||||||
|
V old = this.value;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap.Cell<K, V> next() {
|
public HashMap.Cell<K, V> next() {
|
||||||
|
@ -115,23 +115,34 @@ public class Pattern {
|
|||||||
List<CharSequence> list = new LinkedList();
|
List<CharSequence> list = new LinkedList();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int trailing = 0;
|
int trailing = 0;
|
||||||
while (index < input.length() && list.size() < limit) {
|
int patternLength = pattern.length();
|
||||||
int i = indexOf(input, pattern, index);
|
while (index < input.length() && list.size() < limit - 1) {
|
||||||
|
int i;
|
||||||
|
if (patternLength == 0) {
|
||||||
|
if (list.size() == 0) {
|
||||||
|
i = 0;
|
||||||
|
} else {
|
||||||
|
i = index + 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
i = indexOf(input, pattern, index);
|
||||||
|
}
|
||||||
|
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
if (i == index) {
|
if (patternLength != 0 && i == index) {
|
||||||
++ trailing;
|
++ trailing;
|
||||||
} else {
|
} else {
|
||||||
trailing = 0;
|
trailing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(input.subSequence(index, i));
|
list.add(input.subSequence(index, i));
|
||||||
index = i + pattern.length();
|
index = i + patternLength;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strip && index == input.length()) {
|
if (strip && index > 0 && index == input.length()) {
|
||||||
++ trailing;
|
++ trailing;
|
||||||
} else {
|
} else {
|
||||||
trailing = 0;
|
trailing = 0;
|
||||||
|
@ -65,13 +65,16 @@ const int AltSegFaultSignal = SIGBUS;
|
|||||||
const int AltSegFaultSignal = InvalidSignal;
|
const int AltSegFaultSignal = InvalidSignal;
|
||||||
#endif
|
#endif
|
||||||
const unsigned AltSegFaultSignalIndex = 3;
|
const unsigned AltSegFaultSignalIndex = 3;
|
||||||
|
const int PipeSignal = SIGPIPE;
|
||||||
|
const unsigned PipeSignalIndex = 4;
|
||||||
|
|
||||||
const int signals[] = { VisitSignal,
|
const int signals[] = { VisitSignal,
|
||||||
SegFaultSignal,
|
SegFaultSignal,
|
||||||
InterruptSignal,
|
InterruptSignal,
|
||||||
AltSegFaultSignal };
|
AltSegFaultSignal,
|
||||||
|
PipeSignal };
|
||||||
|
|
||||||
const unsigned SignalCount = 4;
|
const unsigned SignalCount = 5;
|
||||||
|
|
||||||
class MySystem;
|
class MySystem;
|
||||||
MySystem* system;
|
MySystem* system;
|
||||||
@ -530,6 +533,7 @@ class MySystem: public System {
|
|||||||
system = this;
|
system = this;
|
||||||
|
|
||||||
registerHandler(&nullHandler, InterruptSignalIndex);
|
registerHandler(&nullHandler, InterruptSignalIndex);
|
||||||
|
registerHandler(&nullHandler, PipeSignalIndex);
|
||||||
registerHandler(&nullHandler, VisitSignalIndex);
|
registerHandler(&nullHandler, VisitSignalIndex);
|
||||||
|
|
||||||
expect(this, make(&visitLock) == 0);
|
expect(this, make(&visitLock) == 0);
|
||||||
@ -755,7 +759,9 @@ class MySystem: public System {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// fprintf(stderr, "dlerror: %s\n", dlerror());
|
if (Verbose) {
|
||||||
|
fprintf(stderr, "dlerror opening %s: %s\n", name, dlerror());
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -784,6 +790,7 @@ class MySystem: public System {
|
|||||||
|
|
||||||
registerHandler(0, InterruptSignalIndex);
|
registerHandler(0, InterruptSignalIndex);
|
||||||
registerHandler(0, VisitSignalIndex);
|
registerHandler(0, VisitSignalIndex);
|
||||||
|
registerHandler(0, PipeSignalIndex);
|
||||||
system = 0;
|
system = 0;
|
||||||
|
|
||||||
::free(this);
|
::free(this);
|
||||||
@ -860,6 +867,10 @@ handleSignal(int signal, siginfo_t* info, void* context)
|
|||||||
index = InterruptSignalIndex;
|
index = InterruptSignalIndex;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case PipeSignal: {
|
||||||
|
index = PipeSignalIndex;
|
||||||
|
} break;
|
||||||
|
|
||||||
default: abort();
|
default: abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,6 +882,7 @@ handleSignal(int signal, siginfo_t* info, void* context)
|
|||||||
switch (signal) {
|
switch (signal) {
|
||||||
case VisitSignal:
|
case VisitSignal:
|
||||||
case InterruptSignal:
|
case InterruptSignal:
|
||||||
|
case PipeSignal:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -3,6 +3,24 @@ public class Strings {
|
|||||||
if (! v) throw new RuntimeException();
|
if (! v) throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean equal(Object a, Object b) {
|
||||||
|
return a == b || (a != null && a.equals(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean arraysEqual(Object[] a, Object[] b) {
|
||||||
|
if (a.length != b.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < a.length; ++i) {
|
||||||
|
if (! equal(a[i], b[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
expect(new String(new byte[] { 99, 111, 109, 46, 101, 99, 111, 118, 97,
|
expect(new String(new byte[] { 99, 111, 109, 46, 101, 99, 111, 118, 97,
|
||||||
116, 101, 46, 110, 97, 116, 46, 98, 117,
|
116, 101, 46, 110, 97, 116, 46, 98, 117,
|
||||||
@ -13,6 +31,31 @@ public class Strings {
|
|||||||
expect(months.split("\u00ae").length == 3);
|
expect(months.split("\u00ae").length == 3);
|
||||||
expect(months.replaceAll("\u00ae", ".").equals("Jan.Feb.Mar."));
|
expect(months.replaceAll("\u00ae", ".").equals("Jan.Feb.Mar."));
|
||||||
|
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 0), new String[] { "", "x", "y", "z" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 1), new String[] { "xyz" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 2), new String[] { "", "xyz" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 3), new String[] { "", "x", "yz" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 4), new String[] { "", "x", "y", "z" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 5), new String[] { "", "x", "y", "z", "" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", 6), new String[] { "", "x", "y", "z", "" }));
|
||||||
|
expect(arraysEqual
|
||||||
|
("xyz".split("", -1), new String[] { "", "x", "y", "z", "" }));
|
||||||
|
|
||||||
|
expect(arraysEqual("".split("xyz", 0), new String[] { "" }));
|
||||||
|
expect(arraysEqual("".split("xyz", 1), new String[] { "" }));
|
||||||
|
expect(arraysEqual("".split("xyz", -1), new String[] { "" }));
|
||||||
|
|
||||||
|
expect(arraysEqual("".split("", 0), new String[] { "" }));
|
||||||
|
expect(arraysEqual("".split("", 1), new String[] { "" }));
|
||||||
|
expect(arraysEqual("".split("", -1), new String[] { "" }));
|
||||||
|
|
||||||
expect("foo_foofoo__foo".replaceAll("_", "__")
|
expect("foo_foofoo__foo".replaceAll("_", "__")
|
||||||
.equals("foo__foofoo____foo"));
|
.equals("foo__foofoo____foo"));
|
||||||
|
|
||||||
|
6
vm.pro
6
vm.pro
@ -97,3 +97,9 @@
|
|||||||
|
|
||||||
-keepnames public class avian.Callback
|
-keepnames public class avian.Callback
|
||||||
-keepnames public class java.util.concurrent.Callable
|
-keepnames public class java.util.concurrent.Callable
|
||||||
|
|
||||||
|
# Proguard gets confused about clone() and array classes (http://sourceforge.net/tracker/index.php?func=detail&aid=2851344&group_id=54750&atid=474704):
|
||||||
|
|
||||||
|
-keepclassmembers class java.lang.Object {
|
||||||
|
protected java.lang.Object clone();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user