This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Ingeger.getInteger() and Long.getLong()
- To: java-patches at gcc dot gnu dot org
- Subject: Ingeger.getInteger() and Long.getLong()
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Mon, 19 Feb 2001 16:49:58 +1300
These methods would call decode() with a null argument if the System
property was not set, resulting in a NullPointerException when the
"default" argument should have been returned.
I'm checking this in (branch and mainline).
regards
[ bryce ]
2001-02-19 Bryce McKinlay <bryce@albatross.co.nz>
* java/lang/Integer.java (getInteger): Return default argument if
property is not set. Don't call decode with null argument.
* java/lang/Long.java (getLong): Likewise.
Index: java/lang/Long.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/Long.java,v
retrieving revision 1.6
diff -u -r1.6 Long.java
--- Long.java 2001/02/09 02:56:38 1.6
+++ Long.java 2001/02/19 03:41:18
@@ -156,13 +156,15 @@
public static Long getLong(String prop, Long defobj)
{
try
- {
- return decode(System.getProperty(prop));
- }
+ {
+ String val = System.getProperty(prop);
+ if (val != null)
+ return decode(val);
+ }
catch (NumberFormatException ex)
- {
- return defobj;
- }
+ {
+ }
+ return defobj;
}
public int hashCode()
Index: java/lang/Integer.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/Integer.java,v
retrieving revision 1.6
diff -u -r1.6 Integer.java
--- Integer.java 2001/02/09 02:56:38 1.6
+++ Integer.java 2001/02/19 03:41:18
@@ -155,13 +155,15 @@
public static Integer getInteger(String prop, Integer defobj)
{
try
- {
- return decode(System.getProperty(prop));
- }
+ {
+ String val = System.getProperty(prop);
+ if (val != null)
+ return decode(val);
+ }
catch (NumberFormatException ex)
- {
- return defobj;
- }
+ {
+ }
+ return defobj;
}
public int hashCode()