Added Class.getGenericSuperclass() and improved Member subclasses. Fixed Makefile on OS X

This commit is contained in:
Ilya Mizus
2014-10-09 02:32:56 +04:00
parent 998f99af44
commit 85fec988d5
6 changed files with 49 additions and 17 deletions

View File

@ -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);
}
}