mirror of
https://github.com/corda/corda.git
synced 2025-06-17 06:38:21 +00:00
CORDA-1383: Cleaned up the JSON format of WireTransaction and SignedTransaction (#3248)
In particular correctly outputs the custom state and command objects in the txs. Also fixed up deserialisation back into the transaction objects.
This commit is contained in:
@ -6,6 +6,7 @@ import com.esotericsoftware.kryo.io.Output
|
||||
import com.esotericsoftware.kryo.serializers.FieldSerializer
|
||||
import com.esotericsoftware.kryo.util.DefaultClassResolver
|
||||
import com.esotericsoftware.kryo.util.Util
|
||||
import net.corda.core.internal.kotlinObjectInstance
|
||||
import net.corda.core.internal.writer
|
||||
import net.corda.core.serialization.ClassWhitelist
|
||||
import net.corda.core.serialization.SerializationContext
|
||||
@ -15,7 +16,6 @@ import net.corda.serialization.internal.MutableClassWhitelist
|
||||
import net.corda.serialization.internal.TransientClassWhiteList
|
||||
import net.corda.serialization.internal.amqp.hasCordaSerializable
|
||||
import java.io.PrintWriter
|
||||
import java.lang.reflect.Modifier
|
||||
import java.lang.reflect.Modifier.isAbstract
|
||||
import java.nio.charset.StandardCharsets.UTF_8
|
||||
import java.nio.file.Paths
|
||||
@ -75,22 +75,7 @@ class CordaClassResolver(serializationContext: SerializationContext) : DefaultCl
|
||||
|
||||
override fun registerImplicit(type: Class<*>): Registration {
|
||||
val targetType = typeForSerializationOf(type)
|
||||
// Is this a Kotlin object? We use our own reflection here rather than .kotlin.objectInstance because Kotlin
|
||||
// reflection won't work for private objects, and can throw exceptions in other circumstances as well.
|
||||
val objectInstance = try {
|
||||
targetType.declaredFields.singleOrNull {
|
||||
it.name == "INSTANCE" &&
|
||||
it.type == type &&
|
||||
Modifier.isStatic(it.modifiers) &&
|
||||
Modifier.isFinal(it.modifiers) &&
|
||||
Modifier.isPublic(it.modifiers)
|
||||
}?.let {
|
||||
it.isAccessible = true
|
||||
type.cast(it.get(null)!!)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
null
|
||||
}
|
||||
val objectInstance = targetType.kotlinObjectInstance
|
||||
|
||||
// We have to set reference to true, since the flag influences how String fields are treated and we want it to be consistent.
|
||||
val references = kryo.references
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.corda.node.utilities
|
||||
|
||||
import net.corda.core.internal.isStatic
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Modifier
|
||||
import java.lang.reflect.Type
|
||||
import java.time.Instant
|
||||
|
||||
@ -131,7 +131,7 @@ object ObjectDiffer {
|
||||
private fun getFieldFoci(obj: Any) : List<FieldFocus> {
|
||||
val foci = ArrayList<FieldFocus>()
|
||||
for (method in obj.javaClass.declaredMethods) {
|
||||
if (Modifier.isStatic(method.modifiers)) {
|
||||
if (method.isStatic) {
|
||||
continue
|
||||
}
|
||||
if (method.name.startsWith("get") && method.name.length > 3 && method.parameterCount == 0) {
|
||||
|
Reference in New Issue
Block a user