mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
remove GNU Classpath and Apache Harmony compatibility code
Rather than try to support mixing Avian's core classes with those of an external class library -- which necessitates adding a lot of stub methods which throw UnsupportedOperationExceptions, among other comprimises -- we're looking to support such external class libraries in their unmodified forms. The latter strategy has already proven successful with OpenJDK's class library. Thus, this commit removes the stub methods, etc., which not only cleans up the code but avoids misleading application developers as to what classes and methods Avian's built-in class library supports.
This commit is contained in:
parent
8c789fb92c
commit
c1c9d2111b
@ -21,11 +21,9 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.GenericDeclaration;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.io.InputStream;
|
||||
@ -37,9 +35,7 @@ import java.security.ProtectionDomain;
|
||||
import java.security.Permissions;
|
||||
import java.security.AllPermission;
|
||||
|
||||
public final class Class <T>
|
||||
implements Type, GenericDeclaration, AnnotatedElement
|
||||
{
|
||||
public final class Class <T> implements Type, AnnotatedElement {
|
||||
private static final int PrimitiveFlag = 1 << 5;
|
||||
|
||||
public final VMClass vmClass;
|
||||
@ -667,30 +663,6 @@ public final class Class <T>
|
||||
return array;
|
||||
}
|
||||
|
||||
public boolean isEnum() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public TypeVariable<Class<T>>[] getTypeParameters() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Method getEnclosingMethod() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Constructor getEnclosingConstructor() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Class getEnclosingClass() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Class[] getDeclaredClasses() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public ProtectionDomain getProtectionDomain() {
|
||||
Permissions p = new Permissions();
|
||||
p.add(new AllPermission());
|
||||
|
@ -13,7 +13,6 @@ package java.lang;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Comparator;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
import java.io.Serializable;
|
||||
import avian.Utf8;
|
||||
@ -507,9 +506,7 @@ public final class String
|
||||
}
|
||||
|
||||
public static String valueOf(int v) {
|
||||
// use Integer.toString(int, int), because GNU Classpath's
|
||||
// Integer.toString(int) just calls String.valueOf(int):
|
||||
return Integer.toString(v, 10);
|
||||
return Integer.toString(v);
|
||||
}
|
||||
|
||||
public static String valueOf(long v) {
|
||||
@ -575,37 +572,4 @@ public final class String
|
||||
public int codePointCount(int start, int end) {
|
||||
return Character.codePointCount(this, start, end);
|
||||
}
|
||||
|
||||
public String replace(CharSequence match, CharSequence replacement) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String toUpperCase(Locale locale) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String toLowerCase(Locale locale) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static String format(Locale locale, String format, Object ... args) {
|
||||
return new Formatter(locale).format(format, args).toString();
|
||||
}
|
||||
|
||||
public static String format(String format, Object ... args) {
|
||||
return format(Locale.getDefault(), format, args);
|
||||
}
|
||||
|
||||
// for GNU Classpath compatibility:
|
||||
static char[] zeroBasedStringValue(String s) {
|
||||
if (s.offset == 0) {
|
||||
if (s.data instanceof char[]) {
|
||||
char[] data = (char[]) s.data;
|
||||
if (data.length == s.length) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return s.toCharArray();
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,8 @@ public class Thread implements Runnable {
|
||||
private Object sleepLock;
|
||||
private ClassLoader classLoader;
|
||||
private UncaughtExceptionHandler exceptionHandler;
|
||||
|
||||
// package private for GNU Classpath, which inexplicably bypasses
|
||||
// the accessor methods:
|
||||
String name;
|
||||
ThreadGroup group;
|
||||
private String name;
|
||||
private ThreadGroup group;
|
||||
|
||||
private static UncaughtExceptionHandler defaultExceptionHandler;
|
||||
|
||||
@ -287,22 +284,6 @@ public class Thread implements Runnable {
|
||||
return peer;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void stop(Throwable t) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void suspend() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public interface UncaughtExceptionHandler {
|
||||
public void uncaughtException(Thread t, Throwable e);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ package java.lang;
|
||||
import avian.Cell;
|
||||
|
||||
public class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
||||
final ThreadGroup parent; // package private for GNU Classpath compatibility
|
||||
private final ThreadGroup parent;
|
||||
private final String name;
|
||||
private Cell<ThreadGroup> subgroups;
|
||||
|
||||
|
@ -12,9 +12,7 @@ package java.lang.reflect;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public class Constructor<T> extends AccessibleObject
|
||||
implements Member, GenericDeclaration
|
||||
{
|
||||
public class Constructor<T> extends AccessibleObject implements Member {
|
||||
private Method<T> method;
|
||||
|
||||
public Constructor(Method<T> method) {
|
||||
@ -42,10 +40,6 @@ public class Constructor<T> extends AccessibleObject
|
||||
return method.getParameterTypes();
|
||||
}
|
||||
|
||||
public Class[] getExceptionTypes() {
|
||||
return method.getExceptionTypes();
|
||||
}
|
||||
|
||||
public int getModifiers() {
|
||||
return method.getModifiers();
|
||||
}
|
||||
@ -54,10 +48,6 @@ public class Constructor<T> extends AccessibleObject
|
||||
return method.getName();
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
return method.isSynthetic();
|
||||
}
|
||||
|
||||
public <T extends Annotation> T getAnnotation(Class<T> class_) {
|
||||
return method.getAnnotation(class_);
|
||||
}
|
||||
@ -70,14 +60,6 @@ public class Constructor<T> extends AccessibleObject
|
||||
return method.getDeclaredAnnotations();
|
||||
}
|
||||
|
||||
public TypeVariable<Constructor<T>>[] getTypeParameters() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Type[] getGenericParameterTypes() {
|
||||
return method.getGenericParameterTypes();
|
||||
}
|
||||
|
||||
private static native Object make(avian.VMClass c);
|
||||
|
||||
public T newInstance(Object ... arguments)
|
||||
|
@ -254,10 +254,6 @@ public class Field<T> extends AccessibleObject {
|
||||
return getAnnotations();
|
||||
}
|
||||
|
||||
public boolean isEnumConstant() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static native long getPrimitive
|
||||
(Object instance, int code, int offset);
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
/* Copyright (c) 2009, 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.reflect;
|
||||
|
||||
public interface GenericDeclaration {
|
||||
public TypeVariable<?>[] getTypeParameters();
|
||||
}
|
@ -19,6 +19,4 @@ public interface Member {
|
||||
public int getModifiers();
|
||||
|
||||
public String getName();
|
||||
|
||||
public boolean isSynthetic();
|
||||
}
|
||||
|
@ -16,9 +16,7 @@ import avian.SystemClassLoader;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public class Method<T> extends AccessibleObject
|
||||
implements Member, GenericDeclaration
|
||||
{
|
||||
public class Method<T> extends AccessibleObject implements Member {
|
||||
private final VMMethod vmMethod;
|
||||
private boolean accessible;
|
||||
|
||||
@ -200,28 +198,4 @@ public class Method<T> extends AccessibleObject
|
||||
public Annotation[] getDeclaredAnnotations() {
|
||||
return getAnnotations();
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Type[] getGenericParameterTypes() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Type getGenericReturnType() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Class[] getExceptionTypes() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public TypeVariable<Method<T>>[] getTypeParameters() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
/* Copyright (c) 2009, 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.reflect;
|
||||
|
||||
public interface TypeVariable<T extends GenericDeclaration>
|
||||
extends Type
|
||||
{
|
||||
public Type[] getBounds();
|
||||
public T getGenericDeclaration();
|
||||
public String getName();
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/* Copyright (c) 2009, 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 class Formatter {
|
||||
private final Locale locale;
|
||||
|
||||
public Formatter(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public Formatter format(String format, Object ... args) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -36,18 +36,6 @@ public class Matcher {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean requireEnd() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean hitEnd() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean lookingAt() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Matcher reset() {
|
||||
return reset(input);
|
||||
}
|
||||
@ -63,26 +51,6 @@ public class Matcher {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int start(int group) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Pattern pattern() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Matcher region(int start, int end) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int regionEnd() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int regionStart() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String replaceAll(String replacement) {
|
||||
return replace(replacement, Integer.MAX_VALUE);
|
||||
}
|
||||
@ -124,10 +92,6 @@ public class Matcher {
|
||||
return end;
|
||||
}
|
||||
|
||||
public int end(int group) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean find() {
|
||||
return find(end);
|
||||
}
|
||||
@ -143,16 +107,4 @@ public class Matcher {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int groupCount() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String group() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String group(int group) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
@ -92,10 +92,6 @@ public class Pattern {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public static String quote(String s) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String[] split(CharSequence input) {
|
||||
return split(input, 0);
|
||||
}
|
||||
|
30
readme.txt
30
readme.txt
@ -191,36 +191,6 @@ Finally, build with the msvc flag set to the MSVC tool directory:
|
||||
$ make msvc="/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC"
|
||||
|
||||
|
||||
Building with GNU Classpath
|
||||
---------------------------
|
||||
|
||||
** Please note that this feature is still under development and is
|
||||
neither complete nor well-tested. **
|
||||
|
||||
By default, Avian uses its own lightweight class library. However,
|
||||
that library only contains a relatively small subset of the classes
|
||||
and methods included in the JRE. If your application requires
|
||||
features beyond that subset, you may want to tell Avian to use GNU
|
||||
Classpath instead. In order for this to work, you must configure
|
||||
Classpath with "--enable-static" and "--with-pic". For example:
|
||||
|
||||
$ cd classpath-0.98
|
||||
$ ./configure --prefix=/usr/local/classpath-0.98 --disable-plugin \
|
||||
--enable-static --with-pic
|
||||
$ make && make install
|
||||
|
||||
Then, when building Avian, specify the directory where Classpath is
|
||||
installed, e.g.:
|
||||
|
||||
$ cd ../avian
|
||||
$ make clean
|
||||
$ make gnu=/usr/local/classpath-0.98
|
||||
|
||||
This build will use the classes and native code from Classpath, except
|
||||
that certain core classes are replaced with implementations from the
|
||||
Avian class library for compatibility with the VM.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
|
@ -367,7 +367,6 @@ ExceptionCheck(Thread* t)
|
||||
return t->exception != 0;
|
||||
}
|
||||
|
||||
#ifndef AVIAN_GNU
|
||||
jobject JNICALL
|
||||
NewDirectByteBuffer(Thread*, void*, jlong)
|
||||
{
|
||||
@ -385,7 +384,6 @@ GetDirectBufferCapacity(Thread*, jobject)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif// not AVIAN_GNU
|
||||
|
||||
jclass JNICALL
|
||||
GetObjectClass(Thread* t, jobject o)
|
||||
@ -2038,17 +2036,6 @@ append(char** p, const char* value, unsigned length, char tail)
|
||||
|
||||
namespace vm {
|
||||
|
||||
#ifdef AVIAN_GNU
|
||||
jobject JNICALL
|
||||
NewDirectByteBuffer(Thread*, void*, jlong);
|
||||
|
||||
void* JNICALL
|
||||
GetDirectBufferAddress(Thread*, jobject);
|
||||
|
||||
jlong JNICALL
|
||||
GetDirectBufferCapacity(Thread*, jobject);
|
||||
#endif//AVIAN_GNU
|
||||
|
||||
void
|
||||
populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
|
||||
{
|
||||
@ -2081,15 +2068,9 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
|
||||
envTable->ThrowNew = local::ThrowNew;
|
||||
envTable->Throw = local::Throw;
|
||||
envTable->ExceptionCheck = local::ExceptionCheck;
|
||||
#ifdef AVIAN_GNU
|
||||
envTable->NewDirectByteBuffer = vm::NewDirectByteBuffer;
|
||||
envTable->GetDirectBufferAddress = vm::GetDirectBufferAddress;
|
||||
envTable->GetDirectBufferCapacity = vm::GetDirectBufferCapacity;
|
||||
#else
|
||||
envTable->NewDirectByteBuffer = local::NewDirectByteBuffer;
|
||||
envTable->GetDirectBufferAddress = local::GetDirectBufferAddress;
|
||||
envTable->GetDirectBufferCapacity = local::GetDirectBufferCapacity;
|
||||
#endif
|
||||
envTable->DeleteLocalRef = local::DeleteLocalRef;
|
||||
envTable->GetObjectClass = local::GetObjectClass;
|
||||
envTable->IsInstanceOf = local::IsInstanceOf;
|
||||
|
Loading…
Reference in New Issue
Block a user