• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interpreting a Stack Trace  RSS feed

 
Bob Matthews
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone give me some clues on how to understand the following..........................

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to know what an exception means, you can look it up in the API documentation. The documentation of IndexOutOfBoundsException says:
API documentation wrote:Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range.

If you look carefully at the message, it says: "Index: 2 Size: 2". This means that you have an array with two elements, and you are trying to access the third element (note that array indices are zero-based, so index number 2 is the third element!).

The stack trace lists the sequence of method calls that happened up to the point where the exception happened. You can read it from the bottom up. Starting at line 20, we see:

the method 'run' in the class 'com.dukascopy.dds2.greed.actions.c' at line 48 called the method 'GF' in class 'com.dukascopy.dds2.greed.actions.servicesources.StrategyTesterAction' (that's the line above)
then, the method 'GF' in the class 'com.dukascopy.dds2.greed.actions.servicesources.StrategyTesterAction' at line 352 called the method 'HI' of the same class
then the method 'HI' called the method 'a' of class 'com.dukascopy.dds2.greed.agent.strategy.tester.b' at line 1168
etc.

This allows you to find out where exactly in your source code the error occurred.


 
Giovanni Montano
Ranch Hand
Posts: 422
7
Android Open BSD Slackware
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jesper indicated is an IndexOutOfBoundsException.
When you start with java usually the first rows are quite important. In a particular way identifying the kind of error, exception.

of course experienced coders that know what is going on under the hood are able to understand all the messages, threads that can be extremely powerful in certain cases

In android java usually is the same, also if is important to identify the class and line that is part of your project( ex. MainActivity (usually you click on it, some ide make it with a different color)
in Spring instead I found always really important to go trough all the error message.

Is definetely not precise my reply, but is a good rule of thumb to follow when you start to code and are overwhelmed by messages, another important tool are the breakpoints in the debug system( see in the internet), and log messages
usually of some variables, usually System.out.println("variable A"+variableA);

The next step is called junit test, and then there is much more, because is almost a world apart
 
Bill foster
Ranch Hand
Posts: 63
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you can use the debugger as well and see where the program does before it errors.
I use it all of time, here's the section on exceptions: exceptions


take care,

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!