Platform Framework
R24 AMR | Min(s) read

TAFJ Compiler

tCompile is the main entry point for compiling a program. This is a script in the /bin directory. It executes the compiled Basic files.

Below is the tCompile syntax:

tCompile [-cf <confFile>] [-I <insertDir>] <program_path_and_name>

You must give the full path to the program you want to compile. If the directory is missing, then TAFJ tries to find the file in the current directory and if the directory is wrong, then TAFJ reports an error.

You should not use wild chars ('*'. '?') in the file name. However, if you use wild chars, then only the current directory will be used.

If the -I option is passed, then it overrides the value of the temn.tafj.directory.insert property.

The table below shows the compile commands and their actions.

Command Action

tCompile F.WRITE

Looks for F.WRITE in the current directory.

tCompile /home/user/T24.BP/F.WRITE

Looks for /home/user/GLOBUS.BP/F.WRITE and compile it.

tCompile /home/user/T24.BP

Compiles the contents of the T24.BP directory.

tCompile /home/user/T24.BP/F.*

Compiles only the file starting with F..

tCompile ../T24.BP

Compiles the entire relative directory.

File Exclusion from Compilation

When compiling a directory you can also exclude files from the compilation by using the reject option.

tCompile [-cf <confFile>] [-reject rejectPattern] <program_path_and_name>

Below are the reject commands and their actions.

Command Action

tCompile -reject */EB.* /home/user/T24.BP

Compiles the content of the T24.BP directory but not the files starting with EB.

tCompile -reject */SUB/* /home/user/T24.BP

Compiles the content of the T24.BP directory but not the subfolders called SUB.

tCompile -reject */SUB/EB.* /home/user/T24.BP

Compiles the contents of the T24.BP directory but not the files starting with EB contained in subfolder SUB.

tCompile -reject “*/SUB/*|*/SUB2/*” /home/user/T24.BP

Compiles the contents of the T24.BP directory but exclude subfolders SUB and SUB2.

You need to specify your reject pattern between double quotes when using multi-criteria pattern.

Sample Basic File Compilation

--------------------------------------------------------------------------------
Temenos TAFJ Compiler/RunnerTAFJCompiler.jar version "DEV_202304.0"
Copyright (c) 2009-2018 TEMENOS. All rights reserved
--------------------------------------------------------------------------------
Java Version = 11.0.16.1+1-LTS
Java File Encoding = UTF-8
Java Home = C:\Temenos\Development\3rdParty\jdk\java-11-openjdk-11.0.16.1.1-1
Java Classpath = OpenJDK Runtime Environment
--------------------------------------------------------------------------------
User Name = spsakthi
Current Dir = C:\T24_DEV
--------------------------------------------------------------------------------
OS Type = Windows 10
--------------------------------------------------------------------------------
TAFJ_HOME               = C:\T24_DEV\Temenos\TAFJ
Basic Source Dir.       =
Insert Source Dir.      =
Precompile Dir.         =
Java Destination Dir.   = C:\T24_DEV\Temenos\TAFJ\data/tafj/java
Classes Destination Dir.= C:\T24_DEV\Temenos\TAFJ\data/tafj/classes
Report Destination Dir. = C:\T24_DEV\Temenos\TAFJ\report
Max. Grammar Level      = 3
Min. Grammar Level      = 0
Java Package            = com.temenos.t24
Reporting               = false
--------------------------------------------------------------------------------
Arguments :C:\T24_DEV\Temenos\TAFJ\samples\basic\MAIN.PRG.b
--------------------------------------------------------------------------------

Compilation completed for 1 file(s).

================================================================================================================================================================

Multiple Basic File Compilation

The following command is used to compile multiple basic files.

tCompile FILE1 FILE2 FILE3 ...Up to...FILEN

--------------------------------------------------------------------------------
Temenos TAFJ Compiler/Runner
TAFJCompiler.jar version "DEV_202304.0 "
Copyright (c) 2009-2018 TEMENOS. All rights reserved
--------------------------------------------------------------------------------
Java Version = 11.0.16.1+1-LTS
Java File Encoding = UTF-8
Java Home = C:\Temenos\Development\3rdParty\jdk\java-11-openjdk-11.0.16.1.1-1
Java Classpath = OpenJDK Runtime Environment
--------------------------------------------------------------------------------
User Name = spsakthi
Current Dir = C:\T24_DEV
--------------------------------------------------------------------------------
OS Type = Windows 10
--------------------------------------------------------------------------------
TAFJ_HOME               = C:\T24_DEV\Temenos\TAFJ
Basic Source Dir.       =
Insert Source Dir.      =
Precompile Dir.         =
Java Destination Dir.   = C:\T24_DEV\Temenos\TAFJ\data/tafj/java
Classes Destination Dir.= C:\T24_DEV\Temenos\TAFJ\data/tafj/classes
Report Destination Dir. = C:\T24_DEV\Temenos\TAFJ\report
Max. Grammar Level      = 3
Min. Grammar Level      = 0
Java Package            = com.temenos.t24
Reporting               = false
--------------------------------------------------------------------------------
Arguments :C:\T24_DEV\Temenos\TAFJ\samples\basic\MAIN.PRG.b C:\T24_DEV\Temenos\TAFJ\samples\basic\TEST.SUB.b C:\T24_DEV\Temenos\TAFJ\samples\basic\TEST.SUB1.b
--------------------------------------------------------------------------------
Compilation completed for 3 file(s).
--------------------------------------------------------------------------------
Files With Error :
--------------------------------------------------------------------------------
Total Time       : 0 [h] 0 [min] 1 [sec] 812 [ms]
================================================================================

Compilation Workflow

When a tCompile command is executed, the BASIC file is analysed to define the grammar level and then the Java file is generated in memory.

If the option temn.tafj.compiler.generate.class is set to true (default), then the in-memory java file is compiled and placed in the directory specified by the temn.tafj.directory.classes property.

If the option temn.tafj.compiler.generate.java is set to true (default value is false) , then the in-memory java file is flushed on disk at the location specified by the temn.tafj.directory.java property.

The generated java classes extends the main class jRuntime. This class is part of TAFJcore, which contains the definitions of all the BASIC KEYWORDS like OPEN, OCONV, etc.

The Different Grammars

During the compilation, you will discover that there are different levels of grammars, depending on the BASIC file you are compiling. These grammars are different ways of translating the BASIC file to java depending on the quality of the BASIC CODE. Currently, you have two main grammars levels 2/3 and 0.

The grammar 2/3 implies that there are no GOTO, no ON … GOTO, no RETURN TO, and NO label in a branch statement. A branch statement is the block of code you will find between:

  • IF  … THEN  … ELSE … END
  • BEGIN CASE CASE … CASE … END CASE
  • FOR  … NEXT
  • LOOP … WHILE | UNTIL test  DO … REPEAT
The grammar 2/3 is the most optimized, and the generated Java is well formed and more maintainable by a java developer.

The grammar 0 is due to the presence of a label in a branch statement. For example, the branch statement below generates java in grammar 0 (sample from BATCH.JOB.CONTROL):

The LOCK.CONTROL.LIST label is in a branch statement. Thus, this program compiles in grammar 0. To correct it, you need to do the following:

LOOP
 	. . . 
LOOP
LOCK.CONTROL.LIST.AGAIN = 0 
          READU CONTROL.LIST FROM F.BATCH.STATUS, FLAG.ID LOCKED        ;* Get hold of the control list
              LOCK.CONTROL.LIST.AGAIN = 1
          END ELSE    ;* In case we are restarting - wait for lock!!!
		. . .
          END
WHILE LOCK.CONTROL.LIST.AGAIN = 1
REPEAT
    UNTIL CONTROL.LIST = PROCESSED      ;* Until everything has been done ; * BG_100003752 S/E
	. . .
    REPEAT
The solution shown is not absolute. There are many ways to remove labels from a branch statement.

jBC Source Name

In general, only A..Z, a..z , 0..9 and . are accepted in PROGRAM or SUBROUTINE names. Few exceptions such as $, % and ! are also accepted, but there are exceptions and if possible, should not be used.

- is not allowed.

Java Source Name

The name of the java class is defined by the Basic code (SUBROUTINE, PROGRAM and FUNCTION). If Basic code does not exist, then java class name is decided by the name of the Basic file.  Java does not support all the characters that BASIC allows. The conversion rules for the names (Program, Subroutine, Function, VAR, Label, equate and insert are:

Character Action

‘.’

Replaced by ’_’

‘%’

Replaced by ‘_p_’

‘$’

Replaced by ‘_d_’

‘ ’ (space)

Replaced by ‘_s_’

‘(’

Replaced by ‘_l_’

‘)’

Replaced by ‘_r_’

‘!’

Ignored.

  • The SLEEP.JBASE file (SUBROUTINE !SLEEP$) is converted in SLEEP_d_.java (SLEEP_d_.class).
  • BATCH.JOB.CONTROL is replaced by BATCH_JOB_CONTROL.
  • V$FUNCTION is replaced by V_d_FUNCTION.

Generation of Files

The compiler generates two types of files. The java files containing the java source code and the class files containing the bytecode that can be executed. You need to specify where the compiler has to generate these files.

The temn.tafj.directory.java key is used to specify the java source files path. This key is mandatory and you can set only one path.

The temn.tafj.directory.classes key is used to specify the classes files path. This key is mandatory and you can set only one path.

A special temn.tafj.directory.insert key specifies the location of INSERT file. The INSERT file can be in the basic source folder or in the inserts paths.

Usually a java code is part of a package. The compiler creates a same package for all the code compiles. You need to use the temn.tafj.package key to set the package.

Dependencies

There is no need to have all the SUBROUTINE to be able to compile the source required. For example,

PROGRAM A
    CALL B
END

You can tCompile A without having B. However, at runtime, if the class corresponding to B is not found, a runtime error will be raised. Also, the tShow tool is used to report any missing dependency.

$ . ./tShow A 
Home : '/home/user/tafj_dev/bin/..' 
 - Project : 'tafj'  [ FOUND ]              BASIC source : '/home/user/tafj_dev/bin/./A.b'             BASIC package : ''           BASIC Import(s) : 'com.temenos.t24'                JAVAclass: '/home/user/tafj_dev/data/tafj/classes/com/temenos/t24/A_cl.class'              Compiled the : 18 Apr 2017 12:35:45
                       on : LJRQKR32
       Compiled with TAFJ : DEV_201705.0                 Timestamp : 1492511745525                    Grammar : 3 Include Basic Replacement : false  Checking dependencies ...   [MISSING]           Missing dependency : 'B' (com.temenos.t24.B_cl.class) Check completed 

Precompiled Basic Files

The temn.tafj.directory.precompile key is used to specify the location of precompiled class files. You can specify multiple paths separated with a separator “:” or “;”.  These paths are overloaded by temn.tafj.directory.classes.

If you have a class TEST.SUB in temn.tafj.directory.precompile and compile a TEST.PRG call TEST.SUB. The TEST.PRG will call it. Now, if you generate a new TEST.SUB in temn.tafj.directory.classes, then TEST.PRG will not call TEST.SUB in temn.tafj.directory.precompile but call the TEST.SUB in temn.tafj.directory.classes. This path can be a folder or a JAR file. 

This does not apply when running in an application server.  In this case, the new class would have to be added to a JAR within the application server’s path.

Grammar Level

The grammar is automatically defined by the compiler.  You can force the maximum level and the minimum level of the grammar with the keys temn.tafj.compiler.grammar.maxlevel and temn.tafj.compiler.grammar.minlevel.

  • temn.tafj.compiler.grammar.minlevel - Fixes the minimum level of the grammar. If the compiler has to use a level smaller than the level you fix, then an error will be generated.
  • temn.tafj.compiler.grammar.maxlevel - Fixes the maximum level of the grammar. It has to be bigger or equal of the minimum level grammar.

Debugging

If you want to debug the basic process you have to compile with the option: temn.tafj.compiler.grammar.line.number = true

This option generates the java source code with lines numbers.

Warnings and Errors

Each error is automatically shown in the console (depends on the setting of the logger in TAFJTrace.properties). The compiler can log why a grammar level is downgraded with the key temn.tafj.compiler.grammar.warning.depreciation and if an equate is overridden with the key temn.tafj.compiler.grammar.warning.equate.

During the compilation of a Basic file, if a compilation error occurs, then a java file is created which will contain information of the executed call that should be printed on the screen.

In this case the compiler generates a Fake because error subroutine.

Program A

PROGRAM A
CALL B
END 

Subroutime B

SUBROUTINE B()
1  CRT "TOTO"
END


	Error : unexpected token: 1

When you run A the output will be:

> Error on the file B
Line :3 -> unexpected token: 1

$INSERT Statement

By a T24 standard, a Basic Insert file should start with I_% like I_COMMON. The TAFJ compiler accepts any name as $INSERT file, if the temn.tafj.compiler.insert.name.any key is set to true.

Basic File and Class File Compliance

By default, the basic source file encoding should be ISO-8859-1, but you may have to specify another file encoding when running on specific platform, that is ibm zOs.

temn.tafj.compiler.basic.encoding = IBM-1047

A property allows you to define the java version compliance you want to use. That is when setting 1.8 you will be able to execute the generated code on targeted version and later. This property sets both -source and -target javac arguments.

temn.tafj.compiler.javac.compliance = 1.8

JAVAC Options

The TAFJ Compiler uses javac to compile and generate class files.  The temn.tafj.compiler.javac.options key is used to specify the standard javac options.

Windows 32

Usage: javac <options> <source files>
where possible options include:
  -g                            	Generate all debugging info
  -g:none               		Generate no debugging info
  -g:{lines,vars,source}     	Generate only some debugging info
  -nowarn                   	Generate no warnings
  -verbose                   	Output messages about what the compiler is doing
  -deprecation              	Output source locations where deprecated APIs are used
  -classpath <path>         	Specify where to find user class files and annotation processors
  -cp <path>                 	Specify where to find user class files and annotation processors
  -sourcepath <path>         	Specify where to find input source files
  -bootclasspath <path>      	Override location of bootstrap class files
  -extdirs <dirs>            	Override location of installed extensions
  -endorseddirs <dirs>       	Override location of endorsed standards path
  -proc:{none,only}          	Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]   Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      	Specify where to find annotation processors
  -d <directory>            	Specify where to place generated class files
  -s <directory>             	Specify where to place generated source files
  -implicit:{none,class}     	Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       	Specify character encoding used by source files
  -source <release>          	Provide source compatibility with specified release
  -target <release>          	Generate class files for specific VM version
  -version                   	Version information
  -help                      	Print a synopsis of standard options
  -Akey[=value]              	Options to pass to annotation processors
  -X                         	Print a synopsis of nonstandard options
  -J<flag>                   	Pass <flag> directly to the runtime system

Other Compiler Properties

# Flag to indicate if development is internal or not.
# This will spawn additional development rules validation
# if turned on.
#
temn.tafj.compiler.internal.development= true
# Maximum grammar level when compiling. The highest is 3.
#
temn.tafj.compiler.grammar.maxlevel= 3
# Minimum grammar level. For example, if a program cannot be compiled in
# grammar 3, it will tried to be compiled in grammar 2, then 1 ...
# Setting this value higher than 0 will make the program to fail compiling 
# if it fails at the level specified. 
#
temn.tafj.compiler.grammar.minlevel= 0
# Specify if the source must be generated with the BASIC line numbers.
# If set to false, no Debugger would be available.
#
temn.tafj.compiler.grammar.line.number= true
# set encoding of the BASIC Source
# ex for zOS : temn.tafj.compiler.basic.encoding = IBM-1047
# default is ISO-8859-1
#
#temn.tafj.compiler.basic.encoding            = IBM-1047
# Generate traces (logger COMPILER) if a Program cannot be compiled with the 
# highest grammar level.
#
temn.tafj.compiler.grammar.warning.depreciation= false
# Generate traces (logger COMPILER) if duplicates are found in EQUATE.
temn.tafj.compiler.grammar.warning.equate= false
# Accept any name for $INSERT file
temn.tafj.compiler.insert.name.any= true
# Java package to be used when compiling a program.
#
temn.tafj.package= com.temenos.t24

# Options for the java compiler. These options 
# have to be the same than the javac command of the JDK
# This property is not used by the Eclipse plug-in builder
#
temn.tafj.compiler.javac.options          = -g:none -nowarn

# Options for java compiler. Generate class files that target a specified version of the VM.
# Class files will run on the specified target and on later versions, but not on earlier versions of the VM. 
# Valid targets are  1.8.  
# This property set the compliance option of java compiler 
#
temn.tafj.compiler.javac.compliance       = 1.8

# When compiling a JBC file, specify if we want to generate
# the java file or not. Note that we can generate the class 
# without generating the java. 
#
temn.tafj.compiler.generate.java= true

# When asking for compilation, do we want to do the java compilation ?
# The obvious would be 'true', but in some cases, we could only want
# the java generation or nothing (just parsing)
#
temn.tafj.compiler.generate.class= true

# When compiling, do we want to also put the classes in a jar file.
# This will obviously only work if we are generating the classes (see above)
# The jar name will be the name of the package with _ instead of .
# The jar location will be defined by the property 
# temn.tafj.compiler.generated.jar.dir
#
temn.tafj.compiler.generate.jar= true

# Where should the jar be generated during compilation.
# default value is same as temn.tafj.directory.classes directory but in 
# "jars" instead of "classes"
#
temn.tafj.compiler.generated.jar.dir    = 
#
# When set to true enable compilation of new resources in eclipse
#
temn.tafj.compiler.eclipse.new.basic= false
#
# Extensions the compiler will consider. If null, all types 
# or file will be accepted
#
temn.tafj.compiler.extensions= .b;.component;.tut
#
# When set to true stop the compilation if an error append 
# This property is not used by the Eclipse plug-in builder
#
temn.tafj.compiler.exit.if.error          = false

# Eclipse basic editor When set to true file parsing won't be processed on each CR.
# To be used to speed up edition.
#Live code colorizer will be executed on save only.
#
temn.tafj.compiler.disable.cr.refresh= true
#
# Generate an error if variable is not properly initialised.
#
temn.tafj.compiler.force.variable.initialisation= true 

TAFJ Maven Plugin

TAFJ Basic compiler can be used through a maven build, which is helpful if you want to integrate within a build or regression process a T24 compilation. It also speeds up your compilation process depending on the compilation strategy you use.

If you are not familiar with the TAFJ maven plugin, then refer to the TAFJ Maven Plugin documentation. It will help you to get started with a simple demo.

This section assumes you are familiar with maven (commands, profile and lifecycle), TAFJ Maven project creation and basic plugin usage. It covers various plugin options.

TAFJ Maven project is the pom.xml which contains your build parameters. You need to be connected to the Temenos maven repository to use TAFJ maven capabilities.

Copyright © 2020- Temenos Headquarters SA

Published on :
Monday, May 27, 2024 5:14:06 PM IST