Skip to content

Commit 190ffcb

Browse files
authored
Cleanup the use of Float primitive wrapper. As of Java 9, the VM can do a better job of handling the (#3890)
coversion from a float primitive to a Float Object or vice versa. This is an extension of the work done in #2498. No tests have been touched as those expressly need to manage the conversion.
1 parent f47ca71 commit 190ffcb

File tree

21 files changed

+30
-70
lines changed

21 files changed

+30
-70
lines changed

ide/api.debugger/src/org/netbeans/api/debugger/Properties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ public Object read(String className, Properties properties) {
14781478
} else if (classNames[5].equals(className)) {
14791479
return new Long(properties.getLong(propertyName, 0l));
14801480
} else if (classNames[6].equals(className)) {
1481-
return new Float(properties.getFloat(propertyName, 0f));
1481+
return properties.getFloat(propertyName, 0f);
14821482
} else if (classNames[7].equals(className)) {
14831483
return new Double(properties.getDouble(propertyName, 0d));
14841484
}

ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/TokenAcceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public Float getNumberValue(CharSequence image) {
312312
Float f = super.getNumberValue(image);
313313
if(f == null) {
314314
if(image.length() > 0 && image.charAt(0) == '0') {
315-
f = new Float(0);
315+
f = 0F;
316316
}
317317
}
318318
return f;

ide/db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ public static Object validate(Object valueObj, DBColumn col) throws DBException
445445

446446
case Types.FLOAT:
447447
case Types.REAL:
448-
return valueObj instanceof Float ? valueObj : new Float(valueObj.toString());
448+
return valueObj instanceof Float ? valueObj : Float.valueOf(valueObj.toString());
449449

450450
case Types.DECIMAL:
451451
case Types.NUMERIC:

ide/schema2beans/src/org/netbeans/modules/schema2beans/Common.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public static Object defaultScalarValue(int type) {
385385
case Common.TYPE_LONG:
386386
return new Long(0);
387387
case Common.TYPE_FLOAT:
388-
return new Float(0.0);
388+
return 0.0F;
389389
case Common.TYPE_DOUBLE:
390390
return new Double(0.0);
391391
default:

ide/schema2beans/src/org/netbeans/modules/schema2beans/GraphManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ public Object defaultScalarValue(int type) {
898898
case Common.TYPE_LONG:
899899
return new Long(0);
900900
case Common.TYPE_FLOAT:
901-
return new Float(0.0);
901+
return 0.0F;
902902
case Common.TYPE_DOUBLE:
903903
return new Double(0.0);
904904
default:

java/classfile/src/org/netbeans/modules/classfile/CPFloatInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public final class CPFloatInfo extends CPEntry {
3232

3333
CPFloatInfo(ConstantPool pool, float v) {
3434
super(pool);
35-
value = new Float(v);
35+
value = v;
3636
}
3737

3838
public final int getTag() {

java/performance/benchmarks/src/org/netbeans/performance/benchmarks/XMLReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void addSample( String className, String methodName, Object argument, flo
5858
Map methods = getSubMap( classes, className );
5959
Map args = getSubMap( methods, methodName );
6060
List samples = getSubList( args, argument2String(argument) );
61-
samples.add( new Float( value ) );
61+
samples.add(value);
6262
}
6363

6464
public void flush() {

java/performance/sparrow/src/org/netbeans/performance/impl/logparsing/GcLog.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
*/
2424

2525
package org.netbeans.performance.impl.logparsing;
26+
2627
import org.netbeans.performance.spi.html.*;
2728
import org.netbeans.performance.spi.*;
2829
import java.util.*;
30+
2931
/**Wrapper class for a JDK garbage collection log. This wrapper parses the log
3032
* and comes up with statistics representing data from it. It does not hold onto
3133
* all of the GC events in a garbage collection log. For a log wrapper that can
@@ -139,21 +141,21 @@ protected void parse() throws ParseException {
139141
}
140142
}
141143

142-
addElement (new NameValueLogElement (GC_SECONDS, new Float(totalGcTime)));
144+
addElement (new NameValueLogElement (GC_SECONDS, totalGcTime));
143145
addElement (new NameValueLogElement (GC_TOTAL, new Integer(gcs.size())));
144146
addElement (new NameValueLogElement (GC_FULLTOTAL, new Integer(fullGcCount)));
145147
addElement (new NameValueLogElement (GC_MINORTOTAL, new Integer(gcs.size() - fullGcCount)));
146148
addElement (new NameValueLogElement (GC_TOTALGARBAGE, new Long(totalCollected)));
147149
addElement (new NameValueLogElement (GC_HGES, new Integer(heapChangeCount)));
148150
addElement (new NameValueLogElement (GC_AVGCOLLECTEDPERGC, new Long(totalCollected / gcs.size())));
149-
addElement (new NameValueLogElement (GC_SECSMAJOR, new Float(totalMajorGcTime)));
150-
addElement (new NameValueLogElement (GC_SECSMINOR, new Float(totalMinorGcTime)));
151+
addElement (new NameValueLogElement (GC_SECSMAJOR, totalMajorGcTime));
152+
addElement (new NameValueLogElement (GC_SECSMINOR, totalMinorGcTime));
151153
if (fullGcCount != 0) {
152-
addElement (new NameValueLogElement (GC_AVGMILLISMAJOR, new Float((totalMajorGcTime / fullGcCount) * 1000)));
154+
addElement (new NameValueLogElement (GC_AVGMILLISMAJOR, (float)((totalMajorGcTime / fullGcCount) * 1000)));
153155
} else {
154-
addElement (new NameValueLogElement (GC_AVGMILLISMAJOR, new Float (0)));
156+
addElement (new NameValueLogElement (GC_AVGMILLISMAJOR, 0F));
155157
}
156-
addElement (new NameValueLogElement (GC_AVGMILLISMINOR, new Float((totalMinorGcTime / (gcs.size() - fullGcCount))*1000)));
158+
addElement (new NameValueLogElement (GC_AVGMILLISMINOR, (float)((totalMinorGcTime / (gcs.size() - fullGcCount))*1000)));
157159

158160
}
159161
}

java/performance/sparrow/src/org/netbeans/performance/spi/AveragedNameValueLogElement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ protected void averageElements (ValueLogElement[] el) {
7878
* used to create this element.
7979
* the set of values used to create this element. */
8080
public Float getMin() {
81-
return new Float (samples[0]);
81+
return samples[0];
8282
}
8383

8484
/** Returns the highest value in the set of values
8585
* used to create this element.
8686
* the set of values used to create this element. */
8787
public Float getMax() {
88-
return new Float(samples[samples.length-1]);
88+
return samples[samples.length-1];
8989
}
9090

9191
/** Returns the mean, or arithmetic average of
@@ -105,7 +105,7 @@ public Float getMedian() {
105105
} else {
106106
result = samples[samples.length/2];
107107
}
108-
return new Float(result);
108+
return result;
109109
}
110110

111111
/** Returns the values used to create this element. */

nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ private ArrayWrapper readNewArray() throws IOException {
502502
} else if (aw.classdesc.name.equals("[J")) { // NOI18N
503503
aw.values.add(new Long(readLong()));
504504
} else if (aw.classdesc.name.equals("[F")) { // NOI18N
505-
aw.values.add(new Float(Float.intBitsToFloat(readInt())));
505+
aw.values.add(Float.intBitsToFloat(readInt()));
506506
} else if (aw.classdesc.name.equals("[D")) { // NOI18N
507507
aw.values.add(new Double(Double.longBitsToDouble(readLong())));
508508
} else if (aw.classdesc.name.equals("[C")) { // NOI18N
@@ -566,7 +566,7 @@ private List<NameValue> readNoWrClass(ClassDesc cd) throws IOException {
566566
} else if (fd.type.equals("J")) { // NOI18N
567567
values.add(new NameValue(fd, new Long(readLong())));
568568
} else if (fd.type.equals("F")) { // NOI18N
569-
values.add(new NameValue(fd, new Float(Float.intBitsToFloat(readInt()))));
569+
values.add(new NameValue(fd, Float.intBitsToFloat(readInt())));
570570
} else if (fd.type.equals("D")) { // NOI18N
571571
values.add(new NameValue(fd, new Double(Double.longBitsToDouble(readLong()))));
572572
} else if (fd.type.equals("C")) { // NOI18N

0 commit comments

Comments
 (0)