ENT-2967 Fix up use of various JDK performance contention points (#4608)

* ENT-2967 Various JDK contention points

* Move new private method to bottom of class.
This commit is contained in:
Rick Parker
2019-01-22 11:19:51 +00:00
committed by GitHub
parent ee4f4f5702
commit 197a13611d
4 changed files with 27 additions and 9 deletions

View File

@ -24,7 +24,6 @@ class IncompatibleTypeIdentifierException(message: String) : NotSerializableExce
* [TypeIdentifier] provides a family of type identifiers, together with a [prettyPrint] method for displaying them.
*/
sealed class TypeIdentifier {
/**
* The name of the type.
*/
@ -38,7 +37,7 @@ sealed class TypeIdentifier {
* @throws IncompatibleTypeIdentifierException if the type identifier is incompatible with the locally-defined type
* to which it refers.
*/
abstract fun getLocalType(classLoader: ClassLoader = ClassLoader.getSystemClassLoader()): Type
abstract fun getLocalType(classLoader: ClassLoader = systemClassLoader): Type
open val erased: TypeIdentifier get() = this
@ -61,6 +60,9 @@ sealed class TypeIdentifier {
if (simplifyClassNames) split(".", "$").last() else this
companion object {
// This method has locking. So we memo the value here.
private val systemClassLoader: ClassLoader = ClassLoader.getSystemClassLoader()
/**
* Obtain the [TypeIdentifier] for an erased Java class.
*
@ -204,7 +206,7 @@ sealed class TypeIdentifier {
override fun toString() = "Parameterised(${prettyPrint()})"
override fun getLocalType(classLoader: ClassLoader): Type {
val rawType = classLoader.loadClass(name)
val rawType = Class.forName(name, false, classLoader)
if (rawType.typeParameters.size != parameters.size) {
throw IncompatibleTypeIdentifierException(
"Class $rawType expects ${rawType.typeParameters.size} type arguments, " +