Compiling with line numbers

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

Moderators: roger, gloomyandy, skoehler

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(WheelExplorer.java:40)
   at tiggerhome.ev3.robots.WheelExplorer.<init>(WheelExplorer.java:21)
   at tiggerhome.ev3.robots.Launch.main(Launch.java:6)


=> Ah, my problem was in WheelExplorer.java 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"/>
        </javac>
    </target>


Next build the java compiler will add debug information to JAR which help you both in remote debugging and in analyzing your stack traces.
tigger
New User
 
Posts: 17
Joined: Mon Feb 10, 2014 10:04 pm

Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff