From 276cbbcee9d38d5a92df6ff66a0e4f06351cb679 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Mon, 30 Apr 2018 15:52:31 +0200 Subject: Allow building with Java 9. - Must suppress deprecation warning for unit tests because LogRecord.setInstant() is new for Java 9. --- .../com/yahoo/jdisc/handler/ContentInputStream.java | 1 + .../core/ApplicationEnvironmentModuleTestCase.java | 17 +++++++++-------- .../com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'jdisc_core') diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ContentInputStream.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ContentInputStream.java index 3f89ba04aa5..04be3c1e3d4 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ContentInputStream.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ContentInputStream.java @@ -19,6 +19,7 @@ public final class ContentInputStream extends UnsafeContentInputStream { } @Override + @SuppressWarnings("deprecation") // finalize() is deprecated from Java 9 public void finalize() throws Throwable { try { close(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java index e8fb53892f0..965a132cd92 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java @@ -1,22 +1,25 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.core; -import com.google.inject.*; +import com.google.inject.Binding; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; import com.yahoo.jdisc.application.ContainerActivator; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.application.OsgiFramework; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.NonWorkingOsgiFramework; +import org.junit.Test; -import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.concurrent.ThreadFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import static java.util.Collections.emptyList; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * @author Simon Thoresen @@ -37,8 +40,7 @@ public class ApplicationEnvironmentModuleTestCase { expected.add(entry.getKey().getTypeLiteral().getRawType()); } - ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), - Collections.emptyList()); + ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), emptyList()); injector = Guice.createInjector(new ApplicationEnvironmentModule(loader)); for (Map.Entry, Binding> entry : injector.getBindings().entrySet()) { assertNotNull(expected.remove(entry.getKey().getTypeLiteral().getRawType())); @@ -48,8 +50,7 @@ public class ApplicationEnvironmentModuleTestCase { @Test public void requireThatContainerBuilderCanBeInjected() { - ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), - Collections.emptyList()); + ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), emptyList()); assertNotNull(new ApplicationEnvironmentModule(loader).containerBuilder()); assertNotNull(Guice.createInjector(new ApplicationEnvironmentModule(loader)) .getInstance(ContainerBuilder.class)); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java index a5897bea124..7dca8c45d0b 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java @@ -70,6 +70,8 @@ public class OsgiLogHandlerTestCase { } @Test + // TODO: Remove deprecation annotation and replace calls to LogRecord.setMillis() when we no longer have to support Java 8 + @SuppressWarnings("deprecation") public void requireThatJdk14PropertiesAreAvailableThroughServiceReference() { MyLogService logService = new MyLogService(); -- cgit v1.2.3