Re: Review/comment needed for the new public java.util.Base64 class

2012-10-11 Thread Xueming Shen



On 10/11/2012 02:43 AM, Stephen Colebourne wrote:

There are lots of other public base 64 implementations to test/check 
against.
http://commons.apache.org/net/api-3.1/org/apache/commons/net/util/Base64.html 

http://www.cs.berkeley.edu/~jonah/bc/org/bouncycastle/util/encoders/Base64.html 


http://migbase64.sourceforge.net/  (claims to be fast)




I did a quick performance check against migbase64 with the basic base64 
de/encoding

using this non-scientific benchmark.
http://cr.openjdk.java.net/~sherman/4235519/PermBase64.java

Here is the scores
http://cr.openjdk.java.net/~sherman/4235519/scores

It's a tie, j.u.Base64 wins the decoding, but needs some work on 
encoding side.


java -server PermBase64 20 50
 j.u.Base64.encode() : 1390212
  migBase64.encode() : 720517
 j.u.Base64.decode() : 1200642
  migBase64.decode() : 2070015

java -server PermBase64 20 100
 j.u.Base64.encode() : 1239407
  migBase64.encode() : 740404
 j.u.Base64.decode() : 1257092
  migBase64.decode() : 2012910

java -server PermBase64 20 1000
 j.u.Base64.encode() : 1062212
  migBase64.encode() : 657342
 j.u.Base64.decode() : 1133740
  migBase64.decode() : 1930612

java -client PermBase64 20 50
 j.u.Base64.encode() : 961331
  migBase64.encode() : 875635
 j.u.Base64.decode() : 1528790
  migBase64.decode() : 2188473

java -client PermBase64 20 100
 j.u.Base64.encode() : 966453
  migBase64.encode() : 858082
 j.u.Base64.decode() : 1459159
  migBase64.decode() : 2115045

java -client PermBase64 20 1000
 j.u.Base64.encode() : 954401
  migBase64.encode() : 854903
 j.u.Base64.decode() : 1444603
  migBase64.decode() : 2038865




Re: Reviewer needed: 6282196 There should be Math.mod(number, modulo) methods

2012-10-11 Thread Joseph Darcy

Hi Roger,

The changes look fine.  However, I suggest adding an explanatory note 
along the lines of "Normal integer division operates under the round to 
zero rounding mode (truncation).  This operation instead acts under the 
round to negative infinity (floor) rounding mode. The floor rounding 
mode gives different results than truncation when the exact result is 
negative."


Thanks,

-Joe

On 10/10/2012 7:22 AM, Roger Riggs wrote:

A reviewer is needed for:

6282196 There should be Math.mod(number, modulo) methods

The webrev is: http://cr.openjdk.java.net/~rriggs/6282196.4/

Thanks, Roger




Code Review Request: 7198073: (prefs) user prefs not saved [macosx]

2012-10-11 Thread Kurchi Hazra

Hi,

   This is a regression introduced by the fix for 7160252[1] that I 
pushed a few weeks ago. We should
really be using the class member field isUser, rather than the argument 
passed in the constructor as a parameter
for cfFileForNode(). Due to this wrong parameter being passed, user 
preferences were never getting stored into

permanent storage.

Webrev: http://cr.openjdk.java.net/~khazra/7198073/webrev.00/
Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7198073

Thanks,
Kurchi

[1] http://cr.openjdk.java.net/~khazra/7160252/webrev.02/


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

2012-10-11 Thread Mandy Chung

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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.javaThu 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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.javaThu 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.val

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

2012-10-11 Thread Lance Andersen - Oracle
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");

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

2012-10-11 Thread Remi Forax

On 10/11/2012 07:34 PM, Lance Andersen - Oracle wrote:

Hi Remi,

Thank you for the suggestion, I had forgotten about parseDouble.  I 
made your suggested change below.


Best
Lance


thumb up.

regards,
Rémi




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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.javaThu 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.javaThu Oct 
11 11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/FilteredRowSetImpl.javaThu 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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.javaThu 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.javaThu 
Oct 11 11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.javaThu 
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

Re: RFR: 7159567 - inconsistent configuration of MemoryHandler

2012-10-11 Thread Jim Gish
Please review the updated changes at 
http://cr.openjdk.java.net/~jgish/Bug7159567-set-logging-MemoryHandler/


I've changed as you've requested, added some additional tests, did some 
better error handling in the case of a MemoryHandler not specifying a 
target (now throws RuntimeException with an appropriate message instead 
of attempting to load a null class and throwing NPE).  I also corrected 
the copyrights, tested with JCK, all jdk_lang tests and have submitted a 
JPRT job with core tests.


I've forwarded a CCC request (separately) and will await its approval 
and further review of this change.


Thanks,
Jim

On 09/28/2012 05:32 PM, Mandy Chung wrote:

On 9/28/2012 12:13 PM, Jim Gish wrote:
I've re-spun the change with additional usage notes in the spec to 
reflect the long-standing actual behavior.  Note that it doesn't 
change the spec per se, as it was already stated in LogManager. This 
change simply replicates that language with an example in each 
*Handler class to make it easier to find.




Thanks for looking into it.  This statement in LogManager does
specify the properties for handlers:

  The properties for loggers and Handlers will have names starting
  with the dot-separated name for the handler or logger.

Replicating that statement with an example is one way to do it.
Would it be clearer if the prefix of the properties referenced
in the bullet list is replaced from "java.util.logging" to
some kind of prefix - something like this:

 *Configuration:
 * By default eachConsoleHandler  is initialized using the 
following
 *LogManager  configuration properties.  If properties are 
not defined

 * (or have invalid values) then the specified default values are used.
 *
 *.level
 *specifies the default level for theHandler
 *(defaults toLevel.INFO).
 ...
 *
 *
 * For example, the properties for {@code ConsoleHandler} would be:
 * java.util.logging.ConsoleHandler.level=INFO
 * 
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

 *
 * For a custom handler, e.g. com.foo.MyHandler, the properties would be:
 * com.foo.MyHandler.level=INFO
 * com.foo.MyHandler.formatter=java.util.logging.SimpleFormatter

This might add some clarity to the spec.

This is a spec bug fix that I would suggest to file a CCC to
track for compatibility.  I would also suggest running the JCK
tests to find out if there is any regression due to this fix.


The webrev, as posted at 
http://cr.openjdk.java.net/~jgish/Bug7159567-set-logging-MemoryHandler/


See my comment above w.r.t. the spec change.

test/java/util/logging/MemoryHandler.java
  L27: "via via" typo
  L28: @run tag specifies the test name
   So it should be @run main/othervm MemoryHandler

  L43: jtreg runs the test in a different working directory
  other than the test source.  So the test has to read
  the system property ("test.src") to determine the location
  of the properties file.  Typically, we will do this:
String src = System.getProperty("test.src", ".);
File   fname  = new File(src, LM_PROP_FNAME);

  You don't need L44. You can reference LoggingDeadlock3.java test.

  L51: this catch block to throw a RuntimeException doesn't seem
  necessary.  If NPE is thrown, the test will fail anyway.

  One suggestion to the test is to test both cases (one with
  the specified target handler and one without).  You can
  define a custom target handler so that the test can verify
  if the expected one is used.  A simple handler to count
  the number of log messages will do the work.

test/java/util/logging/MemoryHandlerTest.props
  I suggest to take out the comments and just keep the
  properties the test needs to make it easier to tell
  what's configured.
  Perhaps you should also specify
  java.util.logging.MemoryHandler.target to make sure
  that the custom handler with no target handler specified
  will not use j.u.l.MemoryHandler.target as the default.

Mandy



--
Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304
Oracle Java Platform Group | Core Libraries Team
35 Network Drive
Burlington, MA 01803
jim.g...@oracle.com



Re: Review Request: 7186817 - Remove Windows 95/98/ME Support

2012-10-11 Thread Dan Xu

I see. I was not aware of -Xshare:dump. Thanks, Alan.

-Dan

On Thu 11 Oct 2012 03:55:34 AM PDT, Alan Bateman wrote:

On 11/10/2012 11:42, Alan Bateman wrote:

On 10/10/2012 21:18, Dan Xu wrote:

Thanks for your good comments.

I have changed access modifiers for methods in WinNTFileSystem.java.
And the new webrev can be viewed at
http://cr.openjdk.java.net/~dxu/7186817/webrev.01/

I did not change the hashCode implementation in this version. It
will need further complete tests and another round of code review.
But it is a good point to improve our code performance. Please log
another bug to address this issue. Thanks!

-Dan


Thanks Dan, it looks good to me. I'll push this shortly for you.

Dan - I've pushed this for you but without the change to the following
file:

make/tools/sharing/classlist.windows

The reason is that file is auto-generated and has a hash at the end so
it's not meant to be manually edited. The class list is used by
-Xshare:dump to generate the shared archive for class data sharing and
is tolerant of missing classes. I think the class lists are a bit of
date anyway and are overdue a refresh.

-Alan


Request for review: 8000487: Java JNDI connection library on ldap conn is not honoring configured timeout

2012-10-11 Thread Rob McKenna

Hi folks,

Seemingly when using ldap's simple authentication we perform a 
readReply. (an operation which is subject to
com.sun.jndi.ldap.read.timeout as opposed to 
com.sun.jndi.ldap.connect.timeout) This makes an apparent connection to 
a faulty host appear to take much longer than the specified connect 
timeout. The proposed solution is to set the read timeout value to the 
same value as the connect for the duration of the authentication call.


In addition to this I've merged the testcase for this issue with the 
testcases for other ldap timeout issues.


http://cr.openjdk.java.net/~robm/8000487/webrev.01/ 



Thanks,

-Rob



Re: 8000362: (pack200) Deprecate Packer/Unpacker addPropertyChangeLister and removePropertyChangeListener methods

2012-10-11 Thread Mandy Chung

Looks fine with me.
Mandy

On 10/11/2012 6:40 AM, Alan Bateman wrote:


This is a follow-on from yesterday's mail on deprecating the 
LogManager's add/removePropertyChangeListener methods. The other 4 
problematic methods identified in JEP 162 [1] are the same name 
methods on Pack200.Packer and Pack200.Unpacker. The webrev to 
deprecate these methods is here:


http://cr.openjdk.java.net/~alanb/8000362/webrev/

As with the LogManager methods, Mandy Chung searched >2 projects. 
In this case we didn't find any usages of these methods and this gives 
us confidence that these methods are rarely used. We don't propose to 
provide a replacement for these methods but instead just include 
wording to suggest that applications poll the value of the progress 
property if they really need to provide some progress indication.


Kumar is the pack200 guru here and I know he's busy/away at the moment 
so I plan to hold onto this patch until I at least hear from him.


-Alan.

[1] http://openjdk.java.net/jeps/162


Re: Review/comment needed for the new public java.util.Base64 class

2012-10-11 Thread Ariel Weisberg
Hi,

It looks like it tackles the issue of encoding binary data as text in an
isolated fashion and doesn't seem open to adding other ways of encoding
binary data as text such as hex or yEnc. Having a common interface in
java.util for different encodings would be great. I am not asking for
more implementation, just a more abstract interface for Decoder and
Encoder.

I know that ByteBuffers are pain, but I did notice that you can't
specify a source/dest pair when using ByteBuffers and that ByteBuffers
without arrays have to be copied. I don't see a simple safe way to
normalize access to them the way you can if everything is a byte array.

Thanks,
Ariel

On Thu, Oct 11, 2012, at 12:40 PM, Xueming Shen wrote:
> On 10/11/2012 02:43 AM, Stephen Colebourne wrote:
> > The class level javadoc is quite short. It also has hyperlinks in the
> > first sentence, which means that they are visible in package level
> > javadoc. Consider having no hyperlinks in the first sentence, and
> > expanding a little on what base 64 is.
> >
> 
> Sure, will come up something longer.
> > There are lots of other public base 64 implementations to test/check 
> > against.
> > http://commons.apache.org/net/api-3.1/org/apache/commons/net/util/Base64.html
> > http://www.cs.berkeley.edu/~jonah/bc/org/bouncycastle/util/encoders/Base64.html
> > http://migbase64.sourceforge.net/  (claims to be fast)
> 
> I did compare the result against the apache version, the difference 
> appears to
> be the apache (1)append line feeds at the end of the encoded bytes 
> (2)skip the
> padding '=' characters for URL-safe style.  Will try other
> implementations.
> 
> > The arrays are defined inconsistently within the code (3 styles).
> >private Encoder(byte[] base64, byte[] newline, int linemax)
> >byte [] getBytes(ByteBuffer bb)
> >private static final byte toBase64[] =
> > I'd strongly encourage one style be used, and that it is the first of
> > the three above.
> 
> Good catch, the later two are not intentional, the leftover of old code. 
> webrev has
> been updated according.
> 
> Thanks!
> -Sherman
> 
> 
> > Stephen
> >
> >
> > On 10 October 2012 18:54, Xueming Shen  wrote:
> >> A standard/public API for Base64 encoding and decoding has been long
> >> overdue. JDK8  has a JEP [1] for this particular request.
> >>
> >> Here is the draft proposal to add a public Base64 utility class for JDK8.
> >>
> >> http://cr.openjdk.java.net/~sherman/4235519/webrev
> >>
> >> This class basically provides 4 variants of Base64 encoding scheme,
> >>
> >> (1) the default RFC 4648, which uses standard mapping, no line breaks,
> >> (2) the URL-safe RFE 4648, no line breaks, use "-" and "_" to replace "+"
> >> and
> >>  "/" for the mapping
> >> (3) the default MIME style, as in RFC 2045 (and its earlier versions), 
> >> which
> >> uses
> >>  "standard" base64 mapping, a 76 characters per line limit and uses 
> >> crlf
> >> pair
> >>   \r\n for line break.
> >> (4) an extend-able MIME base64, with the char-per-line and the line
> >> separator(s)
> >>   specified by developer.
> >>
> >> The encoder/decoder now provides encoding and decoding for byte[], String,
> >> ByteBuffer and a pair of "EncoderInputStream" and "DecoderOutputStrream",
> >> which we believe/hope should satisfy most of the common use cases.
> >> Additional
> >> method(s) can be added if strongly desired.
> >>
> >> We tried couple slightly different styles of design for such this "simple"
> >> utility
> >> class [2].  We kinda concluded that the version proposed probably provides
> >> the best balance among readability, usability and extensibility.
> >>
> >> Please help review and comment on the API and implementation.
> >>
> >> Thanks!
> >> -Sherman
> >>
> >> [1] http://openjdk.java.net/jeps/135
> >> [2] http://cr.openjdk.java.net/~sherman/base64/
> 


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

2012-10-11 Thread Lance Andersen - Oracle
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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.javaThu 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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.javaThu 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 @@
  */

hg: jdk8/tl/jdk: 7152183: TEST_BUG: java/lang/ProcessBuilder/Basic.java failing intermittently [sol]

2012-10-11 Thread rob . mckenna
Changeset: 7c2f5e52863c
Author:robm
Date:  2012-10-11 18:24 +0100
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7c2f5e52863c

7152183: TEST_BUG: java/lang/ProcessBuilder/Basic.java failing intermittently 
[sol]
Reviewed-by: alanb, martin, dholmes

! test/java/lang/ProcessBuilder/Basic.java



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

2012-10-11 Thread Lance Andersen - Oracle
Hi,

Revised CachedRowSetImpl  as I noticed Findbugs missed a scenario where  you 
should use the XXX.valueOf methods from constructors.

Thank you

Best
Lance



new-host-2:rowset lanceandersen$ hg status -m
M src/share/classes/com/sun/rowset/CachedRowSetImpl.java
M src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
M src/share/classes/javax/sql/rowset/BaseRowSet.java
M src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java

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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.javaThu Oct 11 
13:17:26 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,8 +1746,8 @@
 
 // convert to a Double and compare to zero
 try {
-Double d = new Double(value.toString());
-if (d.compareTo(new Double((double)0)) == 0) {
+Double d = Double.valueOf(value.toString());
+if (d.compareTo(Double.valueOf(0)) == 0) {
 return false;
 } else {
 return true;
@@ -4432,7 +4432,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 +4467,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:17:26 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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.javaThu Oct 11 
13:17:26 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:17:26 2012 -0400
@@ -215,7 +215,7 @@
  */
 @SuppressWarnings("unchecked")
 public void writeFloat(float x) throws SQLException {
-attribs.add(new Float(x));
+

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

2012-10-11 Thread Remi Forax

On 10/11/2012 06:45 PM, Lance Andersen - Oracle wrote:

Hi,

Need a review for changing to use the XXX.valueOf methods from constructors.

Thank you

Best
Lance


Hi Lance,
in CachedRowSetImpl, the code is equivalent to
  return Double.compare(Double.parseDouble(value.toString()), 0) != 0;
which avoid to create the Double objects.

the rest looks good.

cheers,
Rémi





new-host-2:rowset lanceandersen$ hg status -m
M src/share/classes/com/sun/rowset/CachedRowSetImpl.java
M src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
M src/share/classes/javax/sql/rowset/BaseRowSet.java
M src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java

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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.javaThu Oct 11 
12:43:57 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
@@ -1747,7 +1747,7 @@
  // convert to a Double and compare to zero
  try {
  Double d = new Double(value.toString());
-if (d.compareTo(new Double((double)0)) == 0) {
+if (d.compareTo(Double.valueOf(0)) == 0) {
  return false;
  } else {
  return true;
@@ -4432,7 +4432,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 +4467,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 
12:43:57 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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.javaThu Oct 11 
12:43:57 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/SQ

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

2012-10-11 Thread Lance Andersen - Oracle
Hi,

Need a review for changing to use the XXX.valueOf methods from constructors.

Thank you

Best
Lance



new-host-2:rowset lanceandersen$ hg status -m
M src/share/classes/com/sun/rowset/CachedRowSetImpl.java
M src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
M src/share/classes/javax/sql/rowset/BaseRowSet.java
M src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java

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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/com/sun/rowset/CachedRowSetImpl.javaThu Oct 11 
12:43:57 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
@@ -1747,7 +1747,7 @@
 // convert to a Double and compare to zero
 try {
 Double d = new Double(value.toString());
-if (d.compareTo(new Double((double)0)) == 0) {
+if (d.compareTo(Double.valueOf(0)) == 0) {
 return false;
 } else {
 return true;
@@ -4432,7 +4432,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 +4467,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 
12:43:57 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.javaThu Oct 11 
11:47:05 2012 +0100
+++ b/src/share/classes/javax/sql/rowset/BaseRowSet.javaThu Oct 11 
12:43:57 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 12:43:57 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("unche

Re: Review/comment needed for the new public java.util.Base64 class

2012-10-11 Thread Xueming Shen

On 10/11/2012 02:43 AM, Stephen Colebourne wrote:

The class level javadoc is quite short. It also has hyperlinks in the
first sentence, which means that they are visible in package level
javadoc. Consider having no hyperlinks in the first sentence, and
expanding a little on what base 64 is.



Sure, will come up something longer.

There are lots of other public base 64 implementations to test/check against.
http://commons.apache.org/net/api-3.1/org/apache/commons/net/util/Base64.html
http://www.cs.berkeley.edu/~jonah/bc/org/bouncycastle/util/encoders/Base64.html
http://migbase64.sourceforge.net/  (claims to be fast)


I did compare the result against the apache version, the difference 
appears to
be the apache (1)append line feeds at the end of the encoded bytes 
(2)skip the

padding '=' characters for URL-safe style.  Will try other implementations.


The arrays are defined inconsistently within the code (3 styles).
   private Encoder(byte[] base64, byte[] newline, int linemax)
   byte [] getBytes(ByteBuffer bb)
   private static final byte toBase64[] =
I'd strongly encourage one style be used, and that it is the first of
the three above.


Good catch, the later two are not intentional, the leftover of old code. 
webrev has

been updated according.

Thanks!
-Sherman



Stephen


On 10 October 2012 18:54, Xueming Shen  wrote:

A standard/public API for Base64 encoding and decoding has been long
overdue. JDK8  has a JEP [1] for this particular request.

Here is the draft proposal to add a public Base64 utility class for JDK8.

http://cr.openjdk.java.net/~sherman/4235519/webrev

This class basically provides 4 variants of Base64 encoding scheme,

(1) the default RFC 4648, which uses standard mapping, no line breaks,
(2) the URL-safe RFE 4648, no line breaks, use "-" and "_" to replace "+"
and
 "/" for the mapping
(3) the default MIME style, as in RFC 2045 (and its earlier versions), which
uses
 "standard" base64 mapping, a 76 characters per line limit and uses crlf
pair
  \r\n for line break.
(4) an extend-able MIME base64, with the char-per-line and the line
separator(s)
  specified by developer.

The encoder/decoder now provides encoding and decoding for byte[], String,
ByteBuffer and a pair of "EncoderInputStream" and "DecoderOutputStrream",
which we believe/hope should satisfy most of the common use cases.
Additional
method(s) can be added if strongly desired.

We tried couple slightly different styles of design for such this "simple"
utility
class [2].  We kinda concluded that the version proposed probably provides
the best balance among readability, usability and extensibility.

Please help review and comment on the API and implementation.

Thanks!
-Sherman

[1] http://openjdk.java.net/jeps/135
[2] http://cr.openjdk.java.net/~sherman/base64/




Re: 8000362: (pack200) Deprecate Packer/Unpacker addPropertyChangeLister and removePropertyChangeListener methods

2012-10-11 Thread Lance Andersen - Oracle
looks fine alan
On Oct 11, 2012, at 9:40 AM, Alan Bateman wrote:

> 
> This is a follow-on from yesterday's mail on deprecating the LogManager's 
> add/removePropertyChangeListener methods. The other 4 problematic methods 
> identified in JEP 162 [1] are the same name methods on Pack200.Packer and 
> Pack200.Unpacker. The webrev to deprecate these methods is here:
> 
> http://cr.openjdk.java.net/~alanb/8000362/webrev/
> 
> As with the LogManager methods, Mandy Chung searched >2 projects. In this 
> case we didn't find any usages of these methods and this gives us confidence 
> that these methods are rarely used. We don't propose to provide a replacement 
> for these methods but instead just include wording to suggest that 
> applications poll the value of the progress property if they really need to 
> provide some progress indication.
> 
> Kumar is the pack200 guru here and I know he's busy/away at the moment so I 
> plan to hold onto this patch until I at least hear from him.
> 
> -Alan.
> 
> [1] http://openjdk.java.net/jeps/162


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



Re: 8000362: (pack200) Deprecate Packer/Unpacker addPropertyChangeLister and removePropertyChangeListener methods

2012-10-11 Thread Chris Hegarty

The changes look ok to me.

-Chris.

On 11/10/12 14:40, Alan Bateman wrote:


This is a follow-on from yesterday's mail on deprecating the
LogManager's add/removePropertyChangeListener methods. The other 4
problematic methods identified in JEP 162 [1] are the same name methods
on Pack200.Packer and Pack200.Unpacker. The webrev to deprecate these
methods is here:

http://cr.openjdk.java.net/~alanb/8000362/webrev/

As with the LogManager methods, Mandy Chung searched >2 projects. In
this case we didn't find any usages of these methods and this gives us
confidence that these methods are rarely used. We don't propose to
provide a replacement for these methods but instead just include wording
to suggest that applications poll the value of the progress property if
they really need to provide some progress indication.

Kumar is the pack200 guru here and I know he's busy/away at the moment
so I plan to hold onto this patch until I at least hear from him.

-Alan.

[1] http://openjdk.java.net/jeps/162


Re: Reviewer needed: 6282196 There should be Math.mod(number, modulo) methods

2012-10-11 Thread Roger Riggs
The floorDiv/floorMod functions do not throw exceptions for out of range 
values

to be consistent with the builtin language math operations.
The |toIntExact |method is used by developers because it does the
range check and throws an exception.
It is cleaner not to mix the semantics of the two operations.

Roger



On 10/10/2012 10:30 AM, Stephen Colebourne wrote:

On 10 October 2012 15:22, Roger Riggs  wrote:

A reviewer is needed for:

6282196 There should be Math.mod(number, modulo) methods

The webrev is: http://cr.openjdk.java.net/~rriggs/6282196.4/

Just to note that floorMod(long, int) is not present. This is often
useful as the mod side generally fits in 32 bits, which means the
result can fit in 32 bits. This often saves the need to call
toIntExact() on the result.

Stephen


--
Thanks, Roger

Oracle Java Platform Group

Green Oracle  Oracle is committed to 
developing practices and products that help protect the environment




8000362: (pack200) Deprecate Packer/Unpacker addPropertyChangeLister and removePropertyChangeListener methods

2012-10-11 Thread Alan Bateman


This is a follow-on from yesterday's mail on deprecating the 
LogManager's add/removePropertyChangeListener methods. The other 4 
problematic methods identified in JEP 162 [1] are the same name methods 
on Pack200.Packer and Pack200.Unpacker. The webrev to deprecate these 
methods is here:


http://cr.openjdk.java.net/~alanb/8000362/webrev/

As with the LogManager methods, Mandy Chung searched >2 projects. In 
this case we didn't find any usages of these methods and this gives us 
confidence that these methods are rarely used. We don't propose to 
provide a replacement for these methods but instead just include wording 
to suggest that applications poll the value of the progress property if 
they really need to provide some progress indication.


Kumar is the pack200 guru here and I know he's busy/away at the moment 
so I plan to hold onto this patch until I at least hear from him.


-Alan.

[1] http://openjdk.java.net/jeps/162


Re: Review Request: 7186817 - Remove Windows 95/98/ME Support

2012-10-11 Thread Alan Bateman

On 11/10/2012 11:42, Alan Bateman wrote:

On 10/10/2012 21:18, Dan Xu wrote:

Thanks for your good comments.

I have changed access modifiers for methods in WinNTFileSystem.java. 
And the new webrev can be viewed at 
http://cr.openjdk.java.net/~dxu/7186817/webrev.01/


I did not change the hashCode implementation in this version. It will 
need further complete tests and another round of code review. But it 
is a good point to improve our code performance. Please log another 
bug to address this issue. Thanks!


-Dan


Thanks Dan, it looks good to me. I'll push this shortly for you.

Dan - I've pushed this for you but without the change to the following file:

make/tools/sharing/classlist.windows

The reason is that file is auto-generated and has a hash at the end so 
it's not meant to be manually edited. The class list is used by 
-Xshare:dump to generate the shared archive for class data sharing and 
is tolerant of missing classes. I think the class lists are a bit of 
date anyway and are overdue a refresh.


-Alan


Re: Review Request: 7186817 - Remove Windows 95/98/ME Support

2012-10-11 Thread Alan Bateman

On 10/10/2012 21:18, Dan Xu wrote:

Thanks for your good comments.

I have changed access modifiers for methods in WinNTFileSystem.java. 
And the new webrev can be viewed at 
http://cr.openjdk.java.net/~dxu/7186817/webrev.01/


I did not change the hashCode implementation in this version. It will 
need further complete tests and another round of code review. But it 
is a good point to improve our code performance. Please log another 
bug to address this issue. Thanks!


-Dan


Thanks Dan, it looks good to me. I'll push this shortly for you.

-Alan.


Re: Review/comment needed for the new public java.util.Base64 class

2012-10-11 Thread Stephen Colebourne
The class level javadoc is quite short. It also has hyperlinks in the
first sentence, which means that they are visible in package level
javadoc. Consider having no hyperlinks in the first sentence, and
expanding a little on what base 64 is.

There are lots of other public base 64 implementations to test/check against.
http://commons.apache.org/net/api-3.1/org/apache/commons/net/util/Base64.html
http://www.cs.berkeley.edu/~jonah/bc/org/bouncycastle/util/encoders/Base64.html
http://migbase64.sourceforge.net/  (claims to be fast)

The arrays are defined inconsistently within the code (3 styles).
  private Encoder(byte[] base64, byte[] newline, int linemax)
  byte [] getBytes(ByteBuffer bb)
  private static final byte toBase64[] =
I'd strongly encourage one style be used, and that it is the first of
the three above.

Stephen


On 10 October 2012 18:54, Xueming Shen  wrote:
>
> A standard/public API for Base64 encoding and decoding has been long
> overdue. JDK8  has a JEP [1] for this particular request.
>
> Here is the draft proposal to add a public Base64 utility class for JDK8.
>
> http://cr.openjdk.java.net/~sherman/4235519/webrev
>
> This class basically provides 4 variants of Base64 encoding scheme,
>
> (1) the default RFC 4648, which uses standard mapping, no line breaks,
> (2) the URL-safe RFE 4648, no line breaks, use "-" and "_" to replace "+"
> and
> "/" for the mapping
> (3) the default MIME style, as in RFC 2045 (and its earlier versions), which
> uses
> "standard" base64 mapping, a 76 characters per line limit and uses crlf
> pair
>  \r\n for line break.
> (4) an extend-able MIME base64, with the char-per-line and the line
> separator(s)
>  specified by developer.
>
> The encoder/decoder now provides encoding and decoding for byte[], String,
> ByteBuffer and a pair of "EncoderInputStream" and "DecoderOutputStrream",
> which we believe/hope should satisfy most of the common use cases.
> Additional
> method(s) can be added if strongly desired.
>
> We tried couple slightly different styles of design for such this "simple"
> utility
> class [2].  We kinda concluded that the version proposed probably provides
> the best balance among readability, usability and extensibility.
>
> Please help review and comment on the API and implementation.
>
> Thanks!
> -Sherman
>
> [1] http://openjdk.java.net/jeps/135
> [2] http://cr.openjdk.java.net/~sherman/base64/


Re: Review/comment needed for the new public java.util.Base64 class

2012-10-11 Thread Alan Bateman

On 11/10/2012 04:15, Xueming Shen wrote:
There is no plan yet. The sun.misc.BASE64En/Decoder should already 
trigger a compiler
warning for it's a sun private API. @Deprecated annotation might be a 
good fit.


-Sherman
Yes, I think we should deprecate them. The other thing suggested in the 
JEP is that we would also look usages in the JDK, also other 
implementations (as there are many) to see if they can be retired. This 
can of course be done later. It also an opportunity for contributions, 
say for example someone might like to look at java.util.prefs to retire 
the implementation there. Another one that might be able to retire is 
the implementation in the com.sun.net.httpserver.BasicAuthenticator 
class and there are others.


-Alan