我正在開發Burp套件擴展。java中的類中的公共靜態字段
我有一個類BurpExtender,它有公共靜態字段。
public class BurpExtender implements IBurpExtender, IContextMenuFactory{
private IBurpExtenderCallbacks callbacks;
public static PrintWriter stdout;
public static IExtensionHelpers helpers;
...
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
this.callbacks = callbacks;
this.helpers = callbacks.getHelpers();
PrintWriter stdout = new PrintWriter(callbacks.getStdout(), true);
callbacks.setExtensionName("REQUESTSENDER");
callbacks.registerContextMenuFactory(BurpExtender.this);
stdout.println("Registered");
}
public List<JMenuItem> createMenuItems(final IContextMenuInvocation invocation) {
List<JMenuItem> menuItemList = new ArrayList<JMenuItem>();
JMenuItem item = new JMenuItem(new MyAction());
menuItemList.add(item);
return menuItemList;
}
,並在該文件中,我有另一個類MyAction:
private class MyAction extends AbstractAction{
public MyAction(){
super("Name");
}
public void actionPerformed(ActionEvent e) {
//Here i want to use BurpExtender.helpers, but i cant figure out, how to.
//BurpExtender.stdout doesnt work here. Dunno why, NullPoinerException.
}
}
我有另一種解決方案,當我tryed做水木清華像JMenuItem的項目=新的JMenuItem(新AbstractAction( 「123」){ ...}導致它同
U需要初始化靜態變量 – Athul
我的意思是定義它 – Athul
你不知道,但你有沒有搜索是什麼NullPointerException?這是你會遇到最多的例外。 – AxelH