Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   We got Sockets working (http://www.chiefdelphi.com/forums/showthread.php?t=100675)

ProgrammerMatt 02-02-2012 17:33

Re: We got Sockets working
 
This is more for derek but when i send data to my robot using this code http://pastebin.com/x2KZepNR that i made i get a thread error and null pointer any ideas?
here is error

Code:

[cRIO] Default disabled() method running, consider providing your own
[cRIO] Uncaught exception in Thread.run():
[cRIO]    on thread Thread-6
[cRIO] java.lang.NullPointerException
[cRIO]    at edu.wpi.first.wpilibj.templates.Socket.run(Socket.java:40)
[cRIO]    in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO]    in static method #3 of com.sun.squawk.VM(bci=6)


derekwhite 03-02-2012 09:38

Re: We got Sockets working
 
That stack trace suggests that the variable "you" is null at line 40. But it looks like that would only happen if acceptAndOpen() throw an exception, and no exception was printed in the output you showed.

An aside about NullPointerExceptions - for how common these are, they can really only be created by:
  • Trying to get or set a field using an object reference that is null:
    thisIsNull.field = 1;
  • Trying to get or set an array element using an object reference that is null:
    thisIsNull[0] = 1;
  • Trying to get the array length using an object reference that is null:
    thisIsNull.length;
  • Trying to call a non-static method on an object reference that is null:
    thisIsNull.toString();
  • Trying to synchronize an object reference that is null:
    synchronize(thisIsNull) ...
  • Throwing a NullPointerException! This is not too common, but some likely cases are:
    System.arraycopy(), Hashtable.contains().
    In Java SE (not on robot), native methods may throw a NullPointerException. It depends on the method.

For now I suggest adding code that explicitly checks for "you" being null or not.

I hope this helps track down the bug.

ProgrammerMatt 03-02-2012 09:51

Re: We got Sockets working
 
Ok i did figure it out and i can recive data but i see a bunch of exceptions being thrown even know i can send and recive data. any idea why?


All times are GMT -5. The time now is 13:02.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi