Skip to content

Commit bde7362

Browse files
committed
HHH-15634 Extracting reusable Type constants from ByteBuddy InlineDirtyCheckingHandler
1 parent 9335527 commit bde7362

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

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

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232

3333
final class InlineDirtyCheckingHandler implements Implementation, ByteCodeAppender {
3434

35+
private static final String HELPER_TYPE_NAME = Type.getInternalName( InlineDirtyCheckerEqualsHelper.class );
36+
private static final Type PE_INTERCEPTABLE_TYPE = Type.getType( PersistentAttributeInterceptable.class );
37+
private static final Type OBJECT_TYPE = Type.getType( Object.class );
38+
private static final Type STRING_TYPE = Type.getType( String.class );
39+
3540
private final Implementation delegate;
3641

3742
private final TypeDescription managedCtClass;
@@ -137,31 +142,32 @@ public Size apply(
137142
int branchCode;
138143
if ( applyLazyCheck ) {
139144
if ( persistentField.getType().isPrimitive() ) {
145+
final Type fieldType = Type.getType( persistentField.getDescriptor() );
140146
methodVisitor.visitMethodInsn(
141147
Opcodes.INVOKESTATIC,
142-
Type.getInternalName( InlineDirtyCheckerEqualsHelper.class ),
148+
HELPER_TYPE_NAME,
143149
"areEquals",
144150
Type.getMethodDescriptor(
145-
Type.getType( boolean.class ),
146-
Type.getType( PersistentAttributeInterceptable.class ),
147-
Type.getType( String.class ),
148-
Type.getType( persistentField.getDescriptor() ),
149-
Type.getType( persistentField.getDescriptor() )
151+
Type.BOOLEAN_TYPE,
152+
PE_INTERCEPTABLE_TYPE,
153+
STRING_TYPE,
154+
fieldType,
155+
fieldType
150156
),
151157
false
152158
);
153159
}
154160
else {
155161
methodVisitor.visitMethodInsn(
156162
Opcodes.INVOKESTATIC,
157-
Type.getInternalName( InlineDirtyCheckerEqualsHelper.class ),
163+
HELPER_TYPE_NAME,
158164
"areEquals",
159165
Type.getMethodDescriptor(
160-
Type.getType( boolean.class ),
161-
Type.getType( PersistentAttributeInterceptable.class ),
162-
Type.getType( String.class ),
163-
Type.getType( Object.class ),
164-
Type.getType( Object.class )
166+
Type.BOOLEAN_TYPE,
167+
PE_INTERCEPTABLE_TYPE,
168+
STRING_TYPE,
169+
OBJECT_TYPE,
170+
OBJECT_TYPE
165171
),
166172
false
167173
);
@@ -190,9 +196,9 @@ else if ( persistentField.getType().represents( double.class ) ) {
190196
Type.getInternalName( Objects.class ),
191197
"deepEquals",
192198
Type.getMethodDescriptor(
193-
Type.getType( boolean.class ),
194-
Type.getType( Object.class ),
195-
Type.getType( Object.class )
199+
Type.BOOLEAN_TYPE,
200+
OBJECT_TYPE,
201+
OBJECT_TYPE
196202
),
197203
false
198204
);
@@ -208,7 +214,7 @@ else if ( persistentField.getType().represents( double.class ) ) {
208214
Opcodes.INVOKEVIRTUAL,
209215
managedCtClass.getInternalName(),
210216
EnhancerConstants.TRACKER_CHANGER_NAME,
211-
Type.getMethodDescriptor( Type.getType( void.class ), Type.getType( String.class ) ),
217+
Type.getMethodDescriptor( Type.VOID_TYPE, STRING_TYPE ),
212218
false
213219
);
214220
// }

0 commit comments

Comments
 (0)