aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorgjoranv <gv@oath.com>2018-04-26 12:23:04 +0200
committergjoranv <gv@oath.com>2018-04-26 14:24:52 +0200
commitbc11fd9f36d6780ed34c937fef637a5e8f2c7083 (patch)
treec3c22ecb5a6742c141300c8911a88cdfde85fba3 /vespajlib
parentea6c91d76a3e76ada0f0f12a25710832114f8553 (diff)
Remove usage of apis deprecated in Java 9.
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java4
-rw-r--r--vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java4
-rw-r--r--vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java10
-rw-r--r--vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java4
-rw-r--r--vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java2
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/Benchmark.java5
6 files changed, 18 insertions, 11 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java b/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java
index 002b1de9147..6d9a6b6f422 100644
--- a/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java
@@ -4,6 +4,8 @@ package com.yahoo.cache;
import java.util.ArrayList;
import java.util.List;
+import static java.lang.Boolean.TRUE;
+
public class CalcTestCase extends junit.framework.TestCase {
private SizeCalculator calc;
@@ -26,7 +28,7 @@ public class CalcTestCase extends junit.framework.TestCase {
}
public void testBoolean() {
- assertEquals(8+1, calc.sizeOf(new Boolean(true)));
+ assertEquals(8+1, calc.sizeOf(TRUE));
}
public void testArrayPrimitive() {
diff --git a/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java
index 1dc8e5fa62e..4e8398a3ef5 100644
--- a/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java
@@ -247,7 +247,9 @@ public final class ArraySetTestCase {
@Test
public void testSmallEmptySet() {
final ArraySet<Integer> t = new ArraySet<>(3);
- Integer a = new Integer(0), b = new Integer(1), c = new Integer(2);
+ Integer a = 0;
+ Integer b = 1;
+ Integer c = 2;
t.add(a);
t.add(b);
t.add(c);
diff --git a/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java
index 6bf97baf985..2307b2cbca9 100644
--- a/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java
@@ -87,10 +87,10 @@ public class HashletTestCase {
Hashlet<String, Integer> h = new Hashlet<>();
h.put(A, 1);
int indexOfA = h.getIndexOfKey(A);
- assertEquals(new Integer(1), h.value(indexOfA));
+ assertEquals(Integer.valueOf(1), h.value(indexOfA));
h.setValue(indexOfA, 2);
- assertEquals(new Integer(2), h.value(indexOfA));
- assertEquals(new Integer(2), h.get(A));
+ assertEquals(Integer.valueOf(2), h.value(indexOfA));
+ assertEquals(Integer.valueOf(2), h.get(A));
}
@Test
@@ -171,7 +171,7 @@ public class HashletTestCase {
String str = ("" + i + "_str_" + i);
assertThat(hash.get(str), nullValue());
switch (i % 2) {
- case 1: assertThat(hash.put(str, new Integer(i)), nullValue());
+ case 1: assertThat(hash.put(str, i), nullValue());
}
}
assertThat(hash.size(), is(n / 2));
@@ -179,7 +179,7 @@ public class HashletTestCase {
String str = ("" + i + "_str_" + i);
switch (i % 2) {
case 0: assertThat(hash.get(str), nullValue()); break;
- case 1: assertThat(hash.get(str), is(new Integer(i))); break;
+ case 1: assertThat(hash.get(str), is(i)); break;
}
}
}
diff --git a/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java
index e579a0cad23..98aaaf267e8 100644
--- a/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java
@@ -247,7 +247,9 @@ public final class TinyIdentitySetTestCase {
@Test
public void testSmallEmptySet() {
final TinyIdentitySet<Integer> t = new TinyIdentitySet<>(3);
- Integer a = new Integer(0), b = new Integer(1), c = new Integer(2);
+ Integer a = 0;
+ Integer b = 1;
+ Integer c = 2;
t.add(a);
t.add(b);
t.add(c);
diff --git a/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java b/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java
index 787260f2e20..88413f4975f 100644
--- a/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java
@@ -18,7 +18,7 @@ public class ExecutorsTestCase {
static private class ThreadId extends ThreadLocal<Integer> {
@Override
protected Integer initialValue() {
- return new Integer(threadCount.getAndIncrement());
+ return threadCount.getAndIncrement();
}
}
static private ThreadId threadId = new ThreadId();
diff --git a/vespajlib/src/test/java/com/yahoo/text/Benchmark.java b/vespajlib/src/test/java/com/yahoo/text/Benchmark.java
index 14eed6d80d4..9569adcf9f0 100644
--- a/vespajlib/src/test/java/com/yahoo/text/Benchmark.java
+++ b/vespajlib/src/test/java/com/yahoo/text/Benchmark.java
@@ -4,6 +4,7 @@ package com.yahoo.text;
// import com.google.common.base.Preconditions;
// import com.google.inject.Provider;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -27,8 +28,8 @@ class Benchmark {
final Class<? extends Task> taskClass;
public Task get() {
try {
- return taskClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
+ return taskClass.getDeclaredConstructor().newInstance();
+ } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}