Skip to content

Commit 2d9341c

Browse files
committed
add static imports of renamed loggers
1 parent 8863cda commit 2d9341c

File tree

8 files changed

+44
-40
lines changed

8 files changed

+44
-40
lines changed

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/BytecodeEnhancementLogging.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@Internal
3333
public interface BytecodeEnhancementLogging extends BasicLogger {
3434
String LOGGER_NAME = SubSystemLogging.BASE + ".bytecode.enhancement";
35-
BytecodeEnhancementLogging LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), BytecodeEnhancementLogging.class, LOGGER_NAME );
35+
BytecodeEnhancementLogging ENHANCEMENT_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), BytecodeEnhancementLogging.class, LOGGER_NAME );
3636

3737
// ---- trace messages ----
3838
@LogMessage(level = TRACE)

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/BiDirectionalAssociationHandler.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.AnnotatedFieldDescription;
2121
import org.hibernate.bytecode.enhance.spi.EnhancementException;
2222
import org.hibernate.bytecode.enhance.spi.EnhancerConstants;
23-
import org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging;
2423

2524
import net.bytebuddy.asm.Advice;
2625
import net.bytebuddy.description.annotation.AnnotationDescription;
@@ -37,6 +36,8 @@
3736
import net.bytebuddy.jar.asm.Opcodes;
3837
import net.bytebuddy.jar.asm.Type;
3938

39+
import static org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging.ENHANCEMENT_LOGGER;
40+
4041
final class BiDirectionalAssociationHandler implements Implementation {
4142

4243
static Implementation wrap(
@@ -61,8 +62,8 @@ static Implementation wrap(
6162
bidirectionalAttributeName = mappedBy;
6263
}
6364
if ( bidirectionalAttributeName == null || bidirectionalAttributeName.isEmpty() ) {
64-
if ( BytecodeEnhancementLogging.LOGGER.isInfoEnabled() ) {
65-
BytecodeEnhancementLogging.LOGGER.bidirectionalNotManagedCouldNotFindTargetField(
65+
if ( ENHANCEMENT_LOGGER.isInfoEnabled() ) {
66+
ENHANCEMENT_LOGGER.bidirectionalNotManagedCouldNotFindTargetField(
6667
managedCtClass.getName(),
6768
persistentField.getName(),
6869
targetEntity.getCanonicalName()
@@ -116,8 +117,8 @@ static Implementation wrap(
116117
if ( persistentField.hasAnnotation( ManyToMany.class ) ) {
117118

118119
if ( persistentField.getType().asErasure().isAssignableTo( Map.class ) || targetType.isAssignableTo( Map.class ) ) {
119-
if ( BytecodeEnhancementLogging.LOGGER.isInfoEnabled() ) {
120-
BytecodeEnhancementLogging.LOGGER.manyToManyInMapNotSupported(
120+
if ( ENHANCEMENT_LOGGER.isInfoEnabled() ) {
121+
ENHANCEMENT_LOGGER.manyToManyInMapNotSupported(
121122
managedCtClass.getName(),
122123
persistentField.getName()
123124
);
@@ -157,8 +158,8 @@ else if ( mtm != null ) {
157158
targetClass = mtm.getValue( new MethodDescription.ForLoadedMethod( ManyToMany.class.getDeclaredMethod( "targetEntity" ) ) );
158159
}
159160
else {
160-
if ( BytecodeEnhancementLogging.LOGGER.isInfoEnabled() ) {
161-
BytecodeEnhancementLogging.LOGGER.bidirectionalNotManagedCouldNotFindTargetType(
161+
if ( ENHANCEMENT_LOGGER.isInfoEnabled() ) {
162+
ENHANCEMENT_LOGGER.bidirectionalNotManagedCouldNotFindTargetType(
162163
managedCtClass.getName(),
163164
persistentField.getName()
164165
);
@@ -242,8 +243,8 @@ private static String getMappedByManyToMany(AnnotatedFieldDescription target, Ty
242243
if ( context.isPersistentField( annotatedF )
243244
&& target.getName().equals( getMappedBy( annotatedF, entityType( annotatedF.getType() ), context ) )
244245
&& target.getDeclaringType().asErasure().isAssignableTo( entityType( annotatedF.getType() ) ) ) {
245-
if ( BytecodeEnhancementLogging.LOGGER.isTraceEnabled() ) {
246-
BytecodeEnhancementLogging.LOGGER.tracef(
246+
if ( ENHANCEMENT_LOGGER.isTraceEnabled() ) {
247+
ENHANCEMENT_LOGGER.tracef(
247248
"mappedBy association for field [%s#%s] is [%s#%s]",
248249
target.getDeclaringType().asErasure().getName(),
249250
target.getName(),

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/EnhancerImpl.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.hibernate.engine.spi.CompositeOwner;
4646
import org.hibernate.engine.spi.ExtendedSelfDirtinessTracker;
4747
import org.hibernate.engine.spi.Managed;
48-
import org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging;
4948

5049
import java.lang.annotation.Annotation;
5150
import java.lang.reflect.Modifier;
@@ -64,6 +63,7 @@
6463
import static net.bytebuddy.matcher.ElementMatchers.isStatic;
6564
import static net.bytebuddy.matcher.ElementMatchers.named;
6665
import static net.bytebuddy.matcher.ElementMatchers.not;
66+
import static org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging.ENHANCEMENT_LOGGER;
6767
import static org.hibernate.bytecode.enhance.internal.bytebuddy.FeatureMismatchException.Feature.ASSOCIATION_MANAGEMENT;
6868
import static org.hibernate.bytecode.enhance.internal.bytebuddy.FeatureMismatchException.Feature.DIRTY_CHECK;
6969

@@ -170,19 +170,19 @@ private DynamicType.Builder<?> doEnhance(Supplier<DynamicType.Builder<?>> builde
170170
verifyReEnhancement( managedCtClass, infoAnnotation.load(), enhancementContext );
171171
}
172172
// verification succeeded (or not done) - we can simply skip the enhancement
173-
BytecodeEnhancementLogging.LOGGER.skippingAlreadyAnnotated( managedCtClass.getName() );
173+
ENHANCEMENT_LOGGER.skippingAlreadyAnnotated( managedCtClass.getName() );
174174
return null;
175175
}
176176

177177
// can't effectively enhance interfaces
178178
if ( managedCtClass.isInterface() ) {
179-
BytecodeEnhancementLogging.LOGGER.skippingInterface( managedCtClass.getName() );
179+
ENHANCEMENT_LOGGER.skippingInterface( managedCtClass.getName() );
180180
return null;
181181
}
182182

183183
// can't effectively enhance records
184184
if ( managedCtClass.isRecord() ) {
185-
BytecodeEnhancementLogging.LOGGER.skippingRecord( managedCtClass.getName() );
185+
ENHANCEMENT_LOGGER.skippingRecord( managedCtClass.getName() );
186186
return null;
187187
}
188188

@@ -192,7 +192,7 @@ private DynamicType.Builder<?> doEnhance(Supplier<DynamicType.Builder<?>> builde
192192
return null;
193193
}
194194

195-
BytecodeEnhancementLogging.LOGGER.enhancingAsEntity( managedCtClass.getName() );
195+
ENHANCEMENT_LOGGER.enhancingAsEntity( managedCtClass.getName() );
196196
DynamicType.Builder<?> builder = builderSupplier.get();
197197
builder = builder
198198
.implement( constants.INTERFACES_for_ManagedEntity )
@@ -372,7 +372,7 @@ else if ( enhancementContext.isCompositeClass( managedCtClass ) ) {
372372
return null;
373373
}
374374

375-
BytecodeEnhancementLogging.LOGGER.enhancingAsComposite( managedCtClass.getName() );
375+
ENHANCEMENT_LOGGER.enhancingAsComposite( managedCtClass.getName() );
376376

377377
DynamicType.Builder<?> builder = builderSupplier.get();
378378
builder = builder.implement( constants.INTERFACES_for_ManagedComposite );
@@ -409,19 +409,19 @@ else if ( enhancementContext.isMappedSuperclassClass( managedCtClass ) ) {
409409
if ( checkUnsupportedAttributeNaming( managedCtClass, enhancementContext ) ) {
410410
return null;
411411
}
412-
413-
BytecodeEnhancementLogging.LOGGER.enhancingAsMappedSuperclass( managedCtClass.getName() );
414-
415-
DynamicType.Builder<?> builder = builderSupplier.get();
416-
builder = builder.implement( constants.INTERFACES_for_ManagedMappedSuperclass );
417-
return createTransformer( managedCtClass ).applyTo( builder );
412+
else {
413+
ENHANCEMENT_LOGGER.enhancingAsMappedSuperclass( managedCtClass.getName() );
414+
DynamicType.Builder<?> builder = builderSupplier.get();
415+
builder.implement( constants.INTERFACES_for_ManagedMappedSuperclass );
416+
return createTransformer( managedCtClass ).applyTo( builder );
417+
}
418418
}
419419
else if ( enhancementContext.doExtendedEnhancement() ) {
420-
BytecodeEnhancementLogging.LOGGER.extendedEnhancement( managedCtClass.getName() );
420+
ENHANCEMENT_LOGGER.extendedEnhancement( managedCtClass.getName() );
421421
return createTransformer( managedCtClass ).applyExtended( builderSupplier.get() );
422422
}
423423
else {
424-
BytecodeEnhancementLogging.LOGGER.skippingNotEntityOrComposite( managedCtClass.getName() );
424+
ENHANCEMENT_LOGGER.skippingNotEntityOrComposite( managedCtClass.getName() );
425425
return null;
426426
}
427427
}
@@ -434,7 +434,7 @@ private void verifyReEnhancement(
434434
final String enhancementVersion = existingInfo.version();
435435
if ( "ignore".equals( enhancementVersion ) ) {
436436
// for testing
437-
BytecodeEnhancementLogging.LOGGER.skippingReEnhancementVersionCheck( managedCtClass.getName() );
437+
ENHANCEMENT_LOGGER.skippingReEnhancementVersionCheck( managedCtClass.getName() );
438438
}
439439
else if ( !Version.getVersionString().equals( enhancementVersion ) ) {
440440
throw new VersionMismatchException( managedCtClass, enhancementVersion, Version.getVersionString() );
@@ -605,7 +605,7 @@ private static boolean checkUnsupportedAttributeNaming(TypeDescription managedCt
605605
// We shouldn't even be in this method if using LEGACY, see top of this method.
606606
return switch ( strategy ) {
607607
case SKIP -> {
608-
BytecodeEnhancementLogging.LOGGER.propertyAccessorNoFieldSkip(
608+
ENHANCEMENT_LOGGER.propertyAccessorNoFieldSkip(
609609
managedCtClass.getName(),
610610
fieldName,
611611
methodDescription.getName()
@@ -662,7 +662,7 @@ private boolean alreadyEnhanced(TypeDescription managedCtClass) {
662662
private DynamicType.Builder<?> addInterceptorHandling(DynamicType.Builder<?> builder, TypeDescription managedCtClass) {
663663
// interceptor handling is only needed if class has lazy-loadable attributes
664664
if ( enhancementContext.hasLazyLoadableAttributes( managedCtClass ) ) {
665-
BytecodeEnhancementLogging.LOGGER.weavingPersistentAttributeInterceptable( managedCtClass.getName() );
665+
ENHANCEMENT_LOGGER.weavingPersistentAttributeInterceptable( managedCtClass.getName() );
666666

667667
builder = builder.implement( constants.INTERFACES_for_PersistentAttributeInterceptable );
668668

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/FieldAccessEnhancer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import static net.bytebuddy.matcher.ElementMatchers.hasDescriptor;
88
import static net.bytebuddy.matcher.ElementMatchers.named;
9+
import static org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging.ENHANCEMENT_LOGGER;
910

1011
import jakarta.persistence.Id;
1112

@@ -16,7 +17,6 @@
1617
import org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.AnnotatedFieldDescription;
1718
import org.hibernate.bytecode.enhance.spi.EnhancementException;
1819
import org.hibernate.bytecode.enhance.spi.EnhancerConstants;
19-
import org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging;
2020

2121
import net.bytebuddy.asm.AsmVisitorWrapper;
2222
import net.bytebuddy.description.field.FieldList;
@@ -73,7 +73,7 @@ public void visitFieldInsn(int opcode, String owner, String name, String desc) {
7373
&& !field.hasAnnotation( Id.class )
7474
&& !field.getName().equals( "this$0" ) ) {
7575

76-
BytecodeEnhancementLogging.LOGGER.extendedTransformingFieldAccess(
76+
ENHANCEMENT_LOGGER.extendedTransformingFieldAccess(
7777
declaredOwnerType.getName(),
7878
field.getName(),
7979
instrumentedType.getName(),

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/PersistentAttributeTransformer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import static net.bytebuddy.matcher.ElementMatchers.anyOf;
88
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
99
import static net.bytebuddy.matcher.ElementMatchers.not;
10+
import static org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging.ENHANCEMENT_LOGGER;
1011

1112
import java.util.ArrayList;
1213
import java.util.Arrays;
@@ -17,7 +18,6 @@
1718

1819
import org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.AnnotatedFieldDescription;
1920
import org.hibernate.bytecode.enhance.spi.EnhancerConstants;
20-
import org.hibernate.bytecode.enhance.internal.BytecodeEnhancementLogging;
2121

2222
import net.bytebuddy.asm.Advice;
2323
import net.bytebuddy.asm.AsmVisitorWrapper;
@@ -127,8 +127,8 @@ public static PersistentAttributeTransformer collectPersistentFields(
127127
}
128128

129129
AnnotatedFieldDescription[] orderedFields = enhancementContext.order( persistentFieldList.toArray( new AnnotatedFieldDescription[0] ) );
130-
if ( BytecodeEnhancementLogging.LOGGER.isTraceEnabled() ) {
131-
BytecodeEnhancementLogging.LOGGER.persistentFieldsForEntity(
130+
if ( ENHANCEMENT_LOGGER.isTraceEnabled() ) {
131+
ENHANCEMENT_LOGGER.persistentFieldsForEntity(
132132
managedCtClass.getName(),
133133
Arrays.toString( orderedFields )
134134
);
@@ -154,7 +154,7 @@ else if ( !enhancementContext.isMappedSuperclassClass( managedCtSuperclass.asEra
154154
return collectInheritPersistentFields( managedCtSuperclass, enhancementContext );
155155
}
156156

157-
BytecodeEnhancementLogging.LOGGER.foundMappedSuperclass( String.valueOf( managedCtSuperclass ) );
157+
ENHANCEMENT_LOGGER.foundMappedSuperclass( String.valueOf( managedCtSuperclass ) );
158158

159159
List<AnnotatedFieldDescription> persistentFieldList = new ArrayList<>();
160160

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/BytecodeInterceptorLogging.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface BytecodeInterceptorLogging extends BasicLogger {
3333
String LOGGER_NAME = SubSystemLogging.BASE + ".bytecode.interceptor";
3434

3535
Logger LOGGER = Logger.getLogger( LOGGER_NAME );
36-
BytecodeInterceptorLogging MESSAGE_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), BytecodeInterceptorLogging.class, LOGGER_NAME );
36+
BytecodeInterceptorLogging BYTECODE_INTERCEPTOR_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), BytecodeInterceptorLogging.class, LOGGER_NAME );
3737

3838
@LogMessage(level = WARN)
3939
@Message(

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementAsProxyLazinessInterceptor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.hibernate.type.Type;
1919

2020
import static java.util.Collections.unmodifiableSet;
21+
import static org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging.BYTECODE_INTERCEPTOR_LOGGER;
2122
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
2223
import static org.hibernate.engine.internal.ManagedTypeHelper.asSelfDirtinessTracker;
2324
import static org.hibernate.engine.internal.ManagedTypeHelper.isSelfDirtinessTrackerType;
@@ -143,8 +144,8 @@ private Object extractIdValue(Object target, String attributeName) {
143144
}
144145

145146
public Object forceInitialize(Object target, String attributeName) {
146-
if ( BytecodeInterceptorLogging.MESSAGE_LOGGER.isTraceEnabled() ) {
147-
BytecodeInterceptorLogging.MESSAGE_LOGGER.enhancementAsProxyLazinessForceInitialize(
147+
if ( BYTECODE_INTERCEPTOR_LOGGER.isTraceEnabled() ) {
148+
BYTECODE_INTERCEPTOR_LOGGER.enhancementAsProxyLazinessForceInitialize(
148149
entityKey.getEntityName(),
149150
entityKey.getIdentifier(),
150151
attributeName
@@ -164,8 +165,8 @@ public Object forceInitialize(
164165
String attributeName,
165166
SharedSessionContractImplementor session,
166167
boolean isTemporarySession) {
167-
if ( BytecodeInterceptorLogging.MESSAGE_LOGGER.isTraceEnabled() ) {
168-
BytecodeInterceptorLogging.MESSAGE_LOGGER.enhancementAsProxyLazinessForceInitialize(
168+
if ( BYTECODE_INTERCEPTOR_LOGGER.isTraceEnabled() ) {
169+
BYTECODE_INTERCEPTOR_LOGGER.enhancementAsProxyLazinessForceInitialize(
169170
entityKey.getEntityName(),
170171
entityKey.getIdentifier(),
171172
attributeName

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.hibernate.mapping.ToOne;
2020
import org.hibernate.mapping.Value;
2121

22+
import static org.hibernate.bytecode.enhance.spi.interceptor.BytecodeInterceptorLogging.BYTECODE_INTERCEPTOR_LOGGER;
23+
2224
/**
2325
* @author Steve Ebersole
2426
*/
@@ -42,7 +44,7 @@ public static boolean includeInBaseFetchGroup(
4244
if ( ! isEnhanced ) {
4345
if ( value instanceof ToOne toOne ) {
4446
if ( toOne.isUnwrapProxy() ) {
45-
BytecodeInterceptorLogging.MESSAGE_LOGGER.debugf(
47+
BYTECODE_INTERCEPTOR_LOGGER.debugf(
4648
"To-one property `%s#%s` was mapped with LAZY + NO_PROXY but the class was not enhanced",
4749
bootMapping.getPersistentClass().getEntityName(),
4850
bootMapping.getName()
@@ -73,7 +75,7 @@ public static boolean includeInBaseFetchGroup(
7375
// however, at the time being that leads to inefficient SQL - so for now
7476
// we simply log a message that we are ignoring the `@LazyGroup` for to-ones
7577

76-
BytecodeInterceptorLogging.MESSAGE_LOGGER.lazyGroupIgnoredForToOne(
78+
BYTECODE_INTERCEPTOR_LOGGER.lazyGroupIgnoredForToOne(
7779
bootMapping.getPersistentClass().getEntityName(),
7880
bootMapping.getName(),
7981
bootMapping.getLazyGroup()

0 commit comments

Comments
 (0)