From b8002d4b4d75080bb3a4c7628687e64035be92d9 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 22 Nov 2020 14:25:49 +0800 Subject: [PATCH] Hierarchical MPP: - JDK in common target - Disabled common compilations - Android targets - Kotlin 1.4.20 --- build.gradle.kts | 6 + buildSrc/src/main/kotlin/Versions.kt | 9 +- gradle.properties | 2 + mirai-core-api/build.gradle.kts | 21 +- .../src/commonMain/kotlin/event/select.kt | 15 +- .../kotlin/utils/BotConfiguration.common.kt | 4 - .../kotlin/utils/LockFreeLinkedList.kt | 6 +- .../java.bindings/io/BufferedInputStream.kt | 42 - .../java.bindings/io/BufferedOutputStream.kt | 37 - .../java.bindings/io/ByteArrayInputStream.kt | 45 -- .../java.bindings/io/ByteArrayOutputStream.kt | 25 - .../utils/java.bindings/io/Closeable.kt | 47 -- .../utils/java.bindings/io/DataInput.kt | 45 -- .../utils/java.bindings/io/DataOutput.kt | 44 -- .../utils/java.bindings/io/EOFException.kt | 32 - .../kotlin/utils/java.bindings/io/File.kt | 98 --- .../utils/java.bindings/io/FileDescriptor.kt | 58 -- .../utils/java.bindings/io/FileInputStream.kt | 45 -- .../java.bindings/io/FileOutputStream.kt | 45 -- .../java.bindings/io/FilterInputStream.kt | 36 - .../java.bindings/io/FilterOutputStream.kt | 32 - .../utils/java.bindings/io/IOException.kt | 36 - .../utils/java.bindings/io/InputStream.kt | 52 -- .../utils/java.bindings/io/ObjectInput.kt | 36 - .../utils/java.bindings/io/OutputStream.kt | 27 - .../utils/java.bindings/io/Serializable.kt | 25 - .../utils/java.bindings/net/Inet4Address.kt | 46 -- .../utils/java.bindings/net/Inet6Address.kt | 50 -- .../utils/java.bindings/net/InetAddress.kt | 81 -- .../java.bindings/net/InetSocketAddress.kt | 51 -- .../kotlin/utils/java.bindings/net/Proxy.kt | 38 - .../kotlin/utils/java.bindings/net/Socket.kt | 87 --- .../utils/java.bindings/net/SocketAddress.kt | 31 - .../java.bindings/net/SocketException.kt | 36 - .../utils/java.bindings/net/SocketOption.kt | 34 - .../utils/java.bindings/net/SocketOptions.kt | 34 - .../kotlin/utils/java.bindings/net/URI.kt | 67 -- .../kotlin/utils/java.bindings/net/URL.kt | 65 -- .../utils/java.bindings/net/URLConnection.kt | 107 --- .../kotlin/utils/java.bindings/nio/Buffer.kt | 532 ------------- .../utils/java.bindings/nio/ByteBuffer.kt | 725 ------------------ .../utils/java.bindings/nio/ByteOrder.kt | 60 -- .../utils/java.bindings/nio/FileSystem.kt | 45 -- .../kotlin/utils/java.bindings/nio/Path.kt | 70 -- .../kotlin/utils/java.bindings/nio/Paths.kt | 40 - .../utils/java.bindings/nio/Watchable.kt | 31 - .../src/jvmMain/kotlin/BotFactory.kt | 11 +- mirai-core/build.gradle.kts | 19 +- .../ProtoBufWithNullableSupport.kt | 1 - .../tars/internal/TarsDecoder.kt | 9 + settings.gradle.kts | 2 +- 51 files changed, 80 insertions(+), 3062 deletions(-) delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedInputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedOutputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayInputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayOutputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Closeable.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataInput.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataOutput.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/EOFException.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/File.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileDescriptor.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileInputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileOutputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterInputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterOutputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/IOException.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/InputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ObjectInput.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/OutputStream.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Serializable.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet4Address.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet6Address.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetAddress.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetSocketAddress.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Proxy.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Socket.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketAddress.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketException.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOption.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOptions.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URI.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URL.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URLConnection.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Buffer.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteBuffer.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteOrder.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/FileSystem.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Path.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Paths.kt delete mode 100644 mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Watchable.kt diff --git a/build.gradle.kts b/build.gradle.kts index 81432ef79..f85ddf656 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,7 @@ import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.dsl.* import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType +import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import org.jetbrains.kotlin.utils.addToStdlib.safeAs buildscript { @@ -139,6 +140,11 @@ fun Project.configureJvmTarget() { kotlinOptions.jvmTarget = "1.8" } + kotlinTargets.orEmpty().filterIsInstance().forEach { target -> + target.compilations.all { kotlinOptions.jvmTarget = "1.8" } + target.testRuns["test"].executionTask.configure { useJUnitPlatform() } + } + extensions.findByType(JavaPluginExtension::class.java)?.run { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 973800c0d..932c90f1e 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -8,6 +8,9 @@ */ @file:Suppress("ObjectPropertyName", "ObjectPropertyName", "unused") + +import org.gradle.api.attributes.Attribute + /* * Copyright 2019-2020 Mamoe Technologies and contributors. * @@ -22,7 +25,7 @@ object Versions { const val kotlinCompiler = "1.4.20" const val kotlinStdlib = "1.4.20" - const val coroutines = "1.4.0" + const val coroutines = "1.4.1" const val atomicFU = "0.14.4" const val serialization = "1.0.1" const val ktor = "1.4.2" @@ -70,4 +73,6 @@ val `ktor-client-okhttp` = ktor("client-okhttp", Versions.ktor) val `ktor-client-serialization-jvm` = ktor("client-serialization-jvm", Versions.ktor) const val slf4j = "org.slf4j:slf4j-api:" + Versions.slf4j -const val `log4j-api` = "org.apache.logging.log4j:log4j-api:" + Versions.log4j \ No newline at end of file +const val `log4j-api` = "org.apache.logging.log4j:log4j-api:" + Versions.log4j + +val ATTRIBUTE_MIRAI_TARGET_PLATFORM: Attribute = Attribute.of("mirai.target.platform", String::class.java) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index cc3187dd9..46f7e3f1c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,7 @@ kotlin.parallel.tasks.in.project=true org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.vfs.watch=true +kotlin.mpp.enableGranularSourceSetsMetadata=true +kotlin.native.enableDependencyPropagation=false #kotlin.mpp.enableGranularSourceSetsMetadata=true systemProp.org.gradle.internal.publish.checksums.insecure=true \ No newline at end of file diff --git a/mirai-core-api/build.gradle.kts b/mirai-core-api/build.gradle.kts index 8ac9819c6..02a5ff45f 100644 --- a/mirai-core-api/build.gradle.kts +++ b/mirai-core-api/build.gradle.kts @@ -23,6 +23,14 @@ description = "Mirai API module" val isAndroidSDKAvailable: Boolean by project +afterEvaluate { + tasks.getByName("compileKotlinCommon").enabled = false + tasks.getByName("compileTestKotlinCommon").enabled = false + + tasks.getByName("compileCommonMainKotlinMetadata").enabled = false + tasks.getByName("compileKotlinMetadata").enabled = false +} + kotlin { explicitApi() @@ -46,10 +54,18 @@ kotlin { ) } - jvm { - withJava() + jvm("common") { + attributes.attribute(Attribute.of("mirai.target.platform", String::class.java), "common") } + jvm("jvm") { + attributes.attribute(Attribute.of("mirai.target.platform", String::class.java), "jvm") + } + +// jvm("android") { +// attributes.attribute(Attribute.of("mirai.target.platform", String::class.java), "android") +// } + sourceSets { val commonMain by getting { dependencies { @@ -57,6 +73,7 @@ kotlin { api(kotlin("reflect")) api1(`kotlinx-serialization-core`) + api1(`kotlinx-serialization-json`) implementation1(`kotlinx-serialization-protobuf`) api1(`kotlinx-io`) api1(`kotlinx-coroutines-io`) diff --git a/mirai-core-api/src/commonMain/kotlin/event/select.kt b/mirai-core-api/src/commonMain/kotlin/event/select.kt index 055432866..932c2fd12 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/select.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/select.kt @@ -18,8 +18,6 @@ import net.mamoe.mirai.message.data.PlainText import net.mamoe.mirai.message.isContextIdenticalWith import net.mamoe.mirai.message.nextMessage import net.mamoe.mirai.utils.MiraiExperimentalApi -import kotlin.jvm.JvmName -import kotlin.jvm.JvmSynthetic /** @@ -463,14 +461,15 @@ internal suspend inline fun withSilentTimeoutOrCoroutineScope( } @PublishedApi -internal val SELECT_MESSAGE_STUB = Any() +internal val SELECT_MESSAGE_STUB: Any = Any() @PublishedApi -internal val ExceptionHandlerIgnoringCancellationException = CoroutineExceptionHandler { _, throwable -> - if (throwable !is CancellationException) { - throw throwable +internal val ExceptionHandlerIgnoringCancellationException: CoroutineExceptionHandler = + CoroutineExceptionHandler { _, throwable -> + if (throwable !is CancellationException) { + throw throwable + } } -} @PublishedApi @BuilderInference @@ -582,7 +581,7 @@ internal suspend inline fun T.whileSelectMessagesImpl filterContext: Boolean, priority: Listener.EventPriority, crossinline selectBuilder: @MessageDsl MessageSelectBuilder.() -> Unit -) = withSilentTimeoutOrCoroutineScope(timeoutMillis) { +): Unit = withSilentTimeoutOrCoroutineScope(timeoutMillis) { var deferred: CompletableDeferred? = CompletableDeferred() coroutineContext[Job]!!.invokeOnCompletion { deferred?.cancel() diff --git a/mirai-core-api/src/commonMain/kotlin/utils/BotConfiguration.common.kt b/mirai-core-api/src/commonMain/kotlin/utils/BotConfiguration.common.kt index 1a91c833d..fe5c9822c 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/BotConfiguration.common.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/BotConfiguration.common.kt @@ -13,15 +13,12 @@ package net.mamoe.mirai.utils import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob -import kotlinx.serialization.UnstableDefault import kotlinx.serialization.json.Json import net.mamoe.mirai.Bot import net.mamoe.mirai.utils.BotConfiguration.MiraiProtocol import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext import kotlin.coroutines.coroutineContext -import kotlin.jvm.JvmStatic -import kotlin.jvm.JvmSynthetic /** * [Bot] 配置. @@ -157,7 +154,6 @@ public open class BotConfigurationBase internal constructor() { @SinceMirai("1.1.0") @MiraiExperimentalApi public var json: Json = kotlin.runCatching { - @OptIn(UnstableDefault::class) Json { isLenient = true ignoreUnknownKeys = true diff --git a/mirai-core-api/src/commonMain/kotlin/utils/LockFreeLinkedList.kt b/mirai-core-api/src/commonMain/kotlin/utils/LockFreeLinkedList.kt index b33948e5f..7e2756296 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/LockFreeLinkedList.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/LockFreeLinkedList.kt @@ -11,10 +11,10 @@ package net.mamoe.mirai.utils +import kotlinx.atomicfu.AtomicBoolean import kotlinx.atomicfu.AtomicRef import kotlinx.atomicfu.atomic import kotlinx.atomicfu.loop -import kotlin.jvm.JvmOverloads /** * Collect all the elements into a [MutableList] then cast it as a [List] @@ -230,7 +230,7 @@ internal open class LockFreeLinkedList { internal fun LockFreeLinkedListNode.compareAndSetNextNodeRef( expect: LockFreeLinkedListNode, update: LockFreeLinkedListNode - ) = + ): Boolean = this.nextNodeRef.compareAndSet(expect, update) override fun toString(): String = "[" + asSequence().joinToString() + "]" @@ -812,7 +812,7 @@ internal open class LockFreeLinkedListNode( open val nodeValue: E get() = initialNodeValue ?: error("Internal error: nodeValue is not initialized") @PublishedApi - internal val removed = atomic(false) + internal val removed: AtomicBoolean = atomic(false) @Suppress("LeakingThis") internal val nextNodeRef: AtomicRef> = atomic(nextNode ?: this) diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedInputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedInputStream.kt deleted file mode 100644 index 155105648..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedInputStream.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class BufferedInputStream : FilterInputStream { - public constructor(`in`: InputStream) - public constructor(`in`: InputStream, size: Int) - - public open fun read(): Int - public open fun read(b: ByteArray, off: Int, len: Int): Int - public open fun skip(n: Long): Long - public open fun available(): Int - public open fun mark(readlimit: Int) - public open fun reset() - public open fun markSupported(): Boolean - public open fun close() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedOutputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedOutputStream.kt deleted file mode 100644 index 3a4a11490..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/BufferedOutputStream.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class BufferedOutputStream : FilterOutputStream { - public constructor(out: OutputStream) - public constructor(out: OutputStream, size: Int) - - public open fun write(b: Int) - public open fun write(b: ByteArray, off: Int, len: Int) - public open fun flush() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayInputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayInputStream.kt deleted file mode 100644 index 0b9ec64e8..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayInputStream.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class ByteArrayInputStream : InputStream { - public constructor(buf: ByteArray) - public constructor(buf: ByteArray, offset: Int, length: Int) - - public open fun read(): Int - public open fun read(b: ByteArray, off: Int, len: Int): Int - public open fun readAllBytes(): ByteArray - public open fun readNBytes(b: ByteArray, off: Int, len: Int): Int - public open fun transferTo(out: OutputStream): Long - public open fun skip(n: Long): Long - public open fun available(): Int - public open fun markSupported(): Boolean - public open fun mark(readAheadLimit: Int) - public open fun reset() - public open fun close() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayOutputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayOutputStream.kt deleted file mode 100644 index b3893eb3b..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ByteArrayOutputStream.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress("unused", "NO_ACTUAL_FOR_EXPECT", "PackageDirectoryMismatch") - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect class ByteArrayOutputStream() : OutputStream { - public constructor(size: Int) - - public override fun write(oneByte: Int) - public fun toByteArray(): ByteArray - public fun size(): Int -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Closeable.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Closeable.kt deleted file mode 100644 index 588241bc2..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Closeable.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress("unused", "NO_ACTUAL_FOR_EXPECT", "PackageDirectoryMismatch") - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -import kotlinx.io.core.Closeable -import kotlinx.io.errors.IOException - - -/** - * A [Closeable] is a source or destination of data that can be closed. - * The close method is invoked to release resources that the object is - * holding (such as open files). - * - * @since 1.5 - */ -public expect interface Closeable /* : AutoCloseable */ { - /** - * Closes this stream and releases any system resources associated - * with it. If the stream is already closed then invoking this - * method has no effect. - * - * - * As noted in [AutoCloseable.close], cases where the - * close may fail require careful attention. It is strongly advised - * to relinquish the underlying resources and to internally - * *mark* the `Closeable` as closed, prior to throwing - * the `IOException`. - * - * @throws IOException if an I/O error occurs - */ - @Throws(IOException::class) - public fun close() -} diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataInput.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataInput.kt deleted file mode 100644 index 6aa085bef..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataInput.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open interface DataInput { - public open fun readFully(b: ByteArray) - public open fun readFully(b: ByteArray, off: Int, len: Int) - public open fun skipBytes(n: Int): Int - public open fun readBoolean(): Boolean - public open fun readByte(): Byte - public open fun readUnsignedByte(): Int - public open fun readShort(): Short - public open fun readUnsignedShort(): Int - public open fun readChar(): Char - public open fun readInt(): Int - public open fun readLong(): Long - public open fun readFloat(): Float - public open fun readDouble(): Double - public open fun readLine(): String - public open fun readUTF(): String -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataOutput.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataOutput.kt deleted file mode 100644 index a8d89a61e..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/DataOutput.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open interface DataOutput { - public open fun write(b: Int) - public open fun write(b: ByteArray) - public open fun write(b: ByteArray, off: Int, len: Int) - public open fun writeBoolean(v: Boolean) - public open fun writeByte(v: Int) - public open fun writeShort(v: Int) - public open fun writeChar(v: Int) - public open fun writeInt(v: Int) - public open fun writeLong(v: Long) - public open fun writeFloat(v: Float) - public open fun writeDouble(v: Double) - public open fun writeBytes(s: String) - public open fun writeChars(s: String) - public open fun writeUTF(s: String) -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/EOFException.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/EOFException.kt deleted file mode 100644 index 92244aa25..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/EOFException.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class EOFException : IOException { - public constructor() - public constructor(s: String) -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/File.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/File.kt deleted file mode 100644 index e86a8ee8e..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/File.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -import kotlin.jvm.JvmStatic - -public expect class File : Serializable, Comparable { - public constructor(parent: String, child: String) - public constructor(parent: File, child: String) - public constructor(uri: java.net.URI) - - public open fun getName(): String - public open fun getParent(): String - public open fun getParentFile(): File - public open fun getPath(): String - public open fun isAbsolute(): Boolean - public open fun getAbsolutePath(): String - public open fun getAbsoluteFile(): File - public open fun getCanonicalPath(): String - public open fun getCanonicalFile(): File - public open fun toURL(): java.net.URL - public open fun toURI(): java.net.URI - public open fun canRead(): Boolean - public open fun canWrite(): Boolean - public open fun exists(): Boolean - public open fun isDirectory(): Boolean - public open fun isFile(): Boolean - public open fun isHidden(): Boolean - public open fun lastModified(): Long - public open fun length(): Long - public open fun createNewFile(): Boolean - public open fun delete(): Boolean - public open fun deleteOnExit() - public open fun list(): Array? - - //public open fun list(filter: FilenameFilter): Array - public open fun listFiles(): Array? - - //public open fun listFiles(filter: FilenameFilter): Array - //public open fun listFiles(filter: FileFilter): Array - public open fun mkdir(): Boolean - public open fun mkdirs(): Boolean - public open fun renameTo(dest: File): Boolean - public open fun setLastModified(time: Long): Boolean - public open fun setReadOnly(): Boolean - public open fun setWritable(writable: Boolean, ownerOnly: Boolean): Boolean - public open fun setWritable(writable: Boolean): Boolean - public open fun setReadable(readable: Boolean, ownerOnly: Boolean): Boolean - public open fun setReadable(readable: Boolean): Boolean - public open fun setExecutable(executable: Boolean, ownerOnly: Boolean): Boolean - public open fun setExecutable(executable: Boolean): Boolean - public open fun canExecute(): Boolean - public open fun getTotalSpace(): Long - public open fun getFreeSpace(): Long - public open fun getUsableSpace(): Long - public open fun compareTo(pathname: File): Int - public open fun equals(obj: Any?): Boolean - public open fun hashCode(): Int - public open fun toString(): String - public open fun toPath(): java.nio.file.Path - - public companion object { - @JvmStatic - public val separatorChar: Char - - @JvmStatic - public val separator: String - - @JvmStatic - public val pathSeparatorChar: Char - - @JvmStatic - public val pathSeparator: String - - @JvmStatic - public fun createTempFile(prefix: String, suffix: String): File - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileDescriptor.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileDescriptor.kt deleted file mode 100644 index 20ae3f361..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileDescriptor.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -import kotlin.jvm.JvmStatic - -public expect final class FileDescriptor { - public constructor() - - public open fun set(fdo: FileDescriptor, fd: Int) - public open fun get(fdo: FileDescriptor): Int - public open fun setAppend(fdo: FileDescriptor, append: Boolean) - public open fun getAppend(fdo: FileDescriptor): Boolean - public open fun close(fdo: FileDescriptor) - public open fun registerCleanup(fdo: FileDescriptor) - public open fun unregisterCleanup(fdo: FileDescriptor) - public open fun setHandle(fdo: FileDescriptor, handle: Long) - public open fun getHandle(fdo: FileDescriptor): Long - public open fun valid(): Boolean - public open fun sync() - - public companion object { - @JvmStatic - public val `in`: FileDescriptor - - @JvmStatic - public val out: FileDescriptor - - @JvmStatic - public val err: FileDescriptor - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileInputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileInputStream.kt deleted file mode 100644 index 6b0b3eeca..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileInputStream.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class FileInputStream : InputStream { - public constructor(name: String) - public constructor(file: File) - public constructor(fdObj: FileDescriptor) - - public open fun read(): Int - public open fun read(b: ByteArray): Int - public open fun read(b: ByteArray, off: Int, len: Int): Int - public open fun skip(n: Long): Long - public open fun available(): Int - public open fun close() - public final fun getFD(): FileDescriptor - - //public open fun getChannel(): java.nio.channels.FileChannel - protected open fun finalize() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileOutputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileOutputStream.kt deleted file mode 100644 index d0bf2b910..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FileOutputStream.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class FileOutputStream : OutputStream { - public constructor(name: String) - public constructor(name: String, append: Boolean) - public constructor(file: File) - public constructor(file: File, append: Boolean) - public constructor(fdObj: FileDescriptor) - - public open fun write(b: Int) - public open fun write(b: ByteArray) - public open fun write(b: ByteArray, off: Int, len: Int) - public open fun close() - public final fun getFD(): FileDescriptor - - //public open fun getChannel(): java.nio.channels.FileChannel - protected final fun finalize() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterInputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterInputStream.kt deleted file mode 100644 index edcaa2fe6..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterInputStream.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class FilterInputStream : InputStream { - public open fun read(): Int - public open fun read(b: ByteArray): Int - public open fun read(b: ByteArray, off: Int, len: Int): Int - public open fun skip(n: Long): Long - public open fun available(): Int - public open fun close() - public open fun mark(readlimit: Int) - public open fun reset() - public open fun markSupported(): Boolean -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterOutputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterOutputStream.kt deleted file mode 100644 index 1c7cc924f..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/FilterOutputStream.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class FilterOutputStream : OutputStream { - public open fun write(b: Int) - public open fun write(b: ByteArray) - public open fun write(b: ByteArray, off: Int, len: Int) - public open fun flush() - public open fun close() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/IOException.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/IOException.kt deleted file mode 100644 index ca3d10bd8..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/IOException.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open class IOException : Exception { - public constructor() - public constructor(message: String) - public constructor(message: String, cause: Throwable) - public constructor(cause: Throwable) -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/InputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/InputStream.kt deleted file mode 100644 index 5f08dd217..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/InputStream.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -import kotlin.jvm.JvmStatic - -public expect abstract class InputStream : Closeable { - public open fun available(): Int - public open fun read(): Int - public open fun read(b: ByteArray, off: Int, len: Int): Int - public open fun readAllBytes(): ByteArray - public open fun readNBytes(b: ByteArray, off: Int, len: Int): Int - public open fun readNBytes(len: Int): ByteArray - public open fun skip(n: Long): Long - public open fun close() - public open fun read(b: ByteArray): Int - public open fun mark(readlimit: Int) - public open fun reset() - public open fun markSupported(): Boolean - - //public open fun transferTo(out: OutputStream): Long - public companion object { - @JvmStatic - public open fun nullInputStream(): InputStream - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ObjectInput.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ObjectInput.kt deleted file mode 100644 index 3747ea3ce..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/ObjectInput.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect open interface ObjectInput : DataInput /*, AutoCloseable*/ { - public open fun readObject(): Any? - public open fun read(): Int - public open fun read(b: ByteArray): Int - public open fun read(b: ByteArray, off: Int, len: Int): Int - public open fun skip(n: Long): Long - public open fun available(): Int - public open fun close() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/OutputStream.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/OutputStream.kt deleted file mode 100644 index b3a8294ca..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/OutputStream.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress("unused", "NO_ACTUAL_FOR_EXPECT", "PackageDirectoryMismatch") - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -import kotlinx.io.core.Closeable - -public expect abstract class OutputStream : Closeable { - public override fun close() - public open fun flush() - public open fun write(buffer: ByteArray, offset: Int, count: Int) - public open fun write(buffer: ByteArray) - public abstract fun write(oneByte: Int) -} diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Serializable.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Serializable.kt deleted file mode 100644 index 7a6db09a7..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/io/Serializable.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.io - -public expect interface Serializable \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet4Address.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet4Address.kt deleted file mode 100644 index 3edd8e034..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet4Address.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -public expect open class Inet4Address : InetAddress { - public open fun isMulticastAddress(): Boolean - public open fun isAnyLocalAddress(): Boolean - public open fun isLoopbackAddress(): Boolean - public open fun isLinkLocalAddress(): Boolean - public open fun isSiteLocalAddress(): Boolean - public open fun isMCGlobal(): Boolean - public open fun isMCNodeLocal(): Boolean - public open fun isMCLinkLocal(): Boolean - public open fun isMCSiteLocal(): Boolean - public open fun isMCOrgLocal(): Boolean - public open fun getAddress(): ByteArray - public open fun getHostAddress(): String - public open fun hashCode(): Int - public open fun equals(obj: Any?): Boolean -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet6Address.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet6Address.kt deleted file mode 100644 index a06d88e64..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Inet6Address.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -public expect open class Inet6Address : InetAddress { - public open fun isMulticastAddress(): Boolean - public open fun isAnyLocalAddress(): Boolean - public open fun isLoopbackAddress(): Boolean - public open fun isLinkLocalAddress(): Boolean - public open fun isSiteLocalAddress(): Boolean - public open fun isMCGlobal(): Boolean - public open fun isMCNodeLocal(): Boolean - public open fun isMCLinkLocal(): Boolean - public open fun isMCSiteLocal(): Boolean - public open fun isMCOrgLocal(): Boolean - public open fun getAddress(): ByteArray - public open fun getScopeId(): Int - - //public open fun getScopedInterface(): NetworkInterface - public open fun getHostAddress(): String - public open fun hashCode(): Int - public open fun equals(obj: Any?): Boolean - public open fun isIPv4CompatibleAddress(): Boolean -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetAddress.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetAddress.kt deleted file mode 100644 index 8844539a0..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetAddress.kt +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import kotlin.jvm.JvmStatic - -public expect open class InetAddress : java.io.Serializable { - public constructor(hostsFileName: String) - - public open fun run(): Nothing? - public open fun getOriginalHostName(ia: InetAddress): String - public open fun isMulticastAddress(): Boolean - public open fun isAnyLocalAddress(): Boolean - public open fun isLoopbackAddress(): Boolean - public open fun isLinkLocalAddress(): Boolean - public open fun isSiteLocalAddress(): Boolean - public open fun isMCGlobal(): Boolean - public open fun isMCNodeLocal(): Boolean - public open fun isMCLinkLocal(): Boolean - public open fun isMCSiteLocal(): Boolean - public open fun isMCOrgLocal(): Boolean - public open fun isReachable(timeout: Int): Boolean - public open fun getHostName(): String - public open fun getCanonicalHostName(): String - public open fun getAddress(): ByteArray - public open fun getHostAddress(): String - public open fun hashCode(): Int - public open fun equals(obj: Any?): Boolean - public open fun toString(): String - public open fun get(): Array - - //public open fun compareTo(other: CachedAddresses): Int - public open fun getHostByAddr(addr: ByteArray): String - public open fun lookupAllHostAddr(host: String): Array - - public companion object { - @JvmStatic - public open fun getByAddress(host: String, addr: ByteArray): InetAddress - - @JvmStatic - public open fun getByName(host: String): InetAddress - - @JvmStatic - public open fun getAllByName(host: String): Array - - @JvmStatic - public open fun getLoopbackAddress(): InetAddress - - @JvmStatic - public open fun getByAddress(addr: ByteArray): InetAddress - - @JvmStatic - public open fun getLocalHost(): InetAddress - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetSocketAddress.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetSocketAddress.kt deleted file mode 100644 index c40233933..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/InetSocketAddress.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import kotlin.jvm.JvmStatic - -public expect open class InetSocketAddress : SocketAddress { - public constructor(port: Int) - public constructor(addr: InetAddress, port: Int) - public constructor(hostname: String, port: Int) - - public final fun getPort(): Int - public final fun getAddress(): InetAddress - public final fun getHostName(): String - public final fun getHostString(): String - public final fun isUnresolved(): Boolean - public open fun toString(): String - public final fun equals(obj: Any?): Boolean - public final fun hashCode(): Int - - public companion object { - @JvmStatic - public open fun createUnresolved(host: String, port: Int): InetSocketAddress - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Proxy.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Proxy.kt deleted file mode 100644 index 9614f27ac..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Proxy.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import kotlin.jvm.JvmStatic - -public expect open class Proxy { - public open fun address(): SocketAddress - public open fun toString(): String - public final fun equals(obj: Any?): Boolean - public final fun hashCode(): Int - - public companion object { - @JvmStatic - public val NO_PROXY: Proxy - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Socket.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Socket.kt deleted file mode 100644 index bf09e1845..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/Socket.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -public expect open class Socket : java.io.Closeable { - public constructor() - public constructor(proxy: Proxy) - public constructor(host: String, port: Int) - public constructor(address: InetAddress, port: Int) - public constructor(host: String, port: Int, stream: Boolean) - public constructor(host: InetAddress, port: Int, stream: Boolean) - - public open fun connect(endpoint: SocketAddress) - public open fun connect(endpoint: SocketAddress, timeout: Int) - public open fun bind(bindpoint: SocketAddress) - public open fun getInetAddress(): InetAddress - public open fun getLocalAddress(): InetAddress - public open fun getPort(): Int - public open fun getLocalPort(): Int - public open fun getRemoteSocketAddress(): SocketAddress - public open fun getLocalSocketAddress(): SocketAddress - - // public open fun getChannel(): java.nio.channels.SocketChannel - public open fun getInputStream(): java.io.InputStream - public open fun getOutputStream(): java.io.OutputStream - public open fun setTcpNoDelay(on: Boolean) - public open fun getTcpNoDelay(): Boolean - public open fun setSoLinger(on: Boolean, linger: Int) - public open fun getSoLinger(): Int - public open fun sendUrgentData(data: Int) - public open fun setOOBInline(on: Boolean) - public open fun getOOBInline(): Boolean - public open fun setSoTimeout(timeout: Int) - public open fun getSoTimeout(): Int - public open fun setSendBufferSize(size: Int) - public open fun getSendBufferSize(): Int - public open fun setReceiveBufferSize(size: Int) - public open fun getReceiveBufferSize(): Int - public open fun setKeepAlive(on: Boolean) - public open fun getKeepAlive(): Boolean - public open fun setTrafficClass(tc: Int) - public open fun getTrafficClass(): Int - public open fun setReuseAddress(on: Boolean) - public open fun getReuseAddress(): Boolean - public open fun close() - public open fun shutdownInput() - public open fun shutdownOutput() - public open fun toString(): String - public open fun isConnected(): Boolean - public open fun isBound(): Boolean - public open fun isClosed(): Boolean - public open fun isInputShutdown(): Boolean - public open fun isOutputShutdown(): Boolean - public open fun setOption(name: SocketOption, value: T): Socket - public open fun getOption(name: SocketOption): T - public open fun supportedOptions(): Set> - - public companion object { - // @JvmStatic public open fun setSocketImplFactory(fac: SocketImplFactory) - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketAddress.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketAddress.kt deleted file mode 100644 index 15c4868ae..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketAddress.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -public expect abstract class SocketAddress : java.io.Serializable \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketException.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketException.kt deleted file mode 100644 index 1b29b8b41..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketException.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import java.io.IOException - -public expect open class SocketException : IOException { - public constructor(msg: String) - public constructor() -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOption.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOption.kt deleted file mode 100644 index 7f4a97f5e..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOption.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -public expect open interface SocketOption { - public open fun name(): String - // public open fun type(): Class -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOptions.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOptions.kt deleted file mode 100644 index fb3aca972..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/SocketOptions.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT", - "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -public expect open interface SocketOptions { - public open fun setOption(optID: Int, value: Any?) - public open fun getOption(optID: Int): Any? -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URI.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URI.kt deleted file mode 100644 index bb0990268..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URI.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import java.io.Serializable -import kotlin.jvm.JvmStatic - -public expect class URI : Comparable, Serializable { - public constructor(str: String) - public constructor(scheme: String, host: String, path: String, fragment: String) - public constructor(scheme: String, ssp: String, fragment: String) - - public open fun parseServerAuthority(): URI - public open fun normalize(): URI - public open fun resolve(uri: URI): URI - public open fun resolve(str: String): URI - public open fun relativize(uri: URI): URI - public open fun toURL(): URL - public open fun getScheme(): String - public open fun isAbsolute(): Boolean - public open fun isOpaque(): Boolean - public open fun getRawSchemeSpecificPart(): String - public open fun getSchemeSpecificPart(): String - public open fun getRawAuthority(): String - public open fun getAuthority(): String - public open fun getRawUserInfo(): String - public open fun getUserInfo(): String - public open fun getHost(): String - public open fun getPort(): Int - public open fun getRawPath(): String - public open fun getPath(): String - public open fun getRawQuery(): String - public open fun getQuery(): String - public open fun getRawFragment(): String - public open fun getFragment(): String - public open fun equals(ob: Any?): Boolean - public open fun hashCode(): Int - public open fun compareTo(that: URI): Int - public open fun toString(): String - public open fun toASCIIString(): String - public open fun create(scheme: String, path: String): URI - - public companion object { - @JvmStatic - public fun create(str: String): URI - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URL.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URL.kt deleted file mode 100644 index 74ab988e0..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URL.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import java.io.Serializable - -public expect class URL : Serializable { - public constructor(protocol: String, host: String, port: Int, file: String) - public constructor(protocol: String, host: String, file: String) - public constructor(spec: String) - public constructor(context: URL, spec: String) - - //public constructor(context: URL, spec: String, handler: URLStreamHandler) - public open fun getQuery(): String - public open fun getPath(): String - public open fun getUserInfo(): String - public open fun getAuthority(): String - public open fun getPort(): Int - public open fun getDefaultPort(): Int - public open fun getProtocol(): String - public open fun getHost(): String - public open fun getFile(): String - public open fun getRef(): String - public open fun equals(obj: Any?): Boolean - public open fun hashCode(): Int - public open fun sameFile(other: URL): Boolean - public open fun toString(): String - public open fun toExternalForm(): String - public open fun toURI(): URI - public open fun openConnection(): URLConnection - public open fun openConnection(proxy: Proxy): URLConnection - public fun openStream(): java.io.InputStream - public fun getContent(): Any? - - //public final fun getContent(classes: Array>): Any? - //public open fun createURLStreamHandler(protocol: String): URLStreamHandler - public open fun hasNext(): Boolean - - //public open fun next(): java.net.spi.URLStreamHandlerProvider - //public open fun run(): URLStreamHandler - //public open fun getHandler(u: URL): URLStreamHandler - public companion object { - //@JvmStatic public open fun setURLStreamHandlerFactory(fac: URLStreamHandlerFactory) - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URLConnection.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URLConnection.kt deleted file mode 100644 index 89c4dbab1..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/net/URLConnection.kt +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "NON_FINAL_MEMBER_IN_OBJECT", "ConvertSecondaryConstructorToPrimary" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.net - -import kotlin.jvm.JvmStatic - -public expect abstract class URLConnection { - protected constructor(url: URL) - - public open fun getContentTypeFor(fileName: String): String - public abstract fun connect() - public open fun setConnectTimeout(timeout: Int) - public open fun getConnectTimeout(): Int - public open fun setReadTimeout(timeout: Int) - public open fun getReadTimeout(): Int - public open fun getURL(): URL - public open fun getContentLength(): Int - public open fun getContentLengthLong(): Long - public open fun getContentType(): String - public open fun getContentEncoding(): String - public open fun getExpiration(): Long - public open fun getDate(): Long - public open fun getLastModified(): Long - public open fun getHeaderField(name: String): String - public open fun getHeaderFields(): Map> - public open fun getHeaderFieldInt(name: String, Default: Int): Int - public open fun getHeaderFieldLong(name: String, Default: Long): Long - public open fun getHeaderFieldDate(name: String, Default: Long): Long - public open fun getHeaderFieldKey(n: Int): String - public open fun getHeaderField(n: Int): String - public open fun getContent(): Any? - - //public open fun getContent(classes: Array>): Any? - //public open fun getPermission(): java.security.Permission - public open fun getInputStream(): java.io.InputStream - public open fun getOutputStream(): java.io.OutputStream - public open fun toString(): String - public open fun setDoInput(doinput: Boolean) - public open fun getDoInput(): Boolean - public open fun setDoOutput(dooutput: Boolean) - public open fun getDoOutput(): Boolean - public open fun setAllowUserInteraction(allowuserinteraction: Boolean) - public open fun getAllowUserInteraction(): Boolean - public open fun setUseCaches(usecaches: Boolean) - public open fun getUseCaches(): Boolean - public open fun setIfModifiedSince(ifmodifiedsince: Long) - public open fun getIfModifiedSince(): Long - public open fun getDefaultUseCaches(): Boolean - public open fun setDefaultUseCaches(defaultusecaches: Boolean) - public open fun setRequestProperty(key: String, value: String) - public open fun addRequestProperty(key: String, value: String) - public open fun getRequestProperty(key: String): String - public open fun getRequestProperties(): Map> - - //public open fun run(): ContentHandler - public open fun getContent(uc: URLConnection): Any? - - public companion object { - //@JvmStatic public open fun getFileNameMap(): FileNameMap - //@JvmStatic public open fun setFileNameMap(map: FileNameMap) - @JvmStatic - public open fun setDefaultAllowUserInteraction(defaultallowuserinteraction: Boolean) - - @JvmStatic - public open fun getDefaultAllowUserInteraction(): Boolean - - @JvmStatic - public open fun setDefaultUseCaches(protocol: String, defaultVal: Boolean) - - @JvmStatic - public open fun getDefaultUseCaches(protocol: String): Boolean - - @JvmStatic - public open fun setDefaultRequestProperty(key: String, value: String) - - @JvmStatic - public open fun getDefaultRequestProperty(key: String): String - - //@JvmStatic public open fun setContentHandlerFactory(fac: ContentHandlerFactory) - @JvmStatic - public open fun guessContentTypeFromName(fname: String): String - - @JvmStatic - public open fun guessContentTypeFromStream(`is`: java.io.InputStream): String - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Buffer.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Buffer.kt deleted file mode 100644 index ea634a3e4..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Buffer.kt +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress("unused", "NO_ACTUAL_FOR_EXPECT", "PackageDirectoryMismatch") - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio - -/** - * A container for data of a specific primitive type. - * - * - * A buffer is a linear, finite sequence of elements of a specific - * primitive type. Aside from its content, the essential properties of a - * buffer are its capacity, limit, and position: - * - *
- * - * - * A buffer's *capacity* is the number of elements it contains. The - * capacity of a buffer is never negative and never changes. - * - * - * A buffer's *limit* is the index of the first element that should - * not be read or written. A buffer's limit is never negative and is never - * greater than its capacity. - * - * - * A buffer's *position* is the index of the next element to be - * read or written. A buffer's position is never negative and is never - * greater than its limit. - * -
* - * - * - * There is one subclass of this class for each non-boolean primitive type. - * - * - *

Transferring data

- * - * - * Each subclass of this class defines two categories of *get* and - * *put* operations: - * - *
- * - * - * *Relative* operations read or write one or more elements starting - * at the current position and then increment the position by the number of - * elements transferred. If the requested transfer exceeds the limit then a - * relative *get* operation throws a [BufferUnderflowException] - * and a relative *put* operation throws a [ ]; in either case, no data is transferred. - * - * - * *Absolute* operations take an explicit element index and do not - * affect the position. Absolute *get* and *put* operations throw - * an [IndexOutOfBoundsException] if the index argument exceeds the - * limit. - * -
* - * - * - * Data may also, of course, be transferred in to or out of a buffer by the - * I/O operations of an appropriate channel, which are always relative to the - * current position. - * - * - *

Marking and resetting

- * - * - * A buffer's *mark* is the index to which its position will be reset - * when the [reset][.reset] method is invoked. The mark is not always - * defined, but when it is defined it is never negative and is never greater - * than the position. If the mark is defined then it is discarded when the - * position or the limit is adjusted to a value smaller than the mark. If the - * mark is not defined then invoking the [reset][.reset] method causes an - * [InvalidMarkException] to be thrown. - * - * - *

Invariants

- * - * - * The following invariant holds for the mark, position, limit, and - * capacity values: - * - *
- * `0` `<=` - * *mark* `<=` - * *position* `<=` - * *limit* `<=` - * *capacity* -
* - * - * - * A newly-created buffer always has a position of zero and a mark that is - * undefined. The initial limit may be zero, or it may be some other value - * that depends upon the type of the buffer and the manner in which it is - * constructed. Each element of a newly-allocated buffer is initialized - * to zero. - * - * - *

Additional operations

- * - * - * In addition to methods for accessing the position, limit, and capacity - * values and for marking and resetting, this class also defines the following - * operations upon buffers: - * - * - * - * * - * - * [.clear] makes a buffer ready for a new sequence of - * channel-read or relative *put* operations: It sets the limit to the - * capacity and the position to zero. - * - * * - * - * [.flip] makes a buffer ready for a new sequence of - * channel-write or relative *get* operations: It sets the limit to the - * current position and then sets the position to zero. - * - * * - * - * [.rewind] makes a buffer ready for re-reading the data that - * it already contains: It leaves the limit unchanged and sets the position - * to zero. - * - * * - * - * The [.slice] and [slice(index,length)][.slice] - * methods create a subsequence of a buffer: They leave the limit and the - * position unchanged. - * - * * - * - * [.duplicate] creates a shallow copy of a buffer: It leaves - * the limit and the position unchanged. - * - * - * - * - *

Read-only buffers

- * - * - * Every buffer is readable, but not every buffer is writable. The - * mutation methods of each buffer class are specified as *optional - * operations* that will throw a [ReadOnlyBufferException] when - * invoked upon a read-only buffer. A read-only buffer does not allow its - * content to be changed, but its mark, position, and limit values are mutable. - * Whether or not a buffer is read-only may be determined by invoking its - * [isReadOnly][.isReadOnly] method. - * - * - *

Thread safety

- * - * - * Buffers are not safe for use by multiple concurrent threads. If a - * buffer is to be used by more than one thread then access to the buffer - * should be controlled by appropriate synchronization. - * - * - *

Invocation chaining

- * - * - * Methods in this class that do not otherwise have a value to return are - * specified to return the buffer upon which they are invoked. This allows - * method invocations to be chained; for example, the sequence of statements - * - *
- * b.flip();
- * b.position(23);
- * b.limit(42);
- * - * can be replaced by the single, more compact statement - * - *
- * b.flip().position(23).limit(42);
- * - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @since 1.4 - */ -public expect abstract class Buffer internal constructor(mark: Int, pos: Int, lim: Int, cap: Int) { - public var address: Long - - /** - * Returns this buffer's capacity. - * - * @return The capacity of this buffer - */ - public fun capacity(): Int - - /** - * Returns this buffer's position. - * - * @return The position of this buffer - */ - public fun position(): Int - - /** - * Sets this buffer's position. If the mark is defined and larger than the - * new position then it is discarded. - * - * @param newPosition - * The new position value; must be non-negative - * and no larger than the current limit - * - * @return This buffer - * - * @throws IllegalArgumentException - * If the preconditions on `newPosition` do not hold - */ - public fun position(newPosition: Int): Buffer - - /** - * Returns this buffer's limit. - * - * @return The limit of this buffer - */ - public fun limit(): Int - - /** - * Sets this buffer's limit. If the position is larger than the new limit - * then it is set to the new limit. If the mark is defined and larger than - * the new limit then it is discarded. - * - * @param newLimit - * The new limit value; must be non-negative - * and no larger than this buffer's capacity - * - * @return This buffer - * - * @throws IllegalArgumentException - * If the preconditions on `newLimit` do not hold - */ - public fun limit(newLimit: Int): Buffer - - /** - * Verify that `0 < newLimit <= capacity` - * - * @param newLimit - * The new limit value - * - * @throws IllegalArgumentException - * If the specified limit is out of bounds. - */ - public fun createLimitException(newLimit: Int): IllegalArgumentException - - /** - * Sets this buffer's mark at its position. - * - * @return This buffer - */ - public fun mark(): Buffer - - /** - * Resets this buffer's position to the previously-marked position. - * - * - * Invoking this method neither changes nor discards the mark's - * value. - * - * @return This buffer - * - * @throws InvalidMarkException - * If the mark has not been set - */ - public fun reset(): Buffer - - /** - * Clears this buffer. The position is set to zero, the limit is set to - * the capacity, and the mark is discarded. - * - * - * Invoke this method before using a sequence of channel-read or - * *put* operations to fill this buffer. For example: - * - *
-     * buf.clear();     // Prepare buffer for reading
-     * in.read(buf);    // Read data
- * - * - * This method does not actually erase the data in the buffer, but it - * is named as if it did because it will most often be used in situations - * in which that might as well be the case. - * - * @return This buffer - */ - public fun clear(): Buffer - - /** - * Flips this buffer. The limit is set to the current position and then - * the position is set to zero. If the mark is defined then it is - * discarded. - * - * - * After a sequence of channel-read or *put* operations, invoke - * this method to prepare for a sequence of channel-write or relative - * *get* operations. For example: - * - *
-     * buf.put(magic);    // Prepend header
-     * in.read(buf);      // Read data into rest of buffer
-     * buf.flip();        // Flip buffer
-     * out.write(buf);    // Write header + data to channel
- * - * - * This method is often used in conjunction with the [ ][java.nio.ByteBuffer.compact] method when transferring data from - * one place to another. - * - * @return This buffer - */ - public fun flip(): Buffer - - /** - * Rewinds this buffer. The position is set to zero and the mark is - * discarded. - * - * - * Invoke this method before a sequence of channel-write or *get* - * operations, assuming that the limit has already been set - * appropriately. For example: - * - *
-     * out.write(buf);    // Write remaining data
-     * buf.rewind();      // Rewind buffer
-     * buf.get(array);    // Copy data into array
- * - * @return This buffer - */ - public fun rewind(): Buffer - - /** - * Returns the number of elements between the current position and the - * limit. - * - * @return The number of elements remaining in this buffer - */ - public fun remaining(): Int - - /** - * Tells whether there are any elements between the current position and - * the limit. - * - * @return `true` if, and only if, there is at least one element - * remaining in this buffer - */ - public fun hasRemaining(): Boolean - - /** - * Tells whether or not this buffer is read-only. - * - * @return `true` if, and only if, this buffer is read-only - */ - public abstract val isReadOnly: Boolean - - /** - * Tells whether or not this buffer is backed by an accessible - * array. - * - * - * If this method returns `true` then the [array][.array] - * and [arrayOffset][.arrayOffset] methods may safely be invoked. - * - * - * @return `true` if, and only if, this buffer - * is backed by an array and is not read-only - * - * @since 1.6 - */ - public abstract fun hasArray(): Boolean - - /** - * Returns the array that backs this - * buffer  *(optional operation)*. - * - * - * This method is intended to allow array-backed buffers to be - * passed to native code more efficiently. Concrete subclasses - * provide more strongly-typed return values for this method. - * - * - * Modifications to this buffer's content will cause the returned - * array's content to be modified, and vice versa. - * - * - * Invoke the [hasArray][.hasArray] method before invoking this - * method in order to ensure that this buffer has an accessible backing - * array. - * - * @return The array that backs this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is backed by an array but is read-only - * - * @throws UnsupportedOperationException - * If this buffer is not backed by an accessible array - * - * @since 1.6 - */ - public abstract fun array(): ByteArray - - /** - * Returns the offset within this buffer's backing array of the first - * element of the buffer  *(optional operation)*. - * - * - * If this buffer is backed by an array then buffer position *p* - * corresponds to array index *p* + `arrayOffset()`. - * - * - * Invoke the [hasArray][.hasArray] method before invoking this - * method in order to ensure that this buffer has an accessible backing - * array. - * - * @return The offset within this buffer's array - * of the first element of the buffer - * - * @throws ReadOnlyBufferException - * If this buffer is backed by an array but is read-only - * - * @throws UnsupportedOperationException - * If this buffer is not backed by an accessible array - * - * @since 1.6 - */ - public abstract fun arrayOffset(): Int - - /** - * Tells whether or not this buffer is - * [*direct*](ByteBuffer.html#direct). - * - * @return `true` if, and only if, this buffer is direct - * - * @since 1.6 - */ - public abstract val isDirect: Boolean - - /* - /** - * Creates a new buffer whose content is a shared subsequence of - * this buffer's content. - * - * - * The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - * - * The new buffer's position will be zero, its capacity and its limit - * will be the number of elements remaining in this buffer, its mark will be - * undefined. The new buffer will be direct if, and only if, this buffer is - * direct, and it will be read-only if, and only if, this buffer is - * read-only. - * - * @return The new buffer - * - * @since 9 - */ - public abstract fun slice(): Buffer? - - /** - * Creates a new buffer whose content is a shared subsequence of - * this buffer's content. - * - * - * The content of the new buffer will start at position `index` - * in this buffer, and will contain `length` elements. Changes to - * this buffer's content will be visible in the new buffer, and vice versa; - * the two buffers' position, limit, and mark values will be independent. - * - * - * The new buffer's position will be zero, its capacity and its limit - * will be `length`, its mark will be undefined. The new buffer will - * be direct if, and only if, this buffer is direct, and it will be - * read-only if, and only if, this buffer is read-only. - * - * @param index - * The position in this buffer at which the content of the new - * buffer will start; must be non-negative and no larger than - * [limit()][.limit] - * - * @param length - * The number of elements the new buffer will contain; must be - * non-negative and no larger than `limit() - index` - * - * @return The new buffer - * - * @throws IndexOutOfBoundsException - * If `index` is negative or greater than `limit()`, - * `length` is negative, or `length > limit() - index` - * - * @since 13 - */ - public abstract fun slice(index: Int, length: Int): Buffer? - - /** - * Creates a new buffer that shares this buffer's content. - * - * - * The content of the new buffer will be that of this buffer. Changes - * to this buffer's content will be visible in the new buffer, and vice - * versa; the two buffers' position, limit, and mark values will be - * independent. - * - * - * The new buffer's capacity, limit, position and mark values will be - * identical to those of this buffer. The new buffer will be direct if, and - * only if, this buffer is direct, and it will be read-only if, and only if, - * this buffer is read-only. - * - * @return The new buffer - * - * @since 9 - */ - public abstract fun duplicate(): Buffer? - - */ -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteBuffer.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteBuffer.kt deleted file mode 100644 index f92ec15ab..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteBuffer.kt +++ /dev/null @@ -1,725 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress("unused", "NO_ACTUAL_FOR_EXPECT", "PackageDirectoryMismatch") - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio - -import kotlin.jvm.JvmOverloads -import kotlin.jvm.JvmStatic - - -/** - * A byte buffer. - * - * - * This class defines six categories of operations upon - * byte buffers: - * - * - * - * * - * - * Absolute and relative [<i>get</i>][.get] and - * [<i>put</i>][.put] methods that read and write - * single bytes; - * - * * - * - * Absolute and relative [<i>bulk get</i>][.get] - * methods that transfer contiguous sequences of bytes from this buffer - * into an array; - * - * * - * - * Absolute and relative [<i>bulk put</i>][.put] - * methods that transfer contiguous sequences of bytes from a - * byte array or some other byte - * buffer into this buffer; - * - * - * - * * - * - * Absolute and relative [<i>get</i>][.getChar] - * and [<i>put</i>][.putChar] methods that read and - * write values of other primitive types, translating them to and from - * sequences of bytes in a particular byte order; - * - * * - * - * Methods for creating *[view buffers](#views)*, - * which allow a byte buffer to be viewed as a buffer containing values of - * some other primitive type; and - * - * - * - * * - * - * A method for [compacting][.compact] - * a byte buffer. - * - * - * - * - * Byte buffers can be created either by [ <i>allocation</i>][.allocate], which allocates space for the buffer's - * - * - * - * content, or by [<i>wrapping</i>][.wrap] an - * existing byte array into a buffer. - * - * - * - * - * - * - * - * - * - * - * - * - *

Direct *vs.* non-direct buffers

- * - * - * A byte buffer is either *direct* or *non-direct*. Given a - * direct byte buffer, the Java virtual machine will make a best effort to - * perform native I/O operations directly upon it. That is, it will attempt to - * avoid copying the buffer's content to (or from) an intermediate buffer - * before (or after) each invocation of one of the underlying operating - * system's native I/O operations. - * - * - * A direct byte buffer may be created by invoking the [ ][.allocateDirect] factory method of this class. The - * buffers returned by this method typically have somewhat higher allocation - * and deallocation costs than non-direct buffers. The contents of direct - * buffers may reside outside of the normal garbage-collected heap, and so - * their impact upon the memory footprint of an application might not be - * obvious. It is therefore recommended that direct buffers be allocated - * primarily for large, long-lived buffers that are subject to the underlying - * system's native I/O operations. In general it is best to allocate direct - * buffers only when they yield a measureable gain in program performance. - * - * - * A direct byte buffer may also be created by [ ][java.nio.channels.FileChannel.map] a region of a file - * directly into memory. An implementation of the Java platform may optionally - * support the creation of direct byte buffers from native code via JNI. If an - * instance of one of these kinds of buffers refers to an inaccessible region - * of memory then an attempt to access that region will not change the buffer's - * content and will cause an unspecified exception to be thrown either at the - * time of the access or at some later time. - * - * - * Whether a byte buffer is direct or non-direct may be determined by - * invoking its [isDirect][.isDirect] method. This method is provided so - * that explicit buffer management can be done in performance-critical code. - * - * - * - *

Access to binary data

- * - * - * This class defines methods for reading and writing values of all other - * primitive types, except `boolean`. Primitive values are translated - * to (or from) sequences of bytes according to the buffer's current byte - * order, which may be retrieved and modified via the [order][.order] - * methods. Specific byte orders are represented by instances of the [ ] class. The initial order of a byte buffer is always [ ][ByteOrder.BIG_ENDIAN]. - * - * - * For access to heterogeneous binary data, that is, sequences of values of - * different types, this class defines a family of absolute and relative - * *get* and *put* methods for each type. For 32-bit floating-point - * values, for example, this class defines: - * - *
- * float  [.getFloat]
- * float  [getFloat(int index)][.getFloat]
- * void  [putFloat(float f)][.putFloat]
- * void  [putFloat(int index, float f)][.putFloat]
- * - * - * Corresponding methods are defined for the types `char, - * short, int, long`, and `double`. The index - * parameters of the absolute *get* and *put* methods are in terms of - * bytes rather than of the type being read or written. - * - * - * - * - * For access to homogeneous binary data, that is, sequences of values of - * the same type, this class defines methods that can create *views* of a - * given byte buffer. A *view buffer* is simply another buffer whose - * content is backed by the byte buffer. Changes to the byte buffer's content - * will be visible in the view buffer, and vice versa; the two buffers' - * position, limit, and mark values are independent. The [ ][.asFloatBuffer] method, for example, creates an instance of - * the [FloatBuffer] class that is backed by the byte buffer upon which - * the method is invoked. Corresponding view-creation methods are defined for - * the types `char, short, int, long`, and `double`. - * - * - * View buffers have three important advantages over the families of - * type-specific *get* and *put* methods described above: - * - * - * - * * - * - * A view buffer is indexed not in terms of bytes but rather in terms - * of the type-specific size of its values; - * - * * - * - * A view buffer provides relative bulk *get* and *put* - * methods that can transfer contiguous sequences of values between a buffer - * and an array or some other buffer of the same type; and - * - * * - * - * A view buffer is potentially much more efficient because it will - * be direct if, and only if, its backing byte buffer is direct. - * - * - * - * - * The byte order of a view buffer is fixed to be that of its byte buffer - * at the time that the view is created. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

Invocation chaining

- * - * - * - * Methods in this class that do not otherwise have a value to return are - * specified to return the buffer upon which they are invoked. This allows - * method invocations to be chained. - * - * - * - * The sequence of statements - * - *
- * bb.putInt(0xCAFEBABE);
- * bb.putShort(3);
- * bb.putShort(45);
- * - * can, for example, be replaced by the single statement - * - *
- * bb.putInt(0xCAFEBABE).putShort(3).putShort(45);
- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @since 1.4 - */ -public expect abstract class ByteBuffer @JvmOverloads internal constructor( - mark: Int, pos: Int, lim: Int, cap: Int, // package-private - hb: ByteArray? = null, offset: Int = 0 -) : Buffer, Comparable { - /** - * Creates a new, read-only byte buffer that shares this buffer's - * content. - * - * - * The content of the new buffer will be that of this buffer. Changes - * to this buffer's content will be visible in the new buffer; the new - * buffer itself, however, will be read-only and will not allow the shared - * content to be modified. The two buffers' position, limit, and mark - * values will be independent. - * - * - * The new buffer's capacity, limit, position, - * - * and mark values will be identical to those of this buffer, and its byte - * order will be [BIG_ENDIAN][ByteOrder.BIG_ENDIAN]. - * - * - * - * - * - * If this buffer is itself read-only then this method behaves in - * exactly the same way as the [duplicate][.duplicate] method. - * - * @return The new, read-only byte buffer - */ - public abstract fun asReadOnlyBuffer(): ByteBuffer? - // -- Singleton get/put methods -- - /** - * Relative *get* method. Reads the byte at this buffer's - * current position, and then increments the position. - * - * @return The byte at the buffer's current position - * - * @throws BufferUnderflowException - * If the buffer's current position is not smaller than its limit - */ - public abstract fun get(): Byte - - /** - * Relative *put* method  *(optional operation)*. - * - * - * Writes the given byte into this buffer at the current - * position, and then increments the position. - * - * @param b - * The byte to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If this buffer's current position is not smaller than its limit - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract fun put(b: Byte): ByteBuffer - - /** - * Modifies this buffer's byte order. - * - * @param bo - * The new byte order, - * either [BIG_ENDIAN][ByteOrder.BIG_ENDIAN] - * or [LITTLE_ENDIAN][ByteOrder.LITTLE_ENDIAN] - * - * @return This buffer - */ - public fun order(bo: java.nio.ByteOrder): ByteBuffer - - /** - * Absolute *get* method. Reads the byte at the given - * index. - * - * @param index - * The index from which the byte will be read - * - * @return The byte at the given index - * - * @throws IndexOutOfBoundsException - * If `index` is negative - * or not smaller than the buffer's limit - */ - public abstract operator fun get(index: Int): Byte - - /** - * Absolute *put* method  *(optional operation)*. - * - * - * Writes the given byte into this buffer at the given - * index. - * - * @param index - * The index at which the byte will be written - * - * @param b - * The byte value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If `index` is negative - * or not smaller than the buffer's limit - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract fun put(index: Int, b: Byte): ByteBuffer? - // -- Bulk get operations -- - /** - * Relative bulk *get* method. - * - * - * This method transfers bytes from this buffer into the given - * destination array. If there are fewer bytes remaining in the - * buffer than are required to satisfy the request, that is, if - * `length` `>` `remaining()`, then no - * bytes are transferred and a [BufferUnderflowException] is - * thrown. - * - * - * Otherwise, this method copies `length` bytes from this - * buffer into the given array, starting at the current position of this - * buffer and at the given offset in the array. The position of this - * buffer is then incremented by `length`. - * - * - * In other words, an invocation of this method of the form - * `src.get(dst, off, len)` has exactly the same effect as - * the loop - * - *
`for (int i = off; i < off + len; i++)
-     * dst[i] = src.get();
-    `
* - * - * except that it first checks that there are sufficient bytes in - * this buffer and it is potentially much more efficient. - * - * @param dst - * The array into which bytes are to be written - * - * @param offset - * The offset within the array of the first byte to be - * written; must be non-negative and no larger than - * `dst.length` - * - * @param length - * The maximum number of bytes to be written to the given - * array; must be non-negative and no larger than - * `dst.length - offset` - * - * @return This buffer - * - * @throws BufferUnderflowException - * If there are fewer than `length` bytes - * remaining in this buffer - * - * @throws IndexOutOfBoundsException - * If the preconditions on the `offset` and `length` - * parameters do not hold - */ - public open operator fun get(dst: ByteArray, offset: Int, length: Int): ByteBuffer - - /** - * Relative bulk *get* method. - * - * - * This method transfers bytes from this buffer into the given - * destination array. An invocation of this method of the form - * `src.get(a)` behaves in exactly the same way as the invocation - * - *
-     * src.get(a, 0, a.length) 
- * - * @param dst - * The destination array - * - * @return This buffer - * - * @throws BufferUnderflowException - * If there are fewer than `length` bytes - * remaining in this buffer - */ - public operator fun get(dst: ByteArray): ByteBuffer - - // -- Bulk put operations -- - /** - * Relative bulk *put* method  *(optional operation)*. - * - * - * This method transfers the bytes remaining in the given source - * buffer into this buffer. If there are more bytes remaining in the - * source buffer than in this buffer, that is, if - * `src.remaining()` `>` `remaining()`, - * then no bytes are transferred and a [ ] is thrown. - * - * - * Otherwise, this method copies - * *n* = `src.remaining()` bytes from the given - * buffer into this buffer, starting at each buffer's current position. - * The positions of both buffers are then incremented by *n*. - * - * - * In other words, an invocation of this method of the form - * `dst.put(src)` has exactly the same effect as the loop - * - *
-     * while (src.hasRemaining())
-     * dst.put(src.get()); 
- * - * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient. - * - * @param src - * The source buffer from which bytes are to be read; - * must not be this buffer - * - * @return This buffer - * - * @throws BufferOverflowException - * If there is insufficient space in this buffer - * for the remaining bytes in the source buffer - * - * @throws IllegalArgumentException - * If the source buffer is this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public fun put(src: ByteBuffer): ByteBuffer - - /** - * Relative bulk *put* method  *(optional operation)*. - * - * - * This method transfers bytes into this buffer from the given - * source array. If there are more bytes to be copied from the array - * than remain in this buffer, that is, if - * `length` `>` `remaining()`, then no - * bytes are transferred and a [BufferOverflowException] is - * thrown. - * - * - * Otherwise, this method copies `length` bytes from the - * given array into this buffer, starting at the given offset in the array - * and at the current position of this buffer. The position of this buffer - * is then incremented by `length`. - * - * - * In other words, an invocation of this method of the form - * `dst.put(src, off, len)` has exactly the same effect as - * the loop - * - *
`for (int i = off; i < off + len; i++)
-     * dst.put(src[i]);
-    `
* - * - * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient. - * - * @param src - * The array from which bytes are to be read - * - * @param offset - * The offset within the array of the first byte to be read; - * must be non-negative and no larger than `src.length` - * - * @param length - * The number of bytes to be read from the given array; - * must be non-negative and no larger than - * `src.length - offset` - * - * @return This buffer - * - * @throws BufferOverflowException - * If there is insufficient space in this buffer - * - * @throws IndexOutOfBoundsException - * If the preconditions on the `offset` and `length` - * parameters do not hold - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public open fun put(src: ByteArray, offset: Int, length: Int): ByteBuffer - - /** - * Relative bulk *put* method  *(optional operation)*. - * - * - * This method transfers the entire content of the given source - * byte array into this buffer. An invocation of this method of the - * form `dst.put(a)` behaves in exactly the same way as the - * invocation - * - *
-     * dst.put(a, 0, a.length) 
- * - * @param src - * The source array - * - * @return This buffer - * - * @throws BufferOverflowException - * If there is insufficient space in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public fun put(src: ByteArray): ByteBuffer - - /** - * Relative *put* method for writing an int - * value  *(optional operation)*. - * - * - * Writes four bytes containing the given int value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by four. - * - * @param value - * The int value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than four bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract fun putInt(value: Int): ByteBuffer - - /** - * Relative *put* method for writing a long - * value  *(optional operation)*. - * - * - * Writes eight bytes containing the given long value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by eight. - * - * @param value - * The long value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than eight bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract fun putLong(value: Long): ByteBuffer - - /** - * Absolute *get* method for reading a long value. - * - * - * Reads eight bytes at the given index, composing them into a - * long value according to the current byte order. - * - * @param index - * The index from which the bytes will be read - * - * @return The long value at the given index - * - * @throws IndexOutOfBoundsException - * If `index` is negative - * or not smaller than the buffer's limit, - * minus seven - */ - public abstract fun getLong(index: Int): Long - - /** - * Relative *put* method for writing a float - * value  *(optional operation)*. - * - * - * Writes four bytes containing the given float value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by four. - * - * @param value - * The float value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than four bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract fun putFloat(value: Float): ByteBuffer - - /** - * Relative *put* method for writing a double - * value  *(optional operation)*. - * - * - * Writes eight bytes containing the given double value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by eight. - * - * @param value - * The double value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than eight bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract fun putDouble(value: Double): ByteBuffer - - public companion object { - /** - * Allocates a new byte buffer. - * - * - * The new buffer's position will be zero, its limit will be its - * capacity, its mark will be undefined, each of its elements will be - * initialized to zero, and its byte order will be - * - * [BIG_ENDIAN][ByteOrder.BIG_ENDIAN]. - * - * - * - * - * It will have a [backing array][.array], and its - * [array offset][.arrayOffset] will be zero. - * - * @param capacity - * The new buffer's capacity, in bytes - * - * @return The new byte buffer - * - * @throws IllegalArgumentException - * If the `capacity` is a negative integer - */ - @JvmStatic - public fun allocate(capacity: Int): ByteBuffer - } -} diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteOrder.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteOrder.kt deleted file mode 100644 index f2bde11d2..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/ByteOrder.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress("unused", "NO_ACTUAL_FOR_EXPECT", "PackageDirectoryMismatch") - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio - -import kotlin.jvm.JvmStatic - -/** - * A typesafe enumeration for byte orders. - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @since 1.4 - */ -public expect class ByteOrder { - public companion object { - /** - * Constant denoting big-endian byte order. In this order, the bytes of a - * multibyte value are ordered from most significant to least significant. - */ - @JvmStatic - public val BIG_ENDIAN: ByteOrder - - /** - * Constant denoting little-endian byte order. In this order, the bytes of - * a multibyte value are ordered from least significant to most - * significant. - */ - @JvmStatic - public val LITTLE_ENDIAN: ByteOrder - - /** - * Retrieves the native byte order of the underlying platform. - * - * - * This method is defined so that performance-sensitive Java code can - * allocate direct buffers with the same byte order as the hardware. - * Native code libraries are often more efficient when such buffers are - * used. - * - * @return The native byte order of the hardware upon which this Java - * virtual machine is running - */ - @JvmStatic - public fun nativeOrder(): ByteOrder - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/FileSystem.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/FileSystem.kt deleted file mode 100644 index 1363b5b2e..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/FileSystem.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio.file - -import java.io.Closeable - -public expect abstract class FileSystem : Closeable { - //public abstract fun provider(): java.nio.file.spi.FileSystemProvider - public abstract fun close() - public abstract fun isOpen(): Boolean - public abstract fun isReadOnly(): Boolean - public abstract fun getSeparator(): String - public abstract fun getRootDirectories(): Iterable - - //public abstract fun getFileStores(): Iterable - public abstract fun supportedFileAttributeViews(): Set - public abstract fun getPath(first: String, vararg more: String): Path - //public abstract fun getPathMatcher(syntaxAndPattern: String): PathMatcher - //public abstract fun getUserPrincipalLookupService(): UserPrincipalLookupService - // public abstract fun newWatchService(): WatchService -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Path.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Path.kt deleted file mode 100644 index 056004b4b..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Path.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", - "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio.file - -public expect open interface Path : Comparable, Iterable, Watchable { - public open fun getFileSystem(): FileSystem - public open fun isAbsolute(): Boolean - public open fun getRoot(): Path - public open fun getFileName(): Path - public open fun getParent(): Path - public open fun getNameCount(): Int - public open fun getName(index: Int): Path - public open fun subpath(beginIndex: Int, endIndex: Int): Path - public open fun startsWith(other: Path): Boolean - public open fun startsWith(other: String): Boolean - public open fun endsWith(other: Path): Boolean - public open fun endsWith(other: String): Boolean - public open fun normalize(): Path - public open fun resolve(other: Path): Path - public open fun resolve(other: String): Path - public open fun resolveSibling(other: Path): Path - public open fun resolveSibling(other: String): Path - public open fun relativize(other: Path): Path - public open fun toUri(): java.net.URI - public open fun toAbsolutePath(): Path - - //public open fun toRealPath(vararg options: LinkOption): Path - public open fun toFile(): java.io.File - - //public open fun register(watcher: watcher, events: events, WatchEvent.Modifier[0]: new): return - public open fun iterator(): Iterator - public open fun hasNext(): Boolean - public open fun next(): Path - public open fun compareTo(other: Path): Int - public open fun equals(other: Any?): Boolean - public open fun hashCode(): Int - public open fun toString(): String - - public companion object { - //@JvmStatic - public open fun of(first: String, vararg more: String): Path - - //@JvmStatic - public open fun of(uri: java.net.URI): Path - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Paths.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Paths.kt deleted file mode 100644 index 6bf630b7a..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Paths.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE", "NON_FINAL_MEMBER_IN_OBJECT" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio.file - -import kotlin.jvm.JvmStatic - -public expect final class Paths { - - public companion object { - @JvmStatic - public open fun get(first: String, vararg more: String): Path - - @JvmStatic - public open fun get(uri: java.net.URI): Path - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Watchable.kt b/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Watchable.kt deleted file mode 100644 index a2bec503d..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/java.bindings/nio/Watchable.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2019-2020 Mamoe Technologies and contributors. - * - * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. - * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress( - "unused", - "NO_ACTUAL_FOR_EXPECT", - "PackageDirectoryMismatch", - "NON_FINAL_MEMBER_IN_FINAL_CLASS", - "VIRTUAL_MEMBER_HIDDEN", - "RedundantModalityModifier", - "REDUNDANT_MODIFIER_FOR_TARGET", - "REDUNDANT_OPEN_IN_INTERFACE" -) - -/** - * Bindings for JDK. - * - * All the sources are copied from OpenJDK. Copyright OpenJDK authors. - */ - -package java.nio.file - -public expect open interface Watchable { - //public open fun register(watcher: WatchService, vararg events: WatchEvent.Kind): WatchKey -} \ No newline at end of file diff --git a/mirai-core-api/src/jvmMain/kotlin/BotFactory.kt b/mirai-core-api/src/jvmMain/kotlin/BotFactory.kt index 9cb19246f..980aa0edc 100644 --- a/mirai-core-api/src/jvmMain/kotlin/BotFactory.kt +++ b/mirai-core-api/src/jvmMain/kotlin/BotFactory.kt @@ -71,7 +71,8 @@ public actual interface BotFactory { @SinceMirai("1.3.0") public actual companion object INSTANCE : BotFactory { - override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot { + @Suppress("ACTUAL_WITHOUT_EXPECT") + actual override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot { return factory.Bot(context, qq, password, configuration) } @@ -79,7 +80,13 @@ public actual interface BotFactory { return factory.Bot(qq, password, configuration) } - override fun Bot(context: Context, qq: Long, passwordMd5: ByteArray, configuration: BotConfiguration): Bot { + @Suppress("ACTUAL_WITHOUT_EXPECT") + actual override fun Bot( + context: Context, + qq: Long, + passwordMd5: ByteArray, + configuration: BotConfiguration + ): Bot { return factory.Bot(context, qq, passwordMd5, configuration) } diff --git a/mirai-core/build.gradle.kts b/mirai-core/build.gradle.kts index 05686502c..d3b85aec2 100644 --- a/mirai-core/build.gradle.kts +++ b/mirai-core/build.gradle.kts @@ -25,6 +25,11 @@ description = "Mirai Protocol implementation for QQ Android" val isAndroidSDKAvailable: Boolean by project +afterEvaluate { + tasks.getByName("compileKotlinCommon").enabled = false + tasks.getByName("compileTestKotlinCommon").enabled = false +} + kotlin { if (isAndroidSDKAvailable) { apply(from = rootProject.file("gradle/android.gradle")) @@ -46,10 +51,19 @@ kotlin { ) } - jvm("jvm") { - withJava() + jvm("common") { + attributes.attribute(ATTRIBUTE_MIRAI_TARGET_PLATFORM, "common") } + jvm("jvm") { + attributes.attribute(ATTRIBUTE_MIRAI_TARGET_PLATFORM, "jvm") + } + + /* + jvm("android") { + attributes.attribute(ATTRIBUTE_MIRAI_TARGET_PLATFORM, "android") + }*/ + sourceSets.apply { all { dependencies { @@ -60,6 +74,7 @@ kotlin { commonMain { dependencies { api1(`kotlinx-serialization-core`) + api1(`kotlinx-serialization-json`) implementation1(`kotlinx-serialization-protobuf`) api1(`kotlinx-atomicfu`) diff --git a/mirai-core/src/commonMain/kotlin/utils/io/serialization/ProtoBufWithNullableSupport.kt b/mirai-core/src/commonMain/kotlin/utils/io/serialization/ProtoBufWithNullableSupport.kt index 9cff4d651..4dca5f2a4 100644 --- a/mirai-core/src/commonMain/kotlin/utils/io/serialization/ProtoBufWithNullableSupport.kt +++ b/mirai-core/src/commonMain/kotlin/utils/io/serialization/ProtoBufWithNullableSupport.kt @@ -61,7 +61,6 @@ internal class ProtoBufWithNullableSupport(override val serializersModule: Seria @Suppress("OverridingDeprecatedMember") override fun beginStructure( descriptor: SerialDescriptor, - vararg typeSerializers: KSerializer<*> ): CompositeEncoder = when (descriptor.kind) { StructureKind.LIST -> RepeatedWriter(encoder, currentTag) StructureKind.CLASS, StructureKind.OBJECT, is PolymorphicKind -> ObjectWriter(currentTagOrNull, encoder) diff --git a/mirai-core/src/commonMain/kotlin/utils/io/serialization/tars/internal/TarsDecoder.kt b/mirai-core/src/commonMain/kotlin/utils/io/serialization/tars/internal/TarsDecoder.kt index 79b1ec404..b44dfac85 100644 --- a/mirai-core/src/commonMain/kotlin/utils/io/serialization/tars/internal/TarsDecoder.kt +++ b/mirai-core/src/commonMain/kotlin/utils/io/serialization/tars/internal/TarsDecoder.kt @@ -47,6 +47,9 @@ internal class TarsDecoder( private val SimpleByteArrayReader: SimpleByteArrayReaderImpl = SimpleByteArrayReaderImpl() private inner class SimpleByteArrayReaderImpl : AbstractDecoder() { + override val serializersModule: SerializersModule + get() = this@TarsDecoder.serializersModule + override fun decodeSequentially(): Boolean = true override fun endStructure(descriptor: SerialDescriptor) { @@ -82,6 +85,9 @@ internal class TarsDecoder( private val ListReader: ListReaderImpl = ListReaderImpl() private inner class ListReaderImpl : AbstractDecoder() { + override val serializersModule: SerializersModule + get() = this@TarsDecoder.serializersModule + override fun decodeSequentially(): Boolean = true override fun decodeElementIndex(descriptor: SerialDescriptor): Int = error("should not be reached") override fun endStructure(descriptor: SerialDescriptor) { @@ -116,6 +122,9 @@ internal class TarsDecoder( private val MapReader: MapReaderImpl = MapReaderImpl() private inner class MapReaderImpl : AbstractDecoder() { + override val serializersModule: SerializersModule + get() = this@TarsDecoder.serializersModule + override fun decodeSequentially(): Boolean = true override fun decodeElementIndex(descriptor: SerialDescriptor): Int = error("stub") diff --git a/settings.gradle.kts b/settings.gradle.kts index 159bf6401..04f6a9240 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,4 +23,4 @@ rootProject.name = "mirai" include(":mirai-core-api") include(":mirai-core") -include(":mirai-core-all") \ No newline at end of file +// include(":mirai-core-all") \ No newline at end of file