[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Patch: FYI: more 1.5 mergelets
From: |
Tom Tromey |
Subject: |
[cp-patches] Patch: FYI: more 1.5 mergelets |
Date: |
18 Sep 2005 16:53:24 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
I'm checking this in on the trunk.
This brings over a few more 1.5 methods in the primitive wrapper
classes that I neglected earlier. They weren't marked @since 1.5 on
the branch.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
* java/lang/Short.java (valueOf): New method.
* java/lang/Double.java (valueOf): New method.
* java/lang/Float.java (valueOf): New method.
Index: java/lang/Double.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Double.java,v
retrieving revision 1.39
diff -u -r1.39 Double.java
--- java/lang/Double.java 17 Sep 2005 21:58:41 -0000 1.39
+++ java/lang/Double.java 18 Sep 2005 22:56:19 -0000
@@ -173,6 +173,22 @@
}
/**
+ * Returns a <code>Double</code> object wrapping the value.
+ * In contrast to the <code>Double</code> constructor, this method
+ * may cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Double</code>
+ *
+ * @since 1.5
+ */
+ public static Double valueOf(double val)
+ {
+ // We don't actually cache, but we could.
+ return new Double(val);
+ }
+
+ /**
* Create a new <code>Double</code> object using the <code>String</code>.
*
* @param s the <code>String</code> to convert
Index: java/lang/Float.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Float.java,v
retrieving revision 1.32
diff -u -r1.32 Float.java
--- java/lang/Float.java 17 Sep 2005 21:58:41 -0000 1.32
+++ java/lang/Float.java 18 Sep 2005 22:56:19 -0000
@@ -198,6 +198,22 @@
}
/**
+ * Returns a <code>Float</code> object wrapping the value.
+ * In contrast to the <code>Float</code> constructor, this method
+ * may cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Float</code>
+ *
+ * @since 1.5
+ */
+ public static Float valueOf(float val)
+ {
+ // We don't actually cache, but we could.
+ return new Float(val);
+ }
+
+ /**
* Parse the specified <code>String</code> as a <code>float</code>. The
* extended BNF grammar is as follows:<br>
* <pre>
Index: java/lang/Short.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Short.java,v
retrieving revision 1.18
diff -u -r1.18 Short.java
--- java/lang/Short.java 17 Sep 2005 21:58:41 -0000 1.18
+++ java/lang/Short.java 18 Sep 2005 22:56:20 -0000
@@ -202,6 +202,28 @@
}
/**
+ * Returns a <code>Short</code> object wrapping the value.
+ * In contrast to the <code>Short</code> constructor, this method
+ * will cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Short</code>
+ *
+ * @since 1.5
+ */
+ public static Short valueOf(short val)
+ {
+ if (val < MIN_CACHE || val > MAX_CACHE)
+ return new Short(val);
+ synchronized (shortCache)
+ {
+ if (shortCache[val - MIN_CACHE] == null)
+ shortCache[val - MIN_CACHE] = new Short(val);
+ return shortCache[val - MIN_CACHE];
+ }
+ }
+
+ /**
* Convert the specified <code>String</code> into a <code>Short</code>.
* The <code>String</code> may represent decimal, hexadecimal, or
* octal numbers.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Patch: FYI: more 1.5 mergelets,
Tom Tromey <=