mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix Avian classpath build
This commit is contained in:
parent
201473cf87
commit
8546ca5670
@ -317,7 +317,7 @@ public class Classes {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
String spec = new String
|
String spec = new String
|
||||||
(vmMethod.spec, 1, vmMethod.spec.length - 1);
|
(vmMethod.spec, 1, vmMethod.spec.length - 2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < spec.length(); ++i) {
|
for (int i = 0; i < spec.length(); ++i) {
|
||||||
@ -353,6 +353,7 @@ public class Classes {
|
|||||||
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int findField(VMClass vmClass, String name) {
|
public static int findField(VMClass vmClass, String name) {
|
||||||
if (vmClass.fieldTable != null) {
|
if (vmClass.fieldTable != null) {
|
||||||
Classes.link(vmClass);
|
Classes.link(vmClass);
|
||||||
@ -370,7 +371,7 @@ public class Classes {
|
|||||||
return new String(array, 0, array.length - 1);
|
return new String(array, 0, array.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean match(Class[] a, Class[] b) {
|
public static boolean match(Class[] a, Class[] b) {
|
||||||
if (a.length == b.length) {
|
if (a.length == b.length) {
|
||||||
for (int i = 0; i < a.length; ++i) {
|
for (int i = 0; i < a.length; ++i) {
|
||||||
if (! a[i].isAssignableFrom(b[i])) {
|
if (! a[i].isAssignableFrom(b[i])) {
|
||||||
@ -383,7 +384,7 @@ public class Classes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int findMethod(VMClass vmClass, String name,
|
public static int findMethod(VMClass vmClass, String name,
|
||||||
Class[] parameterTypes)
|
Class[] parameterTypes)
|
||||||
{
|
{
|
||||||
if (vmClass.methodTable != null) {
|
if (vmClass.methodTable != null) {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Boolean implements Comparable<Boolean> {
|
public final class Boolean implements Comparable<Boolean> {
|
||||||
public static final Class TYPE = Class.forCanonicalName("Z");
|
public static final Class TYPE = avian.Classes.forCanonicalName("Z");
|
||||||
|
|
||||||
public static final Boolean FALSE = new Boolean(false);
|
public static final Boolean FALSE = new Boolean(false);
|
||||||
public static final Boolean TRUE = new Boolean(true);
|
public static final Boolean TRUE = new Boolean(true);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Byte extends Number implements Comparable<Byte> {
|
public final class Byte extends Number implements Comparable<Byte> {
|
||||||
public static final Class TYPE = Class.forCanonicalName("B");
|
public static final Class TYPE = avian.Classes.forCanonicalName("B");
|
||||||
|
|
||||||
private final byte value;
|
private final byte value;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public final class Character implements Comparable<Character> {
|
|||||||
public static final int MIN_RADIX = 2;
|
public static final int MIN_RADIX = 2;
|
||||||
public static final int MAX_RADIX = 36;
|
public static final int MAX_RADIX = 36;
|
||||||
|
|
||||||
public static final Class TYPE = Class.forCanonicalName("C");
|
public static final Class TYPE = avian.Classes.forCanonicalName("C");
|
||||||
|
|
||||||
private final char value;
|
private final char value;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public final class Class <T> implements Type, AnnotatedElement {
|
|||||||
|
|
||||||
public Field getField(String name) throws NoSuchFieldException {
|
public Field getField(String name) throws NoSuchFieldException {
|
||||||
for (VMClass c = vmClass; c != null; c = c.super_) {
|
for (VMClass c = vmClass; c != null; c = c.super_) {
|
||||||
int index = findField(c, name);
|
int index = Classes.findField(c, name);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return new Field(vmClass.fieldTable[index]);
|
return new Field(vmClass.fieldTable[index]);
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ public final class Class <T> implements Type, AnnotatedElement {
|
|||||||
throw new NoSuchMethodException(name);
|
throw new NoSuchMethodException(name);
|
||||||
}
|
}
|
||||||
for (VMClass c = vmClass; c != null; c = c.super_) {
|
for (VMClass c = vmClass; c != null; c = c.super_) {
|
||||||
int index = findMethod(c, name, parameterTypes);
|
int index = Classes.findMethod(c, name, parameterTypes);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return new Method(vmClass.methodTable[index]);
|
return new Method(vmClass.methodTable[index]);
|
||||||
}
|
}
|
||||||
@ -231,11 +231,11 @@ public final class Class <T> implements Type, AnnotatedElement {
|
|||||||
public Constructor getConstructor(Class ... parameterTypes)
|
public Constructor getConstructor(Class ... parameterTypes)
|
||||||
throws NoSuchMethodException
|
throws NoSuchMethodException
|
||||||
{
|
{
|
||||||
Method m = findMethod(vmClass, "<init>", parameterTypes);
|
int index = Classes.findMethod(vmClass, "<init>", parameterTypes);
|
||||||
if (m == null) {
|
if (index < 0) {
|
||||||
throw new NoSuchMethodException();
|
throw new NoSuchMethodException();
|
||||||
} else {
|
} else {
|
||||||
return new Constructor(m);
|
return new Constructor(new Method(vmClass.methodTable[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ public final class Class <T> implements Type, AnnotatedElement {
|
|||||||
Constructor[] constructors = getDeclaredConstructors();
|
Constructor[] constructors = getDeclaredConstructors();
|
||||||
|
|
||||||
for (int i = 0; i < constructors.length; ++i) {
|
for (int i = 0; i < constructors.length; ++i) {
|
||||||
if (match(parameterTypes, constructors[i].getParameterTypes())) {
|
if (Classes.match(parameterTypes, constructors[i].getParameterTypes())) {
|
||||||
c = constructors[i];
|
c = constructors[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Double extends Number {
|
public final class Double extends Number {
|
||||||
public static final Class TYPE = Class.forCanonicalName("D");
|
public static final Class TYPE = avian.Classes.forCanonicalName("D");
|
||||||
|
|
||||||
public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
|
public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
|
||||||
public static final double POSITIVE_INFINITY = 1.0 / 0.0;
|
public static final double POSITIVE_INFINITY = 1.0 / 0.0;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Float extends Number {
|
public final class Float extends Number {
|
||||||
public static final Class TYPE = Class.forCanonicalName("F");
|
public static final Class TYPE = avian.Classes.forCanonicalName("F");
|
||||||
private static final int EXP_BIT_MASK = 0x7F800000;
|
private static final int EXP_BIT_MASK = 0x7F800000;
|
||||||
private static final int SIGNIF_BIT_MASK = 0x007FFFFF;
|
private static final int SIGNIF_BIT_MASK = 0x007FFFFF;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Integer extends Number implements Comparable<Integer> {
|
public final class Integer extends Number implements Comparable<Integer> {
|
||||||
public static final Class TYPE = Class.forCanonicalName("I");
|
public static final Class TYPE = avian.Classes.forCanonicalName("I");
|
||||||
|
|
||||||
public static final int MIN_VALUE = 0x80000000;
|
public static final int MIN_VALUE = 0x80000000;
|
||||||
public static final int MAX_VALUE = 0x7FFFFFFF;
|
public static final int MAX_VALUE = 0x7FFFFFFF;
|
||||||
|
@ -14,7 +14,7 @@ public final class Long extends Number implements Comparable<Long> {
|
|||||||
public static final long MIN_VALUE = -9223372036854775808l;
|
public static final long MIN_VALUE = -9223372036854775808l;
|
||||||
public static final long MAX_VALUE = 9223372036854775807l;
|
public static final long MAX_VALUE = 9223372036854775807l;
|
||||||
|
|
||||||
public static final Class TYPE = Class.forCanonicalName("J");
|
public static final Class TYPE = avian.Classes.forCanonicalName("J");
|
||||||
|
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Short extends Number implements Comparable<Short> {
|
public final class Short extends Number implements Comparable<Short> {
|
||||||
public static final Class TYPE = Class.forCanonicalName("S");
|
public static final Class TYPE = avian.Classes.forCanonicalName("S");
|
||||||
public static final short MAX_VALUE = 32767;
|
public static final short MAX_VALUE = 32767;
|
||||||
|
|
||||||
private final short value;
|
private final short value;
|
||||||
|
@ -127,6 +127,11 @@ public final class String
|
|||||||
} else {
|
} else {
|
||||||
c = Utf8.decode((byte[])data, offset, length);
|
c = Utf8.decode((byte[])data, offset, length);
|
||||||
if(c instanceof char[]) length = ((char[])c).length;
|
if(c instanceof char[]) length = ((char[])c).length;
|
||||||
|
if (c == null) {
|
||||||
|
throw new RuntimeException
|
||||||
|
("unable to parse \"" + new String(data, offset, length, false)
|
||||||
|
+ "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data = c;
|
this.data = c;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Void {
|
public final class Void {
|
||||||
public static final Class TYPE = Class.forCanonicalName("V");
|
public static final Class TYPE = avian.Classes.forCanonicalName("V");
|
||||||
|
|
||||||
private Void() { }
|
private Void() { }
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class Field<T> extends AccessibleObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Class getType() {
|
public Class getType() {
|
||||||
return Class.forCanonicalName
|
return Classes.forCanonicalName
|
||||||
(vmField.class_.loader,
|
(vmField.class_.loader,
|
||||||
new String(vmField.spec, 0, vmField.spec.length - 1, false));
|
new String(vmField.spec, 0, vmField.spec.length - 1, false));
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ package java.lang.reflect;
|
|||||||
import avian.VMMethod;
|
import avian.VMMethod;
|
||||||
import avian.AnnotationInvocationHandler;
|
import avian.AnnotationInvocationHandler;
|
||||||
import avian.SystemClassLoader;
|
import avian.SystemClassLoader;
|
||||||
|
import avian.Classes;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ public class Method<T> extends AccessibleObject implements Member {
|
|||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
for (int i = 0; i < vmMethod.spec.length - 1; ++i) {
|
for (int i = 0; i < vmMethod.spec.length - 1; ++i) {
|
||||||
if (vmMethod.spec[i] == ')') {
|
if (vmMethod.spec[i] == ')') {
|
||||||
return Class.forCanonicalName
|
return Classes.forCanonicalName
|
||||||
(vmMethod.class_.loader,
|
(vmMethod.class_.loader,
|
||||||
new String
|
new String
|
||||||
(vmMethod.spec, i + 1, vmMethod.spec.length - i - 2, false));
|
(vmMethod.spec, i + 1, vmMethod.spec.length - i - 2, false));
|
||||||
|
@ -127,6 +127,47 @@ class MyClasspath : public Classpath {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual object
|
||||||
|
makeDirectByteBuffer(Thread* t, void* p, jlong capacity)
|
||||||
|
{
|
||||||
|
object c = resolveClass
|
||||||
|
(t, root(t, Machine::BootLoader), "java/nio/DirectByteBuffer");
|
||||||
|
PROTECT(t, c);
|
||||||
|
|
||||||
|
object instance = makeNew(t, c);
|
||||||
|
PROTECT(t, instance);
|
||||||
|
|
||||||
|
object constructor = resolveMethod(t, c, "<init>", "(JI)V");
|
||||||
|
|
||||||
|
t->m->processor->invoke
|
||||||
|
(t, constructor, instance, reinterpret_cast<int64_t>(p),
|
||||||
|
static_cast<int32_t>(capacity));
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void*
|
||||||
|
getDirectBufferAddress(Thread* t, object b)
|
||||||
|
{
|
||||||
|
PROTECT(t, b);
|
||||||
|
|
||||||
|
object field = resolveField(t, objectClass(t, b), "address", "J");
|
||||||
|
|
||||||
|
return reinterpret_cast<void*>
|
||||||
|
(fieldAtOffset<int64_t>(b, fieldOffset(t, field)));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int64_t
|
||||||
|
getDirectBufferCapacity(Thread* t, object b)
|
||||||
|
{
|
||||||
|
PROTECT(t, b);
|
||||||
|
|
||||||
|
object field = resolveField
|
||||||
|
(t, objectClass(t, b), "capacity", "I");
|
||||||
|
|
||||||
|
return fieldAtOffset<int32_t>(b, fieldOffset(t, field));
|
||||||
|
}
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
dispose()
|
dispose()
|
||||||
{
|
{
|
||||||
@ -698,3 +739,41 @@ Avian_avian_Classes_getVMClass
|
|||||||
return reinterpret_cast<int64_t>
|
return reinterpret_cast<int64_t>
|
||||||
(objectClass(t, reinterpret_cast<object>(arguments[0])));
|
(objectClass(t, reinterpret_cast<object>(arguments[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT int64_t JNICALL
|
||||||
|
Avian_avian_Classes_makeMethod
|
||||||
|
(Thread* t, object, uintptr_t* arguments)
|
||||||
|
{
|
||||||
|
object method = arrayBody
|
||||||
|
(t, classMethodTable
|
||||||
|
(t, jclassVmClass(t, reinterpret_cast<object>(arguments[0]))),
|
||||||
|
arguments[1]);
|
||||||
|
PROTECT(t, method);
|
||||||
|
|
||||||
|
object c = resolveClass
|
||||||
|
(t, root(t, Machine::BootLoader), "java/lang/reflect/Method");
|
||||||
|
PROTECT(t, c);
|
||||||
|
|
||||||
|
object instance = makeNew(t, c);
|
||||||
|
PROTECT(t, instance);
|
||||||
|
|
||||||
|
object constructor = resolveMethod(t, c, "<init>", "(Lavian/VMMethod;)V");
|
||||||
|
|
||||||
|
t->m->processor->invoke(t, constructor, instance, method);
|
||||||
|
|
||||||
|
if (byteArrayBody(t, methodName(t, method), 0) == '<') {
|
||||||
|
method = instance;
|
||||||
|
|
||||||
|
c = resolveClass
|
||||||
|
(t, root(t, Machine::BootLoader), "java/lang/reflect/Constructor");
|
||||||
|
|
||||||
|
object instance = makeNew(t, c);
|
||||||
|
|
||||||
|
object constructor = resolveMethod
|
||||||
|
(t, c, "<init>", "(Ljava/lang/Method;)V");
|
||||||
|
|
||||||
|
t->m->processor->invoke(t, constructor, instance, method);
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<uintptr_t>(instance);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user