Debugging a JavaFX program
| Document Status | Permanently Updated. | Top-level document | JavaFXPlugin |
Introduction
This document is intended to collect and track ideas about the Debugger Feature of the JavaFX Plugin for the NetBeans IDE. It will be used as a source for the Debugger Feature Specification. It is also used for refining the Debugger Feature Requirements.
Note: The Java SE platform, version 5.0 MUST BE used as a lowest demonstrator for the Debugger feature of the JavaFX Plugin.
Debugging process
Debugging is a part of the the software development process.
Debugging may be performed after some
Quality Assurance (QA) activity that showed a negative result. Also, the Debugging process may be initiated by the developer. In this case, the developer will use own expectations instead of the formal requirements.
Context of the Debugging process
- application under debug that has runnable status. The application may be compiled with the debug info. In case the interpretable language (script language) is used to describe a program, the interpreter should be used in a role of the application.
- DCP - Debug Configuration Profile
- an informational profile that is used to configure the application before starting it in the debug mode.
- all sources of the application that have been used in building the application. It can be optional if disassembling is supported.
- Sources of libraries (optional)
- Sources of libraries that are used in the Application
- a program that is used to run the Application
- data that is used as the input data for the Application
Outputs
- Source Model View in debug mode
- integrates info about sources.
- Execution (Control Flow) Model View
- integrates info about execution mode and control flow, i.e. displays traces of program execution.
- shows info about custom breakpoints.
- shows info about debugging sessions (i.e native processes under debug) and the threads in the scopes of these sessions.
- integrates info about data flow and data evaluation
- integrates info about a business target of the application under debugging
Mechanisms
- A debugger (tool/application/software system/software&hardware system)
- Test framework (optional)
Java SE Debugging
The Java technology offers two interaction levels with a target VM on the Java SE platform: Native level and Java level.
Resources:
Native level
We need take into account:
- JVM TI may not be available in all implementations of the Java(tm) virtual machine.
- JVM TI was introduced in J2SE 5.0 and replaced JVMDI and JVMPI.
- JVMDI was removed in Java SE 6 and JVMPI will be removed in Java SE 7.
Resources:
Java level
- Java(tm) Debug Interface (JDI) is a high level Java API providing information useful for debuggers and similiar systems needing access to the running state of a (usually remote) virtual machine.
Resources:
JVM Implementation
TODO There are Java Virtual Machines with the different feature sets. See com.sun.jdi.VirtualMachine.canXXX() methods.
Java SE Debugging in the NetBeans IDE
Modules:
- debuggercore Debugger Core - Debugger APIs, UI and infrastructure
- debuggerjpda JPDA Debugger Implementation Plug-In
- debuggertools [obsolete] JDK1.1 (sun.tools.debug.*) Debugger Impl. Plug-In
Resources:
Java ME Debugging in the NetBeans IDE
Resources:
JavaFX Debugging vs. Java SE Debugging
Resources:
Subjects of debugging
In both cases (Java and JavaFX), a JVM is the native application under debug.
There are the following subjects of debugging on the Java level:
| Subject | Java | JavaFX |
| Set of the related Java classes | * pure Java app/lib | * pure JavaFX app and JavaFX+Java lib * stand-alone JavaFX script |
| Stand-alone Java class | * Main class, * Any class + Main test class/framework | XXXXXX |
TODO Applet
Entry points
| Java | JavaFX |
| The public static void main(String [] args) method in the public class | A first executable moduleItem in the JavaFX script, i.e. either statement or expression. See the ANTLR grammar of the JavaFX language. |
TODO Applet
Script Context
The Script Context is established by the JSR 223: Scripting for the JavaTM Platform API as the interface javax.script.ScriptContext. According to the specification each script has own context. Script context provides accessibility of entities from inside of the script, including:
- Set of Attributes. Attribute is the named Java object, whose name is String.
- Set of Bindings. Bindings is the mapping of key/value pairs, all of whose keys are Strings, i.e it is a set of the named Java objects.
- Error Writer - a Writer used to display error output.
- Reader - a Reader to be used by the script to read input.
- Writer - a Writer for scripts to use when displaying output.
Both Attributes and Bindings are associated with a scope. Each scope is identified by the int value. There are two predefined scopes ENGINE_SCOPE (int value = 100) and GLOBAL_SCOPE (int value = 200). There are no way to find symbolic names for other user-defined scopes.
There are predefined names that are defined as Java language String constants in the interface javax.script.ScriptEngine:
| Java Constant Name | Java Constant Value | Comments |
| ARGV | "javax.script.argv" | an array of positional arguments that are passed to a script. |
| ENGINE | "javax.script.engine" | the name of the ScriptEngine implementation. |
| ENGINE_VERSION | "javax.script.engine_version" | the version of the ScriptEngine implementation. |
| FILENAME | "javax.script.filename" | the name of the file being executed. |
| LANGUAGE | "javax.script.language" | the full name of Scripting Language supported by the implementation. |
| LANGUAGE_VERSION | "javax.script.language_version" | the version of the scripting language supported by the implementation. |
| NAME | "javax.script.name" | the short name of the scripting language. The name is used by the ScriptEngineManager to locate a ScriptEngine with a given name in the getEngineByName method. |
Also, there are pseudo-variables generated by the JavaFX Script compiler:
| JavaFX Constant Name | Comments |
| __DIR__ | A URL of the directory where the JavaFX module .class file is placed. This value is based on the value of the __FILE__ pseudo-variable. The expression new java.net.URL(__FILE__, ".") is used to calculate that value (See specification of the constructor URL(URL context, String spec)). |
| __FILE__ | A URL of the JavaFX module .class file. |
| __ARGS__ | A sequence of positional arguments that are passed to a script. Note, elements of the sequence are the same as elements of the array ARGV that is mentioned in the previous table. |
JSR 45
Whether the JSR 45: Debugging Support for Other Languages has any relations or impacts on the JavaFX debugging?
JavaFX Script Language and JavaFX Programs
Resources:
Debugging a program written on a object-oriented language
Debugging a program written on a declarative language
Debugging human interfaces of the JavaFX Programs
Debugging a GUI
- View of the GUI Components. The view lets to investigate hierarchical trees of the GUI components, including their properties and relations.
- Event log.
- User action recorder.
- User action generator. Should be possible to synchronize the generator with the GUI preview.
Debugging an Audio UI
Debugging a Voice UI
Resources:
Voice User Interface (VUI)
Java ME
Java TV
Debugging Complex Strings
Debugging Triggers
Debugging Binding
Debugging a Program with Loadable Recourses
TODO TRANSLATION_KEY, I18N artifacts
Debugging Threads
Debugging Remote Application
Debugging Distributed Application
Proposing Solutions