Implement Method#getDefaultValue()

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2013-10-31 00:28:01 -05:00
parent ff323d46a3
commit 58ec623d7a
2 changed files with 24 additions and 0 deletions

View File

@ -450,6 +450,25 @@ public class Classes {
return (Annotation) a[0];
}
public static Object getAnnotationDefaultValue(ClassLoader loader,
MethodAddendum addendum) {
if (addendum == null) {
return null;
}
byte[] annotationDefault = (byte[]) addendum.annotationDefault;
if (annotationDefault == null) {
return null;
}
try {
return parseAnnotationValue(loader, addendum.pool,
new ByteArrayInputStream(annotationDefault));
} catch (IOException e) {
AssertionError error = new AssertionError();
error.initCause(e);
throw error;
}
}
public static native Method makeMethod(Class c, int slot);
private static native void acquireClassLock();

View File

@ -142,4 +142,9 @@ public class Method<T> extends AccessibleObject implements Member {
public boolean isVarArgs() {
return (getModifiers() & 0x80) != 0;
}
public Object getDefaultValue() {
ClassLoader loader = getDeclaringClass().getClassLoader();
return Classes.getAnnotationDefaultValue(loader, vmMethod.addendum);
}
}