|
18 | 18 | import java.util.Iterator;
|
19 | 19 | import java.util.List;
|
20 | 20 | import java.util.Map;
|
21 |
| -import java.util.concurrent.Callable; |
22 | 21 |
|
23 | 22 | import org.hibernate.HibernateException;
|
24 | 23 | import org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl;
|
@@ -184,7 +183,7 @@ public ReflectionOptimizer getReflectionOptimizer(
|
184 | 183 | .method( setPropertyValuesMethodName )
|
185 | 184 | .intercept( new Implementation.Simple( new SetPropertyValues( clazz, getterNames, setters ) ) )
|
186 | 185 | .method( getPropertyNamesMethodName )
|
187 |
| - .intercept( MethodCall.call( new CloningPropertyCall( getterNames ) ) ) |
| 186 | + .intercept( new Implementation.Simple( new GetPropertyNames( getterNames ) ) ) |
188 | 187 | );
|
189 | 188 |
|
190 | 189 | try {
|
@@ -251,7 +250,7 @@ public ReflectionOptimizer getReflectionOptimizer(
|
251 | 250 | .method( setPropertyValuesMethodName )
|
252 | 251 | .intercept( new Implementation.Simple( new SetPropertyValues( clazz, propertyNames, setters ) ) )
|
253 | 252 | .method( getPropertyNamesMethodName )
|
254 |
| - .intercept( MethodCall.call( new CloningPropertyCall( propertyNames ) ) ) |
| 253 | + .intercept( new Implementation.Simple( new GetPropertyNames( propertyNames ) ) ) |
255 | 254 | );
|
256 | 255 |
|
257 | 256 | try {
|
@@ -1293,17 +1292,29 @@ private static Constructor<?> findConstructor(Class<?> clazz) {
|
1293 | 1292 | }
|
1294 | 1293 | }
|
1295 | 1294 |
|
1296 |
| - public static class CloningPropertyCall implements Callable<String[]> { |
| 1295 | + public static class GetPropertyNames implements ByteCodeAppender { |
1297 | 1296 |
|
1298 | 1297 | private final String[] propertyNames;
|
1299 | 1298 |
|
1300 |
| - private CloningPropertyCall(String[] propertyNames) { |
| 1299 | + private GetPropertyNames(String[] propertyNames) { |
1301 | 1300 | this.propertyNames = propertyNames;
|
1302 | 1301 | }
|
1303 | 1302 |
|
1304 | 1303 | @Override
|
1305 |
| - public String[] call() { |
1306 |
| - return propertyNames.clone(); |
| 1304 | + public Size apply( |
| 1305 | + MethodVisitor methodVisitor, |
| 1306 | + Implementation.Context implementationContext, |
| 1307 | + MethodDescription instrumentedMethod) { |
| 1308 | + methodVisitor.visitLdcInsn( propertyNames.length ); |
| 1309 | + methodVisitor.visitTypeInsn( Opcodes.ANEWARRAY, Type.getInternalName( String.class ) ); |
| 1310 | + for ( int i = 0; i < propertyNames.length; i++ ) { |
| 1311 | + methodVisitor.visitInsn( Opcodes.DUP ); |
| 1312 | + methodVisitor.visitLdcInsn( i ); |
| 1313 | + methodVisitor.visitLdcInsn( propertyNames[i] ); |
| 1314 | + methodVisitor.visitInsn( Opcodes.AASTORE ); |
| 1315 | + } |
| 1316 | + methodVisitor.visitInsn( Opcodes.ARETURN ); |
| 1317 | + return new Size( 4, instrumentedMethod.getStackSize() + 1 ); |
1307 | 1318 | }
|
1308 | 1319 | }
|
1309 | 1320 |
|
|
0 commit comments