From 4e16d00a264d4f922dc97f81ec53479e40a481f2 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 16 Aug 2023 22:38:29 +0200 Subject: [PATCH] HHH-16073 Remove deprecated cfg property 'hibernate.bytecode.use_reflection_optimizer' --- .../userguide/appendices/Configurations.adoc | 3 -- etc/hibernate.properties | 5 --- etc/hibernate.properties.template | 5 --- .../internal/none/BytecodeProviderImpl.java | 7 ++-- .../org/hibernate/cfg/AvailableSettings.java | 10 ------ .../java/org/hibernate/cfg/Environment.java | 36 ------------------- .../hibernate/internal/CoreMessageLogger.java | 4 --- .../EmbeddableRepresentationStrategyPojo.java | 5 --- ...ityRepresentationStrategyPojoStandard.java | 4 --- 9 files changed, 3 insertions(+), 76 deletions(-) diff --git a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc index f7b6b91210..c21aec552d 100644 --- a/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc +++ b/documentation/src/main/asciidoc/userguide/appendices/Configurations.adoc @@ -474,9 +474,6 @@ Enable association management feature in runtime bytecode enhancement which auto `*hibernate.bytecode.provider*` (e.g. `bytebuddy` (default value)):: The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/bytecode/spi/BytecodeProvider.html[`BytecodeProvider`] built-in implementation flavor. Currently, only `bytebuddy` is a valid value, as older deprecated options have been removed. -`*hibernate.bytecode.use_reflection_optimizer*` (e.g. `true` (default value) or `false`):: -Should we use reflection optimization? The reflection optimizer implements the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/bytecode/spi/ReflectionOptimizer.html[`ReflectionOptimizer`] interface and improves entity instantiation and property getter/setter calls. This setting is deprecated for removal without a replacement. - [[configurations-query]] === Query settings diff --git a/etc/hibernate.properties b/etc/hibernate.properties index 0599ab0539..10c9eedee0 100644 --- a/etc/hibernate.properties +++ b/etc/hibernate.properties @@ -345,11 +345,6 @@ hibernate.max_fetch_depth 1 #hibernate.use_identifier_rollback true -## disable bytecode reflection optimizer (enabled by default) - -#hibernate.bytecode.use_reflection_optimizer false - - ##################### ### JDBC Settings ### diff --git a/etc/hibernate.properties.template b/etc/hibernate.properties.template index edabd01f10..d7f7c79a2c 100644 --- a/etc/hibernate.properties.template +++ b/etc/hibernate.properties.template @@ -314,11 +314,6 @@ hibernate.default_batch_fetch_size 8 #hibernate.use_identifier_rollback true -## disable bytecode reflection optimizer (enabled by default) - -#hibernate.bytecode.use_reflection_optimizer false - - ##################### ### JDBC Settings ### diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/BytecodeProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/BytecodeProviderImpl.java index 1446874229..ebb6eb5985 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/BytecodeProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/BytecodeProviderImpl.java @@ -24,8 +24,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; * as an optimisation when not needing any byte code optimisation applied, * for example when the entities have been enhanced at compile time. * Choosing this BytecodeProvider allows to exclude the bytecode enhancement - * libraries from the runtime classpath, but is not compatible - * with the option AvailableSettings#USE_REFLECTION_OPTIMIZER . + * libraries from the runtime classpath. * * @since 5.4 */ @@ -42,12 +41,12 @@ public final class BytecodeProviderImpl implements BytecodeProvider { String[] getterNames, String[] setterNames, Class[] types) { - throw new HibernateException( "Using the ReflectionOptimizer is not possible when the configured BytecodeProvider is 'none'. Disable " + AvailableSettings.USE_REFLECTION_OPTIMIZER + " or use a different BytecodeProvider"); + throw new HibernateException( "Using the ReflectionOptimizer is not possible when the configured BytecodeProvider is 'none'. Use a different BytecodeProvider" ); } @Override public @Nullable ReflectionOptimizer getReflectionOptimizer(Class clazz, Map propertyAccessMap) { - throw new HibernateException( "Using the ReflectionOptimizer is not possible when the configured BytecodeProvider is 'none'. Disable " + AvailableSettings.USE_REFLECTION_OPTIMIZER + " or use a different BytecodeProvider"); + throw new HibernateException( "Using the ReflectionOptimizer is not possible when the configured BytecodeProvider is 'none'. Use a different BytecodeProvider" ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 64a887da50..5be8ff3eb3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -1198,16 +1198,6 @@ public interface AvailableSettings { */ String USE_IDENTIFIER_ROLLBACK = "hibernate.use_identifier_rollback"; - /** - * When enabled, specifies that property access should be optimized via the use - * of generated bytecode. - * - * @deprecated Will be removed without replacement. See HHH-15631 - */ - @Deprecated(forRemoval = true) - @SuppressWarnings("DeprecatedIsStillUsed") - String USE_REFLECTION_OPTIMIZER = "hibernate.bytecode.use_reflection_optimizer"; - /** * When enabled, specifies that Hibernate should attempt to map parameter names * given in a {@link org.hibernate.procedure.ProcedureCall} or diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java index a47f69ba02..1a8f603706 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java @@ -21,9 +21,6 @@ import org.hibernate.internal.util.config.ConfigurationHelper; import org.jboss.logging.Logger; -import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; - - /** * Provides access to configuration properties passed in {@link Properties} objects. *

@@ -36,9 +33,6 @@ import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; * always determined by the {@code Environment} properties in {@link #getProperties()}. * *

- * The only system-level property is {@value #USE_REFLECTION_OPTIMIZER}, - * and it's deprecated. - *

* {@code Environment} properties are populated by calling {@link System#getProperties()} * and then from a resource named {@code /hibernate.properties}, if it exists. System * properties override properties specified in {@code hibernate.properties}. @@ -142,15 +136,12 @@ import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; public final class Environment implements AvailableSettings { private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, Environment.class.getName()); - private static final boolean ENABLE_REFLECTION_OPTIMIZER; - private static final Properties GLOBAL_PROPERTIES; static { Version.logVersion(); GLOBAL_PROPERTIES = new Properties(); - GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.TRUE.toString() ); try { InputStream stream = ConfigHelper.getResourceAsStream( "/hibernate.properties" ); @@ -185,33 +176,6 @@ public final class Environment implements AvailableSettings { catch (SecurityException se) { LOG.unableToCopySystemProperties(); } - - ENABLE_REFLECTION_OPTIMIZER = ConfigurationHelper.getBoolean(USE_REFLECTION_OPTIMIZER, GLOBAL_PROPERTIES); - if ( ENABLE_REFLECTION_OPTIMIZER ) { - LOG.usingReflectionOptimizer(); - } - else { - DEPRECATION_LOGGER.deprecatedSettingForRemoval( USE_REFLECTION_OPTIMIZER, "true" ); - } - } - - /** - * Should we use reflection optimization? - * - * @return True if reflection optimization should be used; false otherwise. - * - * @see #USE_REFLECTION_OPTIMIZER - * @see BytecodeProvider#getReflectionOptimizer - * - * @deprecated Deprecated to indicate that the method will be moved to - * {@link org.hibernate.boot.spi.SessionFactoryOptions} / - * {@link org.hibernate.boot.SessionFactoryBuilder}. - * See HHH-12194 and - * HHH-12193 for details - */ - @Deprecated - public static boolean useReflectionOptimizer() { - return ENABLE_REFLECTION_OPTIMIZER; } /** diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index 4fd931de52..956983adce 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -1380,10 +1380,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Don't use old DTDs, read the Hibernate 3.x Migration Guide", id = 404) void usingOldDtd(); - @LogMessage(level = INFO) - @Message(value = "Using bytecode reflection optimizer", id = 406) - void usingReflectionOptimizer(); - // @LogMessage(level = INFO) // @Message(value = "Using java.io streams to persist binary types", id = 407) // void usingStreams(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableRepresentationStrategyPojo.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableRepresentationStrategyPojo.java index ca2b12dcd6..35b309e6c4 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableRepresentationStrategyPojo.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableRepresentationStrategyPojo.java @@ -16,7 +16,6 @@ import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.bytecode.spi.BytecodeProvider; import org.hibernate.bytecode.spi.ProxyFactoryFactory; import org.hibernate.bytecode.spi.ReflectionOptimizer; -import org.hibernate.cfg.Environment; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.mapping.Backref; @@ -171,10 +170,6 @@ public class EmbeddableRepresentationStrategyPojo extends AbstractEmbeddableRepr Component bootDescriptor, RuntimeModelCreationContext creationContext) { - if ( !Environment.useReflectionOptimizer() ) { - return null; - } - if ( hasCustomAccessors() || bootDescriptor.getCustomInstantiator() != null || bootDescriptor.getInstantiator() != null ) { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java index 8f90a387e4..339b15647e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java @@ -18,7 +18,6 @@ import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.bytecode.spi.BytecodeProvider; import org.hibernate.bytecode.spi.ReflectionOptimizer; import org.hibernate.bytecode.spi.ReflectionOptimizer.InstantiationOptimizer; -import org.hibernate.cfg.Environment; import org.hibernate.classic.Lifecycle; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; @@ -287,9 +286,6 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent } private ReflectionOptimizer resolveReflectionOptimizer(BytecodeProvider bytecodeProvider) { - if ( ! Environment.useReflectionOptimizer() ) { - return null; - } return bytecodeProvider.getReflectionOptimizer( mappedJtd.getJavaTypeClass(), propertyAccessMap