1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockito.internal.invocation.realmethod;
6 
7 import org.mockito.internal.creation.MockitoMethodProxy;
8 import org.mockito.internal.exceptions.stacktrace.ConditionalStackTraceFilter;
9 
10 import java.io.Serializable;
11 
12 public class FilteredCGLIBProxyRealMethod implements RealMethod, HasCGLIBMethodProxy, Serializable {
13 
14     private static final long serialVersionUID = 3596550785818938496L;
15     private final RealMethod realMethod;
16 
FilteredCGLIBProxyRealMethod(MockitoMethodProxy methodProxy)17     public FilteredCGLIBProxyRealMethod(MockitoMethodProxy methodProxy) {
18         this(new CGLIBProxyRealMethod(methodProxy));
19     }
20 
FilteredCGLIBProxyRealMethod(RealMethod realMethod)21     public FilteredCGLIBProxyRealMethod(RealMethod realMethod) {
22         this.realMethod = realMethod;
23     }
24 
invoke(Object target, Object[] arguments)25     public Object invoke(Object target, Object[] arguments) throws Throwable {
26         try {
27             return realMethod.invoke(target, arguments);
28         } catch (Throwable t) {
29             new ConditionalStackTraceFilter().filter(t);
30             throw t;
31         }
32     }
33 
getMethodProxy()34     public MockitoMethodProxy getMethodProxy() {
35         return ((HasCGLIBMethodProxy) realMethod).getMethodProxy();
36     }
37 }