From b77bbf06506ad3aeda64b046c0cfe4e9c3b8ba82 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 24 Jan 2023 17:32:49 +0000 Subject: [PATCH] HHH-16091 Make AbstractStandardBasicType#getReturnedClass return a constant --- .../java/org/hibernate/type/AbstractStandardBasicType.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java index 9dba8cb804..86189c6b48 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AbstractStandardBasicType.java @@ -49,6 +49,7 @@ public abstract class AbstractStandardBasicType private final ValueExtractor jdbcValueExtractor; private final JdbcLiteralFormatter jdbcLiteralFormatter; private final AbstractClassJavaType javaTypeAsAbstractClassJavaType; + private final Class javaTypeClass; public AbstractStandardBasicType(JdbcType jdbcType, JavaType javaType) { this.jdbcType = jdbcType; @@ -58,6 +59,9 @@ public abstract class AbstractStandardBasicType this.jdbcValueBinder = jdbcType.getBinder( javaType ); this.jdbcValueExtractor = jdbcType.getExtractor( javaType ); this.jdbcLiteralFormatter = jdbcType.getJdbcLiteralFormatter( javaType ); + + //A very simple dispatch optimisation, make this a constant: + this.javaTypeClass = javaType.getJavaTypeClass(); //This is a dispatch optimisation to avoid megamorphic invocations on the most common type: if ( javaType instanceof AbstractClassJavaType ) { this.javaTypeAsAbstractClassJavaType = (AbstractClassJavaType) javaType; @@ -123,7 +127,7 @@ public abstract class AbstractStandardBasicType @Override public final Class getReturnedClass() { - return javaType.getJavaTypeClass(); + return javaTypeClass; } @Override