mirror of
https://github.com/corda/corda.git
synced 2025-06-23 09:25:36 +00:00
Review Comments
This commit is contained in:
@ -171,27 +171,25 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processSchema(
|
private fun processSchema(schema: Schema, cl: ClassLoader = DeserializedParameterizedType::class.java.classLoader) {
|
||||||
schema: Schema,
|
|
||||||
cl: ClassLoader = DeserializedParameterizedType::class.java.classLoader) {
|
|
||||||
|
|
||||||
val carpenterSchemas = CarpenterSchemas.newInstance()
|
val carpenterSchemas = CarpenterSchemas.newInstance()
|
||||||
for (typeNotation in schema.types) {
|
for (typeNotation in schema.types) {
|
||||||
try {
|
try {
|
||||||
processSchemaEntry(typeNotation, cl)
|
processSchemaEntry(typeNotation, cl)
|
||||||
}
|
}
|
||||||
catch (e: java.lang.ClassNotFoundException) {
|
catch (e: ClassNotFoundException) {
|
||||||
if ((cl != DeserializedParameterizedType::class.java.classLoader)
|
if ((cl != DeserializedParameterizedType::class.java.classLoader)
|
||||||
|| (typeNotation !is CompositeType)) throw e
|
|| (typeNotation !is CompositeType)) throw e
|
||||||
typeNotation.carpenterSchema(carpenterSchemas = carpenterSchemas)
|
typeNotation.carpenterSchema(carpenterSchemas = carpenterSchemas)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (carpenterSchemas.isEmpty()) return
|
if (carpenterSchemas.isNotEmpty()) {
|
||||||
val mc = MetaCarpenter(carpenterSchemas)
|
val mc = MetaCarpenter(carpenterSchemas)
|
||||||
mc.build()
|
mc.build()
|
||||||
|
|
||||||
processSchema(schema, mc.classloader)
|
processSchema(schema, mc.classloader)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processSchemaEntry(typeNotation: TypeNotation,
|
private fun processSchemaEntry(typeNotation: TypeNotation,
|
||||||
@ -318,10 +316,10 @@ class SerializerFactory(val whitelist: ClassWhitelist = AllWhitelist) {
|
|||||||
fun nameForType(type: Type) : String = when (type) {
|
fun nameForType(type: Type) : String = when (type) {
|
||||||
is Class<*> -> {
|
is Class<*> -> {
|
||||||
primitiveTypeName(type) ?: if (type.isArray) {
|
primitiveTypeName(type) ?: if (type.isArray) {
|
||||||
"${nameForType(type.componentType)}${if (type.componentType.isPrimitive) "[p]" else "[]"}"
|
"${nameForType(type.componentType)}${if(type.componentType.isPrimitive) "[p]" else "[]"}"
|
||||||
} else type.name
|
} else type.name
|
||||||
}
|
}
|
||||||
is ParameterizedType -> "${nameForType(type.rawType)ype.actualTypeArguments.joinToString { nameForType(it) }}>"
|
is ParameterizedType -> "${nameForType(type.rawType)}<${type.actualTypeArguments.joinToString { nameForType(it) }}>"
|
||||||
is GenericArrayType -> "${nameForType(type.genericComponentType)}[]"
|
is GenericArrayType -> "${nameForType(type.genericComponentType)}[]"
|
||||||
else -> throw NotSerializableException("Unable to render type $type to a string.")
|
else -> throw NotSerializableException("Unable to render type $type to a string.")
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ data class CarpenterSchemas (
|
|||||||
get() = carpenterSchemas.size
|
get() = carpenterSchemas.size
|
||||||
|
|
||||||
fun isEmpty() = carpenterSchemas.isEmpty()
|
fun isEmpty() = carpenterSchemas.isEmpty()
|
||||||
|
fun isNotEmpty() = carpenterSchemas.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user