summaryrefslogtreecommitdiffstats
path: root/libjava/java/lang
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/lang')
-rw-r--r--libjava/java/lang/VMFloat.h2
-rw-r--r--libjava/java/lang/VMFloat.java22
-rw-r--r--libjava/java/lang/reflect/natMethod.cc2
3 files changed, 25 insertions, 1 deletions
diff --git a/libjava/java/lang/VMFloat.h b/libjava/java/lang/VMFloat.h
index 58e7ba9bbcc..fec037b2cf1 100644
--- a/libjava/java/lang/VMFloat.h
+++ b/libjava/java/lang/VMFloat.h
@@ -16,6 +16,8 @@ public: // actually package-private
static jint floatToIntBits(jfloat);
static jint floatToRawIntBits(jfloat);
static jfloat intBitsToFloat(jint);
+ static ::java::lang::String * toString(jfloat);
+ static jfloat parseFloat(::java::lang::String *);
public:
static ::java::lang::Class class$;
};
diff --git a/libjava/java/lang/VMFloat.java b/libjava/java/lang/VMFloat.java
index a6570f929c6..72a8c3c6b18 100644
--- a/libjava/java/lang/VMFloat.java
+++ b/libjava/java/lang/VMFloat.java
@@ -96,4 +96,26 @@ final class VMFloat
*/
static native float intBitsToFloat(int bits);
+ /**
+ * @param f the <code>float</code> to convert
+ * @return the <code>String</code> representing the <code>float</code>
+ */
+ static String toString(float f)
+ {
+ return VMDouble.toString(f, true);
+ }
+
+ /**
+ * @param str the <code>String</code> to convert
+ * @return the <code>float</code> value of <code>s</code>
+ * @throws NumberFormatException if <code>str</code> cannot be parsed as a
+ * <code>float</code>
+ * @throws NullPointerException if <code>str</code> is null
+ */
+ static float parseFloat(String str)
+ {
+ // XXX Rounding parseDouble() causes some errors greater than 1 ulp from
+ // the infinitely precise decimal.
+ return (float) Double.parseDouble(str);
+ }
} // class VMFloat
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc
index 4593da7f49e..d95c92f8468 100644
--- a/libjava/java/lang/reflect/natMethod.cc
+++ b/libjava/java/lang/reflect/natMethod.cc
@@ -359,7 +359,7 @@ _Jv_CallAnyMethodA (jobject obj,
jboolean is_constructor,
jboolean is_virtual_call,
JArray<jclass> *parameter_types,
- jvalue *args,
+ const jvalue *args,
jvalue *result,
jboolean is_jni_call,
jclass iface)
OpenPOWER on IntegriCloud