Reviewer needed for 8000763: use XXX.valueOf methods instead of constructors

Lance Andersen - Oracle Lance.Andersen at oracle.com
Thu Oct 11 22:47:24 UTC 2012


Thank you Mandy and Remi.

Mandy, I addressed the nit below before the push

Best
Lance
On Oct 11, 2012, at 6:38 PM, Mandy Chung wrote:

> Lance - this looks good to me.
> 
> In FilteredRowSetImpl.java -
> -            bool = p.evaluate(new Float(x) , columnIndex);
> +            bool = p.evaluate(Float.valueOf(x) , columnIndex);
> 
> I was tempted to suggest removing the space before ','.  But I
> found that the coding convention is kinda inconsistent locally
> in the FilteredRowSetImpl.java itself and so you can either leave
> it as it is or clean that up incrementally when you modify that
> file.  Really minor nit.
> 
> Mandy
> 
> On 10/11/2012 10:34 AM, Lance Andersen - Oracle wrote:
>> Hi Remi,
>> 
>> Thank you for the suggestion, I had forgotten about parseDouble.  I made your suggested change below.
>> 
>> Best
>> Lance
>> 
>> 
>> new-host-2:rowset lanceandersen$ hg diff
>> diff -r c2be39b27e1c src/share/classes/com/sun/rowset/CachedRowSetImpl.java
>> --- a/src/share/classes/com/sun/rowset/CachedRowSetImpl.java	Thu Oct 11 11:47:05 2012 +0100
>> +++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.java	Thu Oct 11 13:32:41 2012 -0400
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
>> + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
>>   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
>>   *
>>   * This code is free software; you can redistribute it and/or modify it
>> @@ -1746,12 +1746,7 @@
>> 
>>          // convert to a Double and compare to zero
>>          try {
>> -            Double d = new Double(value.toString());
>> -            if (d.compareTo(new Double((double)0)) == 0) {
>> -                return false;
>> -            } else {
>> -                return true;
>> -            }
>> +            return Double.compare(Double.parseDouble(value.toString()), 0) != 0;
>>          } catch (NumberFormatException ex) {
>>              throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.boolfail").toString(),
>>                    new Object[] {value.toString().trim(), columnIndex}));
>> @@ -4432,7 +4427,7 @@
>>          // make sure the cursor is on a valid row
>>          checkCursor();
>> 
>> -        Object obj = convertNumeric(new Float(x),
>> +        Object obj = convertNumeric(Float.valueOf(x),
>>          java.sql.Types.REAL,
>>          RowSetMD.getColumnType(columnIndex));
>> 
>> @@ -4467,7 +4462,7 @@
>>          checkIndex(columnIndex);
>>          // make sure the cursor is on a valid row
>>          checkCursor();
>> -        Object obj = convertNumeric(new Double(x),
>> +        Object obj = convertNumeric(Double.valueOf(x),
>>          java.sql.Types.DOUBLE,
>>          RowSetMD.getColumnType(columnIndex));
>> 
>> diff -r c2be39b27e1c src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
>> --- a/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java	Thu Oct 11 11:47:05 2012 +0100
>> +++ b/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java	Thu Oct 11 13:32:41 2012 -0400
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
>> + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
>>   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
>>   *
>>   * This code is free software; you can redistribute it and/or modify it
>> @@ -839,7 +839,7 @@
>> 
>>        if(onInsertRow) {
>>           if(p != null) {
>> -            bool = p.evaluate(new Float(x) , columnIndex);
>> +            bool = p.evaluate(Float.valueOf(x) , columnIndex);
>> 
>>              if(!bool) {
>>                 throw new SQLException(resBundle.handleGetObject("filteredrowsetimpl.notallowed").toString());
>> @@ -906,7 +906,7 @@
>> 
>>        if(onInsertRow) {
>>           if(p != null) {
>> -            bool = p.evaluate(new Double(x) , columnIndex);
>> +            bool = p.evaluate(Double.valueOf(x) , columnIndex);
>> 
>>              if(!bool) {
>>                 throw new SQLException(resBundle.handleGetObject("filteredrowsetimpl.notallowed").toString());
>> diff -r c2be39b27e1c src/share/classes/javax/sql/rowset/BaseRowSet.java
>> --- a/src/share/classes/javax/sql/rowset/BaseRowSet.java	Thu Oct 11 11:47:05 2012 +0100
>> +++ b/src/share/classes/javax/sql/rowset/BaseRowSet.java	Thu Oct 11 13:32:41 2012 -0400
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
>> + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
>>   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
>>   *
>>   * This code is free software; you can redistribute it and/or modify it
>> @@ -1850,7 +1850,7 @@
>>          if(params == null){
>>               throw new SQLException("Set initParams() before setFloat");
>>          }
>> -        params.put(Integer.valueOf(parameterIndex - 1), new Float(x));
>> +        params.put(Integer.valueOf(parameterIndex - 1), Float.valueOf(x));
>>      }
>> 
>>      /**
>> @@ -1882,7 +1882,7 @@
>>          if(params == null){
>>               throw new SQLException("Set initParams() before setDouble");
>>          }
>> -        params.put(Integer.valueOf(parameterIndex - 1), new Double(x));
>> +        params.put(Integer.valueOf(parameterIndex - 1), Double.valueOf(x));
>>      }
>> 
>>      /**
>> diff -r c2be39b27e1c src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
>> --- a/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java	Thu Oct 11 11:47:05 2012 +0100
>> +++ b/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java	Thu Oct 11 13:32:41 2012 -0400
>> @@ -215,7 +215,7 @@
>>       */
>>      @SuppressWarnings("unchecked")
>>      public void writeFloat(float x) throws SQLException {
>> -        attribs.add(new Float(x));
>> +        attribs.add(Float.valueOf(x));
>>      }
>> 
>>      /**
>> @@ -230,7 +230,7 @@
>>       */
>>      @SuppressWarnings("unchecked")
>>      public void writeDouble(double x) throws SQLException{
>> -        attribs.add(new Double(x));
>> +        attribs.add(Double.valueOf(x));
>>      }
>> 
>>      /**
>> new-host-2:rowset lanceandersen$
>> On Oct 11, 2012, at 12:59 PM, Remi Forax wrote:
>> 
>>> return Double.compare(Double.parseDouble(value.toString()), 0) != 0;
>> 
>> Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
>> Oracle Java Engineering
>> 1 Network Drive
>> Burlington, MA 01803
>> Lance.Andersen at oracle.com
>> 


Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering 
1 Network Drive 
Burlington, MA 01803
Lance.Andersen at oracle.com




More information about the core-libs-dev mailing list