Exceptions and their interpretation

Werbung
Exceptions and their interpretation
LeJOS supports most of the standard Java language exception classes, and users can
also create their own exception classes.
If a program throws an exception on the NXT, it is displayed on the LCD, since the NXT
brick does not have a console/ screen. Hereby the exceptions, depending on the program,
are assigned to specific error codes. Suppose our program ExArithmetic.java contains the
following code:
public class ExArithmetic
{
public static void main(String[] args)
{
int x = 1;
int y = 0;
int z = x/y;
}
}
After uploading and starting this program, the LCD shows the following:
Java Exception:
Class:
10
Methode: 0
Every time the error codes are newly generated for every transfer of the program from
your computer to the NXT. In order to display these error codes while uploading, you have
to call nxj with the option verbose. This can be done either in the command line (nxj –-verbose
ExArithmeitic) or in Eclipse. For the latter go to Window -> Preferences -> leJOS NXJ and mark the
check-box Verbose.
Then a list of different Classes and Signatures will appear in the console. Class represents the
type of the thrown exception and Signature (it is displayed Methode on the LCD which is
equal to Signature) the method in which the exception has occurred.
Note that the list of Classes and Signatures can differ from program to program (amount of
listings and assignments) and therefore must be considered for examination of the error
message.
According to our example ExArithmetic.java there was thrown an ArithmeticException in the main
method:
C:\nxj –-verbose ExArithmetic
Linking...
Class 0: java/lang/Object
Class 1: java/lang/Thread
Class 2: java/lang/String
Class 3: java/lang/Throwable
Class 4: java/lang/Error
Class 5: java/lang/OutOfMemoryError
Class 6: java/lang/NoSuchMethodError
Class 7: java/lang/StackOverflowError
Class 8: java/lang/NullPointerException
Class 9: java/lang/ClassCastException
Class 10: java/lang/ArithmeticException
Class 11: java/lang/ArrayIndexOutOfBoundsException
Class 12: java/lang/IllegalArgumentException
Class 13: java/lang/InterruptedException
Class 14: java/lang/IllegalStateException
Class 15: java/lang/IllegalMonitorStateException
Class 16: java/lang/ThreadDeath
Class 17: ExArithmetic
Class 18: java/lang/System
Class 19: java/lang/StringIndexOutOfBoundsException
Class 20: java/lang/RuntimeException
Class 21: java/lang/Exception
Class 22: java/lang/Runtime
Class 23: java/io/PrintStream
Class 24: lejos/nxt/LCDOutputStream
Class 25: java/io/OutputStream
Class 26: java/io/IOException
Class 27: lejos/nxt/LCD
Signature 0: main([Ljava/lang/String;)V
Signature 1: run()V
Signature 2: <init>()V
Signature 3: <clinit>()V
Signature 4: notify()V
Signature 5: notifyAll()V
Signature 6: wait()V
Signature 7: wait(J)V
Signature 8: start()V
Signature 9: yield()V
Signature 10: sleep(J)V
Signature 11: currentThread()Ljava/lang/Thread;
Signature 12: getPriority()I
Signature 13: setPriority(I)V
Signature 14: interrupt()V
Signature 15: interrupted()Z
Signature 16: isInterrupted()Z
Signature 17: setDaemon(Z)V
Signature 18: isDaemon()Z
Signature 19: join()V
Signature 20: join(J)V
Signature 21: currentTimeMillis()J
Signature 22: exit(I)V
Signature 23: freeMemory()J
Signature 24: totalMemory()J
Signature 25: getMessage()Ljava/lang/String;
Signature 26: readSensorValue(I)I
Signature 27: setADTypeById(II)V
Signature 28: setPowerTypeById(II)V
Signature 29: setPoller()V
Signature 30: setThrottle(I)V
Signature 31: test(Ljava/lang/String;Z)V
Signature 32: testEQ(Ljava/lang/String;II)V
Signature 33: floatToIntBits(F)I
Signature 34: intBitsToFloat(I)F
Signature 35: drawString(Ljava/lang/String;II)V
Signature 36: drawInt(III)V
Signature 37: drawInt(IIII)V
Signature 38: refresh()V
Signature 39: clear()V
Signature 40: setDisplay([I)V
Signature 41: getVoltageMilliVolt()I
Signature 42: readButtons()I
Signature 43: getTachoCountById(I)I
Signature 44: controlMotorById(III)V
Signature 45: resetTachoCountById(I)V
Signature 46: i2cEnableById(I)V
Signature 47: i2cBusyById(I)I
Signature 48: i2cStartById(IIII[BII)I
Signature 49: i2cDisableById(I)V
Signature 50: playTone(II)V
Signature 51: btSend([BI)V
Signature 52: btReceive([B)V
Signature 53: btGetBC4CmdMode()I
Signature 54: btSetArmCmdMode(I)V
Signature 55: btStartADConverter()V
Signature 56: usbRead([BI)I
Signature 57: usbWrite([BI)V
Signature 58: usbReset()V
Signature 59: writePage([BI)V
Signature 60: readPage([BI)V
Signature 61: exec(II)V
Signature 62: playSample(IIII)V
Signature 63: getDataAddress(Ljava/lang/Object;)I
Signature 64: gc()V
Signature 65: shutDown()V
Signature 66: btSetResetLow()V
Signature 67: btSetResetHigh()V
Signature 68: btWrite([BII)I
Signature 69: btRead([BII)I
Signature 70: btPending()I
Signature 71: arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
Signature 72: getDisplay()[I
Signature 73: setAutoRefresh(I)V
Signature 74: toString()Ljava/lang/String;
Signature 75: <init>(Ljava/lang/String;)V
Signature 76: <init>([CII)V
Signature 77: <init>([C)V
Signature 78: length()I
Signature 79: charAt(I)C
Signature 80: indexOf(II)I
Signature 81: indexOf(Ljava/lang/String;I)I
Signature 82: lastIndexOf(Ljava/lang/String;I)I
Signature 83: lastIndexOf([CII[CIII)I
Signature 84: indexOf([CII[CIII)I
Signature 85: toCharArray()[C
Signature 86: substring(II)Ljava/lang/String;
Signature 87: getRuntime()Ljava/lang/Runtime;
Signature 88: <init>(Ljava/io/OutputStream;)V
Signature 89: write(I)V
Signature 90: print(Ljava/lang/String;)V
Signature 91: flush()V
Signature 92: write([BII)V
Signature 93: bitBlt([BIIIIIIIII)V
Signature 94: bitBlt(IIIII)V
Signature 95: drawChar(CIIZ)V
Signature 96: drawChar(CIII)V
Signature 97: getDisplay()[B
Signature 98: getSystemFont()[B
Signature 99: bitBlt([BIIII[BIIIIIII)V
Signature 100: scroll()V
Master record : 16 bytes.
Class records : 28 (280 bytes).
Field records : 18 (18 bytes).
Method records: 73 (876 bytes).
Code
: 62 (1196 bytes).
Uploading...
Herunterladen