读书人

java 调用父类的 私有步骤

发布时间: 2012-10-07 17:28:51 作者: rapoo

java 调用父类的 私有方法

protected void setActionsActivated(boolean state) {

Method method= null;

try {

method= AbstractTextEditor.class.getDeclaredMethod("setActionActivation", new Class[] { boolean.class }); //$NON-NLS-1$

} catch (SecurityException ex) {

JavaPlugin.log(ex);

} catch (NoSuchMethodException ex) {

JavaPlugin.log(ex);

}

Assert.isNotNull(method);

method.setAccessible(true);

try {

method.invoke(this, new Object[] { new Boolean(state) });

} catch (IllegalArgumentException ex) {

JavaPlugin.log(ex);

} catch (InvocationTargetException ex) {

JavaPlugin.log(ex);

} catch (IllegalAccessException ex) {

JavaPlugin.log(ex);

}

}

读书人网 >编程

热点推荐