mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
Added Class.getGenericSuperclass() and improved Member subclasses. Fixed Makefile on OS X
This commit is contained in:
parent
998f99af44
commit
85fec988d5
@ -712,10 +712,10 @@ public final class Class <T>
|
||||
throw new UnsupportedOperationException("not yet implemented");
|
||||
}
|
||||
|
||||
public Type[] getGenericInterfaces() {
|
||||
if (vmClass.addendum == null || vmClass.addendum.signature == null) {
|
||||
return getInterfaces();
|
||||
}
|
||||
/**
|
||||
* The first one is the superclass, the others are interfaces
|
||||
**/
|
||||
private String[] getGenericTypeSignatures() {
|
||||
String signature = Classes.toString((byte[]) vmClass.addendum.signature);
|
||||
final char[] signChars = signature.toCharArray();
|
||||
|
||||
@ -753,13 +753,39 @@ public final class Class <T>
|
||||
}
|
||||
if (curTypeSign.length() > 0) typeSigns.add(curTypeSign.toString());
|
||||
|
||||
// Parsing types, ignoring the first item in the array
|
||||
// cause it's the base type
|
||||
Type[] res = new Type[typeSigns.size() - 1];
|
||||
for (i = 0; i < typeSigns.size() - 1; i++) {
|
||||
res[i] = SignatureParser.parse(vmClass.loader, typeSigns.get(i + 1), this);
|
||||
String[] res = new String[typeSigns.size()];
|
||||
return typeSigns.toArray(res);
|
||||
}
|
||||
|
||||
public Type[] getGenericInterfaces() {
|
||||
if (vmClass.addendum == null || vmClass.addendum.signature == null) {
|
||||
return getInterfaces();
|
||||
}
|
||||
|
||||
String[] typeSigns = getGenericTypeSignatures();
|
||||
if (typeSigns.length < 1) {
|
||||
throw new RuntimeException("Class signature doesn't contain any type");
|
||||
}
|
||||
|
||||
// Parsing types
|
||||
Type[] res = new Type[typeSigns.length - 1];
|
||||
for (int i = 0; i < typeSigns.length - 1; i++) {
|
||||
res[i] = SignatureParser.parse(vmClass.loader, typeSigns[i + 1], this);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public Type getGenericSuperclass() {
|
||||
if (vmClass.addendum == null || vmClass.addendum.signature == null) {
|
||||
return getSuperclass();
|
||||
}
|
||||
String[] typeSigns = getGenericTypeSignatures();
|
||||
if (typeSigns.length < 1) {
|
||||
throw new RuntimeException("Class signature doesn't contain any type");
|
||||
}
|
||||
|
||||
return SignatureParser.parse(vmClass.loader, typeSigns[0], this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ import java.lang.annotation.Annotation;
|
||||
public abstract class AccessibleObject implements AnnotatedElement {
|
||||
protected static final int Accessible = 1 << 0;
|
||||
|
||||
// Access and property flags for Member descendants
|
||||
protected static final int ACC_VARARGS = 0x0080;
|
||||
protected static final int ACC_SYNTHETIC = 0x1000;
|
||||
|
||||
public boolean isAnnotationPresent
|
||||
(Class<? extends Annotation> class_)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ import avian.Classes;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public class Field<T> extends AccessibleObject {
|
||||
public class Field<T> extends AccessibleObject implements Member {
|
||||
private static final int VoidField = 0;
|
||||
private static final int ByteField = 1;
|
||||
private static final int CharField = 2;
|
||||
@ -51,6 +51,10 @@ public class Field<T> extends AccessibleObject {
|
||||
public int getModifiers() {
|
||||
return vmField.flags;
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
return (vmField.flags & ACC_SYNTHETIC) != 0;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getName(vmField);
|
||||
|
@ -13,8 +13,8 @@ package java.lang.reflect;
|
||||
public interface Member {
|
||||
public static final int PUBLIC = 0;
|
||||
public static final int DECLARED = 1;
|
||||
|
||||
public Class getDeclaringClass();
|
||||
|
||||
public Class<?> getDeclaringClass();
|
||||
|
||||
public int getModifiers();
|
||||
|
||||
|
@ -146,11 +146,11 @@ public class Method<T> extends AccessibleObject implements Member {
|
||||
}
|
||||
|
||||
public boolean isVarArgs() {
|
||||
return (getModifiers() & 0x80) != 0;
|
||||
return (getModifiers() & ACC_VARARGS) != 0;
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
return (getModifiers() & 0x1000) != 0;
|
||||
return (getModifiers() & ACC_SYNTHETIC) != 0;
|
||||
}
|
||||
|
||||
public Object getDefaultValue() {
|
||||
|
4
makefile
4
makefile
@ -240,9 +240,7 @@ ifneq ($(android),)
|
||||
-g3 \
|
||||
-Werror \
|
||||
-Wno-shift-count-overflow
|
||||
ifeq ($(platform),macosx)
|
||||
android-cflags += -Doff64_t=off_t -Dlseek64=lseek
|
||||
endif
|
||||
|
||||
# on Windows (in MinGW-based build) there are neither __BEGIN_DECLS nor __END_DECLS
|
||||
# defines; we don't want to patch every file that uses them, so we stub them in
|
||||
# using CFLAGS mechanism
|
||||
|
Loading…
Reference in New Issue
Block a user