@@ -331,8 +331,7 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
331
331
aopInterceptor , // for normal advice
332
332
targetInterceptor , // invoke target without considering advice, if optimized
333
333
new SerializableNoOp (), // no override for methods mapped to this
334
- targetDispatcher ,
335
- this .advisedDispatcher ,
334
+ targetDispatcher , this .advisedDispatcher ,
336
335
new EqualsInterceptor (this .advised ),
337
336
new HashCodeInterceptor (this .advised )
338
337
};
@@ -343,14 +342,14 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
343
342
if (isStatic && isFrozen ) {
344
343
Method [] methods = rootClass .getMethods ();
345
344
int methodsCount = methods .length ;
346
- ArrayList <Callback > fixedCallbacks = new ArrayList <>(methodsCount );
345
+ List <Callback > fixedCallbacks = new ArrayList <>(methodsCount );
347
346
this .fixedInterceptorMap = CollectionUtils .newHashMap (methodsCount );
348
347
349
348
int advicedMethodCount = methodsCount ;
350
349
for (int x = 0 ; x < methodsCount ; x ++) {
351
350
Method method = methods [x ];
352
351
//do not create advices for non-overridden methods of java.lang.Object
353
- if (notOverriddenOfObject ( method ) ) {
352
+ if (method . getDeclaringClass () == Object . class ) {
354
353
advicedMethodCount --;
355
354
continue ;
356
355
}
@@ -364,24 +363,14 @@ private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
364
363
// and fixedCallbacks into the callbacks array.
365
364
Callback [] callbacks = new Callback [mainCallbacks .length + advicedMethodCount ];
366
365
System .arraycopy (mainCallbacks , 0 , callbacks , 0 , mainCallbacks .length );
367
- System .arraycopy (fixedCallbacks .toArray (), 0 , callbacks , mainCallbacks .length , advicedMethodCount );
366
+ System .arraycopy (fixedCallbacks .toArray (Callback []::new ), 0 , callbacks ,
367
+ mainCallbacks .length , advicedMethodCount );
368
368
this .fixedInterceptorOffset = mainCallbacks .length ;
369
369
return callbacks ;
370
370
}
371
-
372
371
return mainCallbacks ;
373
372
}
374
373
375
- /**
376
- * Returns true if param is inherited from {@link Object} and not overridden in declaring class.
377
- * We use this to detect {@link Object#notify()}, {@link Object#notifyAll()}, {@link Object#getClass()} etc.
378
- * to skip creation of useless advices for them.
379
- * @param method to be checked
380
- * @return true in case {@code method} belongs to {@link Object}
381
- */
382
- private static boolean notOverriddenOfObject (Method method ) {
383
- return method .getDeclaringClass () == Object .class ;
384
- }
385
374
386
375
@ Override
387
376
public boolean equals (@ Nullable Object other ) {
0 commit comments