From 1a33f744d61f6367d33ad29d936b54df976c1a6e Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Sat, 8 Jul 2017 19:53:29 +0200 Subject: [PATCH] Some improvements for Java interoperability --- .../main/kotlin/ch/dissem/bitmessage/entity/CustomMessage.kt | 2 ++ .../ch/dissem/bitmessage/extensions/pow/ProofOfWorkRequest.kt | 1 + .../main/kotlin/ch/dissem/bitmessage/repository/JdbcHelper.kt | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/kotlin/ch/dissem/bitmessage/entity/CustomMessage.kt b/core/src/main/kotlin/ch/dissem/bitmessage/entity/CustomMessage.kt index a303c94..d6ba4d5 100644 --- a/core/src/main/kotlin/ch/dissem/bitmessage/entity/CustomMessage.kt +++ b/core/src/main/kotlin/ch/dissem/bitmessage/entity/CustomMessage.kt @@ -68,11 +68,13 @@ open class CustomMessage(val customCommand: String, private val data: ByteArray? companion object { val COMMAND_ERROR = "ERROR" + @JvmStatic fun read(`in`: InputStream, length: Int): CustomMessage { val counter = AccessCounter() return CustomMessage(varString(`in`, counter), bytes(`in`, length - counter.length())) } + @JvmStatic fun error(message: String): CustomMessage { return CustomMessage(COMMAND_ERROR, message.toByteArray(charset("UTF-8"))) } diff --git a/extensions/src/main/kotlin/ch/dissem/bitmessage/extensions/pow/ProofOfWorkRequest.kt b/extensions/src/main/kotlin/ch/dissem/bitmessage/extensions/pow/ProofOfWorkRequest.kt index ef987c3..e2c2ba8 100644 --- a/extensions/src/main/kotlin/ch/dissem/bitmessage/extensions/pow/ProofOfWorkRequest.kt +++ b/extensions/src/main/kotlin/ch/dissem/bitmessage/extensions/pow/ProofOfWorkRequest.kt @@ -77,6 +77,7 @@ data class ProofOfWorkRequest @JvmOverloads constructor(val sender: BitmessageAd } companion object { + @JvmStatic fun read(client: BitmessageAddress, `in`: InputStream): ProofOfWorkRequest { return ProofOfWorkRequest( client, diff --git a/repositories/src/main/kotlin/ch/dissem/bitmessage/repository/JdbcHelper.kt b/repositories/src/main/kotlin/ch/dissem/bitmessage/repository/JdbcHelper.kt index ce8ca1f..bbc7b70 100644 --- a/repositories/src/main/kotlin/ch/dissem/bitmessage/repository/JdbcHelper.kt +++ b/repositories/src/main/kotlin/ch/dissem/bitmessage/repository/JdbcHelper.kt @@ -23,7 +23,7 @@ import java.sql.PreparedStatement /** * Helper class that does Flyway migration, provides JDBC connections and some helper methods. */ -abstract class JdbcHelper protected constructor(protected val config: JdbcConfig) { +abstract class JdbcHelper protected constructor(@JvmField protected val config: JdbcConfig) { companion object { @JvmStatic fun writeBlob(ps: PreparedStatement, parameterIndex: Int, data: Streamable?) { if (data == null) {