From ff0ad0493ee1729c726587f667761b04101d774c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 12 Aug 2014 15:09:06 +0200 Subject: java: use 'Integer.valueOf' instead of 'new Integer' Change-Id: Ia8befb8d69914ce971174fc5f2ffc0e2f506a940 --- .../lib/uno/bridges/java_remote/ProxyFactory.java | 2 +- .../sun/star/lib/uno/protocols/urp/Unmarshal.java | 2 +- jurt/com/sun/star/lib/uno/protocols/urp/urp.java | 10 ++++---- jurt/com/sun/star/uno/AnyConverter.java | 6 ++--- .../environments/java/java_environment_Test.java | 2 +- .../lib/uno/protocols/urp/Marshaling_Test.java | 30 +++++++++++----------- .../star/lib/uno/protocols/urp/Protocol_Test.java | 2 +- jurt/test/com/sun/star/uno/AnyConverter_Test.java | 8 +++--- 8 files changed, 31 insertions(+), 31 deletions(-) (limited to 'jurt') diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java index 465769be3768..edcceca44757 100644 --- a/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java +++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java @@ -107,7 +107,7 @@ final class ProxyFactory { return Boolean.valueOf(args[0] != null && oid.equals(UnoRuntime.generateOid(args[0]))); } else if (method.equals(METHOD_HASH_CODE)) { - return new Integer(oid.hashCode()); + return Integer.valueOf(oid.hashCode()); } else if (method.equals(METHOD_TO_STRING)) { return "[Proxy:" + System.identityHashCode(proxy) + "," + oid + "," + type + "]"; diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java b/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java index 2a4c9d5029a9..b2776e23b66d 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/Unmarshal.java @@ -226,7 +226,7 @@ final class Unmarshal { private Integer readLongValue() { try { - return new Integer(input.readInt()); + return Integer.valueOf(input.readInt()); } catch (IOException e) { throw new RuntimeException(e.toString()); } diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java index 08e7ef3380a2..f60f697ead51 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java @@ -204,7 +204,7 @@ public final class urp implements IProtocol { true, PROPERTIES_OID, TypeDescription.getTypeDescription(XProtocolProperties.class), PROPERTIES_FUN_REQUEST_CHANGE, propertiesTid, - new Object[] { new Integer(random) }); + new Object[] { Integer.valueOf(random) }); state = STATE_REQUESTED; } @@ -225,7 +225,7 @@ public final class urp implements IProtocol { case STATE_INITIAL0: case STATE_INITIAL: writeReply( - false, message.getThreadId(), new Integer(1)); + false, message.getThreadId(), Integer.valueOf(1)); state = STATE_WAIT; break; case STATE_REQUESTED: @@ -233,16 +233,16 @@ public final class urp implements IProtocol { = ((Integer) message.getArguments()[0]).intValue(); if (random < n) { writeReply( - false, message.getThreadId(), new Integer(1)); + false, message.getThreadId(), Integer.valueOf(1)); state = STATE_WAIT; } else if (random == n) { writeReply( - false, message.getThreadId(), new Integer(-1)); + false, message.getThreadId(), Integer.valueOf(-1)); state = STATE_INITIAL; sendRequestChange(); } else { writeReply( - false, message.getThreadId(), new Integer(0)); + false, message.getThreadId(), Integer.valueOf(0)); } break; default: diff --git a/jurt/com/sun/star/uno/AnyConverter.java b/jurt/com/sun/star/uno/AnyConverter.java index 873deb157da2..9acdb1622e16 100644 --- a/jurt/com/sun/star/uno/AnyConverter.java +++ b/jurt/com/sun/star/uno/AnyConverter.java @@ -555,10 +555,10 @@ public class AnyConverter case TypeClass.LONG_value: switch (tc) { case TypeClass.BYTE_value: - return new Integer( ((Byte)object).byteValue() ); + return Integer.valueOf( ((Byte)object).byteValue() ); case TypeClass.SHORT_value: case TypeClass.UNSIGNED_SHORT_value: - return new Integer( ((Short)object).shortValue() ); + return Integer.valueOf( ((Short)object).shortValue() ); case TypeClass.LONG_value: return object; } @@ -566,7 +566,7 @@ public class AnyConverter case TypeClass.UNSIGNED_LONG_value: switch (tc) { case TypeClass.UNSIGNED_SHORT_value: - return new Integer( ((Short)object).shortValue() ); + return Integer.valueOf( ((Short)object).shortValue() ); case TypeClass.UNSIGNED_LONG_value: return object; } diff --git a/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java b/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java index fc03dc8ca56d..0b343ed4338e 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java +++ b/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java @@ -27,7 +27,7 @@ public final class java_environment_Test { @Test public void test() { java_environment env = new java_environment(null); - Object obj = new Integer(3); + Object obj = Integer.valueOf(3); String[] oid = new String[1]; Object obj2 = env.registerInterface(obj, oid, diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java index 390c775a7a34..73919da886c9 100644 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java +++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java @@ -37,7 +37,7 @@ public final class Marshaling_Test { TestObject testObject = new TestObject(); TestPrimitiveSeqStruct x = new TestPrimitiveSeqStruct(); - x.zAny = new Object[]{new Integer(1), new Double(2) }; + x.zAny = new Object[]{Integer.valueOf(1), new Double(2) }; Object data[] = new Object[] { @@ -49,28 +49,28 @@ public final class Marshaling_Test { new Double(0.12345), TestEnum.B, new Float(0.5678), - new Integer(0), - new Integer(128), - new Integer(0x0f00), - new Integer(0x0f0000), - new Integer(0x0f000000), - new Integer(-128), - new Integer(0xff00), - new Integer(0xff0000), - new Integer(0xff000000), + Integer.valueOf(0), + Integer.valueOf(128), + Integer.valueOf(0x0f00), + Integer.valueOf(0x0f0000), + Integer.valueOf(0x0f000000), + Integer.valueOf(-128), + Integer.valueOf(0xff00), + Integer.valueOf(0xff0000), + Integer.valueOf(0xff000000), new Long(666L), new Short((short)444), new String("blabla"), - new Integer(10), // Any as object - new Integer(10), // Any as object - new Any(new Type(Integer.class), new Integer(10)), // Any as Any - new Any(new Type(Integer.class), new Integer(10)), // Any as Any + Integer.valueOf(10), // Any as object + Integer.valueOf(10), // Any as object + new Any(new Type(Integer.class), Integer.valueOf(10)), // Any as Any + new Any(new Type(Integer.class), Integer.valueOf(10)), // Any as Any null, new TestPrimitiveStruct(), x, new byte[]{1,2,3,4,5,6,7}, // primitive sequence new int[]{7,6,5,4,3,2,1}, // primitive sequence - new Object[]{new Integer(123), new String("hallo")}, // any sequence + new Object[]{Integer.valueOf(123), new String("hallo")}, // any sequence new TestPrimitiveStruct[]{new TestPrimitiveStruct(), new TestPrimitiveStruct()}, // sequence of primitive structs new TestPrimitiveSeqStruct[]{new TestPrimitiveSeqStruct(), new TestPrimitiveSeqStruct()}, // sequence of primitive structs new TestNestedStruct(), diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java index a7ee1e511c6d..1ded133b09b5 100644 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java +++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java @@ -243,7 +243,7 @@ public final class Protocol_Test { iReceiver.readMessage(); // send a reply iReceiver.writeReply( - false, new ThreadId(new byte[] { 0, 1 }), new Integer(501)); + false, new ThreadId(new byte[] { 0, 1 }), Integer.valueOf(501)); iMessage = iSender.readMessage(); result = iMessage.getResult(); assertEquals(501, result); diff --git a/jurt/test/com/sun/star/uno/AnyConverter_Test.java b/jurt/test/com/sun/star/uno/AnyConverter_Test.java index c4c93261d3f8..ce6316578f68 100644 --- a/jurt/test/com/sun/star/uno/AnyConverter_Test.java +++ b/jurt/test/com/sun/star/uno/AnyConverter_Test.java @@ -41,7 +41,7 @@ public final class AnyConverter_Test { Character aChar= new Character('A'); Byte aByte= new Byte((byte) 111); Short aShort= new Short((short) 11111); - Integer aInt= new Integer( 1111111); + Integer aInt= Integer.valueOf( 1111111); Long aLong= new Long( 0xffffffff); Float aFloat= new Float( 3.14); Double aDouble= new Double( 3.145); @@ -315,7 +315,7 @@ public final class AnyConverter_Test { Any a = new Any( Type.UNSIGNED_SHORT, new Short((short)5) ); assertEquals(5, AnyConverter.toInt(a)); assertEquals(5, AnyConverter.toUnsignedInt(a)); - a = new Any( Type.UNSIGNED_LONG, new Integer(5) ); + a = new Any( Type.UNSIGNED_LONG, Integer.valueOf(5) ); assertEquals(5, AnyConverter.toUnsignedInt(a)); // must fail @@ -386,7 +386,7 @@ public final class AnyConverter_Test { Any a = new Any( Type.UNSIGNED_SHORT, new Short((short)5) ); assertEquals(5, AnyConverter.toLong(a)); assertEquals(5, AnyConverter.toUnsignedLong(a)); - a = new Any( Type.UNSIGNED_LONG, new Integer(5) ); + a = new Any( Type.UNSIGNED_LONG, Integer.valueOf(5) ); assertEquals(5, AnyConverter.toUnsignedLong(a)); assertEquals(5, AnyConverter.toLong(a)); a = new Any( Type.UNSIGNED_HYPER, new Long(5) ); @@ -808,7 +808,7 @@ public final class AnyConverter_Test { assertTrue(AnyConverter.isInt(aInt)); assertTrue(AnyConverter.isInt(anyInt)); assertEquals(Type.LONG, AnyConverter.getType(anyInt)); - Any a = new Any(Type.UNSIGNED_LONG, new Integer(5)); + Any a = new Any(Type.UNSIGNED_LONG, Integer.valueOf(5)); assertEquals(Type.UNSIGNED_LONG, AnyConverter.getType(a)); assertFalse(AnyConverter.isInt(a)); assertFalse(Type.LONG.equals(AnyConverter.getType(a))); -- cgit