2

So I have a problem, where if I just click a key in the frame with no components, it gives me an error. I tried with no components, but this error keeps on coming up, even with no components. Even if I tried another one fresh, this error still happens. Its always when I click a key, in the frame.

2014-07-31 14:13:28.281 java[52432:507] An uncaught exception was raised
2014-07-31 14:13:28.282 java[52432:507] java.lang.NullPointerException
2014-07-31 14:13:28.284 java[52432:507] (
    0   CoreFoundation                      0x00007fff8a62e25c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8baf3e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8a62de09 -[NSException raise] + 9
    3   JavaNativeFoundation                0x000000010ed0a457 JNFCallObjectMethod + 212
    4   liblwawt.dylib                      0x000000010f53b913 -[AWTView attributedSubstringForProposedRange:actualRange:] + 78
    5   AppKit                              0x00007fff8ad6c75d -[NSTextInputContext handleTSMEvent:] + 3476
    6   AppKit                              0x00007fff8ad6b9a5 _NSTSMEventHandler + 205
    7   HIToolbox                           0x00007fff88da81d4 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 892
    8   HIToolbox                           0x00007fff88da7787 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 385
    9   HIToolbox                           0x00007fff88dbb880 SendEventToEventTarget + 40
    10  HIToolbox                           0x00007fff88dfcd0d SendTSMEvent + 33
    11  HIToolbox                           0x00007fff88faa5ff SendTextInputEvent + 1028
    12  HIToolbox                           0x00007fff88ff589c -[IMKInputSession _copyUniCharsForRange:intoBuffer:ofLength:] + 268
    13  HIToolbox                           0x00007fff88ff596b -[IMKInputSession _coreAttributesFromRange:whichAttributes:actualRange:] + 137
    14  HIToolbox                           0x00007fff88ff6a5c -[IMKInputSession attributedSubstringFromRange:] + 89
    15  CoreFoundation                      0x00007fff8a519bec __invoking___ + 140
    16  CoreFoundation                      0x00007fff8a519a54 -[NSInvocation invoke] + 308
    17  CoreFoundation                      0x00007fff8a5bc5e6 -[NSInvocation invokeWithTarget:] + 54
    18  CoreFoundation                      0x00007fff8a58c1c4 ___forwarding___ + 452
    19  CoreFoundation                      0x00007fff8a58bf78 _CF_forwarding_prep_0 + 120
    20  CoreFoundation                      0x00007fff8a519bec __invoking___ + 140
    21  CoreFoundation                      0x00007fff8a519a54 -[NSInvocation invoke] + 308
    22  Foundation                          0x00007fff88310d47 -[NSConnection dispatchInvocation:] + 135
    23  Foundation                          0x00007fff88310a0d -[NSConnection handleRequest:sequence:] + 1434
    24  Foundation                          0x00007fff882b7d50 -[NSConnection handlePortCoder:] + 652
    25  Foundation                          0x00007fff882b7688 -[NSConnection dispatchWithComponents:] + 50
    26  Foundation                          0x00007fff8829bf38 __NSFireMachPort + 257
    27  CoreFoundation                      0x00007fff8a55fb44 __CFMachPortPerform + 388
    28  CoreFoundation                      0x00007fff8a55f9a9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
    29  CoreFoundation                      0x00007fff8a55f91e __CFRunLoopDoSource1 + 478
    30  CoreFoundation                      0x00007fff8a550a16 __CFRunLoopRun + 1830
    31  CoreFoundation                      0x00007fff8a5500b5 CFRunLoopRunSpecific + 309
    32  Foundation                          0x00007fff882b406e -[NSConnection sendInvocation:internal:] + 1965
    33  CoreFoundation                      0x00007fff8a58c1c4 ___forwarding___ + 452
    34  CoreFoundation                      0x00007fff8a58bf78 _CF_forwarding_prep_0 + 120
    35  HIToolbox                           0x00007fff88ff1b3d -[IMKInputSession handleEvent:] + 946
    36  HIToolbox                           0x00007fff88fb51d8 IMKInputSessionProcessEventRef + 45
    37  HIToolbox                           0x00007fff88fb4792 InputMethodInstanceProcessEventRef + 100
    38  HIToolbox                           0x00007fff88fa9d4f TSMEventToInputMethod + 131
    39  HIToolbox                           0x00007fff88dfc4a0 TSMKeyEvent + 301
    40  HIToolbox                           0x00007fff88de92b7 TSMProcessRawKeyEvent + 3807
    41  AppKit                              0x00007fff8ad6b1f0 -[NSTextInputContext handleEvent:] + 731
    42  AppKit                              0x00007fff8ad4aabd -[NSView interpretKeyEvents:] + 180
    43  liblwawt.dylib                      0x000000010f53a880 -[AWTView keyDown:] + 85
    44  AppKit                              0x00007fff8ad1765b -[NSWindow sendEvent:] + 1843
    45  liblwawt.dylib                      0x000000010f53e2f5 -[AWTWindow_Normal sendEvent:] + 86
    46  AppKit                              0x00007fff8acb8c42 -[NSApplication sendEvent:] + 3395
    47  libosxapp.dylib                     0x000000010f5d666f -[NSApplicationAWT sendEvent:] + 179
    48  AppKit                              0x00007fff8ab08b89 -[NSApplication run] + 646
    49  libosxapp.dylib                     0x000000010f5d6557 +[NSApplicationAWT runAWTLoopWithApp:] + 156
    50  liblwawt.dylib                      0x000000010f52eba9 -[AWTStarter starter:] + 873
    51  Foundation                          0x00007fff8829513e __NSThreadPerformPerform + 229
    52  CoreFoundation                      0x00007fff8a55f731 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    53  CoreFoundation                      0x00007fff8a550ea2 __CFRunLoopDoSources0 + 242
    54  CoreFoundation                      0x00007fff8a55062f __CFRunLoopRun + 831
    55  CoreFoundation                      0x00007fff8a5500b5 CFRunLoopRunSpecific + 309
    56  java                                0x00000001065313b0 CreateExecutionEnvironment + 871
    57  java                                0x000000010652bb5c JLI_Launch + 1952
    58  java                                0x000000010653170d main + 101
    59  java                                0x000000010652b3b4 start + 52
    60  ???                                 0x0000000000000005 0x0 + 5
)

Code:

    public class TestGame extends JFrame{

       public static void main(String[] args){
          new TestGame();
       }

       public TestGame(){
           this.setSize(1024, 768);
           this.setLocationRelativeTo(null);
           this.setResizable(true);
           this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           this.setVisible(true);
        }
   }
BlazingBroGamer
  • 51
  • 1
  • 1
  • 3
  • 2
    Can you show code the relevant code please? – Jens Jul 31 '14 at 06:24
  • 1
    Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – DavidPostill Jul 31 '14 at 06:26
  • There are MANY topics on what a `NullPointerException` is and how to fix it. It's one of the most common errors in Java, and it happens for the same reason every time: you get it when you try to call a method/variable from a reference variable that isn't initialized (it == null). http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it – Vince Jul 31 '14 at 06:47
  • 3
    Interesting output. Which Java/OS are you on? The code should launch up w/o any errors with an empty window. – rlegendi Jul 31 '14 at 06:54
  • Something is perhaps odd with your environment (installation of JRE with your OS). When you launch the app try running with the JRE command option -verbose. – javajon Jul 31 '14 at 08:16
  • I have the same problem! (and still don't have any solution yet). I am using OSX 10.9.4 and JDK version 1.7. I ignore it for a moment because it have no effect to my program, but still, looks annoying on my console. – giripp Sep 08 '14 at 03:43

3 Answers3

0

I don't get this on Windows 8 with either Java 7 or 8.

Perhaps launch it the recommended way:

public class TestGame {
    public void launch() {
        JFrame frame = new JFrame();

        frame.setSize(1024, 768);
        frame.setLocationRelativeTo(null);
        frame.setResizable(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new TestGame().launch();
            }
        });
    }
}
javajon
  • 1,660
  • 16
  • 18
0

I experienced the same and wait for the answer on this question for a long time. This error occured when I used Eclipse on OS X 10.9. I've upgraded my OS X to 10.10 and the error is gone!

giripp
  • 285
  • 1
  • 4
  • 13
0

This seems to be a bug on mac os java.

I'm suffering at the same error on netbeans. Everything was fine on 10.9 but it just went wrong after I updated 10.10, which is opposite with @giripp 's anwser.

https://bugs.openjdk.java.net/browse/JDK-8039925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

steven
  • 1,237
  • 2
  • 11
  • 13