無法從靜態上下文中引用非靜態 方法 getClass(),這個是怎么回事
Method md = pattern.structure.proxy.dynamic_proxy.jdk.simulate.Moveable.getClass().getMethod("move"); 錯誤: 無法從靜態上下文中引用非靜態 方法 getClass(),這個是怎么回事?
Method[]?methodArr?=?interfaceCls.getMethods(); String?methodStr?=?""; for?(int?i?=?0;?i?<?methodArr.length;?i++)?{ ????Method?method?=?methodArr[i]; ????methodStr?+=?""?+ ????????????"????@Override\n"?+ ????????????"????public?void?"?+?method.getName()?+?"()?{\n"?+ ????????????"????????Method?md?=?"?+?interfaceCls.getName()?+?".getClass().getMethod(\""?+?method.getName()?+?"\");?\n"?+ ????????????"????????h.invoke(this,md);\n"?+ ????????????"????}\n"; }
2021-05-26
不在一個作用域下吧,環鏡不一樣