This is an automated email from the ASF dual-hosted git repository. bwalker pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new ce03e1d It is more efficient to allow the VM to manage the auto-boxing of certain primitives than it is to invoke the (#3821) ce03e1d is described below commit ce03e1d155a213eadc329f038a70df5b2a994bdf Author: Brad Walker <bwal...@musings.com> AuthorDate: Sun Mar 20 19:30:47 2022 -0600 It is more efficient to allow the VM to manage the auto-boxing of certain primitives than it is to invoke the (#3821) It is more efficient to allow the VM to manage the auto-boxing of certain primitives than it is to invoke the object constructor. This change cleans up Byte & Short for this. Tests have been left untouched because we expressly want to handle the autoboxing in each particular test. --- .../src/org/netbeans/api/debugger/Properties.java | 4 +- .../src/org/netbeans/lib/html/lexer/HtmlLexer.java | 6 +-- .../javascript2/debug/sources/SourceURLMapper.java | 2 +- .../org/netbeans/modules/schema2beans/Common.java | 50 +++++++++++----------- .../modules/schema2beans/GraphManager.java | 6 +-- .../api/debugger/jpda/testapps/EvaluatorApp.java | 3 ++ .../modules/db/test/jdbcstub/JDBCStubUtil.java | 2 +- .../unit/src/org/netbeans/test/stub/api/Stub.java | 4 +- .../netbeans/upgrade/systemoptions/SerParser.java | 11 +++-- .../propertysheet/IndexedPropertyEditor.java | 4 +- .../src/org/openide/filesystems/XMLMapAttr.java | 4 +- .../src/org/openide/windows/TopComponent.java | 2 +- .../websvc/saas/codegen/model/ParameterInfo.java | 2 +- 13 files changed, 51 insertions(+), 49 deletions(-) diff --git a/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java b/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java index 0569573..2878e06 100644 --- a/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java +++ b/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java @@ -1468,11 +1468,11 @@ public abstract class Properties { if (classNames[0].equals(className)) { return Boolean.valueOf(properties.getBoolean(propertyName, false)); } else if (classNames[1].equals(className)) { - return new Byte(properties.getByte(propertyName, (byte) 0)); + return properties.getByte(propertyName, (byte)0); } else if (classNames[2].equals(className)) { return new Character(properties.getChar(propertyName, (char) 0)); } else if (classNames[3].equals(className)) { - return new Short(properties.getShort(propertyName, (short) 0)); + return properties.getShort(propertyName, (short)0); } else if (classNames[4].equals(className)) { return Integer.valueOf(properties.getInt(propertyName, 0)); } else if (classNames[5].equals(className)) { diff --git a/ide/html.lexer/src/org/netbeans/lib/html/lexer/HtmlLexer.java b/ide/html.lexer/src/org/netbeans/lib/html/lexer/HtmlLexer.java index d44dafd..a3cc0ab 100644 --- a/ide/html.lexer/src/org/netbeans/lib/html/lexer/HtmlLexer.java +++ b/ide/html.lexer/src/org/netbeans/lib/html/lexer/HtmlLexer.java @@ -606,7 +606,7 @@ public final class HtmlLexer implements Lexer<HTMLTokenId> { if(input.readLength() > closeDelimiter.length()) { input.backup(closeDelimiter.length()); //save the provider's index in the token's property so we can set the corresponding embdding in HTMLTokenId.language() - return token(HTMLTokenId.EL_CONTENT, new HtmlTokenPropertyProvider(EL_CONTENT_PROVIDER_INDEX, new Byte((byte)(customELIndex - 1)))); + return token(HTMLTokenId.EL_CONTENT, new HtmlTokenPropertyProvider(EL_CONTENT_PROVIDER_INDEX, (byte)(customELIndex - 1))); } else { //return the open symbol token and switch to "in el" state lexerState = INIT; @@ -1088,7 +1088,7 @@ public final class HtmlLexer implements Lexer<HTMLTokenId> { if(input.readLength() > closeDelimiter.length()) { input.backup(closeDelimiter.length()); //save the provider's index in the token's property so we can set the corresponding embdding in HTMLTokenId.language() - return token(HTMLTokenId.EL_CONTENT, new HtmlTokenPropertyProvider(EL_CONTENT_PROVIDER_INDEX, new Byte((byte)(customELIndex - 1)))); + return token(HTMLTokenId.EL_CONTENT, new HtmlTokenPropertyProvider(EL_CONTENT_PROVIDER_INDEX, (byte)(customELIndex - 1))); } else { //return the close symbol token and switch to "in value" state lexerState = ISI_VAL_QUOT; @@ -1416,7 +1416,7 @@ public final class HtmlLexer implements Lexer<HTMLTokenId> { case ISI_EL: case ISI_VAL_QUOT_EL: - return token(HTMLTokenId.EL_CONTENT, new HtmlTokenPropertyProvider(EL_CONTENT_PROVIDER_INDEX, new Byte((byte)(customELIndex - 1)))); + return token(HTMLTokenId.EL_CONTENT, new HtmlTokenPropertyProvider(EL_CONTENT_PROVIDER_INDEX, (byte)(customELIndex - 1))); } diff --git a/ide/javascript2.debug/src/org/netbeans/modules/javascript2/debug/sources/SourceURLMapper.java b/ide/javascript2.debug/src/org/netbeans/modules/javascript2/debug/sources/SourceURLMapper.java index 37f68f2..ee6f191 100644 --- a/ide/javascript2.debug/src/org/netbeans/modules/javascript2/debug/sources/SourceURLMapper.java +++ b/ide/javascript2.debug/src/org/netbeans/modules/javascript2/debug/sources/SourceURLMapper.java @@ -183,7 +183,7 @@ public final class SourceURLMapper extends URLMapper { List<Byte> bytes = new ArrayList<>(); while (text.length() > (i + 2) && text.charAt(i) == '%') { int v = Integer.parseInt(text.substring(i+1, i+3), 16); - bytes.add(new Byte((byte) (v & 0xFF))); + bytes.add((byte)(v & 0xFF)); i += 3; } byte[] byteArray = new byte[bytes.size()]; diff --git a/ide/schema2beans/src/org/netbeans/modules/schema2beans/Common.java b/ide/schema2beans/src/org/netbeans/modules/schema2beans/Common.java index f0c7236..a1e9f39 100644 --- a/ide/schema2beans/src/org/netbeans/modules/schema2beans/Common.java +++ b/ide/schema2beans/src/org/netbeans/modules/schema2beans/Common.java @@ -367,33 +367,33 @@ public class Common { } public static Object defaultScalarValue(int type) { - switch(type & Common.MASK_TYPE) { - case Common.TYPE_STRING: - return ""; // NOI18N - case Common.TYPE_COMMENT: - return ""; // NOI18N - case Common.TYPE_BOOLEAN: - return Boolean.FALSE; - case Common.TYPE_BYTE: - return new Byte((byte)0); - case Common.TYPE_CHAR: - return new Character('\0'); - case Common.TYPE_SHORT: - return new Short((short)0); - case Common.TYPE_INT: - return Integer.valueOf(0); - case Common.TYPE_LONG: - return new Long(0); - case Common.TYPE_FLOAT: - return new Float(0.0); - case Common.TYPE_DOUBLE: - return new Double(0.0); - default: - throw new IllegalArgumentException(Common.getMessage( - "UnknownType_msg", Integer.valueOf(type))); + switch (type & Common.MASK_TYPE) { + case Common.TYPE_STRING: + return ""; // NOI18N + case Common.TYPE_COMMENT: + return ""; // NOI18N + case Common.TYPE_BOOLEAN: + return Boolean.FALSE; + case Common.TYPE_BYTE: + return (byte)0; + case Common.TYPE_CHAR: + return new Character('\0'); + case Common.TYPE_SHORT: + return (short)0; + case Common.TYPE_INT: + return Integer.valueOf(0); + case Common.TYPE_LONG: + return new Long(0); + case Common.TYPE_FLOAT: + return new Float(0.0); + case Common.TYPE_DOUBLE: + return new Double(0.0); + default: + throw new IllegalArgumentException(Common.getMessage( + "UnknownType_msg", Integer.valueOf(type))); } } - + /* * Bundle utility methods. The following methods return a formated message diff --git a/ide/schema2beans/src/org/netbeans/modules/schema2beans/GraphManager.java b/ide/schema2beans/src/org/netbeans/modules/schema2beans/GraphManager.java index a71ef72..50e0569 100644 --- a/ide/schema2beans/src/org/netbeans/modules/schema2beans/GraphManager.java +++ b/ide/schema2beans/src/org/netbeans/modules/schema2beans/GraphManager.java @@ -888,11 +888,11 @@ public class GraphManager extends Object { case Common.TYPE_BOOLEAN: return Boolean.FALSE; case Common.TYPE_BYTE: - return new Byte((byte)0); + return (byte)0; case Common.TYPE_CHAR: return new Character('\0'); case Common.TYPE_SHORT: - return new Short((short)0); + return (short)0; case Common.TYPE_INT: return Integer.valueOf(0); case Common.TYPE_LONG: @@ -902,7 +902,7 @@ public class GraphManager extends Object { case Common.TYPE_DOUBLE: return new Double(0.0); default: - throw new IllegalArgumentException(Common.getMessage("UnknownType", type)); + throw new IllegalArgumentException(Common.getMessage("UnknownType", type)); } } } diff --git a/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java b/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java index b1d8995..b35bbae 100644 --- a/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java +++ b/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/EvaluatorApp.java @@ -42,6 +42,9 @@ import java.util.Vector; * both after the invocation of the expression and invocation of the method. * * @author Martin Entlicher + * + * WARNING: Do not change any of the primitive auto-boxing. It could potentially + * break the tests. We expressly want it done as part of testing. */ public class EvaluatorApp extends BaseClass { diff --git a/java/j2ee.persistence/test/unit/src/org/netbeans/modules/db/test/jdbcstub/JDBCStubUtil.java b/java/j2ee.persistence/test/unit/src/org/netbeans/modules/db/test/jdbcstub/JDBCStubUtil.java index 8d60059..99c74e5 100644 --- a/java/j2ee.persistence/test/unit/src/org/netbeans/modules/db/test/jdbcstub/JDBCStubUtil.java +++ b/java/j2ee.persistence/test/unit/src/org/netbeans/modules/db/test/jdbcstub/JDBCStubUtil.java @@ -209,7 +209,7 @@ public final class JDBCStubUtil { private static void addAllAsReferenceType(List list, short[] values) { for (int i = 0; i < values.length; i++) { - list.add(new Short(values[i])); + list.add(values[i]); } } diff --git a/java/j2ee.persistence/test/unit/src/org/netbeans/test/stub/api/Stub.java b/java/j2ee.persistence/test/unit/src/org/netbeans/test/stub/api/Stub.java index bdd9f4d..eff1eae 100644 --- a/java/j2ee.persistence/test/unit/src/org/netbeans/test/stub/api/Stub.java +++ b/java/j2ee.persistence/test/unit/src/org/netbeans/test/stub/api/Stub.java @@ -143,9 +143,9 @@ public final class Stub { if (retClass.isPrimitive()) { if (retClass == Byte.TYPE) { - return new Byte((byte)0); + return (byte)0; } else if (retClass == Short.TYPE) { - return new Short((short)0); + return (short)0; } else if (retClass == Integer.TYPE) { return new Integer(0); } else if (retClass == Long.TYPE) { diff --git a/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java b/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java index 9d91317..081e347 100644 --- a/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java +++ b/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SerParser.java @@ -493,9 +493,9 @@ public final class SerParser implements ObjectStreamConstants { aw.values = new ArrayList<Object>(size); for (int i = 0; i < size; i++) { if (aw.classdesc.name.equals("[B")) { // NOI18N - aw.values.add(new Byte(readByte())); + aw.values.add(readByte()); } else if (aw.classdesc.name.equals("[S")) { // NOI18N - aw.values.add(new Short(readShort())); + aw.values.add(readShort()); } else if (aw.classdesc.name.equals("[I")) { // NOI18N aw.values.add(new Integer(readInt())); } else if (aw.classdesc.name.equals("[J")) { // NOI18N @@ -553,13 +553,13 @@ public final class SerParser implements ObjectStreamConstants { private List<NameValue> readNoWrClass(ClassDesc cd) throws IOException { List<FieldDesc> fields = cd.fields; - List<NameValue> values = new ArrayList<NameValue>(fields.size()); + List<NameValue> values = new ArrayList<>(fields.size()); for (int i = 0; i < fields.size(); i++) { FieldDesc fd = (FieldDesc)fields.get(i); if (fd.type.equals("B")) { // NOI18N - values.add(new NameValue(fd, new Byte(readByte()))); + values.add(new NameValue(fd, readByte())); } else if (fd.type.equals("S")) { // NOI18N - values.add(new NameValue(fd, new Short(readShort()))); + values.add(new NameValue(fd, readShort())); } else if (fd.type.equals("I")) { // NOI18N values.add(new NameValue(fd, new Integer(readInt()))); } else if (fd.type.equals("J")) { // NOI18N @@ -579,5 +579,4 @@ public final class SerParser implements ObjectStreamConstants { if (DEBUG) System.err.println("readNoWrClass: " + values); // NOI18N return values; } - } diff --git a/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java b/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java index 00b4007..11d786d 100644 --- a/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java +++ b/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java @@ -352,7 +352,7 @@ class IndexedPropertyEditor extends Object implements ExPropertyEditor { } if (getConvertedType().equals(Byte.class)) { - value = new Byte((byte) 0); + value = (byte)0; } if (getConvertedType().equals(Character.class)) { @@ -372,7 +372,7 @@ class IndexedPropertyEditor extends Object implements ExPropertyEditor { } if (getConvertedType().equals(Short.class)) { - value = new Short((short) 0); + value = (short)0; } } else { try { diff --git a/platform/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java b/platform/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java index 56c675a..c95e0ac 100644 --- a/platform/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java +++ b/platform/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java @@ -918,9 +918,9 @@ final class XMLMapAttr implements Map { try { switch (index) { case 0: - return new Byte(value); + return Byte.valueOf(value); case 1: - return new Short(value); + return Short.valueOf(value); case 2: return new Integer(value); //(objI); case 3: diff --git a/platform/openide.windows/src/org/openide/windows/TopComponent.java b/platform/openide.windows/src/org/openide/windows/TopComponent.java index 099747d..2eb922f 100644 --- a/platform/openide.windows/src/org/openide/windows/TopComponent.java +++ b/platform/openide.windows/src/org/openide/windows/TopComponent.java @@ -1164,7 +1164,7 @@ public class TopComponent extends JComponent implements Externalizable, Accessib * @param out the stream to serialize to */ public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(new Short(serialVersion)); + out.writeObject(serialVersion); out.writeInt(closeOperation); out.writeObject(getName()); out.writeObject(getToolTipText()); diff --git a/websvccommon/websvc.saas.codegen/src/org/netbeans/modules/websvc/saas/codegen/model/ParameterInfo.java b/websvccommon/websvc.saas.codegen/src/org/netbeans/modules/websvc/saas/codegen/model/ParameterInfo.java index 3d82e81..d73d9b9 100644 --- a/websvccommon/websvc.saas.codegen/src/org/netbeans/modules/websvc/saas/codegen/model/ParameterInfo.java +++ b/websvccommon/websvc.saas.codegen/src/org/netbeans/modules/websvc/saas/codegen/model/ParameterInfo.java @@ -179,7 +179,7 @@ public class ParameterInfo { if (type == Integer.class || type == Integer.TYPE) { return new Integer(0); } else if (type == Short.class || type == Short.TYPE) { - return new Short((short) 0); + return (short)0; } else if (type == Long.class || type == Long.TYPE) { return new Long(0); } else if (type == Float.class || type == Float.TYPE) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists