When something goes wrong with your application, you need some debugging.
TeaVM supports two ways of debugging your applications: generate
or use IDEA debugger for TeaVM.
Of course, both of them require
class files to contain debug information.
Generating source maps
The preferred way of building TeaVM is to build it by Maven.
Generating source maps in this case is straightforward: in the
sourceMapsGenerated property to
Also, you will need your source files to be included in your web application.
If you don’t want to copy the source files manually, you can also set the
See the following snippet:
<project> ... <build> <plugins> <plugin> <groupId>org.teavm</groupId> <artifactId>teavm-maven-plugin</artifactId> <version>0.5.1</version> <executions> <execution> ... <configuration> ... <sourceMapsGenerated>true</sourceMapsGenerated> <sourceFilesCopied>true</sourceFilesCopied> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>
These two properties are set by default if you generate the project by the
Note that IDEA builder automatically configured from Maven, so if you have configured Maven plugin to generate source maps, IDEA builder will generate them as well.
Using IDEA debugger
TeaVM has its own built-in debugger.
You should enable generation of this file in your Maven configuration.
Simply set the
debugInformationGenerated property to
true, as in the following snippet:
<project> ... <build> <plugins> <plugin> <groupId>org.teavm</groupId> <artifactId>teavm-maven-plugin</artifactId> <version>0.5.1</version> <executions> <execution> ... <configuration> ... <debugInformationGenerated>true</debugInformationGenerated> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>
To debug TeaVM application, you should first install TeaVM debug agent for Google Chrome.
To start debug session, you need to launch a TeaVM debug configuration. In menu, select Run -> Edit configurations…. Click on the plus button and pick TeaVM debug server, a new launch configuration should appear. Close configuration window by pressing OK and start a new debug session.
Now you should connect Google Chrome to TeaVM debug server. Open your application in Google Chrome and press the TeaVM debugger agent button beside the address bar (the green teapot icon). Put breakpoints on your Java code and when they hit, you can see the execution state of your code and issue debug commands.