Compiling with line numbers

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

New User
Posts: 17
Joined: Mon Feb 10, 2014 10:04 pm

Compiling with line numbers

Postby tigger » Mon Feb 17, 2014 9:10 pm

Normally, there is no need for line numbers in JAR files - the bytecode is more compact and faster (and not so easy to decompile) without these line numbers.

But to analyze stack traces line numbers will help:

Code: Select all

Exception in thread "main" java.lang.IllegalArgumentException: Invalid color specified
   at lejos.hardware.sensor.EV3ColorSensor.setFloodlight(Unknown Source)
   at lejos.hardware.sensor.EV3ColorSensor.setFloodlight(Unknown Source)
   at tiggerhome.ev3.robots.WheelExplorer.initBot(
   at tiggerhome.ev3.robots.WheelExplorer.<init>(
   at tiggerhome.ev3.robots.Launch.main(

=> Ah, my problem was in line 40.

As see the ev3classes doesn't have any line numbers so you have to guess where the problem root is hidden.

And to use remote debugging (described in "debug program") it is necessary to include the line numbers into your source.

Fortunately, all you have to do is to add the attribute debug="true" to your JAVAC task in ant:

Code: Select all

   <target name="compile" description="build class files" depends="clean">
        <mkdir dir="${class.dir}"/>
        <javac srcdir="${source.dir}" destdir="${class.dir}" debug="true">
            <classpath refid="libraries.path"/>

Next build the java compiler will add debug information to JAR which help you both in remote debugging and in analyzing your stack traces.

Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 4 guests