Really Happy to hear that. Done.
On Sat, May 24, 2014 at 5:10 PM, Andrej Golovnin <andrej.golov...@gmail.com>wrote: > Hi Otávio, > > it would be nice, if you would not modify the classes > sun.reflect.UnsafeXXXFieldAccessorImpl. > This classes should be changed as a part of the fix for the issue > JDK-5043030. > The patch for this issue is already in work. > > Best regards, > Andrej Golovnin > > On 24.05.2014, at 16:34, Otávio Gonçalves de Santana <otavioj...@java.net> > wrote: > > > The Boolean class has cache for true and false and using it, will save > > memory and will faster than using create new instance of boolean. > > Using JMH[1] with a code test[2] the result was: > > Benchmark Mode > Samples > > Mean Mean error Units > > m.BooleanBenchmark.newInstanceBoolean thrpt 20 > 49801.326 > > 369.897 ops/s > > m.BooleanBenchmark.newInstanceString thrpt 20 > > 365.080 27.537 ops/s > > m.BooleanBenchmark.valueOfBoolean thrpt 20 > 764906233.316 > > 9623009.653 ops/s > > m.BooleanBenchmark.valueOfString thrpt 20 > > 371.174 28.216 ops/s > > > > > > > > The diff is on attachment or can is downloading the webdrev here: > > > https://dl.dropboxusercontent.com/u/16109193/open_jdk/boolean_instance_of.zip > > > > [1] http://openjdk.java.net/projects/code-tools/jmh/ > > > > [2] > > > > @State(Scope.Thread) > > > > @OutputTimeUnit(TimeUnit.SECONDS) > > > > public class BooleanBenchmark { > > > > private static final int SIZE = 1_000_000; > > > > private List<String> booleanString; > > > > private boolean[] booleans; > > > > { > > > > booleans = new boolean[SIZE]; > > > > booleanString = new ArrayList<>(SIZE); > > > > for (int index = 0; index < SIZE; index++) { > > > > if (index % 2 == 0) { > > > > booleans[index] = true; > > > > booleanString.add(Boolean.TRUE.toString()); > > > > } else { > > > > booleans[index] = false; > > > > booleanString.add(Boolean.FALSE.toString()); > > > > } > > > > } > > > > } > > > > @GenerateMicroBenchmark > > > > public void valueOfBoolean() { > > > > > > for(boolean b: booleans) { > > > > Boolean result = b; > > > > } > > > > } > > > > @GenerateMicroBenchmark > > > > public void valueOfString() { > > > > for(String b: booleanString) { > > > > Boolean result = Boolean.valueOf(b); > > > > } > > > > } > > > > @GenerateMicroBenchmark > > > > public void newInstanceBoolean() { > > > > > > for(boolean b: booleans) { > > > > Boolean result = new Boolean(b); > > > > } > > > > } > > > > @GenerateMicroBenchmark > > > > public void newInstanceString() { > > > > for(String b: booleanString) { > > > > Boolean result = new Boolean(b); > > > > } > > > > } > > > > } > > > > -- > > Atenciosamente. > > > > Otávio Gonçalves de Santana > > > > blog: http://otaviosantana.blogspot.com.br/ > > twitter: http://twitter.com/otaviojava > > site: http://www.otaviojava.com.br > > (11) 98255-3513 > > <boolean.diff> > > -- Atenciosamente. Otávio Gonçalves de Santana blog: http://otaviosantana.blogspot.com.br/ twitter: http://twitter.com/otaviojava site: http://www.otaviojava.com.br (11) 98255-3513
diff -r 28d1de89ff27 src/share/classes/java/net/Socket.java --- a/src/share/classes/java/net/Socket.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/java/net/Socket.java Sat May 24 10:55:43 2014 -0300 @@ -1017,7 +1017,7 @@ if (isClosed()) throw new SocketException("Socket is closed"); if (!on) { - getImpl().setOption(SocketOptions.SO_LINGER, new Boolean(on)); + getImpl().setOption(SocketOptions.SO_LINGER, on); } else { if (linger < 0) { throw new IllegalArgumentException("invalid value for SO_LINGER"); diff -r 28d1de89ff27 src/share/classes/sun/font/SunFontManager.java --- a/src/share/classes/sun/font/SunFontManager.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/sun/font/SunFontManager.java Sat May 24 10:55:43 2014 -0300 @@ -2871,8 +2871,7 @@ new java.security.PrivilegedAction<Object>() { public Object run() { SecurityManager sm = System.getSecurityManager(); - return new Boolean - (sm instanceof sun.applet.AppletSecurity); + return sm instanceof sun.applet.AppletSecurity; } }); return appletSM.booleanValue(); diff -r 28d1de89ff27 src/share/classes/sun/management/StackTraceElementCompositeData.java --- a/src/share/classes/sun/management/StackTraceElementCompositeData.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/sun/management/StackTraceElementCompositeData.java Sat May 24 10:55:43 2014 -0300 @@ -68,7 +68,7 @@ ste.getMethodName(), ste.getFileName(), new Integer(ste.getLineNumber()), - new Boolean(ste.isNativeMethod()), + ste.isNativeMethod(), }; try { return new CompositeDataSupport(stackTraceElementCompositeType, diff -r 28d1de89ff27 src/share/classes/sun/management/ThreadInfoCompositeData.java --- a/src/share/classes/sun/management/ThreadInfoCompositeData.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/sun/management/ThreadInfoCompositeData.java Sat May 24 10:55:43 2014 -0300 @@ -120,8 +120,8 @@ new Long(threadInfo.getLockOwnerId()), threadInfo.getLockOwnerName(), stackTraceData, - new Boolean(threadInfo.isSuspended()), - new Boolean(threadInfo.isInNative()), + threadInfo.isSuspended(), + threadInfo.isInNative(), lockedMonitorsData, lockedSyncsData, }; diff -r 28d1de89ff27 src/share/classes/sun/management/VMOptionCompositeData.java --- a/src/share/classes/sun/management/VMOptionCompositeData.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/sun/management/VMOptionCompositeData.java Sat May 24 10:55:43 2014 -0300 @@ -59,7 +59,7 @@ final Object[] vmOptionItemValues = { option.getName(), option.getValue(), - new Boolean(option.isWriteable()), + option.isWriteable(), option.getOrigin().toString(), }; diff -r 28d1de89ff27 src/share/classes/sun/security/jgss/GSSManagerImpl.java --- a/src/share/classes/sun/security/jgss/GSSManagerImpl.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/sun/security/jgss/GSSManagerImpl.java Sat May 24 10:55:43 2014 -0300 @@ -50,8 +50,8 @@ if (osname.startsWith("SunOS") || osname.contains("OS X") || osname.startsWith("Linux")) { - return new Boolean(System.getProperty - (USE_NATIVE_PROP)); + return Boolean.valueOf(System.getProperty + (USE_NATIVE_PROP)); } return Boolean.FALSE; } diff -r 28d1de89ff27 src/share/classes/sun/security/provider/PolicyFile.java --- a/src/share/classes/sun/security/provider/PolicyFile.java Thu May 22 12:54:02 2014 -0700 +++ b/src/share/classes/sun/security/provider/PolicyFile.java Sat May 24 10:55:43 2014 -0300 @@ -1271,7 +1271,7 @@ Boolean imp = AccessController.doPrivileged (new PrivilegedAction<Boolean>() { public Boolean run() { - return new Boolean(entry.getCodeSource().implies(cs)); + return entry.getCodeSource().implies(cs); } }); if (!imp.booleanValue()) {