是什么导致AWT-EventQueue-0中的NullPointerException? [英] Whats causing this NullPointerException in AWT-EventQueue-0?

查看:176
本文介绍了是什么导致AWT-EventQueue-0中的NullPointerException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序:

一个简单的模拟器,用于学习Java的基础知识.用户可以在提供的编辑器中输入自己的代码,该编辑器可以使玩家跨领域移动.此代码在单独的线程中执行.除了当前的问题之外,该程序还可以正常运行,该错误突然出现并没有出现过.

A simple Simulator to learn the very basics of Java. The user can input his own code in a supplied editor, which moves players across a field. This code is executed in a separate thread. Aside from this current issue the program works fine, this error popped out of the blue and did not appear before.

问题:

由于某种原因,玩家会在随机的时间间隔内抛出以下异常.玩家执行什么动作都没有关系,因为在执行无限次重复的单个动作后的随机时间之后也会显示出来.每次在字段上执行任何操作时都会引发此错误,这意味着控制台日志一遍又一遍地填充了相同的错误消息.

For some reason and in random time intervals the player throws the exception seen below. It does not matter what action the player has performed, as this also shows up after a random time when executing an infinitely repeated single action. This error is thrown every time any action on the field is performed, which means that the console log is getting filled up with the same error message over and over.

代码

这是执行用户代码的方式,CompileActionListener调用JavaCompiler:

This is how the user code is executed, the CompileActionListener calls the JavaCompiler:

method = CompileActionListener.getNewActor().getClass().getMethod("main");
method.invoke(CompileActionListener.getNewActor());

就我而言,其他代码不应引发执行(堆栈树不会暗示我自己的任何类).由于这是NPE,因此应该易于追溯,但是由于缺少对我的课程的引用以及随机的时间间隔,我一无所知.

As far as I'm concerned the other code should not throw said execution (stack tree does not hint towards any of my own classes). Since this is a NPE it should be easy to trace back, but because of the lack of references towards my classes and the random time interval I'm clueless.

堆栈跟踪

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.text.GlyphView.getBreakSpot(GlyphView.java:799)
at javax.swing.text.GlyphView.getBreakWeight(GlyphView.java:724)
at javax.swing.text.FlowView$LogicalView.getPreferredSpan(FlowView.java:733)
at javax.swing.text.FlowView.calculateMinorAxisRequirements(FlowView.java:233)
at javax.swing.text.ParagraphView.calculateMinorAxisRequirements(ParagraphView.java:717)
at javax.swing.text.BoxView.checkRequests(BoxView.java:935)
at javax.swing.text.BoxView.getMinimumSpan(BoxView.java:568)
at javax.swing.text.BoxView.calculateMinorAxisRequirements(BoxView.java:903)
at javax.swing.text.BoxView.checkRequests(BoxView.java:935)
at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:343)
at javax.swing.text.BoxView.layout(BoxView.java:708)
at javax.swing.text.BoxView.setSize(BoxView.java:397)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1722)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:912)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1659)
at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1332)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:821)
at java.awt.Container.layout(Container.java:1508)
at java.awt.Container.doLayout(Container.java:1497)
at java.awt.Container.validateTree(Container.java:1693)
at java.awt.Container.validateTree(Container.java:1702)
at java.awt.Container.validateTree(Container.java:1702)
at java.awt.Container.validate(Container.java:1628)
at javax.swing.RepaintManager$3.run(RepaintManager.java:704)
at javax.swing.RepaintManager$3.run(RepaintManager.java:702)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:701)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1719)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

感谢您前进< 3

Thank you in forward <3

推荐答案

功能强大的try/catch可以轻松解决您的问题.

You can easily solve your problem with the powerful try / catch.

这篇关于是什么导致AWT-EventQueue-0中的NullPointerException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆