Difference between revisions of "VMS IDE for Java (Kotlin, Scala)"

From VSI OpenVMS Wiki
Jump to: navigation, search
(Steps to run java project)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
'''Note: coming soon'''
 
  
== Steps to run java project ==
+
== Working on a Java, Kotlin or Scala project ==
  
# Change project settings: '''project type''' (java, scala or kotlin), '''project name''', '''root folder''', '''source''', '''headers''', '''resource''' and '''listing''' masks
+
=== Prerequirements ===
 +
 
 +
* Java (Scala, Kotlin) must be installed on VMS host
 +
* Add '''set process/parse_style=extended''' to your LOGIN.COM
 +
 
 +
=== Creating and building a project ===
 +
The general development process includes the following steps:
 +
# Change project settings:  
 +
#* '''project type''' - specify ''java'', ''scala'' or ''kotlin''
 +
#* '''project name'''
 +
#* '''root folder'''
 +
#* '''source''', '''headers''', '''resource''', and '''listing''' masks
 
# Write code
 
# Write code
 
# Create MMS
 
# Create MMS
# Upload
+
# Upload source files
# Build
+
# Build the project
# Collect Java classes
+
# Collect Java classes. This step is required for debugging.
# Run
+
# Run the project
  
== Abilities ==
+
=== Restrictions ===
 +
Because the project target is compiled by one command for all source files, do not mix Kotlin, Scala, and Java source files in one project.
  
* Java, Scala or Kotlin project can depend on other Java, Scala or Kotlin projects.
+
=== Abilities ===
 +
A Java, Scala or Kotlin project may depend on other Java, Scala or Kotlin projects.
  
 
== Debugging ==
 
== Debugging ==
  
In order to use breakpoints one should execute '''Collect Java classes''' before debugging if project is changed and built.
+
=== Before starting debug ===
 +
To be able to use breakpoints during debugging, run '''Collect Java classes''' after editing and building the project.
 +
 
 +
=== Running VMS JVM Debugger ===
 +
<ol>
 +
<li> To start Debugger, press <code>F5</code>. If no debug configuration is selected, the ''Select environment'' dropdown will be shown.<br> [[File:Jvm-dbg-select.png|dbg-select]]</li>
 +
<li> Choose '''VMS JVM Debugger'''. If all java classes are collected successfully, the ''entry class'' QuickPick popup will be shown.<br> [[File:Jvm-dbg-select-main.png|select-main]]</li>
 +
<li> Select one and debugging will start. </li>
 +
</ol>
 +
 
 +
=== Creating Debug Configurations ===
 +
You can configure 'launch.json' to start predefined debug configuration. To do this,
 +
<ol>
 +
<li> Click 'Configure or Fix...' button on the DEBUG panel.<br>
 +
[[File:Jvm-dbg-configure-or-fix.png|dbg-configure-or-fix]]<br></li>
 +
<li> The next step depends on whether the '''launch.json''' file exists or not:
 +
<ul>
 +
<li> If there is no '''launch.json''' file, the '''Select environment''' dropdown is displayed. Choose '''VMS JVM Debugger'''.</li>
 +
<li> If the '''launch.json''' file exist, click '''Add Configuration''' button in the bottom-right corner of the VS Code and select '''VMS IDE: Launch JVM'''.</li>
 +
</ul>
 +
<li> Edit the ''launch.json'' file
 +
<pre>
 +
{
 +
  "type": "vms jvm debugger",
 +
  "request": "launch",
 +
  "name": "Launch JVM",
 +
  "classpath": "${command:FillClassPath}",
 +
  "class": "${command:FillClassName}",
 +
  "port": "5005-5105",
 +
  "arguments": "",
 +
  "stopOnEntry": true
 +
}
 +
</pre>
 +
* Do not change '''type''' and '''request'''
 +
* Specify the '''name'''
 +
* Set the class path - ''A colon-separated list of directories, JAR archives, and ZIP archives where to search for class files in''. In case of "${command:FillClassPath}" class path will be taken from project settings.
 +
* Enter full class name with the static '''main''' method. In case of "${command:FillClassName}" the 'select executable class' QuickPick will be displayed when debugging is started.
 +
* '''port''' is range of ports for JDB.
 +
* '''arguments''' is a string with arguments passed to the program.
 +
* '''stopOnEntry''' indicates whether do stop or not on the program entry.
 +
</li>
 +
</ol>
 +
 
 +
=== Breakpoints ===
 +
Breakpoints are shown grayed until the corresponding class is loaded into memory. Also, they are grayed if no Java class information collected.
 +
 
 +
==== Function breakpoints ====
 +
To add a function breakpoint:
 +
# Click '+' in the Breakpoints view.
 +
# Enter the function name using ''<full_class_path>.<method>(<arg_type1>, <arg_type2>...)'' format. You can omit any part of the function name. QuickPick popup with available functions will appear. Then select the required one.
 +
# If no dialog appears, click '''Activate Breakpoints'''.
 +
 
 +
==== Data breakpoints ====
 +
There is no specific UI for data breakpoints.
 +
 
 +
To create a data breakpoint, type '''watch all <class>.<field>''' in the debugging console input while the program is paused.
 +
To remove data breakpoints, type '''unwatch all <class>.<field>'''.
  
Breakpoints are shown grayed until corresponding class is loaded into memory. Also they are grayed if no java class information collected.
+
'''Note:''' This feature does not catch the changing of particular variables. It catches all changes to the <field> of all instances of <class>. Also, it does not work for local variables.
  
String variable is displayed 'as is', without escaping. Char variable is escaped if its value is less than 0x20 or greater than 0x7f.
+
=== Displaying/Setting variables ===
 +
A string variable is displayed ''as is'', without escaping.<br>
 +
Char variable is escaped if its value is less than 0x20 or greater than 0x7f.<br>
 +
To set the value of a string or char variable, you can write an escaped string (using Java rules). Enclosing quotes are not required.
  
To set the value of a string or char variable, you can write an escaped string (in java rules).
+
=== Debugging console ===
 +
When a program is running, anything that you type to the debugging console is sent to the program.
 +
When a program is paused, anything that you type to the debugging console is sent to the debugger.  
  
If the program is running, everything written in the input debugging console will be sent to the program.
+
Note this to avoid issues with breaking the debugger. For example, 'eval a=100' will change the value of variable ''a'' and this will not be caught by the extension.
If the program is paused, everything written in the input debugging console will be sent to the debugger. So be careful not to break the debugger. For example 'eval a=100' will change the value of variable and this won't be caught by extension.
 
  
 
[[Category: VMS IDE]]
 
[[Category: VMS IDE]]

Latest revision as of 08:02, 11 September 2019


Working on a Java, Kotlin or Scala project

Prerequirements

  • Java (Scala, Kotlin) must be installed on VMS host
  • Add set process/parse_style=extended to your LOGIN.COM

Creating and building a project

The general development process includes the following steps:

  1. Change project settings:
    • project type - specify java, scala or kotlin
    • project name
    • root folder
    • source, headers, resource, and listing masks
  2. Write code
  3. Create MMS
  4. Upload source files
  5. Build the project
  6. Collect Java classes. This step is required for debugging.
  7. Run the project

Restrictions

Because the project target is compiled by one command for all source files, do not mix Kotlin, Scala, and Java source files in one project.

Abilities

A Java, Scala or Kotlin project may depend on other Java, Scala or Kotlin projects.

Debugging

Before starting debug

To be able to use breakpoints during debugging, run Collect Java classes after editing and building the project.

Running VMS JVM Debugger

  1. To start Debugger, press F5. If no debug configuration is selected, the Select environment dropdown will be shown.
    dbg-select
  2. Choose VMS JVM Debugger. If all java classes are collected successfully, the entry class QuickPick popup will be shown.
    select-main
  3. Select one and debugging will start.

Creating Debug Configurations

You can configure 'launch.json' to start predefined debug configuration. To do this,

  1. Click 'Configure or Fix...' button on the DEBUG panel.
    dbg-configure-or-fix
  2. The next step depends on whether the launch.json file exists or not:
    • If there is no launch.json file, the Select environment dropdown is displayed. Choose VMS JVM Debugger.
    • If the launch.json file exist, click Add Configuration button in the bottom-right corner of the VS Code and select VMS IDE: Launch JVM.
  3. Edit the launch.json file
    {
      "type": "vms jvm debugger",
      "request": "launch",
      "name": "Launch JVM",
      "classpath": "${command:FillClassPath}",
      "class": "${command:FillClassName}",
      "port": "5005-5105",
      "arguments": "",
      "stopOnEntry": true
    }
    
    • Do not change type and request
    • Specify the name
    • Set the class path - A colon-separated list of directories, JAR archives, and ZIP archives where to search for class files in. In case of "${command:FillClassPath}" class path will be taken from project settings.
    • Enter full class name with the static main method. In case of "${command:FillClassName}" the 'select executable class' QuickPick will be displayed when debugging is started.
    • port is range of ports for JDB.
    • arguments is a string with arguments passed to the program.
    • stopOnEntry indicates whether do stop or not on the program entry.

Breakpoints

Breakpoints are shown grayed until the corresponding class is loaded into memory. Also, they are grayed if no Java class information collected.

Function breakpoints

To add a function breakpoint:

  1. Click '+' in the Breakpoints view.
  2. Enter the function name using <full_class_path>.<method>(<arg_type1>, <arg_type2>...) format. You can omit any part of the function name. QuickPick popup with available functions will appear. Then select the required one.
  3. If no dialog appears, click Activate Breakpoints.

Data breakpoints

There is no specific UI for data breakpoints.

To create a data breakpoint, type watch all <class>.<field> in the debugging console input while the program is paused. To remove data breakpoints, type unwatch all <class>.<field>.

Note: This feature does not catch the changing of particular variables. It catches all changes to the <field> of all instances of <class>. Also, it does not work for local variables.

Displaying/Setting variables

A string variable is displayed as is, without escaping.
Char variable is escaped if its value is less than 0x20 or greater than 0x7f.
To set the value of a string or char variable, you can write an escaped string (using Java rules). Enclosing quotes are not required.

Debugging console

When a program is running, anything that you type to the debugging console is sent to the program. When a program is paused, anything that you type to the debugging console is sent to the debugger.

Note this to avoid issues with breaking the debugger. For example, 'eval a=100' will change the value of variable a and this will not be caught by the extension.