add misc methods to classpath

This commit is contained in:
Joel Dice 2007-09-13 20:19:44 -06:00
parent ce97b6eecb
commit 5e42158f4b
4 changed files with 22 additions and 0 deletions

View File

@ -12,6 +12,10 @@ public final class Boolean {
this.value = value;
}
public Boolean(String s) {
this.value = "true".equals(s);
}
public static Boolean valueOf(boolean value) {
return (value ? Boolean.TRUE : Boolean.FALSE);
}

View File

@ -12,6 +12,10 @@ public final class Integer extends Number {
this.value = value;
}
public Integer(String s) {
this.value = parseInt(s);
}
public static Integer valueOf(int value) {
return new Integer(value);
}

View File

@ -9,6 +9,10 @@ public final class Long extends Number {
this.value = value;
}
public Long(String s) {
this.value = parseLong(s);
}
public static Long valueOf(long value) {
return new Long(value);
}

View File

@ -110,4 +110,14 @@ public class Method<T> extends AccessibleObject implements Member {
public static native Object invoke(Method method, Object instance,
Object ... arguments)
throws InvocationTargetException, IllegalAccessException;
public Class getReturnType() {
for (int i = 0; i < spec.length - 1; ++i) {
if (spec[i] == ')') {
return Class.forCanonicalName
(new String(spec, i + 1, spec.length - i - 2, false));
}
}
throw new RuntimeException();
}
}