From 5e42158f4b87cc678ca78eddaa5ba2aa33d2b18c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 13 Sep 2007 20:19:44 -0600 Subject: [PATCH] add misc methods to classpath --- classpath/java/lang/Boolean.java | 4 ++++ classpath/java/lang/Integer.java | 4 ++++ classpath/java/lang/Long.java | 4 ++++ classpath/java/lang/reflect/Method.java | 10 ++++++++++ 4 files changed, 22 insertions(+) diff --git a/classpath/java/lang/Boolean.java b/classpath/java/lang/Boolean.java index c74c306269..be44e955d5 100644 --- a/classpath/java/lang/Boolean.java +++ b/classpath/java/lang/Boolean.java @@ -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); } diff --git a/classpath/java/lang/Integer.java b/classpath/java/lang/Integer.java index ad51bdb2c0..d30bb804b1 100644 --- a/classpath/java/lang/Integer.java +++ b/classpath/java/lang/Integer.java @@ -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); } diff --git a/classpath/java/lang/Long.java b/classpath/java/lang/Long.java index 4439bfaf60..913267d7bf 100644 --- a/classpath/java/lang/Long.java +++ b/classpath/java/lang/Long.java @@ -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); } diff --git a/classpath/java/lang/reflect/Method.java b/classpath/java/lang/reflect/Method.java index 606eb4d969..c84a394b3f 100644 --- a/classpath/java/lang/reflect/Method.java +++ b/classpath/java/lang/reflect/Method.java @@ -110,4 +110,14 @@ public class Method 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(); + } }