Project

General

Profile

Eclipse Configuration

Install Eclipse

https://www.eclipse.org/downloads/packages/installer

Use Eclipse installer to install Eclipse, change the mirror if the downloading speed is too slow.

Choose the Eclipse IDE for Enterprise Java and Web Developers. Choose java 1.8 or 11 depending on your project requirments. In eclipse.ini, that is found in your installation folder, you can go and change the heap size to -Xmx16g.

Import ~/shared/dev_tools/eclipse/code-style/formatter-profile.xml (Window -> Preferences -> Java -> Code Style -> Formatter).

Import ~/shared/dev_tools/eclipse/code-style/cleanup-profile.xml (Window -> Preferences -> Java -> Code Style -> Clean Up)

Update "Organize Imports" (Window -> Preferences -> Java -> Code Style -> Organize Imports). Set 'Number of imports needed...' and 'Number of static imports needed...' to 2.

(Optional - only if you want to format the code when saving it)
Window -> Preferences -> Java -> Editor -> Save Actions and check:
  • Perform the selected actions on save
  • Format source code

Add projects from an existing Ant Buildfile

An Eclipse project can be created from an existing And Buildfile in the following way (required):
  • Open Eclipse -> File -> New -> Project -> Expand Java -> Choose Java Project from Existing Ant Buildfile -> Next -> Browse the root of the project branch (can be FWD or a customer project branch) and look for the build.xml file -> Rename the project if necessary -> Finish
Additional Sources can be added in the following way (optional):
  • Right click on the existing project -> Properties -> Java Build Path -> Source -> Link Source -> Choose a folder to be able to view in the project (usually rules or udf folders for a FWD project) -> Finish -> Apply and Close.
Add projects on the build path (requires existent project, optional):
  • Right click on the existing project -> Properties -> Java Build Path -> Projects -> Add -> Check the necessary projects -> Ok -> Apply and Close.
Add project libraries (required):
  • Right click on the existing project -> Properties -> Java Build Path -> Libraries -> Add External JARs... -> Navigate to project/build/lib/ or/and project/deploy/lib, select all *.zip and *jar files -> Open -> Apply/Apply and Close.
  • Right click on the existing project -> Properties -> Java Build Path -> Libraries -> Add Library... -> Select JRE System Library -> Check Workspace default JRE or Alternate JRE from Installed JREs... -> Finish
    -> Apply and Close.

Add FWD as a Project (with Java 8)

First of all, you need to ensure you comply with the Java requirements of FWD (java-8-openjdk-amd64). You will need to set both the JRE and JDK used.

  • Reach for Window > Preferences > Java > Installed JREs
  • If you already have java-8-openjdk-amd64 set as your JRE, skip the following steps
  • Use Add... > Standard JVM
  • Use for JRE home /usr/lib/jvm/java-8-openjdk-amd64
  • The JRE system libraries should be populated. Use Finish and check java-8-openjdk-amd64 as your in-use JRE
  • In Window > Preferences > Java > Compiler, make sure you have set Compiler compliance level to 1.8

Afterwards, you need to set-up the FWD project:

  • Create a new Java project named fwd
  • Delete the src folder from the Java project
  • Enter the project properties: Right Click fwd project > Properties (Alt + Enter). Enter Java Build Path
  • Reach the Source tab. Use Link Source ... to add the sources: ~/gcd/trunk/src
  • Reach the Libraries tab. Remove the existing JRE (if not already set on java-8-openjdk-amd64)
  • Use Add External JARs.... Select all JAR files from ~/gcd/trunk/build/lib
  • To set the JRE, you can use Add Library ... > JRE System Library > Finish

Configure Builds

TBD: make sure to include things like ecj or AspectJ

Setup Debugging Profiles

Using Remove Java Application

By far, this is the quickest and easiest way to start debugging an application.

  • Run the server in detached mode using ./server.sh -d. The -d option will open a port for the debugger to attach to when the server is started. The port will be printed in the terminal or in stdout log: the default is 2080. Multiple applications can be debugged at the same time, as long as they are configured to use different ports.
  • From the top menu bar select Run -> Debug Configurations -> Right click Remove Java Application -> New Configuration -> Select the project, connection type should be Standard (Socket Attach), host should be localhost and the port must be changed to either 2080 (default) or other if the project was configured differently.
  • Debugging the server startup is also possible using -y option which allows the JVM to be suspended at startup (by default it is not), this will suspend the process until the debugger is attached. The command for this will be ./server.sh -d -y.

Using a Run Configuration

  • From the top menu bar select Run -> Run Configurations -> Right click Java Application -> New Configuration.
  • In Main, select the project corresponding to the P2J branch and browse the com.goldencode.p2j.main.ServerDriver Main Class (There is another entry point when using AppCDS that can be used: com.goldencode.p2j.main.FwdLauncher)
  • In Arguments there are three sections that need to be filled, but those require running ./server.sh -t. This will print in the terminal the final command used to run the server (note that it will not run the server). From this command you will get the following (approximately):
    java -ea -XX:StringTableSize=1000003 -Xmx8192m -server -Djava.locale.providers=SPI,CLDR,COMPAT 
    --add-opens java.base/java.lang=ALL-UNNAMED 
    -classpath [<run_jars]
    -Djava.library.path=../lib/ 
    -Djava.system.class.loader=com.goldencode.p2j.classloader.MultiClassLoader -Drules.tracing=true 
    com.goldencode.p2j.main.ServerDriver 
    server.xml net:connection:secure=true net:server:secure_port=3333 net:server:insecure_port=3433
    
  • The Program arguments are mentioned after com.goldencode.p2j.main.ServerDriver: server.xml net:connection:secure=true net:server:secure_port=3333 net:server:insecure_port=3433
  • The VM arguments include everything mentioned before com.goldencode.p2j.main.ServerDriver except: java, -classpath [<run_jars>] and Program arguments.
  • The Working directory is /path/to/project/deploy/server and must be set in Other.
  • In Classpath section, add all the libraries from the P2J project. Those can be found in /path/to/branch/build/lib/.

Interpreting and setting up debugging for other FWD specific processes

For this section, the example project is dataset. Both run configuration and remote java application configurations can be setup for specific project commands found in the build.xml file (e.g. ant convert, ant import.db). The following debugging examples can be used to better understand how to debug a process and to create other debugging configurations.

Debugging Conversion

This corresponds to the ant convert command, it is required to run ant clean from the command line to avoid running the incremental conversion.

The command from build.xml:

   <!-- convert Progress code from ${app.4gl.src} into ${src}, using ${app.4gl.pattern} pattern -->
   <target name="convert" 
           depends="init, check-file-cvt-list" 
           description="Convert the Progress ABL source code to Java source code, using a pattern as input." 
           unless="file-cvt-list">
      <record name="cvt_${LOG_STAMP}.log" action="start"/>
      <java classname="com.goldencode.p2j.convert.ConversionDriver" 
            fork="true" 
            failonerror="true" 
            dir="${basedir}">
         <jvmarg value="-server"/>
         <jvmarg value="-Xmx16G"/>
         <jvmarg value="-XX:-OmitStackTraceInFastThrow"/>
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
         <jvmarg value="-Xdebug"/>
         <jvmarg value="-Xnoagent"/>
         <jvmarg value="-Djava.compiler=NONE"/>
         <arg value="-SId2"/>
         <arg value="f2+m0+cb"/>
         <arg value="${app.4gl.src}"/>
         <arg value="${app.4gl.pattern}"/>
         <classpath refid="compile.classpath"/>
      </java>
      <record name="cvt_${LOG_STAMP}.log" action="stop"/>
   </target>

Run Configuration

  • From the top menu bar select Run -> Run Configurations -> Right click Java Application -> New Configuration.
  • In Main, select the project corresponding to the P2J branch and browse the com.goldencode.p2j.main.ConversionDriver Main Class.
  • In Arguments there are three sections that need to be filled, the Program arguments and VM arguments are available in the target command.
  • The Program arguments are mentioned in the <arg value="[my_argument]"/> tags, the arguments will then be: -SId2 f2+m0+cb ${app.4gl.src} ${app.4gl.pattern}. IMPORTANT: ${app.4gl.src} ${app.4gl.pattern} need to be replaced with the appropriate values, these can be properties defined in the same build.xml file and can be overridden by defining them in the build.properties file found in the project root (at the same level as build.xml). The final arguments should look like: -SId2 f2+m0+cb ./abl/ (*.[pPwW]|*.cls)
  • The VM arguments are mentioned in the <jvmarg value="[my_argument]"/>, the arguments will then be: -server -Xmx16G -XX:-OmitStackTraceInFastThrow -DP2J_HOME=${p2j.home} -Xdebug -Xnoagent -Djava.compiler=NONE. IMPORTANT: ${p2j.home} needs to be replaced with the appropriate value, this property is defined in the same build.xml file.
  • The Working directory is /path/to/project/ and must be set in Other.
  • In Classpath section, add all the libraries from the P2J project. Those can be found in /path/to/branch/build/lib/.

Remove Java Application

Requirements:
  •  <jvmarg value="-Xdebug"/>
     <jvmarg value="-Xnoagent"/>
     <jvmarg value="-Djava.compiler=NONE"/>
     <jvmarg value="-Xrunjdwp:transport=dt_socket,address=2090,server=y,suspend=y"/>
    
    must be added to the convert command in build.xml, suspend=y will suspend the process until the debugger is attached.
Creating:
  • From the top menu bar select Run -> Debug Configurations -> Right click Remove Java Application -> New Configuration -> Select the project, connection type should be Standard (Socket Attach), host should be localhost and the port must be changed to either 2090 or other if the project was configured differently.
Running:
  • Go to the project root and run ant clean && ant convert
  • Start debugging.

Debugging Database Import

This corresponds to the ant import.db command. IMPORTANT The command can differ between dialects, this means that it is necessary to create/update the existent configuration to reflect the change in dialect (program/vm arguments)

The command from build_db.xml:

   <target name="import.db.pg" 
           description="Import data (.d files) into PostgreSQL database." 
           if="${db.postgresql}">
      <record name="import_db_pg_${db.name}_${LOG_STAMP}.log" action="start"/>
      <java classname="com.goldencode.p2j.pattern.PatternEngine" 
            fork="true" 
            failonerror="true" 
            dir="${basedir}" >
         <jvmarg value="-Xmx1g"/>
         <jvmarg value="-Djava.system.class.loader=com.goldencode.asm.AsmClassLoader"/>
         <jvmarg value="-Dfile.encoding=UTF-8"/>
         <jvmarg value="-Djava.util.logging.config.file=${p2j.home}/cfg/logging.properties"/>
         <arg value ="-d"/>
         <arg value ="2"/>
         <arg value ="dbName=${escaped.quotes}${db.name}${escaped.quotes}"/>
         <arg value ="targetDb=${escaped.quotes}postgresql${escaped.quotes}"/>
         <arg value ="url=${escaped.quotes}${sql.url.pg}${escaped.quotes}"/>
         <arg value ="uid=${escaped.quotes}${sql.user}${escaped.quotes}"/>
         <arg value ="pw=${escaped.quotes}${sql.user.pass}${escaped.quotes}"/>
         <arg value ="maxThreads=4"/>
         <arg value ="schema/import"/>
         <arg value ="${data.rel}"/>
         <arg value ="${db.name}.p2o"/>
         <classpath refid="app.classpath"/>
      </java>
      <record name="import_db_pg_${db.name}_${LOG_STAMP}.log" action="stop"/>
   </target>

Run Configuration

  • From the top menu bar select Run -> Run Configurations -> Right click Java Application -> New Configuration.
  • In Main, select the project corresponding to the P2J branch and browse the com.goldencode.p2j.pattern.PatternEngine Main Class.
  • In Arguments there are three sections that need to be filled, the Program arguments and VM arguments are available in the target command.
  • The Program arguments are mentioned in the <arg value="[my_argument]"/> tags. IMPORTANT: ${sql.url.pg}, ${sql.user}, ${sql.user.pass}, ${data.rel}, ${db.name} need to be replaced with the appropriate values, these can be properties defined in the same build.xml file and can be overridden by defining them in the build.properties file found in the project root (at the same level as build.xml).
  • The VM arguments are mentioned in the <jvmarg value="[my_argument]"/> tags. IMPORTANT: ${p2j.home} needs to be replaced with the appropriate value, this property is defined in the same build.xml file.
  • The Working directory is /path/to/project/ and must be set in Other.
  • In Classpath section, add all the libraries from the P2J project. Those can be found in /path/to/branch/build/lib/.

Remove Java Application

Requirements:
  •  <jvmarg value="-Xdebug"/>
     <jvmarg value="-Xnoagent"/>
     <jvmarg value="-Djava.compiler=NONE"/>
     <jvmarg value="-Xrunjdwp:transport=dt_socket,address=2090,server=y,suspend=y"/>
    
    must be added to the import.db.pg command in build_db.xml, suspend=y will suspend the process until the debugger is attached.
Creating:
  • From the top menu bar select Run -> Debug Configurations -> Right click Remove Java Application -> New Configuration -> Select the project, connection type should be Standard (Socket Attach), host should be localhost and the port must be changed to either 2090 or other if the project was configured differently.
Running:
  • Go to the project root and run ant import.db
  • Start debugging.

Start Debugging on the Client

Using Remove Java Application (Web Client)

Requirements:
  • In clientConfig node of directory.xml (from /path/to/project/deploy/server/), modify jvmArgs to match the following (do not remove anything from the existing jvmArgs, just append what does not exist already):
              <node class="string" name="jvmArgs">
                <node-attribute name="value" value="-Xmx512m -XX:MaxPermSize=64m -Djava.awt.headless=true -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=2998,server=y,suspend=y"/>
              </node>
    
  • The port should be set to 2998.
  • In webClient node, 'port' should be fixed and non-zero:
              <node class="integer" name="port">
                <node-attribute name="value" value="7449"/>
              </node>
    
Limitations:
  • Only one web client can be executed at a time.
  • Sometimes the web client hangs, so it must be killed with:
    ps aux | grep ClientDriver
    kill -9 <pid>
    

    or
    pkill -f 'ClientDriver'
    
  • From the top menu bar select Run -> Debug Configurations -> Right click Remove Java Application -> New Configuration -> Select the project, connection type should be Standard (Socket Attach), host should be localhost and the port must be changed to either 2998 (default) or other if the project was configured differently.
  • The client will not start until the debugger is attached, to change that modify the jvmArgs to use suspend=n.

Using Remove Java Application (Command line Client)

  • From the top menu bar select Run -> Debug Configurations -> Right click Remove Java Application -> New Configuration -> Select the project, connection type should be Standard (Socket Attach), host should be localhost and the port must be changed to either 2090 (default) or other if the project was configured differently.
  • Run the client using ./client.sh -d 2090, if it is necessary for the client to be suspended until the debugger is attached use ./client.sh -d 2090 -s.

Using a Run Configuration

  • From the top menu bar select Run -> Run Configurations -> Right click Java Application -> New Configuration.
  • In Main, select the project corresponding to the P2J branch and browse the com.goldencode.p2j.main.ClientDriver Main Class
  • In Arguments there are three sections that need to be filled, but those require running ./client.sh -t. This will print in the terminal the final command used to run the server (note that it will not run the client). From this command you will get the following (approximately):
    java -ea -Duser.country=US -Duser.language=en -XX:+HeapDumpOnOutOfMemoryError -Djava.library.path=../lib/ 
    -classpath [<run_jars>] 
    -Dwidget.browser 
    com.goldencode.p2j.main.ClientDriver 
    net:server:host=localhost net:connection:secure=false net:server:secure_port=3333 net:server:insecure_port=3433 client:driver:type=gui_swing
    
  • The Program arguments are mentioned after com.goldencode.p2j.main.ClientDriver: net:server:host=localhost net:connection:secure=false net:server:secure_port=3333 net:server:insecure_port=3433 client:driver:type=gui_swing
  • The VM arguments include everything mentioned before com.goldencode.p2j.main.ClientDriver except: java, -classpath [<run_jars>] and Program arguments.
  • The Working directory is /path/to/project/deploy/client and must be set in Other.
  • In Classpath section, add all the libraries from the P2J project. Those can be found in /path/to/branch/build/lib/.

Start Debugging on the Server

See Setup-Debugging-Profiles for debugging the FWD server.

Configure to Match FWD Coding Standards

  1. Install Eclipse (Install Eclipse)
  2. Import ~/shared/dev_tools/eclipse/code-style/formatter-profile.xml (Window -> Preferences -> Java -> Code Style -> Formatter).
  3. Import ~/shared/dev_tools/eclipse/code-style/cleanup-profile.xml (Window -> Preferences -> Java -> Code Style -> Clean Up).
  4. Update "Organize Imports" (Window -> Preferences -> Java -> Code Style -> Organize Imports). Set 'Number of imports needed...' and 'Number of static imports needed...' to 2.

© 2004-2021 Golden Code Development Corporation. ALL RIGHTS RESERVED.