Declare serialisation default interface methods as Java8-style defaults. (#3086)

This commit is contained in:
Chris Rankin
2018-05-18 12:31:01 +01:00
committed by GitHub
parent 215e54f1ab
commit a38250c100
3 changed files with 6 additions and 4 deletions

View File

@ -173,6 +173,7 @@ allprojects {
apiVersion = "1.2" apiVersion = "1.2"
jvmTarget = "1.8" jvmTarget = "1.8"
javaParameters = true // Useful for reflection. javaParameters = true // Useful for reflection.
freeCompilerArgs = ['-Xenable-jvm-default']
} }
} }

View File

@ -8,9 +8,9 @@ import java.nio.ByteBuffer
class OrdinalBits(private val ordinal: Int) { class OrdinalBits(private val ordinal: Int) {
interface OrdinalWriter { interface OrdinalWriter {
val bits: OrdinalBits val bits: OrdinalBits
val encodedSize get() = 1 @JvmDefault val encodedSize get() = 1
fun writeTo(stream: OutputStream) = stream.write(bits.ordinal) @JvmDefault fun writeTo(stream: OutputStream) = stream.write(bits.ordinal)
fun putTo(buffer: ByteBuffer) = buffer.put(bits.ordinal.toByte())!! @JvmDefault fun putTo(buffer: ByteBuffer) = buffer.put(bits.ordinal.toByte())!!
} }
init { init {

View File

@ -31,6 +31,7 @@ interface AMQPSerializer<out T> {
/** /**
* Write the given object, with declared type, to the output. * Write the given object, with declared type, to the output.
*/ */
@JvmDefault
fun writeObject(obj: Any, data: Data, type: Type, output: SerializationOutput, fun writeObject(obj: Any, data: Data, type: Type, output: SerializationOutput,
context: SerializationContext, debugIndent: Int = 0) context: SerializationContext, debugIndent: Int = 0)