在Eclipse插件中使用Java深度克隆库时出现java.lang.NullPointerException

时间:2015-09-07 11:32:31

标签: java eclipse

大家好,我正在开发自己的Eclipse插件,并且它对其他插件有一些依赖性。它需要的另一个插件使用Java深度克隆库。当我从我自己的插件调用此插件的方法时,抛出java.lang.NullPointerException,如下所示:

java.lang.NullPointerException
at org.eclipse.ui.internal.AbstractWorkingSetManager$1.compare(AbstractWorkingSetManager.java:97)
at java.util.TreeMap.put(TreeMap.java:547)
at com.rits.cloning.FastClonerTreeMap.clone(FastClonerTreeMap.java:22)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:21)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:21)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerHashSet.clone(FastClonerHashSet.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerHashSet.clone(FastClonerHashSet.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:21)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:21)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:21)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.FastClonerHashMap.clone(FastClonerHashMap.java:21)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:462)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.FastClonerArrayList.clone(FastClonerArrayList.java:20)
at com.rits.cloning.Cloner.fastClone(Cloner.java:108)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:437)
at com.rits.cloning.Cloner.cloneInternal(Cloner.java:491)
at com.rits.cloning.Cloner.deepClone(Cloner.java:323)
at generativeGrammar.designAbstractionGraph.impl.FPGAMonitoringImpl.genMonitoringSoCs(FPGAMonitoringImpl.java:181)
at generativeGrammar.designAbstractionGraph.impl.FPGAMonitoringImpl.GenerateMonitoringSoCs(FPGAMonitoringImpl.java:174)
at org.spiritconsortium.xml.schema.spirit.spirit.tests._1GenerativGrammarProject.main(_1GenerativGrammarProject.java:237)
at gripgui.frame.Frame4$2.actionPerformed(Frame4.java:142)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6288)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2045)
at java.awt.Component.dispatchEventImpl(Component.java:4649)
at java.awt.Container.dispatchEventImpl(Container.java:2103)
at java.awt.Component.dispatchEvent(Component.java:4475)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
at java.awt.Container.dispatchEventImpl(Container.java:2089)
at java.awt.Window.dispatchEventImpl(Window.java:2588)
at java.awt.Component.dispatchEvent(Component.java:4475)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:687)
at java.awt.EventQueue.access$400(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:646)
at java.awt.EventQueue$2.run(EventQueue.java:644)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:119)
at java.awt.EventQueue$3.run(EventQueue.java:660)
at java.awt.EventQueue$3.run(EventQueue.java:658)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:108)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:657)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

抛出此异常后,JVM也可能崩溃。

然而,稍后,我运行插件,我自己的插件依赖于一个Java应用程序,并且没有任何异常发生。

有人知道问题出在哪里吗?

抱歉我的英语不好,因为英语不是我的母语

其他信息:

我使用的Eclipse版本是Indigo版本,我使用的Java SDK版本是1.6

修改

我将在这里提供一些源代码。

我已经多次调试代码,并且可以确保方法使用的参数不为空。

    private void genMonitoringSoCs(DesignAbstraction des, List<GenerativRulePair> grs){

    Cloner cloner = new Cloner();
    DesignAbstraction ndes = cloner.deepClone(des);
    List<GenerativRulePair> ngrs = cloner.deepClone(grs);

    DesignGeneration generateDesign = new DesignGeneration();

    for (Iterator<GenerativRulePair> j = grs.iterator(); j.hasNext();) {
        GenerativRulePair gr = (GenerativRulePair) j.next();
        boolean check = this.checkRuleForFPGA(ndes, gr);
        if (check) {
            ndes = generateDesign.GenerateNewDesign(ndes, gr);
            ngrs.remove(0);
        } else {
            DesignAbstraction nndes = cloner.deepClone(des);
            this.genMonitoringSoCs(nndes,ngrs);
        }
    }
    allDes.add(ndes);       
} 

1 个答案:

答案 0 :(得分:0)

首先在此行之前验证null,并检查在运行时是否发生这种情况。

第二件事是我发现this问题与你的问题非常相似。

  

集合和列表的快速克隆器应该在尝试添加到集合之前检查来自cloner.cloneInternal()的空响应,因为由于ignoredInstances或忽略的类可能会返回null。