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.creation; 6 7 import java.io.Serializable; 8 9 import org.mockito.cglib.proxy.MethodProxy; 10 import org.mockito.internal.util.reflection.Whitebox; 11 12 public class SerializableMockitoMethodProxy extends AbstractMockitoMethodProxy implements Serializable { 13 14 private static final long serialVersionUID = -5337859962876770632L; 15 private final Class<?> c1; 16 private final Class<?> c2; 17 private final String desc; 18 private final String name; 19 private final String superName; 20 private transient MethodProxy methodProxy; 21 SerializableMockitoMethodProxy(MethodProxy methodProxy)22 public SerializableMockitoMethodProxy(MethodProxy methodProxy) { 23 Object info = Whitebox.getInternalState(methodProxy, "createInfo"); 24 c1 = (Class<?>) Whitebox.getInternalState(info, "c1"); 25 c2 = (Class<?>) Whitebox.getInternalState(info, "c2"); 26 desc = methodProxy.getSignature().getDescriptor(); 27 name = methodProxy.getSignature().getName(); 28 superName = methodProxy.getSuperName(); 29 this.methodProxy = methodProxy; 30 } 31 getMethodProxy()32 public MethodProxy getMethodProxy() { 33 if (methodProxy == null) 34 methodProxy = MethodProxy.create(c1, c2, desc, name, superName); 35 return methodProxy; 36 } 37 }