代码如下:
```java
public class VideoProcessEngineProxy implements InvocationHandler {
private Object tar;
//绑定委托对象,并返回代理类
public Object bind(Object tar) {
this.tar = tar;
return Proxy.newProxyInstance(
tar.getClass().getClassLoader(),
tar.getClass().getInterfaces(),
this);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = method.invoke(tar, args);
System.out.println("VideoProcessEngineProxy:" + method.getName() + ", " + result);
return result;
}
public static VideoProcessEngine createVideoProcessEngine(String mInputPath,
SurfaceHolder mSurface,
Context context) {
VideoProcessEngine _ins = VideoProcessEngine.createVideoProcessEngine(mInputPath, mSurface, context);
VideoProcessEngineProxy proxy = new VideoProcessEngineProxy();
return (VideoProcessEngine) proxy.bind(_ins);
}
}
``
调用
createVideoProcessEngine方法时, 报
java.lang.ClassCastException: $Proxy3 cannot be cast toVideoProcessEngine`
啥情况?