From f90b9df505a08a712118e382a0b3d9e7356785de Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 19 Jan 2021 20:18:53 +0000 Subject: [PATCH] Replace Paths.get() with Path.of() Paths.get() may be deprecated in a future release. Signed-off-by: Graham --- .idea/codeInsightSettings.xml | 1 + cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt | 4 ++-- .../test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt | 3 +-- .../test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt | 4 ++-- cache/src/test/kotlin/org/openrs2/cache/StoreTest.kt | 6 +++--- conf/src/main/kotlin/org/openrs2/conf/ConfigProvider.kt | 6 +++--- .../src/main/kotlin/org/openrs2/crypto/RsaKeyProvider.kt | 4 ++-- .../kotlin/org/openrs2/deob/ast/gl/GlRegistryProvider.kt | 4 ++-- .../openrs2/deob/bytecode/DeobfuscateBytecodeCommand.kt | 6 +++--- .../kotlin/org/openrs2/deob/bytecode/ProfileProvider.kt | 4 ++-- .../kotlin/org/openrs2/deob/processor/NameMapProcessor.kt | 3 +-- deob-util/src/main/kotlin/org/openrs2/deob/util/Module.kt | 5 ++--- .../kotlin/org/openrs2/deob/util/map/NameMapProvider.kt | 3 +-- .../src/main/kotlin/org/openrs2/patcher/PatchCommand.kt | 8 ++++---- 14 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.idea/codeInsightSettings.xml b/.idea/codeInsightSettings.xml index 129aaf5125..7a392b3f74 100644 --- a/.idea/codeInsightSettings.xml +++ b/.idea/codeInsightSettings.xml @@ -8,6 +8,7 @@ com.google.inject.Provider com.google.inject.ScopeAnnotation com.google.inject.Singleton + java.nio.file.Paths.get org.junit.jupiter.api.AfterEach org.junit.jupiter.api.Assertions.assertEquals org.junit.jupiter.api.Assertions.assertFalse diff --git a/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt b/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt index 06bb570826..51b2f69407 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt @@ -8,7 +8,7 @@ import org.openrs2.buffer.use import org.openrs2.util.io.recursiveCopy import org.openrs2.util.io.recursiveEquals import java.io.FileNotFoundException -import java.nio.file.Paths +import java.nio.file.Path import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -16,7 +16,7 @@ import kotlin.test.assertFalse import kotlin.test.assertTrue object DiskStoreTest { - private val ROOT = Paths.get(DiskStoreTest::class.java.getResource("disk-store").toURI()) + private val ROOT = Path.of(DiskStoreTest::class.java.getResource("disk-store").toURI()) @Test fun testBounds() { diff --git a/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt b/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt index f0b83cd79e..9759e18162 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt @@ -9,7 +9,6 @@ import org.openrs2.util.io.recursiveCopy import org.openrs2.util.io.recursiveEquals import java.io.FileNotFoundException import java.nio.file.Path -import java.nio.file.Paths import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -18,7 +17,7 @@ import kotlin.test.assertTrue object FlatFileStoreTest { private val IGNORE_GIT_EMPTY = { path: Path -> path.fileName.toString() != ".gitempty" } - private val ROOT = Paths.get(FlatFileStoreTest::class.java.getResource("flat-file-store").toURI()) + private val ROOT = Path.of(FlatFileStoreTest::class.java.getResource("flat-file-store").toURI()) @Test fun testBounds() { diff --git a/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt b/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt index 39b99e4366..10020b82b5 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt @@ -3,12 +3,12 @@ package org.openrs2.cache import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled import org.openrs2.buffer.use -import java.nio.file.Paths +import java.nio.file.Path import kotlin.test.Test import kotlin.test.assertEquals object Js5MasterIndexTest { - private val ROOT = Paths.get(FlatFileStoreTest::class.java.getResource("master-index").toURI()) + private val ROOT = Path.of(FlatFileStoreTest::class.java.getResource("master-index").toURI()) private val encoded = byteArrayOf(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4) private val decoded = Js5MasterIndex( mutableListOf( diff --git a/cache/src/test/kotlin/org/openrs2/cache/StoreTest.kt b/cache/src/test/kotlin/org/openrs2/cache/StoreTest.kt index 9e53160824..56698f3ffd 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/StoreTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/StoreTest.kt @@ -1,12 +1,12 @@ package org.openrs2.cache -import java.nio.file.Paths +import java.nio.file.Path import kotlin.test.Test import kotlin.test.assertTrue object StoreTest { - private val DISK_ROOT = Paths.get(StoreTest::class.java.getResource("disk-store/empty").toURI()) - private val FLAT_FILE_ROOT = Paths.get(StoreTest::class.java.getResource("flat-file-store/empty").toURI()) + private val DISK_ROOT = Path.of(StoreTest::class.java.getResource("disk-store/empty").toURI()) + private val FLAT_FILE_ROOT = Path.of(StoreTest::class.java.getResource("flat-file-store/empty").toURI()) @Test fun testOpen() { diff --git a/conf/src/main/kotlin/org/openrs2/conf/ConfigProvider.kt b/conf/src/main/kotlin/org/openrs2/conf/ConfigProvider.kt index a211514130..ae8c9d218d 100644 --- a/conf/src/main/kotlin/org/openrs2/conf/ConfigProvider.kt +++ b/conf/src/main/kotlin/org/openrs2/conf/ConfigProvider.kt @@ -3,7 +3,7 @@ package org.openrs2.conf import com.fasterxml.jackson.databind.ObjectMapper import org.openrs2.yaml.Yaml import java.nio.file.Files -import java.nio.file.Paths +import java.nio.file.Path import javax.inject.Inject import javax.inject.Provider @@ -19,7 +19,7 @@ public class ConfigProvider @Inject constructor(@Yaml private val mapper: Object } private companion object { - private val CONFIG_PATH = Paths.get("etc/config.yaml") - private val EXAMPLE_CONFIG_PATH = Paths.get("etc/config.example.yaml") + private val CONFIG_PATH = Path.of("etc/config.yaml") + private val EXAMPLE_CONFIG_PATH = Path.of("etc/config.example.yaml") } } diff --git a/crypto/src/main/kotlin/org/openrs2/crypto/RsaKeyProvider.kt b/crypto/src/main/kotlin/org/openrs2/crypto/RsaKeyProvider.kt index 9f9be8d844..c1da961544 100644 --- a/crypto/src/main/kotlin/org/openrs2/crypto/RsaKeyProvider.kt +++ b/crypto/src/main/kotlin/org/openrs2/crypto/RsaKeyProvider.kt @@ -2,7 +2,7 @@ package org.openrs2.crypto import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters import java.nio.file.Files -import java.nio.file.Paths +import java.nio.file.Path import javax.inject.Provider public class RsaKeyProvider : Provider { @@ -17,6 +17,6 @@ public class RsaKeyProvider : Provider { } private companion object { - private val PATH = Paths.get("etc/game.key") + private val PATH = Path.of("etc/game.key") } } diff --git a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/gl/GlRegistryProvider.kt b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/gl/GlRegistryProvider.kt index a3ced2bafb..d6a8d65bf9 100644 --- a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/gl/GlRegistryProvider.kt +++ b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/gl/GlRegistryProvider.kt @@ -1,7 +1,7 @@ package org.openrs2.deob.ast.gl import java.nio.file.Files -import java.nio.file.Paths +import java.nio.file.Path import javax.inject.Provider public class GlRegistryProvider : Provider { @@ -12,6 +12,6 @@ public class GlRegistryProvider : Provider { } private companion object { - private val PATH = Paths.get("share/deob/gl.xml") + private val PATH = Path.of("share/deob/gl.xml") } } diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/DeobfuscateBytecodeCommand.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/DeobfuscateBytecodeCommand.kt index 95395cc86f..5dc6600175 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/DeobfuscateBytecodeCommand.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/DeobfuscateBytecodeCommand.kt @@ -2,7 +2,7 @@ package org.openrs2.deob.bytecode import com.github.ajalt.clikt.core.CliktCommand import com.google.inject.Guice -import java.nio.file.Paths +import java.nio.file.Path public fun main(args: Array): Unit = DeobfuscateBytecodeCommand().main(args) @@ -11,8 +11,8 @@ public class DeobfuscateBytecodeCommand : CliktCommand(name = "bytecode") { val injector = Guice.createInjector(BytecodeDeobfuscatorModule) val deobfuscator = injector.getInstance(BytecodeDeobfuscator::class.java) deobfuscator.run( - input = Paths.get("nonfree/lib"), - output = Paths.get("nonfree/var/cache/deob") + input = Path.of("nonfree/lib"), + output = Path.of("nonfree/var/cache/deob") ) } } diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/ProfileProvider.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/ProfileProvider.kt index a3be4bf0fb..5d1ba8b7dd 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/ProfileProvider.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/ProfileProvider.kt @@ -3,7 +3,7 @@ package org.openrs2.deob.bytecode import com.fasterxml.jackson.databind.ObjectMapper import org.openrs2.yaml.Yaml import java.nio.file.Files -import java.nio.file.Paths +import java.nio.file.Path import javax.inject.Inject import javax.inject.Provider @@ -15,6 +15,6 @@ public class ProfileProvider @Inject constructor(@Yaml private val mapper: Objec } private companion object { - private val PATH = Paths.get("share/deob/profile.yaml") + private val PATH = Path.of("share/deob/profile.yaml") } } diff --git a/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt b/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt index c0f8ae4345..f53ec6e7fb 100644 --- a/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt +++ b/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt @@ -16,7 +16,6 @@ import org.openrs2.util.io.useAtomicBufferedWriter import org.openrs2.yaml.Yaml import java.nio.file.Files import java.nio.file.Path -import java.nio.file.Paths import java.util.TreeMap import javax.annotation.processing.AbstractProcessor import javax.annotation.processing.ProcessingEnvironment @@ -58,7 +57,7 @@ public class NameMapProcessor : AbstractProcessor() { private fun getPath(): Path? { val map = processingEnv.options["map"] ?: return null - return Paths.get(map) + return Path.of(map) } override fun process(annotations: Set, env: RoundEnvironment): Boolean { diff --git a/deob-util/src/main/kotlin/org/openrs2/deob/util/Module.kt b/deob-util/src/main/kotlin/org/openrs2/deob/util/Module.kt index ff967331d7..c4e50ced2c 100644 --- a/deob-util/src/main/kotlin/org/openrs2/deob/util/Module.kt +++ b/deob-util/src/main/kotlin/org/openrs2/deob/util/Module.kt @@ -1,11 +1,10 @@ package org.openrs2.deob.util import java.nio.file.Path -import java.nio.file.Paths public class Module(public val name: String, public val dependencies: Set = emptySet()) { - public val jar: Path = Paths.get("nonfree/var/cache/deob").resolve("$name.jar") - public val sources: Path = Paths.get("nonfree").resolve(name).resolve("src/main/java") + public val jar: Path = Path.of("nonfree/var/cache/deob").resolve("$name.jar") + public val sources: Path = Path.of("nonfree").resolve(name).resolve("src/main/java") public val transitiveDependencies: Set = dependencies.plus(dependencies.flatMap { it.transitiveDependencies }) diff --git a/deob-util/src/main/kotlin/org/openrs2/deob/util/map/NameMapProvider.kt b/deob-util/src/main/kotlin/org/openrs2/deob/util/map/NameMapProvider.kt index 6e5d8a40d4..2448cfdfd5 100644 --- a/deob-util/src/main/kotlin/org/openrs2/deob/util/map/NameMapProvider.kt +++ b/deob-util/src/main/kotlin/org/openrs2/deob/util/map/NameMapProvider.kt @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.openrs2.yaml.Yaml import java.nio.file.Files import java.nio.file.Path -import java.nio.file.Paths import javax.inject.Inject import javax.inject.Provider @@ -31,7 +30,7 @@ public class NameMapProvider @Inject constructor(@Yaml private val mapper: Objec } private companion object { - private val PATH = Paths.get("share/deob/map") + private val PATH = Path.of("share/deob/map") private const val YAML_SUFFIX = ".yaml" } } diff --git a/patcher/src/main/kotlin/org/openrs2/patcher/PatchCommand.kt b/patcher/src/main/kotlin/org/openrs2/patcher/PatchCommand.kt index eb29101d67..8ffeb0f7e1 100644 --- a/patcher/src/main/kotlin/org/openrs2/patcher/PatchCommand.kt +++ b/patcher/src/main/kotlin/org/openrs2/patcher/PatchCommand.kt @@ -2,7 +2,7 @@ package org.openrs2.patcher import com.github.ajalt.clikt.core.CliktCommand import com.google.inject.Guice -import java.nio.file.Paths +import java.nio.file.Path public fun main(args: Array): Unit = PatchCommand().main(args) @@ -11,9 +11,9 @@ public class PatchCommand : CliktCommand(name = "patch") { val injector = Guice.createInjector(PatcherModule) val patcher = injector.getInstance(Patcher::class.java) patcher.run( - input = Paths.get("nonfree/lib"), - output = Paths.get("nonfree/var/cache/client"), - keyStorePath = Paths.get("etc/loader.p12") + input = Path.of("nonfree/lib"), + output = Path.of("nonfree/var/cache/client"), + keyStorePath = Path.of("etc/loader.p12") ) } }