java.awt.eventqueue,是什么导致AWT-EventQueue-0中的NullPointerException?

The Program:

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.

The Problem:

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.

The Code

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

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

method.invoke(CompileActionListener.getNewActor());

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.

The stack trace

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)

Thank you in forward <3

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值