JP6982920B1 - Source code converter and program - Google Patents

Source code converter and program Download PDF

Info

Publication number
JP6982920B1
JP6982920B1 JP2021145203A JP2021145203A JP6982920B1 JP 6982920 B1 JP6982920 B1 JP 6982920B1 JP 2021145203 A JP2021145203 A JP 2021145203A JP 2021145203 A JP2021145203 A JP 2021145203A JP 6982920 B1 JP6982920 B1 JP 6982920B1
Authority
JP
Japan
Prior art keywords
class
item
group item
source code
cobol
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2021145203A
Other languages
Japanese (ja)
Other versions
JP2023038463A (en
Inventor
健二 田島
Original Assignee
株式会社Shift
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 株式会社Shift filed Critical 株式会社Shift
Priority to JP2021145203A priority Critical patent/JP6982920B1/en
Application granted granted Critical
Publication of JP6982920B1 publication Critical patent/JP6982920B1/en
Publication of JP2023038463A publication Critical patent/JP2023038463A/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

【課題】集団項目の記述を含むCOBOLのソースコードに対応するJavaのソースコードの汎用性及び保守性を高める。【解決手段】集団項目50が記述されたCOBOLのソースコードをJavaのソースコードに変換するソースコード変換装置1において、前記集団項目50が含む基本項目51の階層構造、及び従属関係に対応する親子関係を有した親クラス71、及び子クラス72を含む、プリミティブ型のクラス70に前記集団項目50を変換する集団項目コンバータ34を備え、前記集団項目コンバータ34は、前記集団項目50の前記基本項目51の値が並んだ固定長バイト配列80に関する情報を示すアノテーションを前記クラス70に付与する。【選択図】図2PROBLEM TO BE SOLVED: To improve the versatility and maintainability of a Java source code corresponding to a COBOL source code including a description of a group item. SOLUTION: In a source code conversion device 1 for converting a COBOL source code in which a group item 50 is described into a Java source code, a parent-child corresponding to a hierarchical structure of a basic item 51 included in the group item 50 and a dependency relationship. A group item converter 34 that converts the group item 50 into a primitive type class 70 including a parent class 71 and a child class 72 having a relationship is provided, and the group item converter 34 is the basic item of the group item 50. Annotation indicating information about the fixed-length byte array 80 in which the values of 51 are arranged is given to the class 70. [Selection diagram] Fig. 2

Description

本発明は、ソースコード変換装置、及びプログラムに関する。 The present invention relates to a source code converter and a program.

近年、メインフレームを含む比較的大規模なレガシーシステムを改修する、いわゆるモダナイゼーションが広く行われている(例えば、特許文献1参照)。
多くのレガシーシステムは、一般に、レガシー言語のCOBOLによって記述されたプログラムをメインフレームで実行させており、モダナイゼーションの推進の際には、COBOLによって記述されたソースコードを、Java(登録商標)によって記述されたソースコードに変換する、いわゆるコンバージョン開発が行われている(例えば、特許文献2、特許文献3、及び特許文献4参照)。
コンバージョン開発に係る文献には、例えば、特許文献5、及び特許文献6があり、これら特許文献5、及び特許文献6には、COBOLのソースコードのデータ部(DATA DIVISION)に記述された集団項目を、Javaのソースコードにおいて、独自定義のラッパークラスを用いて記述する技術が示されている。
In recent years, so-called modernization, in which a relatively large-scale legacy system including a mainframe is modified, has been widely performed (see, for example, Patent Document 1).
Many legacy systems generally run programs written in COBOL in the legacy language on the mainframe, and when promoting modernization, the source code written in COBOL is written in Java®. So-called conversion development is being carried out in which the source code is converted (see, for example, Patent Document 2, Patent Document 3, and Patent Document 4).
Documents related to conversion development include, for example, Patent Document 5 and Patent Document 6, and these Patent Documents 5 and 6 include group items described in the data part (DATA DIVISION) of the COBOL source code. Is shown in the Java source code using a uniquely defined wrapper class.

特開2018−151713号公報Japanese Unexamined Patent Publication No. 2018-1517113 特開2019−040399号公報Japanese Unexamined Patent Publication No. 2019-040399 国際公開第2015/015622号International Publication No. 2015/015622 特開2004−118374号公報Japanese Unexamined Patent Publication No. 2004-118374 特開2010−86218号公報Japanese Unexamined Patent Publication No. 2010-86218 特開2020−60842号公報Japanese Unexamined Patent Publication No. 2020-60842

しかしながら、特許文献5、及び特許文献6の技術において、Javaの実行環境は、上記独自定義のラッパークラスを解釈する機能を予め備えている必要があり、また、コンバージョン開発を行うプログラマは、上記独自定義のラッパークラスの仕様を理解している必要がある。このため、変換後のJavaのソースコードは実行環境の汎用性が低く、また、開発者にとっては保守性の点で問題があった。 However, in the techniques of Patent Document 5 and Patent Document 6, the Java execution environment needs to have a function of interpreting the wrapper class of the above-mentioned original definition in advance, and the programmer who develops the conversion is the above-mentioned original. You need to understand the specifications of the definition wrapper class. Therefore, the converted Java source code has low versatility in the execution environment, and has a problem in terms of maintainability for the developer.

本発明は、集団項目の記述を含むCOBOLのソースコードに対応するJavaのソースコードの汎用性及び保守性を高めることができるソースコード変換装置、及びプログラムを提供することを目的とする。 An object of the present invention is to provide a source code conversion device and a program capable of enhancing the versatility and maintainability of Java source code corresponding to COBOL source code including description of group items.

本発明の一態様は、集団項目が記述されたCOBOLのソースコードをJavaのソースコードに変換するソースコード変換装置において、前記集団項目が含む基本項目の階層構造、及び従属関係に対応する親子関係を有した親クラス、及び子クラスを含む、プリミティブ型のクラスに前記集団項目を前記Javaのソースコードにおいて定義する集団項目コンバータを備え、前記集団項目コンバータは、前記集団項目の前記基本項目の値が並んだ固定長バイト配列に関する情報を示すアノテーションを前記クラスに付与することを特徴とする。 One aspect of the present invention is a source code conversion device that converts a COBOL source code in which a group item is described into a Java source code, in which a hierarchical structure of basic items included in the group item and a parent-child relationship corresponding to a dependent relationship are provided. A primitive type class including a parent class having a and a child class includes a group item converter that defines the group item in the Java source code, and the group item converter is a value of the basic item of the group item. It is characterized in that an annotation indicating information about a fixed-length byte array in which is arranged is given to the class.

本発明の一態様は、COBOLのソースコードに対応したJavaのソースコードをコンピュータに生成させるプログラムであって、前記COBOLのソースコードに記述される集団項目が含む基本項目の階層構造、及び従属関係に対応する親子関係を有した親クラス、及び子クラスを含む、プリミティブ型のクラスを定義することと、前記集団項目の前記基本項目の値が並んだ固定長バイト配列に関する情報を示すアノテーションを前記クラスに付与することと、をコンピュータに実行させるプログラムである。 One aspect of the present invention is a program that causes a computer to generate Java source code corresponding to COBOL source code, and has a hierarchical structure of basic items including group items described in the COBOL source code, and dependent relationships. Annotation indicating information about a fixed-length byte array in which the values of the basic items of the group item are arranged is defined by defining a primitive type class including a parent class having a parent-child relationship corresponding to and a child class. It is a program that allows a computer to execute what is given to a class.

本発明の一態様によれば、集団項目の記述を含むCOBOLのソースコードに対応するJavaのソースコードの汎用性及び保守性が高められる。 According to one aspect of the present invention, the versatility and maintainability of the Java source code corresponding to the COBOL source code including the description of the group item is enhanced.

本発明の実施形態に係るソースコード変換装置の構成を、プロセッサの機能的構成とともに示す図である。It is a figure which shows the structure of the source code conversion apparatus which concerns on embodiment of this invention together with the functional structure of a processor. 変換処理部の機能的構成を示す図である。It is a figure which shows the functional structure of the conversion processing part. COBOLソースの構成を集団項目の一例とともに模式的に示す図である。It is a figure which shows schematically the composition of a COBOL source together with an example of a group item. 変換後のJavaのクラスの一例を模式的に示す図である。It is a figure which shows an example of the Java class after conversion schematically. COBOLの基本項目のデータ型とJavaのプリミティブ型との対応を示す図である。It is a figure which shows the correspondence between the data type of the basic item of COBOL and the primitive type of Java. 集団項目変換処理のフローチャートである。It is a flowchart of a group item conversion process. 集団項目からクラスへの変換の一例を示す図である。It is a figure which shows an example of the conversion from a group item to a class. COBOLとJavaとの記述例を示す図である。It is a figure which shows the description example of COBOL and Java. COBOLにおける配列を含む集団項目と、Javaにおけるクラスとの対応を示す図である。It is a figure which shows the correspondence between the group item including the sequence in COBOL and the class in Java. COBOLにおける「再定義」を含む集団項目と、Javaにおけるクラスとの対応を示す図である。It is a figure which shows the correspondence between the group item including "redefinition" in COBOL and the class in Java. Setterメソッドの一例を示す図である。It is a figure which shows an example of the Setter method.

以下、図面を参照して本発明の実施形態について説明する。
図1は、本実施形態に係るソースコード変換装置1の構成を、プロセッサ16の機能的構成とともに示す図である。
ソースコード変換装置1は、COBOLで記述されたソースコード(以下、COBOLソースNCという)を、Javaで記述されたソースコード(以下、JavaソースNJという)に言語変換する装置であり、入力I/F回路10と、出力I/F回路12と、記憶デバイス14と、プロセッサ16と、を有するコンピュータによって構成されている。
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
FIG. 1 is a diagram showing the configuration of the source code conversion device 1 according to the present embodiment together with the functional configuration of the processor 16.
The source code conversion device 1 is a device that translates the source code described in COBOL (hereinafter referred to as COBOL source NC) into the source code described in Java (hereinafter referred to as Java source NJ), and is an input I /. It is composed of a computer having an F circuit 10, an output I / F circuit 12, a storage device 14, and a processor 16.

入力I/F回路10は、入力装置2が接続されるインターフェース回路である。
入力装置2は、COBOLソースNCのデータをソースコード変換装置1へ入力する装置であり、ユーザ操作装置や、読取装置、受信装置といった、データ入力機能を有する各種の装置が該当する。ユーザ操作装置は、キーボードやマウス、タッチパネルなどのユーザ操作型の装置である。読取装置は、半導体メモリや光記録ディスク、紙媒体などの記録媒体に記録されたCOBOLソースNCを読み取る装置である。受信装置は、有線通信又は無線通信を通じて外部装置からCOBOLソースNCを受信する装置である。なお、ソースコード変換装置1が入力装置2を内蔵してもよい。
The input I / F circuit 10 is an interface circuit to which the input device 2 is connected.
The input device 2 is a device for inputting COBOL source NC data to the source code conversion device 1, and corresponds to various devices having a data input function such as a user operation device, a reading device, and a receiving device. The user operation device is a user operation type device such as a keyboard, a mouse, and a touch panel. The reading device is a device that reads the COBOL source NC recorded on a recording medium such as a semiconductor memory, an optical recording disk, or a paper medium. The receiving device is a device that receives COBOL source NC from an external device through wired communication or wireless communication. The source code conversion device 1 may include the input device 2.

出力I/F回路12は、出力装置4が接続されるインターフェース回路である。
出力装置4は、JavaソースNJをソースコード変換装置1から出力する装置であり、表示装置や、書込装置、送信装置といった、データ出力機能を有する各種の装置が該当する。表示装置は、JavaソースNJを表示する装置である。書込装置は、半導体メモリや光記録ディスク、紙媒体などの記録媒体にJavaソースNJを書き込む装置である。送信装置は、有線通信又は無線通信を通じ外部装置へJavaソースNJを送信する装置である。なお、ソースコード変換装置1が出力装置4を内蔵してもよい。
The output I / F circuit 12 is an interface circuit to which the output device 4 is connected.
The output device 4 is a device that outputs a Java source NJ from the source code conversion device 1, and corresponds to various devices having a data output function such as a display device, a writing device, and a transmitting device. The display device is a device that displays the Java source NJ. The writing device is a device that writes the Java source NJ to a recording medium such as a semiconductor memory, an optical recording disk, or a paper medium. The transmitting device is a device that transmits a Java source NJ to an external device through wired communication or wireless communication. The source code conversion device 1 may include the output device 4.

記憶デバイス14は、COBOLソースNCやJavaソースNJなどの各種のデータを記憶する装置であり、例えば、RAMやROMなどのメモリデバイス(主記憶装置とも呼ばれる)、及び、HDDやSSDなどのディスクドライブ装置(補助記憶装置とも呼ばれる)が該当する。また、記憶デバイス14は、ソースコード変換を実現するプログラム18を記憶する。 The storage device 14 is a device that stores various data such as COBOL source NC and Java source NJ, and is, for example, a memory device (also referred to as a main storage device) such as RAM and ROM, and a disk drive such as HDD and SSD. This applies to devices (also called auxiliary storage devices). Further, the storage device 14 stores the program 18 that realizes the source code conversion.

プロセッサ16は、記憶デバイス14に記憶されているOS(Operating System)を実行することでソースコード変換装置1の各部を中枢的に制御する演算処理装置である。また、プロセッサ16は上記プログラム18を実行することで、ソースコード変換に要する各種の機能的構成を実現する。
かかる機能的構成は、図1に示すように、取得部20と、変換処理部22と、出力部24と、を含んでいる。
The processor 16 is an arithmetic processing unit that centrally controls each part of the source code conversion device 1 by executing an OS (Operating System) stored in the storage device 14. Further, the processor 16 realizes various functional configurations required for source code conversion by executing the above program 18.
As shown in FIG. 1, such a functional configuration includes an acquisition unit 20, a conversion processing unit 22, and an output unit 24.

取得部20は、COBOLソースNCを記憶デバイス14から取得し、変換処理部22へ出力する。変換処理部22は、COBOLソースNCをJavaソースNJに変換し、出力部24へ出力するものであり、詳細な構成については後述する。出力部24は、JavaソースNJを記憶デバイス14へ出力する。 The acquisition unit 20 acquires the COBOL source NC from the storage device 14 and outputs it to the conversion processing unit 22. The conversion processing unit 22 converts the COBOL source NC into a Java source NJ and outputs it to the output unit 24, and the detailed configuration will be described later. The output unit 24 outputs the Java source NJ to the storage device 14.

図2は変換処理部22の機能的構成を示す図である。また図3はCOBOLソースNCの構成を集団項目50の一例とともに模式的に示す図である。
変換処理部22は、図2に示すように、COBOLソースNCをJavaソースNJに変換する言語変換部30と、COBOLソースNCを解析するCOBOLコンパイラ32と、を備え、さらに言語変換部30は、集団項目コンバータ34を備え、当該集団項目コンバータ34がCOBOLソースNCに記述された集団項目50(図3、図5参照)を、Javaのクラス70(図5参照)に変換する。
FIG. 2 is a diagram showing a functional configuration of the conversion processing unit 22. Further, FIG. 3 is a diagram schematically showing the configuration of the COBOL source NC together with an example of the group item 50.
As shown in FIG. 2, the conversion processing unit 22 includes a COBOL source NC for converting a COBOL source NC into a Java source NJ, and a COBOL compiler 32 for analyzing the COBOL source NC. Further, the COBOL processing unit 30 includes a COBOL source NC. A group item converter 34 is provided, and the group item converter 34 converts the group item 50 (see FIGS. 3 and 5) described in the COBOL source NC into a Java class 70 (see FIG. 5).

変換元であるCOBOLソースNCは、図3に示すように、一般に、見出し部(「IDENTIFICATION DIVISION」とも呼ばれる)40と、環境部(「ENVIRONMENT DIVISION」とも呼ばれる)41と、データ部(「DATA DIVISION」とも呼ばれる)42と、手続き部(「PROCEDURE DIVISION」とも呼ばれる)43と、を含み、これらが、この順番で記述されている。
見出し部40は、COBOLソースNCを識別するための情報(プログラム名など)が記述される箇所である。環境部41は、主に、COBOLソースNCを実行するコンピュータ名や、環境変数などの情報の定義などが記述される箇所である。データ部42は、主に、集団項目50やファイルのレコードの宣言が記述される箇所である。手続き部43は、主に、メインの処理内容が記述される箇所である。
As shown in FIG. 3, the COBOL source NC that is the conversion source generally has a heading unit (also referred to as “IDENTIFICATION DIVISION”) 40, an environment unit (also referred to as “ENVIRONMENT DIVISION”) 41, and a data unit (“DATA DIVISION”). (Also also referred to as) 42 and a procedure unit (also referred to as “PROCEDURE DIVISION”) 43, which are described in this order.
The heading unit 40 is a place where information (program name, etc.) for identifying the COBOL source NC is described. The environment unit 41 is mainly a place where the name of the computer that executes the COBOL source NC and the definition of information such as environment variables are described. The data unit 42 is mainly a place where the group item 50 and the declaration of the record of the file are described. The procedure unit 43 is mainly a place where the main processing content is described.

本実施形態の言語変換部30は、データ部42に記述された集団項目50を、集団項目コンバータ34によってJavaのクラス70に変換するとともに、それ以外の部分については、例えば機械翻訳的にJavaのソースコードに変換する。「機械翻訳的な変換」とは、命令語単位、構文単位、又はCOBOL文法に則した様々な単位で、COBOLソースNCの文字列を、Javaの文字列に変換することを言う。なお、集団項目50以外の部分の変換には、「機械翻訳的な変換」の他にも、公知または周知の任意の手法を用いることができる。 The language conversion unit 30 of the present embodiment converts the group item 50 described in the data unit 42 into the Java class 70 by the group item converter 34, and the other parts are, for example, machine-translated by Java. Convert to source code. "Machine translation conversion" means converting a COBOL source NC character string into a Java character string in a command word unit, a syntactic unit, or various units according to the COBOL grammar. In addition to the "machine translation conversion", any known or well-known method can be used for the conversion of the portion other than the group item 50.

COBOL文法において、集団項目50は、1つ以上の基本項目51の集合体であり、各基本項目51に付されたラベル番号52によって、基本項目51の階層構造及び従属関係が規定されている。基本項目51は、基本のデータ型54が宣言された単一のデータ項目の場合もある。データ項目は、使用するデータ型54の長さ(確保すべき記憶領域の大きさ)と、データ項目の名称との対を含む定義文であり、JavaやC言語などの他の言語における変数に対応する。かかる集団項目50は、コンパイラによってコンパイルされると、各基本項目51の値を格納した配列要素が並んだ固定長バイト配列80(図7参照)に変換される。このように、集団項目50は固定長バイト配列80で表されるため、集団項目50の定義は、一般に、プログラムなどの間で集団項目50に係るデータを送受する際のデータのレイアウトにも用いられている。 In the COBOL grammar, the group item 50 is a collection of one or more basic items 51, and the label number 52 attached to each basic item 51 defines the hierarchical structure and the dependency relationship of the basic items 51. The basic item 51 may be a single data item in which the basic data type 54 is declared. The data item is a definition statement including a pair of the length of the data type 54 to be used (the size of the storage area to be secured) and the name of the data item, and is a variable in other languages such as Java and C language. handle. When the group item 50 is compiled by the compiler, it is converted into a fixed-length byte array 80 (see FIG. 7) in which array elements storing the values of each basic item 51 are arranged. In this way, since the group item 50 is represented by the fixed-length byte array 80, the definition of the group item 50 is generally used for the layout of data when sending and receiving data related to the group item 50 between programs and the like. Has been done.

COBOLコンパイラ32は、COBOLをコンパイルする一般的なコンパイラの機能を備え、COBOLソースNCに対して、字句解析、構文解析、及び意味解析等の解析処理を実行し、当該解析処理によって得られた解析結果36を言語変換部30に出力する。
本実施形態のCOBOLコンパイラ32は、集団項目50の各基本項目51の階層構造及び従属関係、並びに、集団項目50の定義に基づいて記憶領域に確保される固定長バイト配列80に関する情報を少なくとも解析し、これらの解析の結果を上記解析結果36に含めて言語変換部30に出力する。固定長バイト配列80に関する情報は、固定長バイト配列80の配列要素の数、当該固定長バイト配列80における各基本項目51のデータ長、及び位置などを含む。
なお、言語変換部30は、COBOLソースNCの集団項目50以外の部分の変換に、COBOLコンパイラ32の解析結果36を用いてもよい。また以下の説明において、固定長バイト配列80の各配列要素の順番は、先頭をゼロ番目(i=0)としてカウントする。
The COBOL compiler 32 has a general compiler function for compiling COBOL, executes analysis processing such as lexical analysis, syntactic analysis, and semantic analysis on the COBOL source NC, and analyzes the analysis obtained by the analysis processing. The result 36 is output to the language conversion unit 30.
The COBOL compiler 32 of the present embodiment analyzes at least information about the hierarchical structure and subordination of each basic item 51 of the group item 50, and the fixed-length byte array 80 reserved in the storage area based on the definition of the group item 50. Then, the results of these analyzes are included in the analysis result 36 and output to the language conversion unit 30. The information about the fixed-length byte array 80 includes the number of array elements of the fixed-length byte array 80, the data length of each basic item 51 in the fixed-length byte array 80, the position, and the like.
The language conversion unit 30 may use the analysis result 36 of the COBOL compiler 32 for conversion of parts other than the group item 50 of the COBOL source NC. Further, in the following description, the order of each array element of the fixed-length byte array 80 is counted with the head as the zeroth (i = 0).

集団項目コンバータ34は、COBOLソースNCの集団項目50を、Javaにおけるプリミティブ型のクラス70に変換する。 The group item converter 34 converts the group item 50 of the COBOL source NC into the class 70 of the primitive type in Java.

図4は、変換後のJavaのクラス70の一例を模式的に示す図である。
同図に示すように、クラス70は、1つの親クラス71と、1又は複数の子クラス72とを含む。これら親クラス71、及び子クラス72の各フィールド73が基本項目51に対応し、また、親クラス71、及び子クラス72の親子関係が基本項目51の階層構造及び従属関係に対応する。すなわち、ある子クラス72が含むフィールド73は、その子クラス72の派生元の子クラス72又は親クラス71よりも下の階層に位置し、また、子クラス72の派生関係が基本項目51の従属関係に対応する。
FIG. 4 is a diagram schematically showing an example of Java class 70 after conversion.
As shown in the figure, class 70 includes one parent class 71 and one or more child classes 72. Each field 73 of the parent class 71 and the child class 72 corresponds to the basic item 51, and the parent-child relationship of the parent class 71 and the child class 72 corresponds to the hierarchical structure and the subordinate relationship of the basic item 51. That is, the field 73 included in a child class 72 is located in a hierarchy below the child class 72 or the parent class 71 from which the child class 72 is derived, and the derivation relationship of the child class 72 is a dependency relationship of the basic item 51. Corresponds to.

さらに、本実施形態のクラス70において、親クラス71、及び子クラス72には、クラス用アノテーション75Aが付され、フィールド73には、フィールド用アノテーション75Bが付される。クラス用アノテーション75A、及びフィールド用アノテーション75Bは、集団項目50の固定長バイト配列80に関する情報を示すものであり、その詳細については後述する。 Further, in the class 70 of the present embodiment, the parent class 71 and the child class 72 are attached with the class annotation 75A, and the field 73 is attached with the field annotation 75B. The annotation 75A for the class and the annotation 75B for the field show information about the fixed-length byte array 80 of the group item 50, and the details thereof will be described later.

またクラス70において、親クラス71は、独自に定義したスーパークラス(以下、「オリジナルスーパークラス」という)65を継承したクラスであり、このオリジナルスーパークラス65には、クラス用アノテーション75A、及びフィールド用アノテーション75Bが示す、固定長バイト配列80に関する情報に基づいて、固定長バイト配列80へアクセスするメソッドなどが定義されている。 Further, in the class 70, the parent class 71 is a class that inherits the superclass (hereinafter referred to as “original superclass”) 65 defined independently, and the original superclass 65 includes the class annotation 75A and the field. Based on the information about the fixed-length byte array 80 indicated by the annotation 75B, a method for accessing the fixed-length byte array 80 and the like are defined.

本実施形態の集団項目コンバータ34は、基本項目51の階層構造及び従属関係、並びに、固定長バイト配列80に関する情報を、COBOLコンパイラ32の解析結果36に基づいて特定しており、プログラマによる集団項目50の記述の仕方に依存することなく、これらの情報が正確かつ簡単に特定可能になっている。 The group item converter 34 of the present embodiment specifies the hierarchical structure and dependencies of the basic item 51 and the information regarding the fixed-length byte array 80 based on the analysis result 36 of the COBOL compiler 32, and the group item by the programmer. This information can be identified accurately and easily without depending on the description method of 50.

図5は、COBOLの基本項目51のデータ型54とJavaのプリミティブ型との対応を示す図である。
Javaのプリミティ型は、「short型」、「byte型」、「long型」、「int型」、「double型」、「float型」、「String型」、「boolean型」、「BigDecimal型」などの型があり、図5に示すように、COBOLの基本項目51が取り得る各データ型54が、Javaのプリミティブ型のいずれかに予め対応付けられている。COBOLの固定小数点における小数点の位置は、Javaの「BigDecimal型」における「scale」の値に対応付けられる。
かかる対応付けを示す型対応データ37(図2参照)は、集団項目コンバータ34に予め組み込まれており、集団項目コンバータ34は、当該型対応データ37を参照して、各基本項目51をプリミティブ型のフィールド73に変換する。
FIG. 5 is a diagram showing the correspondence between the data type 54 of the basic item 51 of COBOL and the primitive type of Java.
Java's primitive types are "short type", "byte type", "long type", "int type", "double type", "float type", "String type", "Boolean type", and "BigDecimal type". As shown in FIG. 5, each data type 54 that can be taken by the basic item 51 of COBOL is associated with any of the primitive types of Java in advance. The position of the decimal point in the fixed point of COBOL is associated with the value of "scale" in Java's "BigDecimal type".
The type correspondence data 37 (see FIG. 2) showing such correspondence is preliminarily incorporated in the group item converter 34, and the group item converter 34 refers to the type correspondence data 37 and sets each basic item 51 as a primitive type. Convert to field 73 of.

このように、変換後のクラス70(親クラス71、及び子クラス72)はプリミティブ型となるため(すなわち全てのフィールド73がプリミティブ型であるため)、Javaの開発環境、及び実行環境が特別なライブラリ(上記特許文献5及び特許文献6に記載された独自定義のラッパークラス含むライブラリ)をインポートせずともクラス70を使用できる。すなわち、変換後のクラス70は、いわゆるPOJO(Plain Old Java Object)となるため、変換後のJavaソースNJの汎用性、及び保守性が大幅に向上することとなる。
また、JavaソースNJにおいて、プリミティブ型のクラス70は、フィールド73の値を「値渡し」により他の関数等に渡すため、COBOLにおける「MOVE」命令と同じ動きとなり、開発者が誤解を生じ難くできる。また、プリミティブ型以外のクラス70を用いた場合、「値渡し」ではなく「参照渡し」が行われる可能性があり、バグを内包する危険性がある。これに対し、本実施形態のクラス70によれば、かかる危険性を確実に回避することができる。
In this way, since the converted class 70 (parent class 71 and child class 72) is a primitive type (that is, all fields 73 are primitive types), Java's development environment and execution environment are special. The class 70 can be used without importing the library (the library including the uniquely defined wrapper class described in Patent Documents 5 and 6). That is, since the converted class 70 is a so-called POJO (Plan Old Java Object), the versatility and maintainability of the converted Java source NJ are greatly improved.
Further, in the Java source NJ, the primitive type class 70 passes the value of the field 73 to another function or the like by "passing by value", so that the behavior is the same as the "MOVE" instruction in COBOL, and the developer is less likely to misunderstand. can. Further, when a class 70 other than the primitive type is used, "passing by reference" may be performed instead of "passing by value", and there is a risk of including a bug. On the other hand, according to the class 70 of the present embodiment, such a risk can be surely avoided.

ここで、COBOLのデータ型54をJavaのプリミティブ型に対応付ける場合、Javaにおける一つのプリミティブ型に、COBOLにおける異なるデータ型54が対応付けられることがある。例えば、図5において、COBOLのパック10進数、及びゾーン10進数の数値はいずれもJavaの「long型」に対応付けられている。
そこで、前掲図4に示すように、フィールド用アノテーション75Bは、基本項目51のデータ型54を示す第1引数75B1を含み、この第1引数75B1によって、フィールド73に対応する基本項目51のデータ型54が識別可能となる。
一方、クラス用アノテーション75Aは、承継元の上記オリジナルスーパークラスを示す第1引数75A1を含んでいる。
Here, when the COBOL data type 54 is associated with the Java primitive type, one primitive type in Java may be associated with a different data type 54 in COBOL. For example, in FIG. 5, the COBOL packed decimal number and the zone decimal number are both associated with Java's "long type".
Therefore, as shown in FIG. 4 above, the field annotation 75B includes the first argument 75B1 indicating the data type 54 of the basic item 51, and the data type of the basic item 51 corresponding to the field 73 is provided by the first argument 75B1. 54 becomes identifiable.
On the other hand, the annotation 75A for the class includes the first argument 75A1 indicating the original superclass of the succession source.

また、本実施形態のクラス用アノテーション75A、及びフィールド用アノテーション75Bはいずれも、集団項目50の固定長バイト配列80に関する情報を示す引数を含んでいる。
具体的には、クラス用アノテーション75Aは、固定長バイト配列80のデータ長(本実施形態では配列要素の数)を示す第2引数75A2を含み、フィールド用アノテーション75Bは、基本項目51の桁数(文字型の場合は文字数に相当)を示す第2引数75B2と、固定長バイト配列80における位置(本実施形態では開始位置)を示す第3引数75B3と、を含む。
これら第2引数75A2、75B2、第3引数75B3によって、集団項目50に対応する固定長バイト配列80に関する情報がクラス70に記述される。
Further, both the class annotation 75A and the field annotation 75B of the present embodiment include an argument indicating information regarding the fixed-length byte array 80 of the group item 50.
Specifically, the class annotation 75A includes a second argument 75A2 indicating the data length of the fixed-length byte array 80 (the number of array elements in this embodiment), and the field annotation 75B has the number of digits of the basic item 51. It includes a second argument 75B2 indicating (corresponding to the number of characters in the case of a character type) and a third argument 75B3 indicating a position (start position in this embodiment) in the fixed-length byte array 80.
The second argument 75A2, 75B2, and the third argument 75B3 describe information about the fixed-length byte array 80 corresponding to the group item 50 in the class 70.

次いで集団項目コンバータ34による変換動作を説明する。 Next, the conversion operation by the group item converter 34 will be described.

図6は集団項目変換処理のフローチャートである。図7は集団項目50からクラス70への変換の一例を示す図である。
図6に示すように、集団項目コンバータ34は、先ず、COBOLソースNC、又は、COBOLコンパイラ32の解析結果36に基づいて、集団項目50の全ての基本項目51についてプリミティブ型のフィールド73を定義し、基本項目51の階層構造及び従属関係に対応する親子関係の親クラス71、及び子クラス72を定義する(ステップS1)。
FIG. 6 is a flowchart of the group item conversion process. FIG. 7 is a diagram showing an example of conversion from the group item 50 to the class 70.
As shown in FIG. 6, the group item converter 34 first defines a primitive type field 73 for all the basic items 51 of the group item 50 based on the analysis result 36 of the COBOL source NC or the COBOL compiler 32. , The parent class 71 of the parent-child relationship corresponding to the hierarchical structure and the subordination of the basic item 51, and the child class 72 are defined (step S1).

図7に示すように、集団項目50が、例えば、ラベル番号52が「01」、「02」、及び「03」から成る3層構造である場合、集団項目コンバータ34は、トップ層(第1層)の「01 STRUCT_TOP」に対応して「class STRUCT_TOP」と命名した親クラス71を定義し、また、第2層(ラベル番号52=「02」)の各基本項目51に対応して、親クラス71の各フィールド73を定義する。なお、図7において、上記オリジナルスーパークラス65の名称は「Struct」であり、集団項目コンバータ34は、この「Struct」クラスを「extends」によって承継した親クラス71を定義する。 As shown in FIG. 7, when the group item 50 has, for example, a three-layer structure in which the label number 52 is composed of “01”, “02”, and “03”, the group item converter 34 is the top layer (first layer). A parent class 71 named "class STRUCT_TOP" corresponding to "01 STRUCT_TOP" of the layer) is defined, and a parent corresponds to each basic item 51 of the second layer (label number 52 = "02"). Each field 73 of class 71 is defined. In FIG. 7, the name of the original superclass 65 is "Struct", and the group item converter 34 defines a parent class 71 that inherits this "Struct" class by "extends".

また図7において、第2層の「02 STRUCT_CHILD」も集団項目50であるため、集団項目コンバータ34は、この「02 STRUCT_CHILD」に対応して「class STRUCT_CHILD」と命名した子クラス72を定義する。そして、集団項目コンバータ34は、第3層(ラベル番号52=「03」)の各基本項目51に対応して、この子クラス72の各フィールド73を定義する。 Further, in FIG. 7, since the second layer “02 STRUCT_CHILD” is also a group item 50, the group item converter 34 defines a child class 72 named “class STRUCT_CHILD” corresponding to this “02 STRUCT_CHILD”. Then, the group item converter 34 defines each field 73 of the child class 72 corresponding to each basic item 51 of the third layer (label number 52 = “03”).

図7に示すように、集団項目コンバータ34は、親クラス71、子クラス72、及びフィールド73の定義において、それらの名称に、対応する集団項目50、及び基本項目51の名称の全部又は一部を含めており、クラス70と集団項目50との互いの対応関係を開発者が把握し易くなっている。 As shown in FIG. 7, the group item converter 34 defines all or part of the names of the group item 50 and the basic item 51 corresponding to those names in the definitions of the parent class 71, the child class 72, and the field 73. It is easy for the developer to understand the mutual correspondence between the class 70 and the group item 50.

図6に戻り、集団項目コンバータ34は、COBOLコンパイラ32の解析結果36(固定長バイト配列80に係る解析結果)に基づいて、クラス用アノテーション75A及びフィールド用アノテーション75Bをクラス70に付与する(ステップS2)。
これにより、集団項目50がプリミティブ型のクラス70に変換される。
Returning to FIG. 6, the group item converter 34 assigns the annotation 75A for the class and the annotation 75B for the field to the class 70 based on the analysis result 36 (analysis result relating to the fixed-length byte array 80) of the COBOL compiler 32 (step). S2).
As a result, the group item 50 is converted into the primitive type class 70.

クラス用アノテーション75A及びフィールド用アノテーション75Bの生成について、より詳細には、集団項目コンバータ34は、集団項目50の固定長バイト配列80に基づいてクラス用アノテーション75Aを生成し、当該クラス用アノテーション75Aを親クラス71及び子クラス72に付与する。また、集団項目コンバータ34は、固定長バイト配列80、基本項目51のデータ型54、及び桁数に基づいてフィールド用アノテーション75Bを生成し、当該フィールド用アノテーション75Bをフィールド73に付与する。 Regarding the generation of the annotation 75A for the class and the annotation 75B for the field, the group item converter 34 generates the annotation 75A for the class based on the fixed-length byte array 80 of the group item 50, and generates the annotation 75A for the class. It is given to the parent class 71 and the child class 72. Further, the group item converter 34 generates the field annotation 75B based on the fixed-length byte array 80, the data type 54 of the basic item 51, and the number of digits, and assigns the field annotation 75B to the field 73.

図7の例では、集団項目50のコンパイルの結果、16進数で表記された値が格納された6バイト長の固定長バイト配列80が生成される。かかる固定長バイト配列80において、先頭(i=0)の配列要素に「01 CHARA_VALUE」の値(図示例「41」(=ASCII文字「A」))が格納されており、1番目(i=1)の配列要素に「03 CHARA_VALUE」の値(図示例「42」(=ASCII文字「B」))が格納されており、2番目(i=2)から3番目(i=3)の配列要素にかけて「03 SHORT_VALUE」の値(図示例「00」「0B」)が格納されており、また、4番目(i=4)から5番目(i=5)の配列要素にかけて「03 PACK_VALUE」の値(図示例「12」「3C」)が格納されている。 In the example of FIG. 7, as a result of compiling the group item 50, a fixed-length byte array 80 having a length of 6 bytes is generated in which the value expressed in hexadecimal is stored. In the fixed-length byte array 80, the value of "01 CARA_VALUE" (illustrated example "41" (= ASCII character "A")) is stored in the array element at the head (i = 0), and the first (i =). The value of "03 CARA_VALUE" (illustrated example "42" (= ASCII character "B")) is stored in the array element of 1), and the second (i = 2) to third (i = 3) array. The value of "03 ASCII_VALUE" (illustrated example "00" and "0B") is stored in the element, and the value of "03 PACK_VALUE" is stored in the fourth (i = 4) to fifth (i = 5) array elements. Values (illustrated examples "12" and "3C") are stored.

集団項目コンバータ34は、クラス用アノテーション75Aを生成する場合、親クラス71及び子クラス72について、固定長バイト配列80に占める配列要素の数を特定し、当該配列要素の数を第2引数75A2に格納する。
図7の例では、親クラス70に対応する「01 STRUCT_TOP」、及び、子クラス72に対応する「02 STRUCT_CHILD」のそれぞれの配列要素の数は「6」及び「5」であるため、集団項目コンバータ34は、親クラス71のクラス用アノテーション75Aの第2引数75A2(名称:length)に「6」を格納し、子クラス72のクラス用アノテーション75Aの第2引数75A2に「5」を格納する。
When generating the annotation 75A for the class, the group item converter 34 specifies the number of array elements in the fixed-length byte array 80 for the parent class 71 and the child class 72, and sets the number of the array elements to the second argument 75A2. Store.
In the example of FIG. 7, since the number of sequence elements of "01 STRUCT_TOP" corresponding to the parent class 70 and "02 STRUCT_CHILD" corresponding to the child class 72 is "6" and "5", the group items. The converter 34 stores "6" in the second argument 75A2 (name: lens) of the class annotation 75A of the parent class 71, and stores "5" in the second argument 75A2 of the class annotation 75A of the child class 72. ..

一方、集団項目コンバータ34は、フィールド用アノテーション75Bを生成する場合、各フィールド73について、対応する基本項目51のデータ型54、桁数、及び、固定長バイト配列80における開始位置を特定し、それぞれを第1引数75B1、第2引数75B2、及び第3引数75B3に格納する。 On the other hand, when generating the field annotation 75B, the group item converter 34 specifies the data type 54, the number of digits, and the start position in the fixed-length byte array 80 of the corresponding basic item 51 for each field 73, respectively. Is stored in the first argument 75B1, the second argument 75B2, and the third argument 75B3.

図7の例では、「02 CHARA_VALUE」は、データ型54がX型(半角文字)であり、桁数が「1」であり、固定長バイト配列80における開始位置が先頭(i=0)の配列要素である。この場合、集団項目コンバータ34は、フィールド用アノテーション75Bの第1引数75B1(名称:type)に、X型であることを明示する「CBLType.X」を格納し、第2引数75B2(名称:digit)に「1」を格納し、第3引数75B3(名称:location)に、先頭の配列要素を示す「0」を格納する。 In the example of FIG. 7, in "02 CARA_VALUE", the data type 54 is X type (half-width character), the number of digits is "1", and the start position in the fixed-length byte array 80 is the head (i = 0). It is an array element. In this case, the group item converter 34 stores "CBLType.X" clearly indicating that it is an X type in the first argument 75B1 (name: type) of the field annotation 75B, and stores the second argument 75B2 (name: digit). ), And "0" indicating the first array element is stored in the third argument 75B3 (name: location).

また図7の例では、「03 PACK_VALUE」は、データ型54がパック10進数型であり、桁数が「3」である。この「03 PACK_VALUE」に対応するフィールド73は子クラス72に属するため、固定長バイト配列80における開始位置には、固定長バイト配列80内で子クラス72が占めるバイト配列80Aにおける開始位置が用いられる。図7の例では、子クラス72が占めるバイト配列80Aにおいて、「03 PACK_VALUE」の開始位置は3番目(j=3)の配列要素である。
この場合、集団項目コンバータ34は、フィールド用アノテーション75Bの第1引数75B1に、パック10進数型であることを明示する「CBLType.us9_COMP9」を格納し、第2引数75B2に「3」を格納し、第3引数75B3に開始位置の「3」を格納する。
Further, in the example of FIG. 7, in "03 PACK_VALUE", the data type 54 is a packed decimal type and the number of digits is "3". Since the field 73 corresponding to this "03 PACK_VALUE" belongs to the child class 72, the start position in the byte array 80A occupied by the child class 72 in the fixed-length byte array 80 is used as the start position in the fixed-length byte array 80. .. In the example of FIG. 7, in the byte array 80A occupied by the child class 72, the start position of "03 PACK_VALUE" is the third (j = 3) array element.
In this case, the group item converter 34 stores "CBLType.us9_COMP9" that clearly indicates that it is a packed decimal type in the first argument 75B1 of the field annotation 75B, and stores "3" in the second argument 75B2. , The start position "3" is stored in the third argument 75B3.

なお、本実施形態において、フィールド用アノテーション75Bの第1引数75B1に使用する文字列は、COBOLの基本項目51のデータ型54に対応して予め設定されており、また、当該文字列は、対応するフィールド73に設定されたアノテーション情報から参照される。また、このオリジナルスーパークラス65には、上述の通り、フィールド用アノテーション75Bの第1引数75B1、第2引数75B2、及び第3引数75B3に基づいて、固定長バイト配列80へアクセスするメソッドなどが定義されている。固定長バイト配列80へのアクセスは、例えば、固定長バイト配列80に対する値の読み書きや、固定長バイト配列80の生成などを含む。 In this embodiment, the character string used for the first argument 75B1 of the field annotation 75B is preset corresponding to the data type 54 of the basic item 51 of COBOL, and the character string corresponds to the data type 54. It is referred from the annotation information set in the field 73 to be used. Further, as described above, the original superclass 65 defines a method for accessing the fixed-length byte array 80 based on the first argument 75B1, the second argument 75B2, and the third argument 75B3 of the field annotation 75B. Has been done. Access to the fixed-length byte array 80 includes, for example, reading and writing values to the fixed-length byte array 80 and generating the fixed-length byte array 80.

このように、クラス70は、集団項目50の基本項目51に対応する親クラス71、子クラス72、及びフィールド73のそれぞれに、固定長バイト配列80に関する情報を含むクラス用アノテーション75A及びフィールド用アノテーション75Bが付与される。
これにより、変換後のJavaソースNJにおいては、固定長バイト配列80に関する処理(例えば、フィールド73と固定長バイト配列80との間のデータのやり取り)を、クラス用アノテーション75A及びフィールド用アノテーション75Bを用いて実現することができる。本実施形態では、クラス70は、固定長バイト配列80へのアクセスするメソッドを含むオリジナルスーパークラス65を継承しているため、固定長バイト配列80を扱う処理のコーディングに要する労力が低減される。
さらに、クラス用アノテーション75A及びフィールド用アノテーション75Bは、クラス70に付随する形でJavaソースNJに記述されるため可読性を向上させることができる。
As described above, in the class 70, each of the parent class 71, the child class 72, and the field 73 corresponding to the basic item 51 of the group item 50 contains the annotation 75A for the class and the annotation for the field containing information about the fixed-length byte array 80. 75B is given.
As a result, in the converted Java source NJ, the processing related to the fixed-length byte array 80 (for example, data exchange between the field 73 and the fixed-length byte array 80) is performed by the class annotation 75A and the field annotation 75B. It can be realized by using. In the present embodiment, since the class 70 inherits the original superclass 65 including the method for accessing the fixed-length byte array 80, the labor required for coding the process for handling the fixed-length byte array 80 is reduced.
Further, since the annotation 75A for the class and the annotation 75B for the field are described in the Java source NJ in a form accompanying the class 70, the readability can be improved.

また、クラス70は、基本項目51の階層構造及び従属関係に対応する親子関係の親クラス71、及び子クラス72を有するため、COBOL文法における「OF修飾」と同様の表記が、言語変換部30による変換後のJavaソースNJにおいて記述される。例えば、図7に示した集団項目50の第3層の「03 CHAR_VALUE」の「MOVE」命令は、図8に示すように、記述例1のように記述される。一方、JavaソースNJにおいては、記述例1と同等の命令が記述例2のように記述され、変換後のJavaソースNJの可読性が向上する。 Further, since the class 70 has a parent class 71 and a child class 72 of a parent-child relationship corresponding to the hierarchical structure and the subordination of the basic item 51, the same notation as "OF modification" in the COBOL grammar is used in the language conversion unit 30. Described in the Java source NJ after conversion by. For example, the "MOVE" instruction of "03 CHAR_VALUE" in the third layer of the group item 50 shown in FIG. 7 is described as in the description example 1 as shown in FIG. On the other hand, in the Java source NJ, the same instructions as in the description example 1 are described as in the description example 2, and the readability of the converted Java source NJ is improved.

図9は、COBOLにおける配列を含む集団項目50と、Javaにおけるクラス70との対応を示す図である。
集団項目50の中において、「配列」は、「OCCURS句」を用いて宣言され、図9の例では、単一のデータ項目形式の配列が「02 CHAR_VALUE PIC X(02) OCCURS 2.」によって定義されており、また、集団項目形式の配列が「02 STRUCT_CHILD OCCURS 2.」によって定義されている。
同図の例では、単一のデータ項目形式の配列に対応する固定長バイト配列80−1は、2バイト×2の一次元配列となっており、文字「A」、「1」、「A」、「2」のそれぞれを16進数によって示した値が各配列要素に格納されている。
また、同図の例では、集団項目形式の配列は、文字型のデータ項目と数値型のデータ項目とから成る配列であり、当該配列に対応する固定長バイト配列80−2の各配列要素には、文字「B」、符号付き数値「+10」、文字「C」、符号付き数値「+11」のそれぞれを16進数によって示した値が格納されている。
FIG. 9 is a diagram showing the correspondence between the group item 50 including the sequence in COBOL and the class 70 in Java.
Within the population item 50, the "array" is declared using the "OCCURS clause", and in the example of FIG. 9, an array in the form of a single data item is represented by "02 CHAR_VALUE PIC X (02) OCCURS 2." It is defined, and an array in the form of a group item is defined by "02 STRUCT_CHILD OCCURS 2.".
In the example of the figure, the fixed-length byte array 80-1 corresponding to the array of a single data item format is a one-dimensional array of 2 bytes × 2, and the characters “A”, “1”, and “A”. , And each of "2" are represented by hexadecimal numbers, and the values are stored in each array element.
Further, in the example of the figure, the array in the group item format is an array consisting of a character type data item and a numerical type data item, and is used for each array element of the fixed length byte array 80-2 corresponding to the array. Stores a value in which each of the character "B", the signed numerical value "+10", the character "C", and the signed numerical value "+11" is indicated by a hexadecimal number.

集団項目コンバータ34が、かかる集団項目50をJavaのクラス70に変換する場合、先ず、基本項目51の階層構造及び従属関係に対応する親子関係の親クラス71、及び子クラス72を定義する。図9の例では、集団項目コンバータ34は、集団項目50の「01 OCCURS_STRUCT」に対応する「class OCCURS_STRUCT」を親クラス71として定義し、「02 STRUC_CHILD OCCURS 2.」に対応する「class STRUCT_CHILD」を子クラス72として定義する。また、集団項目コンバータ34は、COBOLの配列に対応するフィールド73を同じく配列として定義する。なお、図9では、配列として定義されたフィールド73には、他のフィールド73と区別するために、符号73−1、73−2を付している。 When the group item converter 34 converts such a group item 50 into a Java class 70, first, the parent class 71 and the child class 72 of the parent-child relationship corresponding to the hierarchical structure and the dependency relationship of the basic item 51 are defined. In the example of FIG. 9, the group item converter 34 defines “class OCCURS_STRUCT” corresponding to “01 OCCURS_STRUCT” of group item 50 as the parent class 71, and “class STRUCT_CHILD” corresponding to “02 STRUC_CHILD OCCURS 2.”. It is defined as a child class 72. Further, the group item converter 34 also defines the field 73 corresponding to the COBOL sequence as an array. In FIG. 9, the fields 73 defined as an array are designated by reference numerals 73-1 and 73-2 in order to distinguish them from the other fields 73.

次いで、集団項目コンバータ34は、クラス用アノテーション75A及びフィールド用アノテーション75Bをクラス70に付与する。この場合において、COBOLの配列に対応するフィールド73−1、73−2に付与されるフィールド用アノテーション75Bは、COBOLの配列に対応する旨を示す第4引数75B4(図示例、「occurs」)を含んでおり、この第4引数75B4によって配列に関する情報がクラス70に記述される。そして、この第4引数75B4と、固定長バイト配列80−1、80−2に関する情報を示す上述した他の引数(第2引数75A2、75B2、第3引数75B3)とによって、COBOLにおける「配列」と同等の機能がJavaのクラス70によって実現される。 Next, the group item converter 34 assigns the annotation 75A for the class and the annotation 75B for the field to the class 70. In this case, the field annotation 75B given to the fields 73-1 and 73-2 corresponding to the COBOL sequence has a fourth argument 75B4 (illustrated example, "occurs") indicating that the field annotation 75B corresponds to the COBOL sequence. It is included, and information about the array is described in class 70 by this fourth argument 75B4. Then, by the fourth argument 75B4 and the above-mentioned other arguments (second argument 75A2, 75B2, third argument 75B3) indicating information about the fixed-length byte arrays 80-1 and 80-2, the "array" in COBOL is used. The same function as is realized by Java class 70.

本実施形態では、オリジナルスーパークラス65(図示例では「Structクラス」)は、フィールド用アノテーション75Bが含む第4引数75B4(「occurs」)の値に基づいて、フィールド73−1、73−2が配列に対応することを特定し、当該配列に対応した固定長バイト配列80−1、80−2に基づいて、フィールド73−1、73−2に値を設定する機能を有することで、「COBOL」の配列と同等の機能が実現されている。
例えば、図9において、単一のデータ項目形式の配列に対応したフィールド73−1について、オリジナルスーパークラス65は、フィールド73−1の「String[]」の各配列要素に「CHAR_VALUE[0]=”A1”」、「CHAR_VALUE[1]=”A2”」となるように値を設定する。
また、集団項目形式の配列に対応したフィールド73−2について、オリジナルスーパークラス65は、フィールド73−2の「STRUCT_CHILD[]」の各配列要素に、次のように値を設定する。すなわち、オリジナルスーパークラス65は、「STRUCT_CHILD[0]」に「String=”B”」と「short=+10」の値を設定し、「STRUCT_CHILD[1]」に「String=”C”」と「short=+11」の値を設定する。
In the present embodiment, the original super class 65 (“Struct class” in the illustrated example) has fields 73-1 and 73-2 based on the value of the fourth argument 75B4 (“occurs”) included in the field annotation 75B. By specifying that it corresponds to an array and having a function of setting a value in fields 73-1 and 73-2 based on the fixed-length byte arrays 80-1 and 80-2 corresponding to the array, "COBOL" The same function as the array of "" is realized.
For example, in FIG. 9, for field 73-1 corresponding to an array of single data item format, the original superclass 65 puts "CHAR_VALUE [0] =" in each array element of "String []" in field 73-1. The values are set so that "A1" and "CHAR_VALUE [1] =" A2 "".
Further, for the field 73-2 corresponding to the array of the group item format, the original superclass 65 sets the value in each array element of "STRUCT_CHILD []" of the field 73-2 as follows. That is, in the original super class 65, the values of "String =" B "" and "short = + 10" are set in "STRUCT_CHILD [0]", and "String =" C "" and "String =" C "" are set in "STRUCT_CHILD [1]". Set the value of "short = +11".

図10は、COBOLにおける「再定義」を含む集団項目50と、Javaにおけるクラス70との対応を示す図である。
集団項目50の中において、「再定義」は、「REDEFINES句」を用いて宣言され、図10の例では、「YYYYMMDD」が「REDEFINES句」によって「YYMMDD_R」として再定義されている。また、同図において、「YYYYMMDD」は年月日を8桁の文字列数字(年が3桁、月及び日がそれぞれ2桁)で示す基本項目51であり、「YYMMDD_R」は年月日を6桁の文字列数字(年、月、及び日がそれぞれ2桁)で示す基本項目61として定義されている。
そして、かかる「YYYYMMDD」は、コンパイラによってコンパイルされると、8個の配列要素から成る固定長バイト配列80に変換され、各配列要素には、年月日の各桁の文字列数字を16進数によって表記した値が格納される。
FIG. 10 is a diagram showing the correspondence between the group item 50 including “redefinition” in COBOL and the class 70 in Java.
In the group item 50, "redefinition" is declared using the "REDDEFINES clause", and in the example of FIG. 10, "YYYYMMDD" is redefined as "YYMMDD_R" by the "REDDEFINES clause". Further, in the figure, "YYYYMMDD" is a basic item 51 indicating the date as an 8-digit character string number (3 digits for the year and 2 digits for the month and day), and "YYMMDD_R" indicates the date. It is defined as a basic item 61 indicated by a 6-digit character string number (2 digits each for year, month, and day).
Then, when the "YYYYMMDD" is compiled by the compiler, it is converted into a fixed-length byte array 80 consisting of eight array elements, and each array element contains a character string number of each digit of the date in hexadecimal. The value indicated by is stored.

図10の例は、「YYYYMMDD」が示す年月日が「2021年08月10日」である場合を示しており、かかる年月日を示す8桁の文字列数値は16進数表記を用いると、「32」「30」「32」「31」「30」「38」「31」「30」と表記され、これらの各値が固定長バイト配列80の各配列要素に格納される。
一方、「YYMMDD_R」については、図10における「03 FILLER PIC X(02)」によって固定長バイト配列80の0番目(i=0)及び1番目(i=1)の配列要素が無視され、「03 YYMMDD PIC X(06)」によって固定長バイト配列80の2番目(i=2)から7番目(i=7)までの配列要素が参照される。
The example of FIG. 10 shows the case where the date indicated by "YYYYMMDD" is "August 10, 2021", and the 8-digit character string numerical value indicating the date is expressed in hexadecimal notation. , "32", "30", "32", "31", "30", "38", "31", and "30", and each of these values is stored in each array element of the fixed-length byte array 80.
On the other hand, for "YYMMDD_R", the 0th (i = 0) and 1st (i = 1) array elements of the fixed-length byte array 80 are ignored by "03 FILLER PIC X (02)" in FIG. 03 YYMMDD PIC X (06) ”refers to the array elements from the second (i = 2) to the seventh (i = 7) of the fixed-length byte array 80.

集団項目コンバータ34が、かかる集団項目50をJavaのクラス70に変換する場合、先ず、基本項目51の階層構造及び従属関係に対応する親子関係の親クラス71、及び子クラス72を定義する。図10の例では、集団項目コンバータ34は、集団項目50の「01 REDEFINES_STRUCT」に対応する「class REDEFINES_STRUCT」を親クラス71として定義し、「02 YYMMDD_R REDEFINES YYYYMMDD」に対応する「class YYMMDD_R」を子クラス72として定義する。 When the group item converter 34 converts such a group item 50 into a Java class 70, first, the parent class 71 and the child class 72 of the parent-child relationship corresponding to the hierarchical structure and the dependency relationship of the basic item 51 are defined. In the example of FIG. 10, the group item converter 34 defines "class REDDEFINES_STRUCT" corresponding to "01 REDEFINES_STRUCT" of the group item 50 as the parent class 71, and "class YYMMDD" corresponding to "02 YYMMDD_R REDEFINES YYYYMMDD". Defined as class 72.

次いで、集団項目コンバータ34は、クラス用アノテーション75A及びフィールド用アノテーション75Bをクラス70に付与する。この場合において、再定義句に対応するフィールド73(図10における「Public YYMMDD_R YYMMDD_R;」)に付与するフィールド用アノテーション75Bは、再定義元の基本項目51を示す第5引数75B5(図示例、「redefines」)を含んでおり、この第5引数75B5によって再定義に関する情報がクラス70に記述される。そして、この第5引数75B5と、固定長バイト配列80に関する情報を示す上述した他の引数(第2引数75A2、75B2、第3引数75B3)とによって、COBOLにおける「再定義」と同等の機能がJavaのクラス70によって実現されることとなる。 Next, the group item converter 34 assigns the annotation 75A for the class and the annotation 75B for the field to the class 70. In this case, the field annotation 75B assigned to the field 73 (“Public YYMMDD_R YYMMDD_R;” in FIG. 10) corresponding to the redefinition clause is the fifth argument 75B5 (illustration example, “Public YYMMDD_R YYMMDD_R;”) indicating the basic item 51 of the redefinition source. "Redefines") is included, and the information regarding the redefinition is described in the class 70 by this fifth argument 75B5. Then, the fifth argument 75B5 and the other arguments described above (second argument 75A2, 75B2, third argument 75B3) indicating information about the fixed-length byte array 80 provide the same function as "redefinition" in COBOL. It will be realized by Java class 70.

なお、JavaソースNJにおいて、再定義先に対応する子クラス72(図10における「class YYMMDD_R」)のフィールド73(図10における「String YYMMDD;」)の更新は、図11に示すSetterメソッド77を子クラス72に追加し、再定義先に対応する子クラス72の変更を再定義元に対応する親クラス71に反映することで可能である。同図において、かかる反映のためのプロセスがロジック部77Aにコーディングされている。 In the Java source NJ, the field 73 (“String YYMMDD;” in FIG. 10) of the child class 72 (“class YYMMDD_R” in FIG. 10) corresponding to the redefinition destination is updated by the Setter method 77 shown in FIG. It is possible by adding to the child class 72 and reflecting the change of the child class 72 corresponding to the redefinition destination in the parent class 71 corresponding to the redefinition source. In the figure, the process for such reflection is coded in the logic unit 77A.

本実施形態によれば、次の効果を奏する。 According to this embodiment, the following effects are obtained.

本実施形態のソースコード変換装置1は、集団項目50が記述されたCOBOLソースNCをJavaソースNJに変換する装置であって、集団項目コンバータ34を備える。
集団項目コンバータ34は、集団項目50が含む基本項目51の階層構造、及び従属関係に対応する親子関係を有した親クラス71、及び子クラス72を含む、プリミティブ型のクラス70に集団項目50を変換する。また集団項目コンバータ34は、集団項目50の基本項目51の値が並んだ固定長バイト配列80に関する情報を示すクラス用アノテーション75A及びフィールド用アノテーション75Bをクラス70に付与する。
The source code conversion device 1 of the present embodiment is a device that converts a COBOL source NC in which a group item 50 is described into a Java source NJ, and includes a group item converter 34.
The group item converter 34 puts the group item 50 into the primitive class 70 including the hierarchical structure of the basic item 51 included in the group item 50, the parent class 71 having the parent-child relationship corresponding to the dependency relationship, and the child class 72. Convert. Further, the group item converter 34 assigns the class annotation 75A and the field annotation 75B indicating information about the fixed-length byte array 80 in which the values of the basic item 51 of the group item 50 are arranged to the class 70.

この構成によれば、集団項目50を変換したクラス70がプリミティブ型であるため、Javaの開発環境、及び実行環境が特別なライブラリをインポートせずともクラス70を使用でき、変換後のJavaソースNJの汎用性、及び保守性が大幅に向上する。
加えて、クラス70は、固定長バイト配列80に関する情報を含むクラス用アノテーション75A及びフィールド用アノテーション75Bが付与されため、固定長バイト配列80に関する処理を、クラス用アノテーション75A及びフィールド用アノテーション75Bを用いて実現することができる。
さらに、クラス用アノテーション75A及びフィールド用アノテーション75Bは、クラス70に付随する形でJavaソースNJに記述されるため可読性を向上させることができる。
According to this configuration, since the class 70 obtained by converting the group item 50 is a primitive type, the class 70 can be used without importing a special library in the Java development environment and execution environment, and the converted Java source NJ can be used. The versatility and maintainability of the are greatly improved.
In addition, since the class 70 is given the annotation 75A for the class and the annotation 75B for the field containing the information about the fixed-length byte array 80, the processing related to the fixed-length byte array 80 is performed by using the annotation 75A for the class and the annotation 75B for the field. Can be realized.
Further, since the annotation 75A for the class and the annotation 75B for the field are described in the Java source NJ in a form accompanying the class 70, the readability can be improved.

本実施形態のソースコード変換装置1において、基本項目51に対応するフィールド73に付与されるフィールド用アノテーション75Bは、対応する基本項目51のデータ型54の情報を含んでいる。
この構成によれば、COBOLの複数のデータ型54が1つのプリミティブ型に対応付けられていても、各データ型54をフィールド用アノテーション75Bによって正しく識別できる。
In the source code conversion device 1 of the present embodiment, the field annotation 75B given to the field 73 corresponding to the basic item 51 includes the information of the data type 54 of the corresponding basic item 51.
According to this configuration, even if a plurality of COBOL data types 54 are associated with one primitive type, each data type 54 can be correctly identified by the field annotation 75B.

本実施形態のソースコード変換装置1において、集団項目コンバータ34は、クラス用アノテーション75A及びフィールド用アノテーション75Bに基づいて、固定長バイト配列80へのアクセスを含むメソッドを有した独自定義のオリジナルスーパークラス65を継承した親クラス71を生成する。 In the source code conversion device 1 of the present embodiment, the group item converter 34 is an original superclass of an original definition having a method including access to the fixed-length byte array 80 based on the annotation 75A for the class and the annotation 75B for the field. Generate a parent class 71 that inherits 65.

この構成によれば、固定長バイト配列80を扱う処理のコーディングに要する労力を低減することができる。 According to this configuration, it is possible to reduce the labor required for coding the process for handling the fixed-length byte array 80.

なお、上述した実施形態は、あくまでも本発明の一態様の例示であり、本発明の主旨を逸脱しない範囲において任意に変形、及び応用が可能である。 It should be noted that the above-described embodiment is merely an example of one aspect of the present invention, and can be arbitrarily modified and applied without departing from the gist of the present invention.

上述した実施形態において、集団項目コンバータ34は、固定長バイト配列80に関する情報を示すアノテーションとして、クラス用アノテーション75A及びフィールド用アノテーション75Bの2種類のアノテーションを生成した。しかしながら、アノテーションの態様は、固定長バイト配列80に関する情報を示すものでれば任意である。 In the above-described embodiment, the group item converter 34 generates two types of annotations, a class annotation 75A and a field annotation 75B, as annotations indicating information about the fixed-length byte array 80. However, the form of annotation is arbitrary as long as it shows information about the fixed-length byte array 80.

上述した実施形態において、上記プログラム18は、COBOLソースNCの全部をJavaソースNJに変換する機能を実現するものではなく、少なくとも集団項目コンバータ34の機能を実現するものであってもよい。
この場合、プログラム18は、COBOLソースNCに記述される集団項目50が含む基本項目51の階層構造、及び従属関係に対応する親子関係を有した親クラス71、及び子クラス72を含む、Javaにおけるプリミティブ型のクラス70を定義することと、集団項目50の基本項目51の値が並んだ固定長バイト配列80に関する情報を示すアノテーションをクラス70に付与することと、をコンピュータに実行させるものとなる。
コンピュータがプログラム18を実行することで、COBOLソースNCに記述される集団項目50に対応するクラス70を生成する。
なお、光ディスクや可搬型半導体メモリ等の記録媒体にプログラム18を記録することで、又は、電気通信回線を通じて送信することで、当該プログラム18を頒布可能である。
In the above-described embodiment, the program 18 does not realize the function of converting all of the COBOL source NC into the Java source NJ, but may at least realize the function of the collective item converter 34.
In this case, the program 18 is in Java, which includes the hierarchical structure of the basic item 51 included in the group item 50 described in the COBOL source NC, and the parent class 71 and the child class 72 having a parent-child relationship corresponding to the dependency relationship. It is to make the computer execute the definition of the class 70 of the primitive type and the addition of the annotation indicating the information about the fixed-length byte array 80 in which the values of the basic item 51 of the group item 50 are arranged to the class 70. ..
When the computer executes the program 18, the class 70 corresponding to the group item 50 described in the COBOL source NC is generated.
The program 18 can be distributed by recording the program 18 on a recording medium such as an optical disk or a portable semiconductor memory, or by transmitting the program 18 through a telecommunication line.

図1及び図2に示す機能ブロックは、本願発明を理解容易にするために、構成要素を主な処理内容に応じて分類して示した概略図であり、各構成要素は、処理内容に応じて、さらに多くの構成要素に分類することもできる。また、1つの構成要素がさらに多くの処理を実行するように分類することもできる。 The functional blocks shown in FIGS. 1 and 2 are schematic views showing the components classified according to the main processing contents in order to make the invention of the present application easy to understand, and each component corresponds to the processing contents. It can also be classified into more components. It can also be categorized so that one component performs more processing.

1 ソースコード変換装置
22 変換処理部
30 言語変換部
32 COBOLコンパイラ
34 集団項目コンバータ
36 解析結果
37 型対応データ
42 データ部
50 集団項目
51 基本項目
54 データ型
65 オリジナルスーパークラス
70 クラス
71 親クラス
72 子クラス
73 フィールド
75A クラス用アノテーション
75B フィールド用アノテーション
80 固定長バイト配列
NC COBOLソース
NJ Javaソース
1 Source code converter 22 Conversion processing unit 30 Language conversion unit 32 COBOL compiler 34 Group item converter 36 Analysis result 37 type Corresponding data 42 Data unit 50 Group item 51 Basic item 54 Data type 65 Original super class 70 Class 71 Parent class 72 Child Class 73 Field 75A Class Annotation 75B Field Annotation 80 Fixed Length Byte Array NC COBOL Source NJ Java Source

Claims (4)

集団項目が記述されたCOBOLのソースコードをJavaのソースコードに変換するソースコード変換装置において、
前記集団項目が含む基本項目の階層構造、及び従属関係に対応する親子関係を有した親クラス、及び子クラスを含む、プリミティブ型のクラスに前記集団項目を変換する集団項目コンバータを備え、
前記集団項目コンバータは、
前記集団項目の前記基本項目の値が並んだ固定長バイト配列に関する情報を示すアノテーションを前記クラスに付与する
ことを特徴とするソースコード変換装置。
In a source code conversion device that converts a COBOL source code in which a group item is described into a Java source code.
It is provided with a group item converter that converts the group item into a primitive type class including a hierarchical structure of the basic items included in the group item, a parent class having a parent-child relationship corresponding to a dependency relationship, and a child class.
The collective item converter
A source code conversion device characterized in that an annotation indicating information regarding a fixed-length byte array in which the values of the basic items of the group item are arranged is added to the class.
前記アノテーションは、
前記基本項目のデータ型の情報を含む
ことを特徴とする請求項1に記載のソースコード変換装置。
The annotation is
The source code conversion device according to claim 1, wherein the information of the data type of the basic item is included.
前記集団項目コンバータは、
前記アノテーションに基づいて前記固定長バイト配列へのアクセスを含むメソッドを有したスーパークラスを継承した前記親クラスを生成する
ことを特徴とする請求項1または2に記載のソースコード変換装置。
The collective item converter
The source code conversion device according to claim 1 or 2, wherein the parent class inherits the superclass having a method including access to the fixed-length byte array based on the annotation.
COBOLのソースコードに記述される集団項目が含む基本項目の階層構造、及び従属関係に対応する親子関係を有した親クラス、及び子クラスを含む、Javaにおけるプリミティブ型のクラスを定義することと、
前記集団項目の前記基本項目の値が並んだ固定長バイト配列に関する情報を示すアノテーションを前記クラスに付与することと、
をコンピュータに実行させるプログラム。
To define a primitive type class in Java, including a hierarchical structure of basic items included in the group items described in the COBOL source code, a parent class having a parent-child relationship corresponding to a dependent relationship, and a child class.
Annotating the class with information about a fixed-length byte array in which the values of the basic items of the group item are arranged is added.
A program that causes a computer to run.
JP2021145203A 2021-09-07 2021-09-07 Source code converter and program Active JP6982920B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2021145203A JP6982920B1 (en) 2021-09-07 2021-09-07 Source code converter and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2021145203A JP6982920B1 (en) 2021-09-07 2021-09-07 Source code converter and program

Publications (2)

Publication Number Publication Date
JP6982920B1 true JP6982920B1 (en) 2021-12-17
JP2023038463A JP2023038463A (en) 2023-03-17

Family

ID=79170014

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2021145203A Active JP6982920B1 (en) 2021-09-07 2021-09-07 Source code converter and program

Country Status (1)

Country Link
JP (1) JP6982920B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP7287725B1 (en) 2022-09-07 2023-06-06 株式会社Shift SOURCE CODE CONVERSION DEVICE, SOURCE CODE CONVERSION METHOD, AND SOURCE CODE CONVERSION PROGRAM

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016115070A (en) * 2014-12-12 2016-06-23 Tis株式会社 Program conversion system
JP2016115071A (en) * 2014-12-12 2016-06-23 Tis株式会社 Program conversion system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016115070A (en) * 2014-12-12 2016-06-23 Tis株式会社 Program conversion system
JP2016115071A (en) * 2014-12-12 2016-06-23 Tis株式会社 Program conversion system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP7287725B1 (en) 2022-09-07 2023-06-06 株式会社Shift SOURCE CODE CONVERSION DEVICE, SOURCE CODE CONVERSION METHOD, AND SOURCE CODE CONVERSION PROGRAM
JP2024037601A (en) * 2022-09-07 2024-03-19 株式会社Shift Source code conversion device, source code conversion method, and source code conversion program

Also Published As

Publication number Publication date
JP2023038463A (en) 2023-03-17

Similar Documents

Publication Publication Date Title
US9182962B2 (en) Method for translating a cobol source program into readable and maintainable program code in an object oriented second programming language
CN102402451B (en) Compile-time bounds checking for user-defined types
Smith Extending SUIF for machine-dependent optimizations
JP5974191B2 (en) A method for modeling source code having code segments that lack a source location
US20120167065A1 (en) Compiler compiler system with syntax-controlled runtime and binary application programming interfaces
Metcalf et al. Modern Fortran Explained: Incorporating Fortran 2023
Verwaest et al. Flexible object layouts: enabling lightweight language extensions by intercepting slot access
Fritzson et al. Towards Modelica 4 meta-programming and language modeling with MetaModelica 2.0
JP6982920B1 (en) Source code converter and program
TW200416569A (en) System and method for defining and using subclasses declaratively within markup
US7386840B1 (en) Method, apparatus, and program for source code translation from COBOL to object-oriented code
JP5600301B2 (en) System representation and handling technology
Bergeron et al. Systems programming languages
Blagodarov et al. Tool demo: Raincode assembler compiler
Monnier et al. Evolution of emacs lisp
CN102365622B (en) Translation device, translation method, and storage medium for program
Dillig et al. SAIL: Static analysis intermediate language with a two-level representation
Berz et al. COSY INFINITY 10.2
Hogenson Foundations of C++/CLI: the visual C++ language for. Net 3.5
Mössenböck C# to the Point
Curlett Flexible method for inter-object communication in C++
Falvo BN-Hermes: a decompilation and analysis plugin for react native's Hermes bytecode
Feldman Edward W. Czeck
Ahmad et al. Unification of Programming Languages.
Mattsson Implementation of concurrent Pascal on LSI—11

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20210907

A871 Explanation of circumstances concerning accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A871

Effective date: 20210907

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20211109

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20211115

R150 Certificate of patent or registration of utility model

Ref document number: 6982920

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150