调试模式在Eclipse中抛出NullPointer异常

时间:2017-07-11 12:52:00

标签: java eclipse

所以我有一个在java 1.8中使用图形的类,我正在使用Eclipse。问题是当我正常运行程序时,它可以工作,但是当我想使用调试模式时,它会因为NullPointer异常而下降。终端写道:

main.Game at localhost:54045    
    Thread [AWT-EventQueue-0] (Running) 
    Thread [Thread-2] (Suspended (exception NullPointerException))  
        owns: TrueTypeFont  (id=40) 
        owns: Win32FontManager  (id=41) 
        TrueTypeFont.open(boolean) line: not available  
        TrueTypeFont.verify(boolean) line: not available    
        TrueTypeFont.<init>(String, Object, int, boolean, boolean) line: not available  
        TrueTypeFont.<init>(String, Object, int, boolean) line: not available   
        Win32FontManager(SunFontManager).resolveFontFiles(HashSet<String>, ArrayList<String>) line: not available   
        Win32FontManager(SunFontManager).resolveWindowsFonts() line: not available  
        Win32FontManager(SunFontManager).getFullNameToFileMap() line: not available 
        Win32FontManager(SunFontManager).findFontFromPlatform(String, int) line: not available  
        Win32FontManager(SunFontManager).findFont2D(String, int, int) line: not available   
        Font.getFont2D() line: not available    
        Font.access$000(Font) line: not available   
        Font$FontAccessImpl.getFont2D(Font) line: not available 
        FontUtilities.getFont2D(Font) line: not available   
        SunGraphics2D.checkFontInfo(FontInfo, Font, FontRenderContext) line: not available  
        SunGraphics2D.getFontInfo() line: not available 
        SolidTextRenderer(GlyphListPipe).drawString(SunGraphics2D, String, double, double) line: not available  
        SunGraphics2D.drawString(String, int, int) line: not available  
        Menu.render(Graphics) line: 35  
        Game.render() line: 115 
        Game.run() line: 58 
        Thread.run() line: not available    
    Thread [DestroyJavaVM] (Running)

Menu.render(Graphics)第35行的代码是g.drawString(),当我注释我用g.setFont(font)设置字体的行时,不会抛出NullPointer。我可以在没有调试模式的情况下工作,但我想解决这个问题......你不知道它能是什么吗?感谢。

0 个答案:

没有答案