Go to Post "Simple" is about staying within boundaries. - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 02-02-2012, 17:33
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
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)

Last edited by ProgrammerMatt : 02-02-2012 at 17:46.
Reply With Quote
  #17   Spotlight this post!  
Unread 03-02-2012, 09:38
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
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.
Reply With Quote
  #18   Spotlight this post!  
Unread 03-02-2012, 09:51
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
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?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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