About Press Partners Employment Contact
Java Convert

Technical Overview

Techné’s leading edge JConvert/PB transformation tool uses technology similar to that used by compilers. There are three basic phases: analysis, transformation, and generation. The input to JConvert/PB consists of PowerBuilder export files corresponding to the objects and DataWindows of an application.

Analysis Phase
The analysis phase reads in the export files and builds an internal data structure of the application. In this phase, every occurrence of a type name is linked to the appropriate PowerBuilder type definition or application object definition. In addition, every variable name is linked to the appropriate declaration and every function call is linked to the appropriate function definition.

Transformation Phase
In the transformation phase, traversing the representation of the PowerBuilder application creates a data structure describing the resulting Java application. During this phase, decisions are made as to what Java classes need to be generated, visual components are identified, transformation of PowerScript syntax (e.g. case statements to if-then-else statements) is performed, and PowerBuilder variables and function names are transformed to the appropriate Java variable and method names.

Generation Phase
In the generation phase, the representation of the Java application is output to Java source files. During this phase, code generation templates are applied and aspects of coding style such as location of braces and indentation are applied. Code generation templates are pieces of Java code containing placeholders that drive the form of the generated code. The roles of the templates include controlling the organization of methods and declarations in Java classes and controlling the location of code for creating Swing components and setting their properties. The templates can easily be modified to suit the needs of a particular application or Java programming environment.

Conversion Process
Visually, JConvert/PB’s conversion process can be depicted in this manner:

Steps to Conversion
  1. Export all of the PowerBuilder objects and DataWindows to the file system. Usually, one directory or folder is created for each PowerBuilder library so that the conversion can make use of the application’s library structure.

  2. Perform an initial analysis of the application using JConvert/PB to confirm that all of the relevant PowerBuilder objects have been exported. If, during the analysis phase, JConvert/PB fails to locate the definition of a type or DataWindow, or to locate the declaration of a variable or function, a message is written to the log file. The missing objects are then exported from PowerBuilder and this step is repeated.

  3. Application specific configuration information is developed to guide the transformation process. This consists of a small amount of advice to JConvert/PB –such as how particular DataWindows are used and which frames are internal—that provides information to the conversion process that is not available from the PowerBuilder export files.
    Once this advice is gathered, the conversion is run again and the conversion log files are reviewed to determine whether the application touches areas of PowerBuilder not yet addressed by JConvert/PB. If this is the case, the Techné team works closely with clients in order solve these problems through modifications to system configuration files, tool modifications, and additions to the runtime library.

  4. Generated Java source is imported into a Java IDE and compiled. At this point some compilation errors may be reported due to limitations of the tool. These must be repaired as part of the handwork. For some IDEs such as IBM’s VAJava, the handwork also requires opening visual objects in the visual composition editor, reconstructing the visuals from source, and adding certain objects and connections that the IDE cannot automatically recover. The conversion process then moves to debugging and quality assurance.
If at any time throughout the handwork process changes occur to JConvert/PB, the configuration files, or even the original PowerBuilder application, the conversion can be quickly rerun—and selected portions of the resulting Java code can be incorporated into the project—to minimize impact on already completed handwork.

Runtime Library – PBJ™
JConvert/PB comes with a comprehensive runtime library called PBJ that, where it is not otherwise available in Java, supplies analogues to the rich set of system objects and global functions available in the PowerBuilder environment. This library is written in Java with no references to proprietary libraries. The resulting applications are therefore portable to any platform running Java.

Included in the library are the base classes that implement DataWindow functionality and the DataWindow API. This functionality includes mechanisms for retrieval, inserting and deleting rows, generating database updates, filtering, sorting, etc.

Techné provides JConvert/PB customers with the runtime library in source format. Future Java development is not strictly dependent on it; developers can make use of it when they want to continue to use PowerBuilder paradigms such as DataWindows, etc. Otherwise, they can choose to program directly in pure Java with or without the use of additional libraries.

In the translated Java code, any DataWindow that is used to provide user interface elements displayed on the screen (as opposed to those used purely as DataStores) can be edited graphically using the visual editor of the IDE. This is accomplished by generating a Java class for each DataWindow. These classes inherit the DataWindow functionality from the base classes in the library. The class-specific code consists of code for creating the visual components and setting their properties, translations of any expressions associated with fields of the DataWindow, and code for setting properties of the DataWindow, including the select statement. PowerBuilder PBSelect statements are converted to SQL SELECT statements.

The form of the class that a particular DataWindow is translated to depends on how the DataWindow is used in the application. JConvert/PB generates distinct code for drop down DataWindows, tabular DataWindows, free form DataWindows, and DataWindows used only as DataStores. The latter has no need of code for creating user interface components. The translation of tabular DataWindows includes a component derived from JTable while the translation of a free form DataWindow

consists of a JPanel containing user interface components. The translation of a drop down DataWindow is a class implementing CombBoxModel.

Resulting Code
A Java class is generated for each PowerBuilder object and for each component within a container (i.e. within a window or user object). User interface objects are translated to classes that extend classes derived from the appropriate Swing classes.

The application-specific configuration controls the names of the packages into which the Java classes are generated and the import statements of the Java code on a per-object basis.

Functions and event handlers become Java methods. The PowerScript code in the function and event handler bodies is translated to appropriate Java code. Event handlers are connected to the appropriate Swing events through appropriate listener classes. The form of these connections is specific to the IDE that will be used to edit the Java code.

Inline SQL is translated to corresponding JDBC calls inside try-catch blocks to handle errors. Variables acquiring values do to an inline SQL statement are translated to assignments on method calls on a JDBC ResultSet object.

Application Architecture
The following depicts the before (PowerBuilder) and after (Java) application architecture:

Note that the JConvert/PB supports the conversion of applications that make use of PowerBuilder Foundation Classes (PFC).


It is obvious that current PowerBuilder users face challenges in how to move to more current technologies. This paper has put forward the case for automated conversion. As stated, illustrated and evidenced in this paper, Techné’s JConvert/PB conversion solution is a rapid, accurate and valid way for organizations to migrate their applications from PowerBuilder to Java.

Reducing the conversion process significantly, JConvert/PB frees businesses up from the translation process so they can continue to do what they do best—remain dedicated to running their core business functions instead of dedicating themselves to one usually lengthy migration project.

And by working with the Techné team of specialists, organizations receive the added benefit of applying years of experience and unparalleled, advanced expertise to their unique and often complex requirements.