Home

Fujitsu J Adapter Class Generator User's Manual

image

Contents

1. Method name Type Function NEW ARRAY Factory Generates an array object GET ARRAY LENGTH Object Obtains the number of elements of an array GET ARRAY ELEMENT Object Fetches a value from an array element SET ARRAY ELEMENT Object Sets a value in an array element 5 An n dimensional array is handled as a one dimensional array having an n 1 dimensional array as an element Therefore for n dimensional array n adapter classes J A n XYZ J A n 1 XYZ JA 1 XYZ are generated J A n XYZ is a one dimensional array having J A n 1 XYZ as an element Generation example The adapter class for java lang String is generated as shown below Chapter 5 Adapter Class Reference 67 CLASS ID JA 1 STRING AS JA 1 java lang String INHERITS J OBJECT END CLASS JA 1 STRING Adapter classes of int are generated as shown below CLASS ID JA 3 INT AS JA 3 int INHERITS J OBJECT END CLASS JA 3 INT CLASS ID JA 2 INT AS JA 2 int INHERITS J OBJECT END CLASS JA 2 INT CLASS ID JA 1 INT AS JA 1 int INHERITS J OBJECT END CLASS JA 1 INT 1 One dimensional array having a JA 2 int class object as an element 2 One dimensional array having a J A 1 int class object as an element 3 One dimensional array having int as an element Note No array exceeding 9 dimensions can be handled NEW ARRAY method factory method Explanation This method generates an array object Syntax INVOKE
2. Note The way of assigning numbers may be different depending on the order adapter classes are generated Use the same generation name management file to generate adapter classes to be used under the same environment Supplement e These naming rules also apply to class methods e java fields variables class instance are associated with COBOL property methods The same rules as those for methods also apply to property methods e The way of assigning numbers may be different depending on the version of J DK or J 2SDK used for adapter class generation Chapter 6 Messages This chapter explains the messages output by the J adapter class generator including the operator responses to the messages 74 Chapter 6 Messages Java2cob Command Messages This section explains the messages output by the java2cob command including the operator responses to the messages Adapter class generation failed because of a memory space shortage Terminate unnecessary applications and retry A memory space shortage occurred Terminate unnecessary applications then reenter the java2cob command Java VM could not be started Check the J DK environment definition PATH CLASSPATH and J DK installation The J DK or J 2SDK environment contains an error Check whether environment variables PATH and CLASSPATH are set normally and whether J DK or J 2SDK is installed normally Java2cob class loading failed Reinstall the J adapter class gene
3. ad E Java VM initialization 1 INVOKE FuJ JAVA CONTROL JYM INIT helek AIL connection to Java VM Thread initiation INVOKE J xXXx Adapter class invocation Disconnection Java VM sn Le and INVOKE FJ JAVA CONTROL JYM TERMINATE java VM termination 3 1 Initialization of Java YM is performed only for the first calling of JYM INIT or JYM ATTACH 2 End of Java YM is performed only for the last calling of JYM TERMINATE Figure 3 2 Generating an Object Generate an object by invoking the adapter class factory method corresponding to the constructor Generate the factory method with the following name see Constructor Create JavaClassName nn nn is 01 to 99 24 Chapter 3 Developing Programs An example of generating a Date class object is shown below REPOSITORY CLASS J Date AS java util Date WORKING STORAGE SECTION 01 anDate OBJECT REFERENCE J Date PROCEDURE DIVISION INVOKE J Date Create Date 01 RETURNING anDate Note e Since the adapter class name is very long it is recommended that an alias be assigned by specifying AS in the REPOSITORY paragraph Invoking a Method Invoke an instance method by invoking the corresponding adapter class object method The method name is the same as that of Java However if more than one method is defined with the same name append a numeric suffix to distinguish them see Class method and Instance method An example of invoki
4. Bin gt 4 IE S gt Seventh Edition August 2005 The contents of this manual may be revised without prior notice No part of this document may be reproduced or transmitted in any form or by any means electronic or mechanical for any purpose without the express written permission of Fujitsu Limited O 1996 2005 Fujitsu Limited All Rights Reserved Preface The NetCOBOL Adapter Class Generator is a tool that generates a COBOL class adapter class used to call a Java class Using the adapter class thus generated makes the J ava class library available from COBOL A Java runtime environment must be installed to execute the generator or the adapter class generated See Preparations for required products Purpose of This Manual This manual provides information on how to enable COBOL programs to use J ava classes The information includes the ways of creating adapter classes writing programs and running the programs Refer to the Fujitsu NetCOBOL Language Reference for the COBOL syntax For information on how to develop programs using Fujitsu NetCOBOL refer to the Fujitsu NetCOBOL User s Guide Intended Readers This manual is intended for persons who develop COBOL programs using J ava classes Prerequisites Readers are required to have the following knowledge to read this manual e Basic knowledge of COBOL syntax e Basic knowledge of COBOL object oriented programming e Basic knowledge of J ava
5. Organization of This Manual This manual consists of the following chapters Chapter 1 Outline of J Adapter Class Generator Chapter 1 explains the function and operating environment of the J adapter class generator Chapter 2 J Adapter Class Generator Framework Chapter 2 explains the framework of the J adapter class generator Chapter 3 Developing Programs Chapter 3 explains how to develop programs that uses J ava classes Chapter 4 Using the Generator Command Chapter 4 explains how to use the generator command java2cob NetCOBOL J Adapter Class Generator User s Guide 3 Chapter 5 Adapter Class Reference Chapter 5 provides detailed information on the FJ J AVA BASE FJ J AVA CONTROL and FJ J AVA ERROR classes provided by the J adapter class generator and adapter classes generated by the J adapter class generator Appendix A Message List Appendix A explains the messages output by the J adapter class generator including the operator responses to the messages Appendix B Exception Type List The Appendix B describes the types of exception generated by the J adapter class generator and their remedial measures How to Use This Manual When using the J adapter class generator for the first time begin to read from Chapter 1 Chapter 1 provides an outline of the J adapter class generator Chapter 2 explains the framework and Chapter 3 explains the procedures from development to execution Chapters 4 and 5 provide
6. Java2 J 2SDK 1 2 2 or later open project file DATEO1J AVA2 PRJ 2 Select Build from the Project menu An adapter class DLL DATE DLL is generated 3 Open project file DATEMAIN PR 4 Select Build from the Project menu Running the program Run the executable program from the MS DOS prompt The date and time are displayed Chapter 7 Samples 83 Sample 2 Specifying Method Example 2 Example of generating an adapter class by specifying constructor method field This program description explains Sample Program Example 2 provided with this product Example 2 shows how to generate the adapter class specifying constructor method field Outline The program contents are the same as example 1 However example 2 generates the adapter class specifying the Java constructor method field name used by the program Distribution files JADPO02 TXT program description JAVA2COB MGT generation name management file DATEMAIN PR project file DATEMAIN CBI compiler option file DATEMAIN COB COBOL source program DATEO2 AVA PR project file DATEO02J AVA CBI compiler option file DATEO02J AVA2 PR project file DATE02J AVA2 CBI compiler option file COBOL functions used Object oriented programming functions Object generation Method invocation Java classes and constructor method field used java lang System class out field java io PrintStream class printin java lan
7. OUT which is the uppercase of the Java field name to J F Chapter 5 Adapter Class Reference 57 2 out is mapped to J PRINTSTREAM internal class name of java io PrintStream because its attribute is java io PrintStream Supplement When a property name is generated from a field name a number is assigned to secure the uniqueness of the name The class browser can be used to check the correspondence between fields and properties Class method Explanation A public class method static method is mapped to a COBOL factory method Expansion format METHOD ID internal method name AS external method name OVERRIDE DATA DIVISION LINKAGE SECTION parameter return value PROCEDURE DIVISION USING parameter RETURNING return value RAISING exception class name END METHOD internal method name Generation rules 1 The internal method name is internally used by the J adapter class generator and cannot be viewed from the class user 2 The external method name is used to identify the method The class user identifies the method with the external method name 3 An external method name is generated according to the following rules JavaMethodName nn A Java method name is used as is as a COBOL method name Ifa same method name has already been assigned the second and subsequent method names are each suffixed with a hyphen followed by a two digit number 01 to 99 to prevent
8. Determines national data item length NEW STRI NG X method factory method Explanation This method generates a String object having the character string specified for the alphanumeric data item as an initial value Syntax INVOKE class name NEW STRING X USING nit alvalue RETURNING createdObject 62 Chapter 5 Adapter Class Reference Parameter and return value e class name Specifies the internal class name of the java lang String class declared in the REPOSITORY paragraph e _initialValue attribute PIC X ANY LENGTH Specifies an alphanumeric data item as the initial value of the String object e createdObject attribute OBJECT REFERENCE SELF Returns the generated object Supplement When a data name is specified for initialValue a String object as long as data item length is generated However inserting X 00 in the statement can generate a String object shorter than data item length REPOSITORY CLASS J String AS java lang String WORKING STORAGE SECTION 01 initialValue PIC X 50 01 aString OBJECT REFERENCE J String PROCEDURE DIVISION MOVE ABC TO initialValue INVOKE J String NEW STRING X USING initialValue RETURNING aString 1 MOVE ABC amp X 00 TO initialValue INVOKE J String NEW STRING X USING initialValue RETURNING aString 2 1 A String object consisting of 50 characters with the last 47 character area padded with blanks is generated 2 A String o
9. aString 28 Chapter 3 Developing Programs If an adapter class is generated by specifying the t option or the Option Terminal parameter the character string that is shorter than the data item length can be passed to a method without setting the end of string since the end X 00 of the character string is set in the adapter class The following example shows that ABC is copied to alphanumeric item initialValue having the length of 50 characters and is passed to the NEW STRING X method REPOSITORY CLASS J String AS java lang String WORKING STORAGE SECTION 01 initialValue PIC X 50 01 aString OBJECT REFERENCE J String PROCEDURE DIVISION MOVE ABC TO initialValue INVOKE J String NEW STRING X USING initialValue RETURNING aString Exception Processing When an adapter class detects an error during processing the exception object is generated FJ JAVA ERROR class is the class of the exception object In order to detect an exception generated in the adapter class using the exception object the exception handling needs be described in the declaratives of the procedure division of the program using the USE statement When the method of the FJ JAVA ERROR class is used in the exception handling the exception message exception type and J ava exception information can be extracted For the details of the exception handling using the USE statement refer to Defining Exception Processes of the Fujitsu N
10. accomplished by creating the optional file Refer to the paragraph When the optional file is specified of command syntax Format The parameters that can be placed in an optional file are as follows Parameter name Explanation Note Class c ass name interface name Specify a class name or interface name of Java that generates the adapter class If necessary specify the constructor method field generated as an adapter class Omission is not allowed Multiple settings are allowed Option ClassPath Specify a search path of the J ava class interface Omission is allowed Multiple setting is not allowed Option Code Specify a code system during execution time Omission is allowed Multiple setting is not allowed Option Specify directly options of the java2cob Omission is allowed CommandOptions command Multiple setting is not Option GenOnlyUsed Specify whether or not to specify a constructor method field generated as an adapter class allowed Omission is allowed Multiple setting is not allowed Option MethodTable Specify whether or not to output the method name cross reference list file Omission is allowed Multiple setting is not allowed Option OutPutPath Specify a folder to output the source of the adapter class Omission is allowed Multiple setting is not allowed Option OverWrite Option ReduceClass Specify to overwrite an existing adapter c
11. adapter class generator was executed A constructor was executed in an abstract class The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface Type conversion failed Check the parameter passed to the J NARROW method The object specified in the parameter is not a subclass or object of the class Check the parameter passed to the J NARROW method No J ava field is found Check whether the J ava class interface was changed after execution of the J adapter class generator The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface Java class initialization failed Call the adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 92 Appendix A Message List No J ava method is found Check whether the J ava class interface was changed after execution of the J adapter class generator The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface The character string could not be fetched from the String object Call the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer The subscript of the array object is invalid Specify a subscript within the array range The subscript val
12. as follows Microsoft Windows and Windows NT are registered trademarks of Microsoft Corporation in the U S and other countries Java and other trademarks including Java are trademarks of Sun Microsystems Inc in the U S and other countries J Adapter Class Generator User s Guide 5 6 NetCOBOL J Adapter Class Generator User s Guide Contents Chapter 1 Outline of J Adapter Class Generator nnnvrnnnnvnnnnvnnnnnnnnnnnnnnvennner 9 What is the J Adapter Class Generator 10 What the J Adapter Class Generator Can Do 11 What the J Adapter Class Generator Cannot DO see eee eee 11 Preparation fente an en deal ei i eed ea 52 12 Chapter 2 Adapter Class Generator Framework nrrnnnxvnnnnvnnnnnnnnnnvnnnnnnnnunen 13 Adapter Class tnt sen Aided ask el eee ee 14 Adapter Object ccaveeshe tina depots dd aaa a a MeloMles ida endce act adel 15 Chapter 3 Developing Programs ansxnnnsannnnnnnnnnnnnnnnnnnnnnnnnnunnnnnnnnnnnnnnnnnnnnnnnen 17 Creating Adapter ClasseSnnansdassvadtsatmnaismdr able acheter 18 Developing an Application That Uses an Adapter Class see eee 22 Running Programman pennn knr fee ae ee ie 29 Conversion to Java2 Lakes eder gea 30 Chapter 4 Using the Generator Command asanannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnuen 31 Starting the J Adapter Class Generator 32 Optional Fe ata SE 36 OUP LR Re Dekan NER 42 Chapter 5 Adapter Class Reference sssansannnnnnnnnnnnnnnunnnnnnnunnnnnnnnnnnnnnnnnnnnnnuen 45 Class Configu
13. available to COBOL a mechanism for converting the J ava class interface into the COBOL interface is required The J adapter class generator works as an interface converting mechanism to generate adapter classes corresponding to Java classes To use a Java class from a COBOL program the adapter class created by the generator can be called The adapter class is written in COBOL and therefore can be called in the same manner as a COBOL class The relationship between the J ava class interface and adapter class is shown below J adapter class generator COBOL class COBOL adapter class Java class interface INVOKE Bo ok om o 2 as o gt go E So gt D Y Interface conversion Java interface COBOL interface Figure 2 1 Java class interface and adapter class Chapter 2 Adapter Class Generator Framework 15 Adapter Object At execution time an adapter class generates the adapter object corresponding to a Java instance object The adapter object e Holds the pointer to the corresponding J ava instance object e Calls the corresponding J ava method of the corresponding J ava instance object Only the adapter object can be seen from the COBOL program Every operation on the adapter object is transmitted to the corresponding J ava object To the COBOL program the adapter object seems as if it were a J ava object The adapter object since it works for the J ava object is also cal
14. detailed information on how to use commands and classes Read these chapters for program development The Appendix A describes the messages that are output form the J adapter class generator and the Appendix B describes the exception types that the J adapter class generator sets Read them as necessity requires Product Names Microsoft Windows NTR Workstation Operating System Version 4 0 Product Name Abbreviation Microsoft Windows 98 Operating System Windows 98 Microsoft Windows Me Operating System Windows Me Windows NT or Windows NT 4 0 Microsoft Windows NT Server Network Operating System Version 4 0 Windows NT or Windows NT 4 0 Microsoft Windows NT Server Network Operating System Enterprise Edition Version 4 0 Microsoft Windows 2000 Professional Operating System Windows NT or Windows NT 4 0 Windows 2000 or Windows 2000 Professional Microsoft Windows 2000 Server Operating System Windows 2000 or Windows 2000 Server Microsoft Windows 2000 Advanced Server Operating System Windows 2000 or Windows 2000 Server Microsoft Windows 2003 Server Operating System Windows 2003 or Windows 2000 Server Windows 98 Windows Me Windows NT and Windows 2000 Windows NetCOBOL J Adapter Class Generator User s Guide Registered Trademarks The registered trademarks appearing in this manual are
15. mapped into PIC X ANY LENGTH e Return values of the java lang String type in the method e Argument of the java lang String type in the constructor and method e Fields class variables and instance variables of the java lang String type Example When the s option and Option String parameter are not specified the conversion between the String object and the COBOL data items must be performed in the user s application using the java lang String class method such as NEW STRING X and GET STRING X REPOSITORY CLASS J Date AS java util Date CLASS J String AS java lang String CLASS J DateFormat AS java text DateFormat WORKING STORAGE SECTION 01 aDateFormat OBJECT REFERENCE J DateFormat 01 aDate OBJECT REFERENCE J Date 01 dateString OBJECT REFERENCE J String 01 dateValue PIC X 30 PROCEDURE DIVISION MOVE 2000 01 01 amp X 00 TO dateValue INVOKE J String NEW STRING X USING dateValue RETURNING dateString INVOKE aDateFormat parse USING dateString RETURNING aDate INVOKE aDate toString RETURNING dateString INVOKE dateString GET STRING X RETURNING dateValue Chapter 3 Developing Programs 27 kr When the s option or the Option String parameter is specified the conversion between the String object and the COBOL data items is not necessary since an alphanumeric item can be specified as the String type argument and returns a value directly REPOSITORY CLASS J Date AS java util Date CLASS
16. rules are used For instance Java permits multiple methods with the same name to be defined within the same class if they have different parameters while COBOL does not permit such definition In this case methods with the same name in Java must be generated so that they correspond to different names in COBOL The J adapter class generator generates a unique name from each corresponding J ava name by adding a hyphen followed by a number This section explains the rules of assigning numbers to names used for adapter classes Effective range of name The names handled by the J adapter class generator are classified into the following three types depending on the effective range of a name e Name that is always unique according to generation rules Class name Array class name e Name that needs to be unique between super classes subclasses Factory method name corresponding to constructor e Name that needs to be unique within an entire run unit Method name class instance Field variable name class instance 70 Chapter 5 Adapter Class Reference Name that is always unique according to generation rules A class name is generated from a class name or interface name qualified by a J ava package name Since the qualified name is unique the COBOL name generated from it is always unique The same applies to an array class name Thus no class names and array class names are numbered Name that needs to be unique betw
17. set object is invalid Specify a subclass of the array element class An attempt was made to set an invalid class object in an array element Set an object of a valid class An object of the array element class or its subclass must be set An internal logical error inconsistency between the return value and object reference occurred Call the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer Java VM detected an error Remove the error cause exception name supplementary information The Java VM detected an execution time error Determine the error cause from the exception name and supplementary information and remove it An internal logical error failure of the error detecting feature occurred Call the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 80 Chapter 6 Messages Chapter 7 Samples Sample 1 Using Classes Example 1 Example of using java lang System java io PrintStream and java util Date classes This section explains the Sample Program Example 1 provided with this product Example 1 shows how the java lang System java io PrintStream and java util Date classes of J ava are used from COBOL Outline Generate an instance of the java util Date class and place the content on the standard output class variabl
18. the J ava field attribute See Data types for the correspondence of data types Generation rules The property method corresponding to the instance variable nval of the java io StreamTokenizer class is generated as shown below METHOD ID GET PROPERTY JF NVAL LINKAGE SECTION 01 GET VALUE COMP 2 PROCEDURE DIVISION RETURNING GET VALUE END METHOD JF NVAL METHOD ID SET PROPERTY JF NVAL LINKAGE SECTION 01 SET VALUE COMP 2 PROCEDURE DIVISION USING SET VALUE END METHOD JF NVAL 1 The property name is generated by adding NVAL which is the uppercase of the Java field name to JF 2 nval is mapped to COMP 2 because its attribute is double 3 Since FINAL is not specified a property method with the SET specification is also generated Supplement When a property name is generated from a field name a number is assigned to secure the uniqueness of the name The class browser can be used to check the correspondence between fields and properties 60 Chapter 5 Adapter Class Reference Instance Method Explanation A non public instance method non static method is mapped to a COBOL object method Expansion format METHOD ID internal method name AS external method name OVERRIDE DATA DIVISION LINKAGE SECTION parameter return value PROCEDURE DIVISION USING parameter RETURNING return value RAISING exception class name END METHOD internal method name Gene
19. thread from the J ava VM JVM DETACH Factory Disconnects the current thread from the Java VM J VM I NIT Method factory method Explanation When it is called initially in a process Java VM is initialized This must be executed before using the adapter class Also the current thread is connected to Java VM In the multithread applications the current thread must be connected to J ava VM for each thread This is equivalent to the J VM ATTACH method Syntax INVOKE FJ JAVA CONTROL J VM INIT Environment variable The J ava VM execution environment can be customized by specifying the following environment variables Refer to the Fujitsu NetCOBOL User s Guide for information on how to specify the environment variables Chapter 5 Adapter Class Reference 49 Environment variable name Function COBJNI MAX NSTACK Specifies the maximum size bytes of the stack used for the native code The default is 128 kilobytes COBJNI JAVA STACK Specifies the maximum size bytes of the stack used for the Java code The default is 400 kilobytes COBJNI MIN HEAP Specifies the startup size of the memory allocation pool in bytes The default is 1 megabyte COBJNI MAX HEAP Specifies the maximum size of the memory allocation pool in bytes The default is 16 megabytes COBJNI CLASSPATH Specifies the execution time class path Environment variable CLASSPATH specifies the generation time class path and has no effec
20. type Adapter class type Format Explanation Class interface package name Class name fully qualified by a package name Package class name and class names are separated by Array of boolean Z The number of indicates the number of dimensions basic For instance Z is used for a 2 dimensional array oe byte B The number of indicates the number of dimensions char C The number of indicates the number of dimensions short S The number of indicates the number of dimensions int l The number of indicates the number of dimensions long J The number of indicates the number of dimensions float F The number of indicates the number of dimensions double D The number of indicates the number of dimensions Class interface array L package name The number of indicates the number of dimensions A class name class name fully qualified by a package name is enclosed between L and Java VM initialization failed Check the environment variables PATH COB NI_ CLASSPATH and J DK or J RE install environment The J DK J 2SDK J RE or J 2RE environment contains an error Check whether the environment variables PATH and COB NI_ CLASSPATH are correct or whether JDK J 2SDK JRE or J 2RE is installed properly The current thread could not be connected to J ava VM Check whether the program properly invokes the J VM INIT method or the J VM
21. 0 characters results in an unusable name 76 Chapter 6 Messages Warning The method name of constructor xxx exceeded 160 characters The characters after the first 160 characters were deleted Check whether deleting the characters after the first 160 characters results in an unusable name Error Class information was not found Generation was interrupted Check whether there is a class interface class file referenced from the class interface see Generating an adapter class when the class file is not available Error A memory space shortage occurred Generation was interrupted Terminate unnecessary applications and retry Error Asystem error occurred Generation was interrupted The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer Chapter 6 Messages 77 Messages Output during Execution This section explains the messages output during execution of programs using adapter classes including the operator responses to the messages The message format is shown below Class name information Message text Class name information indicates the adapter class in which an error occurred The format of class name information varies depending on the class type Adapter class type Format Explanation Class interface package name class Class name fully qualified by a name package name Package and class names are separated by Array of bo
22. ATTACH method The current thread could not be disconnected from J ava VM Check whether the program properly invokes the J VM TERMINATE method or the J VM DETACH method Appendix A Message List 91 The adapter class generated by the J adapter class generator contains a Java class name in invalid format Contact the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer Asame name is used for a parent and its child in the J ava class interface definition Use different names for the parent and child The J ava class interface definition contains an error Check the J ava class interface A required J ava class interface definition is not found Check the environment variable COBJ NI_ CLASSPATH No Java class interface is found on the search path Check whether the value of the environment variable COB NI CLASSPATH is valid Amemory space shortage occurred Increase the values of environment variables COBJNI MAX NSTACK COBJNI JAVA STACK COBJNI MIN HEAP and COBJNI MAX HEAP then retry A memory space shortage occurred in the Java VM Increase the values of environment variables COBJNI MAX NSTACK COBJNI JAVA STACK COBJNI MIN HEAP and COBJNI MAX HEAP to increase memory space available for the Java VM No J ava interface abstract class instance can be generated Check whether the J ava class interface was changed after the J
23. BOL data type type boolean PIC1 byte PIC X char PIC X 2 e When an ANK character is stored the first byte is used and the second byte is X 00 e When a Japanese character is stored two bytes are used e Data is mapped when code option cs native code or no code option is specified PIC N e When an ANK character is stored the first byte is used and the second byte is X 00 e When a Japanese character is stored two bytes are used e Data is mapped when code option cu Unicode is specified short PIC S9 4 COMP 5 int PIC S9 9 COMP 5 long PIC S9 18 COMP 5 float COMP 1 double COMP 2 Array Object reference array adapter class Object Object reference adapter class Class and interface Explanation Public classes and interface are mapped to COBOL classes The inheritance relationships of adapter classes are the same as those of the corresponding J ava classes Note that the following Java class inherits no other classes or interfaces but the adapter classes generated inherit J F J AVA BASE e java lang Object class Similarly the following interface inherits no other classes or interfaces but the adapter classes generated inherit java lang Object e Interface that inherits no other interface Chapter 5 Adapter Class Reference 53 Expansion format CLASS ID internal class name 1 AS external class name INHERITS internal class name 2 FACTORY lt lt Factory method corresponding to a constructor gt gt
24. END METHOD JM GETTIME 1 Since there is only one method with name getTime a method with name getTime is generated with no number assigned Supplement When a COBOL method name is generated from a Java method name a number is assigned to secure the uniqueness of the name The class browser or method name cross reference list file can be used to check the correspondence between Java methods and COBOL methods In the case of class browser it can be identified from the parameter that appears during method selection In the case of method name cross reference list file it can be identified from the type of argument of the constructor java lang String class Like other classes the java lang String class is mapped to the java lang String class However the java lang String class has the following methods for referencing or setting character string data in addition to the methods defined in the java lang String class Method name Type Function NEW STRING X Factory Generates a String object having the specified alphanumeric data item as the initial value NEW STRING N Factory Generates a String object having the specified national data item as the initial value GET STRING X Object Fetches the character string as an alphanumeric data item GET STRING N Object Fetches the character string as a national data item GET STRING LENGTH X Object Determines alphanumeric data item length GET STRING LENGTH N Object
25. GTH RETURNING e mNum Parameter and return value e anObject Specifies the array object from which the number of elements is obtained e elmNum attribute PIC S9 9 COMP 5 Returns the number of elements of an array GET ARRAY ELEMENT method object method Explanation This method fetches an element from an array object Syntax INVOKE anObject GET ARRAY ELEMENT USING inx RETURNING e emValue Parameter and return value e anObject Specifies the array object from which an element is to be fetched e _inx attribute PIC S9 9 COMP 5 Specifies the subscript of the element to be fetched The subscript begins from 0 e elemValue attribute Array element type Returns the value of the array element fetched Chapter 5 Adapter Class Reference 69 SET ARRAY ELEMENT method object method Explanation This method sets an element of an array object Syntax INVOKE anObject SET ARRAY ELEMENT USING nx elemValue Parameter and return value e anObject Specifies the array object in which an element is to be set e inx attribute PIC S9 9 COMP 5 Specifies the subscript of the element to be set The subscript begins from 0 e elemValue attribute Array element type Specifies the value to be set in the array element Numbering Names The J adapter class generator generates adapter class names from the names used for Java classes or interfaces However some names cannot be used in both J ava and COBOL because different syntax
26. J DateFormat AS java text DateFormat WORKING STORAGE SECTION 01 aDateFormat OBJECT REFERENCE J DateFormat 01 aDate OBJECT REFERENCE J Date 01 dateValue PIC X 30 PROCEDURE DIVISION MOVE 2000 01 01 amp X 00 TO dateValue INVOKE aDateFormat parse USING dateValue RETURNING aDate INVOKE aDate toString RETURNING dateValue Notes e The return value of the java lang String class constructor is the java lang String class e When the String object method is used the creation of the object calling the String constructor or calling the NEW STRING X method is necessary e To refer set the java lang String type field class variable or instance variable specify its size using s option or Option String parameter e When you want to handle the String type NULL object do not use the s option and Option String parameter End Control of Character String When passing a character string that is shorter than the data item length to an ordinary adapter class the end of string X 00 must be set The following example shows that ABC is copied to alphanumeric item initialValue having length of 50 characters and is passed to the NEW STRING X method REPOSITORY CLASS J String AS java lang String WORKING STORAGE SECTION 01 initialValue PIC X 50 01 aString OBJECT REFERENCE J String PROCEDURE DIVISION MOVE ABC amp X 00 TO initialValue INVOKE J String NEW STRING X USING initialValue RETURNING
27. JECT REFERENCE J Date 01 Date 2 OBJECT REFERENCE J Date 01 rst PIC 1 PROCEDURE DIVISION INVOKE Date 1 J EQUALS USING CONTENT Date 2 RETURNING rst IF rst B 1 THEN Condition met Assignment to a Subclass COBOL uses AS to assign an object to a subclass However it uses the J NARROW method instead of AS to assign an adapter object The adapter class always has the J NARROW method 26 Chapter 3 Developing Programs An example of assigning an object which has been referenced with Object class data into Data class data is shown below REPOSITORY CLASS J Object AS java lang Object CLASS J Date AS java util Date WORKING STORAGE SECTION 01 anDate OBJECT REFERENCE J Date 01 anObject OBJECT REFERENCE J Object PROCEDURE DIVISION INVOKE J Date J NARROW USING CONTENT anObject RETURNING anDate Mapping java lang String into PIC X The java lang String is mapped into the java lang String class in the generation of the normal adapter class In this case creation of the user s application becomes somewhat complicated because conversion between the String object and the COBOL data items must be performed using the java lang String class method such as NEW STRING X GET STRING X When the adapter class is generated by specifying the s option or by specifying the Option String parameter the following items can be handled as alphanumeric items in the user s applications since the java lang String type is
28. OL is required to develop programs using the adapter class generator Fujitsu NetCOBOL or Fujitsu NetCOBOL Runtime System is required to execute applications developed by the J adapter class generator Java Development Kit or J ava Runtime Environment Java Development Kit J DK is provided by Sun Microsystems Inc provides the basic general purpose class libraries required for program development with J ava Java 2 SDK J 2SDK is a software development kit available for creating applications conforming to J ava 2 released by Sun Microsystems Inc J2SDK provides basic general purpose class libraries required for program development with J ava 2 Java Runtime Environment J RE is the JDK runtime environment released by Sun Microsystems Inc It is required to run programs developed with J ava Java 2 Runtime Environment J 2RE is the run time environment of applications conforming Java 2 released by Sun Microsystems Inc It is required to run programs developed with J ava 2 JDK 1 1 8 J 2SDK 1 2 2 or a later version is required to develop programs using the J adapter class generator JDK 1 1 8 J2SDK 1 2 2 JRE 1 1 8 J2RE 1 2 2 or a later version is required to run applications developed using the J adapter class generator Chapter 2 Adapter Class Generator Framework This chapter explains the framework of the J adapter class generator 14 Chapter 2 Adapter Class Generator Framework Adapter Class To make J ava classes
29. a class interface was probably changed after generation of an adapter class Check the J ava class interface Type conversion failed Check the parameter passed to the J NARROW method The object specified in the parameter is not a subclass or object of the class Check the parameter passed to the J NARROW method Chapter 6 Messages 79 No J ava field is found Check whether the J ava class interface was changed after execution of the J adapter class generator The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface J ava class initialization failed Call the adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer No J ava method is found Check whether the J ava class interface was changed after execution of the J adapter class generator The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface The character string could not be fetched from the String object Call the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer The subscript of the array object is invalid Specify a subscript within the array range The subscript value is outside the range from 0 to element count 1 Specify a valid subscript The class of the
30. a lang String class are not output to the method name cross reference list file NEW STRING X NEW STRING N GET STRING X GET STRING N GET STRING LENGTH X GET STRING LENGTH N Chapter 5 Adapter Class Reference This chapter provides detailed information on the FJ J AVA BASE FJ JAVA CONTROL and FJ J AVA ERROR classes provided by the J adapter class generator and adapter classes generated by the J adapter class generator 46 Chapter 5 Adapter Class Reference Class Configuration The figure below shows the hierarchical relationships among the FJ JAVA BASE FJ JAVA CONTROL and FJ J AVA ERROR classes provided by the J adapter class generator and adapter classes generated by the J adapter class generator FJBASE FJ JAVA BASE java lang Object FJ JAVA CONTROL Array adapter classes FJ JAVA ERROR Interface adapter classes EI Class provided by COBOL97 CJ class provided by J adapter class generator C Class generated by J adapter class generator Other class adapter classes Figure 5 0 1 Class Hierarchy FJ JAVA BASE Super class of every adapter class FJ JAVA CONTROL Initializes or terminates the J ava VM or connects or disconnects a thread to the Java VM FJ J AVA ERROR Class of exception object generated in the adapter class Class adapter class An adapter class java lang Object of the java lang Object class is generated as a subclass of FJ JAVA BASE Other adapter classes having th
31. and remote it 2 Meaning No Java method is found Check whether the J ava class interface was changed after execution of the J adapter class generator Response The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface 3 Meaning Java class initialization failed Call the J adapter class generator supplier Response The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 4 Meaning A memory space shortage occurred Increase the values of environment variables COBJNI MAX NSTACK COBJNI JAVA STACK COBJNI MIN HEAP and COBJNI MAX HEAP then retry Response A memory space shortage occurred in the Java VM Increase the values of environment variables COBJNI MAX NSTACK COBJNI JAVA STACK COBJNI MIN HEAP and COBJNI MAX HEAP to increase memory space available for the Java VM 94 Appendix B Exception Type List 5 Meaning No Java field is found Check whether the J ava class interface was changed after execution of the J adapter class generator Response The J ava class interface was probably changed after generation of an adapter class Check the J ava class interface 6 Meaning The subscript of the array object is invalid Specify a subscript within the array range Response The subscript value is outside the range from 0 to element count 1 Specify a valid subscript 7 Meani
32. aracter string of the String object as the length number of characters of the alphanumeric data item Syntax INVOKE anObject GET STRING LENGTH X RETURNING stringLength Parameter and return value e anObject Specifies the String object whose character length is to be checked e stringLength attribute PIC S9 9 COMP 5 Returns character string length Chapter 5 Adapter Class Reference 65 GET STRING LENGTH N method object method Explanation This method returns the length of the character string of the String object as the length number of characters of the national data item Syntax INVOKE anObject GET STRING LENGTH N RETURNING stringLength Parameter and return value e anObject Specifies the String object whose character length is to be checked e StringLength attribute PIC S9 9 COMP 5 Returns character string length Array Adapter Class A Java array is handled as an object in COBOL Therefore an adapter class is generated for each array attribute element type and number of dimensions This section explains how J ava arrays are mapped to COBOL classes Array class Explanation An adapter class corresponding to the array is generated when e An array is used as a parameter of a public constructor e The type of a public field static or non static is an array e An array is used as a parameter or return value of a public method static or non static Arrays whose attributes shown below match are
33. associated with the same adapter class e Array element type e Number of dimensions 66 Chapter 5 Adapter Class Reference Expansion format CLASS ID internal class l AS external class name INHERITS internal class name 2 FACTORY lt lt NEW ARRAY method gt gt END FACTORY OBJECT lt lt GET ARRAY LENGTH method gt gt lt lt GET ARRAY ELEMENT method gt gt lt lt SET ARRAY ELEMENT method gt gt END OBJECT END CLASS internal class name l Generation rules 1 Internal class names 1 and 2 are internally used by the J adapter class generator and are not viewed from the class user 2 The external class name is used to identify the class The class user can identify the class with the external class name 3 An external class name is generated according to the following rules JA NumberOfDimensions ElementTypeName JA is followed by the number of dimensions 1 to 9 and element type name with a hyphen inserted in between them An element type name is generated depending on the type in the following format Object External class name of the adapter class corresponding to the J ava class See Class and interface Basic type Java keyword representing a type boolean byte char short int long float or double An external class name exceeding 160 characters is truncated after the 160th character 4 The following methods are generated in the factory or method definition
34. ate class Create Date 07 Date long Create Date 08 Name that needs to be unique within an entire run unit Java method names are normally used as they are in COBOL However Java permits multiple methods with a same name to be defined if they have different parameters In this case numbers are assigned to COBOL method names for identification However to take advantage of polymorphism diversification that is the characteristics of object oriented programming methods having the same name and parameter are always assigned the same name This correspondence relationship must be consistent within the run unit of the COBOL program that uses Chapter 5 Adapter Class Reference 71 the J adapter class generator For instance the java io ObjectlnputStream class inherits the java io Objectinput interface and java io InputStream class see the figure below java io Objectinput lt lt interface gt gt java io InputStream read read read byte read byte int int read byte read byte int int java io ObjectlinputStream III lt lt implements gt gt read read byte int int Figure 5 2 Relationships among java io Objectl nput interface java io I nputStream class and java io Objectl nputStream class For the adapter class corresponding to these interface and classes methods of the same name must be generated for the read methods having the same parameters The J adapter class generato
35. ber of bytes of Java exception message is returned class attribute PIC X ANY LENGTH Specifies the data item that stores the Java exception class classLength attribute PIC S9 9 COMP 5 Length number of bytes of Java exception message is returned result attribute PIC S9 9 COMP 5 0 is returned when J ava exception information exists 1 is returned when Java exception information does not exist Notes The J ava exception information can be acquired only when the exception type is 1 Class or Interface Adapter Class A COBOL class adapter class is generated for a J ava class or interface This section explains how J ava class and interface elements are mapped to COBOL class elements below The J ava language elements are mapped to the COBOL language elements as shown Java COBOL Class Class Interface Class Constructor Factory method Class variable static field Factory property Class method static method Factory method Instance variable nonstatic field Object property Instance method nonstatic field Object method Java basic data type COBOL basic data type Only public elements are mapped to COBOL Any class interface constructor field and method that are not public are not mapped to COBOL 52 Chapter 5 Adapter Class Reference Data types The J ava data types are mapped to the COBOL data types as shown below Java data CO
36. bject consisting of three characters is generated NEW STRI NG N method factory method Explanation This method generates a String object having the character string specified for the national data item as an initial value Syntax INVOKE class name NEW STRING N USING nitialValue RETURNING createdObject Parameter and return value e class name Specifies the internal class name of the java lang String class declared in the REPOSITORY paragraph e _initialValue attribute PIC N ANY LENGTH Specifies a national data item as the initial value of the String object Chapter 5 Adapter Class Reference 63 e createdObject attribute OBJECT REFERENCE SELF Returns the generated object Supplement When a data name is specified for initialValue a String object as long as data item length is generated However inserting X 0000 in the statement can generate a String object shorter than data item length REPOSITORY CLASS J String AS java lang String WORKING STORAGE SECTION 01 initialValue PIC N 50 01 aString OBJECT REFERENCE J String PROCEDURE DIVISION MOVE NC Two byte code TO initialValue INVOKE J String NEW STRING N USING initialValue RETURNING aString MOVE NC Two byte code amp X 0000 TO initialValue INVOKE J String NEW STRING N USING initialValue RETURNING aString 1 A String object consisting of 50 characters with the last 47 character area padded with blanks is generated 2 A St
37. c ass name NEW ARRAY USING e mNum RETURNING createdObject Parameter and return value e class name Specifies the internal class name of the array class declared in the REPOSITORY paragraph e elmNum attribute PIC S9 9 COMP 5 Specifies the number of elements of the array to be generated e createdObject attribute OBJECT REFERENCE SELF Returns the array object generated Supplement When a multidimensional array is generated a n 1 dimensional array is generated and stored in each element of the n dimensional array For instance a n x m two dimensional array is generated as follows 68 Chapter 5 Adapter Class Reference REPOSITORY CLASS JA 2 INT AS JA 2 int CLASS JA 1 INT AS JA 1 int anArray OBJECT REFERENCE JA 2 INT wArray OBJECT REFERENCE JA 1 INT INVOKE JA 2 INT NEW ARRAY USING n RETURNING anArray PERFORM VARYING I FROM 0 BY I UNTIL I gt n INVOKE JA 1 INT NEW ARRAY USING m RETURNING wArray INVOKE anArray SET ARRAY ELEMENT USING I wArray END PERFORM SET wArray TO NULL Il 1 A two dimensional array object of int is generated number of elements 2 A one dimensional array object of int is generated number of elements m 3 The one dimensional array generated in 2 is set in each element of the first dimension of anArray GET ARRAY LENGTH method object method Explanation This method returns the number of elements of an array object Syntax INVOKE anObject GET ARRAY LEN
38. chapter explains the messages output by the J adapter class generator including the operator responses to the messages 86 Appendix A Message List Java2cob Command Messages This section explains the messages output by the java2cob command including the operator responses to the messages Adapter class generation failed because of a memory space shortage Terminate unnecessary applications and retry A memory space shortage occurred Terminate unnecessary applications then reenter the java2cob command Java VM could not be started Check the J DK environment definition PATH CLASSPATH and J DK installation The J DK or J 2SDK environment contains an error Check whether environment variables PATH and CLASSPATH are set normally and whether J DK or J 2SDK is installed normally Java2cob class loading failed Reinstall the J adapter class generator and retry The J adapter class generator is not installed normally Reinstall the adapter class generator Failed to open the optional file Check the file status Generation was interrupted Check status of the optional file if the filename that is specified with the i option is correct or not if the file is set to read protection and re execute the processing Optional filename is not specified Generation was interrupted Specify the filename of the i option and re execute the processing Appendix A Message List 87 Messages Output during Generation T
39. clude the original type information instead Refer to Specifying the om option or Option ReduceClass parameter Thus method can be distinguished with the class browser in most cases If method cannot be distinguished with the class browser because the parameter name is too long and because of other reasons it can be distinguished using the method name cross reference list file If omitted it is assumed that NO is specified Meaning of the parameter e YES Reduces the number of adapter classes e NO The number of adapter classes is not reduced Option String Specification format Option String YES 7 NO Specification contents Specify whether or not to generate an adapter class in which the java lang String type is mapped into the alphanumeric item PIC X Refer to Mapping the java lang String into PIC X If omitted it is assumed that NO is specified Meaning of the parameter e YES 7 The java lang String type is mapped into the alphanumeric item n specifies the parameter size PIC XL 011 of the property method that corresponds to the String type field If omitted it is assumed that 256 is specified e NO The java lang String type is not mapped into the alphanumeric item Chapter 4 Using the Generator Command 41 Option Terminal Specification format Option Terminal YES NO Specification contents Specify whether or not to generate an adapter class allowed to set end character str
40. d could not be disconnected from J ava VM Check whether the program properly invokes the J VM DETACH method The adapter class generated by the J adapter class generator contains a Java class name in invalid format Contact the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer Asame name is used for a parent and its child in the J ava class interface definition Use different names for the parent and child The J ava class interface definition contains an error Check the J ava class interface Arequired J ava class interface definition is not found Check the environment variable COBJ NI_ CLASSPATH No Java class interface is found on the search path Check whether the value of the environment variable COB NI CLASSPATH is valid Amemory space shortage occurred Increase the values of environment variables COBJNI MAX NSTACK COBJNI JAVA STACK COBJNI MIN HEAP and COBJNI MAX HEAP then retry A memory space shortage occurred in the Java VM Increase the values of environment variables COBJNI MAX NSTACK COBJNI JAVA STACK COBJNI MIN HEAP and COBJNI MAX HEAP to increase memory space available for the Java VM No J ava interface abstract class instance can be generated Check whether the J ava class interface was changed after the J adapter class generator was executed A constructor was executed in an abstract class The J av
41. d with name Create Date followed by a number The factory method corresponding to the constructor Date long of the java sql Date class java util Date subclass is generated as shown below METHOD ID CREATE 08 AS Create Date 08 LINKAGE SECTION 01 CREATED OBJECT OBJECT REFERENCE SELF 01 PARA 1 PIC S9 18 COMP 5 PROCEDURE DIVISION USING PARA 1 RETURNING CREATED OBJECT END METHOD CREATE 08 2 The factory method of java sql Date is also generated with name Create Date followed by a number To prevent name duplication serial numbers including java util Date factory methods are assigned Supplement A factory method name is generated from a constructor a number is assigned to the name to secure the uniqueness of the name The class browser or method name cross reference list file can be used to check the correspondence between constructors and factory methods In the case of class browser it can be identified from the parameter that appears during method selection In the case of method name cross reference list file it can be identified from the type of argument of the constructor 56 Chapter 5 Adapter Class Reference Class variable Explanation A public class variable static field is mapped to a COBOL property method factory Expansion format METHOD ID GET PROPERTY property name LINKAGE SECTION 01 property value data description entry PROCEDURE DIVISION RETURNING property value END METHOD
42. dapter class generator generates an adapter class that converts the J ava interface into the COBOL interface What the J Adapter Class Generator Can Do Using adapter classes generated by the J adapter class generator enables the following types of operation for J ava To COBOL programs J ava objects seem to be COBOL objects Therefore Java objects can be handled the same way as ordinary COBOL objects Accessing a class variable Access to a public class variable static field declared in a J ava class is enabled COBOL handles it as a factory property Invoking a class method A public class method static method declared in a J ava class can be invoked COBOL handles it as a factory method Generating an instance object invoking a constructor Invoking a constructor can create a J ava instance object COBOL handles it as a factory method that returns an object Accessing an instance variable Access to a public instance variable non static field of a Java instance object is enabled COBOL handles it as an object property Invoking an instance method A public instance method non static method of a J ava instance object can be invoked COBOL handles it as an object method Receiving an exception An exception caused when a class method constructor or instance method is invoked can be trapped to perform error processing COBOL uses the USE statement to receive an exception object What the J Adapter Class Generato
43. e out of the java lang System class Distribution files J ADPO1 TXT program description J AVA2COB MGT generation name management file DATEMAIN PR project file DATEMAIN CBI compiler option file DATEMAIN COB COBOL source program DATEO1J AVA PR project file DATEO1 AVA CBI compiler option file DATEO1J AVA2 PR project file DATEO1 AVA2 CBI compiler option file COBOL functions used Object oriented programming functions Object generation Method invocation Java classes used java lang System java io PrintStream java util Date 82 Chapter 7 Samples Generating adapter classes Generate adapter classes using the java2cob command java2cob java lang Object 1 java2cob java lang System 2 java2cob java until Data 3 1 Generate an adapter class of the java lang Object class required for calling Java 2 Generate an adapter class of the java lang System class used for standard output An adapter class of the java util PrintStream class referenced from the java lang System class is also generated 3 Generate an adapter class of the java util Date class Project build or rebuild function This section explains how to create an executable program using the build function of the project manager Refer to the Fujitsu COBOL User s Guide for detailed information on how to use the project manager 1 When using Java JDK 1 1 x open project file DATEOLJAVA PRJ When using
44. e same inheritance relationships as J ava classes are generated An adapter class of the class in which a J ava interface is installed inherits an interface adapter class as well Interface adapter class The adapter class of an interface that inherits no other interface is generated as a subclass of java lang Object The adapter class of an interface that inherits another interface is generated so that it has the same inheritance relationship as the J ava interface Array adapter class Every array adapter class is generated as a subclass of java lang Object Chapter 5 Adapter Class Reference 47 FJ J AVA BASE class The FJ JAVA BASE class is the super class of every adapter class The FJ JAVA BASE class has the methods shown below Method name Type Function J NARROW Factory Assigns an object to a subclass J DUPLICATE Object Duplicates an adapter object J EQUALS Object Checks whether the J ava objects indicated by two adapter objects are equal J NARROW Method factory method Explanation This method assigns an adapter object to a subclass Syntax INVOKE class name NARROW USING object 1 RETURNING object 2 Parameter and return value class name Specifies the class name of assignment target data e object 1 attribute OBJECT REFERENCE FJ J AVA BASE Specifies the object to be assigned e object 2 attribute OBJECT REFERENCE SELF Returns the object that was converted into the ass
45. een super classes subclasses A factory method name corresponding a constructor is generated from a class name that is not qualified by a package name Factory method names including methods inherited from the super classes must all be unique to one another However names conflict when e Super classes have a same name qualified by different packages e Two or more constructors are defined for one class In this case the J adapter class generator assigns numbers to the methods with a same name according to the following rules 1 Number 01 is assigned to the name that appears first and then serial numbers are assigned in ascending order to the subsequent names 2 The above rule is applied to names in order from the constructor defined in the super class When two or more constructors are defined for one class the rule is applied to them in order they are defined Example The factory methods corresponding to the constructor of the java util Date class and java sql Date class subclass of the java util Date class are assigned names as shown below Java constructor COBOL factory method java util Date class Date ava util Date class Create Date 01 Date int int int Create Date 02 Date int int int int int Create Date 03 Date int int int int int Create Date 04 int Date long Create Date 05 Date String Create Date 06 java sql Date class Date int int int java sql D
46. enerated s The Japanese cannot be included in class names or interface names e When Unicode is specified for the execution time code specify RCS UCS2 in a compiler option see Building an adapter class Example Using the options is described in the following examples of the java2cob command e All of the adapter classes that are related to the java io PrintStream class and the java util Date class are generated c gt java2cob java io PrintStream java util Date e The adapter class that is related to all printin methods of the java io PrintStream class and that is related to all constructors of the java util Date class are generated c gt java2cob r java io PrintStream gm println r java util Date gc e Only the adapter classes that are related to the printIn Object of the java io PrintStream class and to the Date constructor of the java util Date class are generated c gt java2cob r java io PrintStream gm println java lang Object r java util Date gc Date 36 Chapter 4 Using the Generator Command Optional File The optional file is a text format file used to define generator options in a file instead of on the command line The optional file is specified in a command line of the java2cob command For example specifying the many method names etc in the command line every time is troublesome during the specification of the constructor method field It can be more readily and accurately
47. epeated specification e Italic type indicates variable character string Options classpath c ass path Specifies the J ava class interface search path When specifying two or more folders separate them with a semicolon When this option is specified environment variable CLASSPATH is ignored This option must be specified right after the java2cob command c s u Specifies the code used for execution Specify the same code as the COBOL program that uses J ava classes The default is native code cs native code is used for the execution time code cu Unicode is used for the execution time code d output folder Specifies the folder to which an adapter class source is output The default is the current folder gc constructor name parameter type Specify the constructor name generated as an adapter class for the last class name interface name specified before this option If the constructor name is omitted all of the constructors within the corresponding class interface are Chapter 4 Using the Generator Command 33 generated When specifying two or more constructors they must be delimited by comma or a blank When two or more constructors of the same name exist only the constructor that matches the parameter type is generated by specifying the parameter type Ifa parameter type is omitted all of the constructors of the same name are generated When specifying a parameter type enclose the
48. er class source from the java util Date class is shown below Figure 3 1 Note The class file referenced by the class interface may not always be available depending on the execution environment For information on how to generate Chapter 3 Developing Programs 19 adapter classes when the class file is not available see Generating an adapter class when the class file is not available Building an Adapter Class Finally compile and link edit the generated adapter class source to create an adapter class library DLL Use the COBOL project manager to do so Refer to the Fujitsu NetCOBOL User s Guide for information on how to use the COBOL project manager Follow the procedure below to build an adapter class 1 Create a new project using the project manager 2 Register the target DLL 3 Create a COBOL source file folder and store the generated adapter class in it 4 Specify compiler options Specify XXX REP XXX is the J adapter class generator install folder for REPIN Specify ALPHAL WORD When creating an adapter class running with Unicode specify RCS UCS2 5 To determine the compilation order select Repository File Search from the Edit menu and then select All 6 Create a library folder and store the runtime library F3BIJART LIB of the J adapter class generator in it F3BIJART LIB is available from the LIB folder of the install folder 7 Execute build The following file
49. etCOBOL User s Guide Example of coding of the exception handling is shown as follows REPOSITORY CLASS FJ JAVA ERROR WORKING STORAGE SECTION 01 errMessage PIC X 256 01 expMessage PIC X 1024 01 expClass PIC X 256 01 errCode PIC S9 9 COMP 5 01 errMessageLen PIC S9 9 COMP 5 01 expMessageLen PIC S9 9 COMP 5 01 expClassLen PIC S9 9 COMP 5 01 rc PIC S9 9 COMP 5 PROCEDURE DIVISION DECLARATIVES ERR SECTION USE AFTER EXCEPTION FJ JAVA ERROR INVOKE EXCEPTION OBJECT GET CODE RETURNING errCode INVOKE EXCEPTION OBJECT GET MESSAGE USING errMessage RETURNING errMessageLen INVOKE EXCEPTION OBJECT GET EXCEPTION USING expMessage expMessageLen expClass expClassLen RETURNING rc Chapter 3 Developing Programs 29 DISPLAY Error Code errCode DISPLAY Error Message errMessage l errMessageLen IF rc NOT 1 THEN DISPLAY Java Class Name expClass 1 expClassLen DISPLAY Java Exception Message expMessage 1 expMessageLen END IF END DECLARATIVES Note When the exception handling is not described in a program the program runtime error J MP01041 U occurs due to the occurrence of the exception object Constructing a Program This section explains how to construct a program that uses an adapter class by using the COBOL project manager The following files generated from the adapter class are required to construct a program e Adapter class LIB file for linkage e Adapter class
50. fy it when the code system during execution time is native code e UNICODE Specify it when the code system during execution time is Unicode Option CommandOptions Specification format Option CommandOptions command options Specification contents Specify options of the java2cob command directly But the i option cannot be specified When a parameter of the same type as the command options is specified as an optional file the specified value of the command options overrides the option file Option GenOnlyUsed Specification format Option GenOnlyUsed YES NO Specification contents Specify whether or not specify a constructor method field generated as an adapter class When a constructor method field is specified size of the adapter class can be reduced Refer to Specify the constructor method field When omitted it is assumed that NO is specified The specification value of the Option GenOnlyUsed parameter affects all of the Class class name interface name inside the optional file The Option GenOnlyUsed parameter is exclusive with the Option ReduceClass parameter Meaning of the parameter e YES Specifies the constructor method field e NO Does not specify constructor method field Chapter 4 Using the Generator Command 39 Option MethodTable Specification format Option MethodTable YES NO Specification contents Specify whether or not to output the method name cross reference list file
51. g Object method java util Date class Date constructor 84 Chapter 7 Samples Generating adapter classes Generate adapter classes using the java2cob command java2cob r java lang System gf out 1 r java io PrintStream gm printin java lang Object 2 r java util Date gc Date 3 Note shows the continuance line 1 Generate an adapter class of the java lang System class that contains the out field used for standard output Generate an adapter class of the java io PrintStream class that contains the printin java lang Object method used for standard output Generate an adapter class of the java util Date class that contains the Date constructor Project build or rebuild function This section explains how to create an executable program using the build function of the project manager Refer to the Fujitsu COBOL User s Guide for detailed information on how to use the project manager 1 3 4 When using J ava J DK 1 1 x open project file DATEO02J AVA PRJ When using J ava2 J2SDK 1 2 2 or later open project file DATE02J AVA2 PRJ Select Build from the Project menu An adapter class DLL DATE DLL is generated Open project file DATEMAIN PR Select Build from the Project menu Running a program Run the executable program from the MS DOS prompt The date and time are displayed Appendix A Message List This
52. generated Check whether the correct folder name was specified in the d option or Option OutPutPath parameter or whether the generation name management file java2cob mgt is write protected then retry 88 Appendix A Message List Error The suffix number exceeded 99 Generation was interrupted Retry while specifying r option gc option gm option gf option om option constructor method field specifying option in Class class name interface name parameter or Option ReduceClass parameter to decrease the number of classes fields variables or methods Error The status of file xxx is invalid for generation Check the file status Check the file status whether the folder name specified in the d option or Option OutPutPath parameter is valid or whether the file is write protected then retry Error An error occurred during writing to file xxx Check whether the output destination has enough free space then retry Error Both of the om option Option ReduceClass and the r option Option GenOnlyUsed cannot be specified at the same time Generation was interrupted Specify either om option or Option ReduceClass parameter or the r option or Option GenOnlyUsed parameter and re execute the processing The r option or Option GenOnlyUsed parameter is recommended Error Both of the om option Option ReduceClass and the s option Option String cannot be specified at the same ti
53. generated Creation of an adapter class by specifying the constructor method field without specifying a constructor method field is not permitted s n Specify this option when creating the adapter class in which the java lang String type is mapped into alphanumeric item PIC X Refer to the paragraph Specifying java lang String into PIC X n specifies the parameter size PIC XL 011 of the property method that corresponds to the String type field When omitted it is assumed that 256 is specified t Specify this option when creating an adapter class in which the end of the character string needs to be set Refer to End control of character string Class name interface name Specifies the J ava class name or interface name for which an adapter class is to be generated by qualifying it with a package name When specifying an internal class Chapter 4 Using the Generator Command 35 name replace the period of the internal class name with a dollar sign More than one class name or interface name can be specified Environment Variable CLASSPATH Specifies the J ava class interface search path When classpath is specified the CLASSPATH environment variable is ignored Notes e When specifying constructor method field be sure to specify the r option class name interface name gc option gm option and gf option successively If another option is specified among these options specification error is g
54. hether deleting the characters after the first 160 characters results in an unusable name Error Class information was not found Generation was interrupted Check whether there is a class interface class file referenced from the class interface see Generating an adapter class when the class file is not available Error A memory space shortage occurred Generation was interrupted Terminate unnecessary applications and retry Error Asystem error occurred Generation was interrupted The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 90 Appendix A Message List Messages Output during Execution This section explains the messages output during execution of programs using adapter classes including the operator responses to the messages Messages given while execution is underway are output to the same target output as that of the DISPLAY statement that is specified by UPON SYSERR of COBOL Refer to Fujitsu COBOL User s Guide for the target output of the DISPLAY statement that is specified by UPON SYSERR of COBOL Output of the messages given while execution is underway can be suppressed by setting YES to the environment variable COBJNI NOMESSAGE The message format is shown below Class name information Message text Class name information indicates the adapter class in which an error occurred The format of class name information varies depending on the class
55. his section explains the messages output during adapter class generation including the operator responses to the messages The message format is shown below Message type Message text The message types are shown below Message type Level Meaning Error Severe No adapter class is generated Warning Cautionary An adapter class is generated However the user must check whether it has been generated as expected Warning An invalid option xxx was specified The option was ignored to continue processing Specify a valid option and retry Error A required class name or interface name was missing Generation was interrupted Specify a valid class name or interface name and retry Error An invalid class name xxx was specified Specify a J ava class name or interface name qualified by a package name Specify a valid class name or interface name and retry Warning A valid directory name was missing The option was ignored to continue processing Specify a valid directory name and retry Error An invalid directory name xxx was specified Generation was interrupted Specify a valid directory name and retry Warning xxx specified for class xxx was not generated Check the specified name and parameter Check whether the correct constructor method field was specified then retry see Specifying the constructor method field Warning The generation name management file could not be
56. ignment target class J DUPLI CATE Method object method Explanation This method duplicates an adapter object It duplicates no J ava object A duplicated adapter object points to the same J ava object as the original adapter object Syntax INVOKE anObject DUPLICATE RETURNING duplicatedObject Parameter and return value e anObject attribute OBJECT REFERENCE adapter class Specifies the adapter object to be duplicated e duplicatedObject attribute OBJECT REFERENCE CLASS OF SELF Returns the duplicated object 48 Chapter 5 Adapter Class Reference J EQUALS Method object method Explanation This method checks whether the Java objects indicated by two adapter objects are equal Syntax INVOKE object 1 EQUALS USING object 2 RETURNING result Parameter and return value e object 1 object 2 attribute OBJECT REFERENCE FJ JAVA BASE Specifies the adapter objects to be compared e result attribute PIC 1 Returns B 1 if a match occurs otherwise returns B 0 FJ JAVA CONTROL class The FJ JAVA CONTROL class controls the Java VM The FJ JAVA CONTROL class has the methods shown below Methods used to control Java VM Method name Type Function JVM INIT Factory Initializes the Java VM Only at the first calling Connects the current thread to the Java VM JVM ATTACH Factory Same as JVM INIT JVM TERMINATE Factory Terminates the Java VM Only at the last calling Disconnects the current
57. ing The FJ JAVA ERROR class has the following methods Methods that Acquire Exception I nformation Method name Type Function GET MESSAGE Object Returns the exception message GET CODE Object Returns the type of exception GET EXCEPTION Object Returns the J ava exception information GET MESSAGE method object method Explanation Returns the exception message It is used to indicate the error content Syntax INVOKE EXCEPTION OBJ ECT GET MESSAGE USING message RETURNING messageLength Parameter and return value e message attribute PIC X ANY LENGTH Specifies the data item that stores the exception message e messageLength attribute PIC S9 9 COMP 5 Length number of bytes of the exception message is returned GET CODE method object method Explanation Returns the type of exception Syntax INVOKE EXCEPTION OBJ ECT GET CODE RETURNING code Parameter and return value e code attribute PIC S9 9 COMP 5 Type of exception is returned Chapter 5 Adapter Class Reference 51 GET EXCEPTI ON method object method Explanation The J ava exception information is returned Syntax INVOKE EXCEPTION OBJ ECT GET EXCEPTION USING message messageLength class classLength RETURNING result Parameter and return value message attribute PIC X ANY LENGTH Specifies the data item that stores the J ava exception message messageLength attribute PIC S9 9 COMP 5 Length num
58. ings for the method that has string type fields and string type parameters Refer to End control of character string If omitted it is assumed that NO is specified Meaning of the parameter e YES Generate an adapter class in which the end character string setting is made e NO Does not generate an adapter class in which the end character string setting is made Example When creating only an adapter class that is related to the printin Object method of the java io PrintStream class or related to the Date constructor of the java util Date class specify as follows Option GenOnlyUsed YES Class java io PrintStream gm println java lang Object Class java util Date gc Date Notes e When two or more parameter of the same type are specified the parameter that is specified last becomes valid But the parameters of Class c ass name interface name become valid respectively e The line in which is described in the first column is ignored as the comment line e The line in which is described as the end of the line is continued on to the next line 42 Chapter 4 Using the Generator Command Output The generator outputs the following files e Adapter class source file e Generation name management file e Method name cross reference list file Adapter Class Source File The adapter class source file corresponding to the specified J ava class or interface is generated If the specified clas
59. interface name 34 37 42 53 internal class 53 Invoking COBOL from Java 12 Japanese 12 35 Java class 11 14 18 34 37 51 Java object 11 25 Java VM 22 23 29 46 48 J DUPLICATE 47 J EQUALS 48 J NARROW 47 JVM ATTACH 49 JVM DETACH 49 JVM INIT 48 JVM TERMINATE 49 method name 24 33 43 70 71 multithread 23 48 49 name duplication 56 NEW ARRAY 67 NEW STRING N 62 NEW STRING X 61 oi 33 43 om 20 21 33 34 40 optional file 31 33 36 38 OutPutPath 39 ov 34 OverWrite 39 property method 56 public elements 51 98 Index r 20 33 34 58 ReduceClass 40 restrictions 12 return value 57 Runtime 12 s n 34 SET ARRAY ELEMENT 69 98 source file 19 29 42 String class 26 44 54 61 t 34 Termination 22 Unicode 35 38 unique name 69
60. lass or not to overwrite it when an adapter class of the same name already exists Specify whether or not to reduce the number of adapter classes Omission is allowed Multiple setting is not allowed Omission is allowed Multiple setting is not allowed Option String Specify whether or not to generate an adapter class in which the java lang String type is mapped into alphanumeric item Omission is allowed Multiple setting is not allowed Option Terminal Specify whether or not to generates an adapter class in which the end character string setting is made for the method that has the parameter of String type field and the String type Omission is allowed Multiple setting is not allowed Chapter 4 Using the Generator Command 37 Notes on describing the optional file e Clauses enclosed by square brackets can be omitted e Curly brackets indicate selection of clause that is delimited by e Italic type indicates a variable character string Class class name interface name Specification format Class class name interface name constructor method field specifying option Specification contents Specify the Java class name or interface name that generates an adapter class Also specify constructor method field specifying options when constructor method fields are generated as an adapter class for that c ass name interface name Meaning of the parameter e class name i
61. led a proxy object The relationship between the Java object and adapter object is shown below COBOL program Adapter object Java object r COBOL method Java method Invoking a Processing Java method Figure 2 2 Java object and adapter object 16 Chapter 2 Adapter Class Generator Framework Chapter 3 Developing Programs This chapter explains how to develop programs that use J ava classes 18 Chapter 3 Developing Programs Creating Adapter Classes This section explains how to generate an adapter class from a Java class I nvestigating the J ava Class First investigate the specifications of the J ava class and interface to be used class name package name usage and so on to check whether the J adapter class generator can handle the class and interface See What the J Adapter Class Generator Can Do and What the J Adapter Class Generator Cannot Do for information on which classes and interfaces can be used Generating Adapter Class Source If the target Java class and interface can be used generate adapter class source Use the java2cob command to generate adapter classes The java2cob command reads the class file extension class of the J ava class interface and generates the corresponding adapter class source The java2cob command generates adapter classes of not only the class specified by the option but also every other class interface required to use the class An example of generating adapt
62. list of adapter class methods that correspond to the J ava class methods If omitted it is assumed that NO is specified The method name cross reference list file is output using the format of source file name txt of the adapter class for each J ava class Meaning of the parameter e YES The method name cross reference list file is output e NO The method name cross reference list file is not output Option OutPutPath Specification format Option OutPutPath output folder Specification contents Specify the folder to which source of the adapter class is output When a folder include a blank enclose the entire output target folder with double quotation If omitted it is generated in the current directory Option OverWrite Specification format Option OverWrite YES NO Specification contents Specify whether to overwrite an existing adapter class or to overwrite it when an adapter class of the same name already exists If omitted it is assumed that NO is specified Meaning of the parameter e YES Overwrite is executed e NO Overwrite is not executed 40 Chapter 4 Using the Generator Command Option ReduceClass Specification format Option ReduceClass YES NO Specification contents Specify whether or not to reduce the number of adapter classes When YES is specified the type of object reference except RETURNING becomes java lang Object and the parameter name is generated so as to in
63. lt lt Property method corresponding to a class variable gt gt lt lt Factory method corresponding to a class method gt gt END FACTORY OBJECT lt lt Property method corresponding to an instance variable gt gt lt lt Object method corresponding to an instance method gt gt END OBJECT END CLASS internal class name l Generation rules 1 Internal class names 1 and 2 are internally used by the J adapter class generator and are not viewed from the class user 2 The external class name is used to identify the class The class user can identify the class with the external class name 3 An external class name is generated according to the following rules PackageName PackageName ClassName InterfaceName Period used in the class name or interface name fully qualified with a package name is replaced with hyphen A name exceeding 160 characters is truncated after the 160th character 4 The following three methods are generated in the FACTORY definition Factory method corresponding to a constructor Property method corresponding to a class variable Factory method corresponding to a class method 5 The following two methods are generated in the OBJ ECT definition Property method corresponding to an instance variable Object method corresponding to an instance method Generation example The adapter class of the java util Date class is generated as shown below CLASS ID J DATE AS java u
64. me Generation was interrupted Specify either om option or Option ReduceClass parameter or the s option or Option String parameter and re execute the processing Error Failed to open the optional file Check the file status Generation was interrupted Check status of the optional file if the filename that is specified with the i option is correct if the file is set to read protection and re execute the processing Error An invalid definition xxx was specified in the optional file The definition was ignored to continue processing Specify the correct definition and re execute the processing Warning The name of class xxx exceeded 160 characters The characters after the first 160 characters were deleted Check whether deleting the characters after the first 160 characters results in an unusable name Appendix A Message List 89 Warning The property name of field xxx exceeded 30 characters The characters after the first 30 characters were deleted Check whether deleting the characters after the first 30 characters results in an unusable name Warning The name of method xxx exceeded 160 characters The characters after the first 160 characters were deleted Check whether deleting the characters after the first 160 characters results in an unusable name Warning The method name of constructor xxx exceeded 160 characters The characters after the first 160 characters were deleted Check w
65. me cross reference list file it can be identified from the type of argument of the constructor I nstance variable Explanation A public instance variable non static field is mapped to a COBOL property method object Expansion format METHOD ID GET PROPERTY property name LINKAGE SECTION 01 property value data description entry PROCEDURE DIVISION RETURNING property value END METHOD property name METHOD ID SET PROPERTY property name LINKAGE SECTION 01 property value data description entry PROCEDURE DIVISION USING property value END METHOD property name Generation rules 1 The property name is used to identify the property The class user can identify the property with the property name 2 A property name is generated according to the following rules JF JavaFieldName nn F is followed by a J ava field name in uppercase Chapter 5 Adapter Class Reference 59 Ifa same property name has already been assigned the second and subsequent property names are each suffixed with a hyphen followed by a two digit number 01 to 99 to prevent name duplication See Numbering names A name exceeding 30 characters is truncated after the 30th character 3 When FINAL is specified no property method with the SET specification is generated 4 The property value is a parameter used to transfer a property value The data description entry expands the COBOL description entry corresponding to
66. ment to a subclass Mapping java lang String into PIC X End control of character string Exception processing Initializing the J ava VM To use an adapter class the J ava virtual machine VM must first be initialized Use the JVM INIT method or the J VM ATTACH method of the FJ J AVA CONTROL class to initialize the J ava VM A coding sample is shown below REPOSITORY CLASS FJ JAVA CONTROL PROCEDURE DIVISION INVOKE FJ JAVA CONTROL JVM INIT Chapter 3 Developing Programs 23 Terminating the J ava VM When an adapter class is no longer used the Java VM must be terminated Use the JVM TERMINATE method of the FJ JAVA CONTROL class to terminate the Java VM A coding sample is shown below REPOSITORY CLASS FJ JAVA CONTROL PROCEDURE DIVISION INVOKE FJ JAVA CONTROL JVM TERMINATE Developing a Multithread Application A multithread application using an adapter class must connect the current thread to the Java virtual machine VM When the multithread application is terminated the current thread must first be disconnected from the Java VM Use the J VM INIT method or the J VM ATTACH method of the FJ J AVA CONTROL class to connect the current thread to the J ava VM To disconnect the current thread from the Java VM use the J VM TERMINATE method or the JVM DETACH method of the FJ J AVA CONTROL class A multithread application sample is shown below Application N Main thread Multithread
67. n ReduceClass Parameter Specifying the om option or the Option ReduceClass parameter can reduce the number of adapter classes generated To check for parameter validity at method invocation the J adapter class generator generates adapter classes corresponding to individual parameters Thus many adapter classes are generated for one class When the om option or the Option ReduceClass parameter is specified all object type method parameters are mapped to the java lang Object class This function suppresses the generation of adapter classes corresponding to the method parameters and thereby reduces the number of adapter classes generated Notes e When the method of the adapter class generated with the om option or the Option ReduceClass parameter specified is invoked BY CONTENT must be specified as an object reference parameter e When the om option or the Option ReduceClass parameter is specified the object reference types of method parameters excluding the return value become java lang Object and therefore the original parameter types become uncertain Therefore for a parameter whose object reference type becomes java lang Object a parameter name is generated according to the following rules so that the original type information is included in the parameter name Pn ClassName e P is followed by a parameter serial number 1 to 99 e The hyphen is followed by an external class name excluding a package name after c
68. name duplication See Numbering names A name exceeding 160 characters is truncated after the 160th character 4 When a parameter is declared for the method the corresponding parameter is generated See Data types for the correspondence between parameter data types 5 When a return value is declared for the method the corresponding return value is generated See Data types for the correspondence between return value data types 6 When an exception is declared for the constructor the RAISING specification is generated 58 Chapter 5 Adapter Class Reference Generation example The factory method corresponding to class method abs long of the java lang Math class is generated as shown below METHOD ID JM ABS 01 AS abs 01 LINKAGE SECTION 01 RTN VALUE PIC S9 18 COMP 5 01 PARA 1 PIC S9 18 COMP 5 PROCEDURE DIVISION USING PARA 1 RETURNING RTN VALUE END METHOD JM ABS 01 1 Since more than one abs method is declared a method with name abs 01 is generated for abs long that is declared second Supplement When a COBOL method name is generated from a Java method name a number is assigned to secure the uniqueness of the name The class browser or method name cross reference list file can be used to check the correspondence between Java methods and COBOL methods In the case of class browser it can be identified from the parameter that appears during method selection In the case of method na
69. ng The adapter class generated by the J adapter class generator contains a J ava class name in invalid format Contact the J adapter class generator supplier Response The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 8 Meaning A same name is used for a parent and its child in the J ava class interface definition Use different names for the parent and child Response The J ava class interface definition contains an error Check the J ava class interface 9 Meaning The class of the set object is invalid Specify a subclass of the array element class Response An attempt was made to set an invalid class object in an array element Set an object of a valid class An object of the array element class or its subclass can be set Appendix B Exception Type List 95 10 Meaning A required J ava class interface definition is not found Check the environment variable COBJNI CLASSPATH Response No J ava class interface is found on the search path Check whether the value of the environment variable COBJ NI_CLASSPATH is valid 11 Meaning No J ava interface abstract class instance can be generated Check whether the J ava class interface was changed after the adapter class generator was executed Response A constructor was executed in an abstract class The J ava class interface was probably changed after generation of an adapter class Check the Java clas
70. ng the getTime method of the Date class is shown below REPOSITORY CLASS J Date AS java util Date WORKING STORAGE SECTION 01 anDate OBJECT REFERENCE J Date 01 currentTime PIC S9 9 COMP 5 PROCEDURE DIVISION INVOKE anDate getTime RETURNING currentTime Manipulating a Variable Manipulate a variable through the corresponding adapter class property The property name is a J ava field name with the prefix F However if more than one field is defined with the same name append a numeric suffix to distinguish them see Class variable and Instance variable Chapter 3 Developing Programs 25 An example of referencing the class variable AM PM FIELD static field of the DateFormat class is shown below REPOSITORY CLASS J DateFormat AS java text DateFormat WORKING STORAGE SECTION 01 FMT Type PIC S9 9 COMP 5 PROCEDURE DIVISION MOVE JF AM PM FIELD OF J DateFormat TO FMT Type Comparing Object References COBOL uses to check whether multiple object references point to the same object To check whether the Java objects pointed to by the adapter objects are the same COBOL uses the J EQUALS method of the adapter class instead of The adapter class always has the J EQUALS method An example of comparing two Date objects is shown below The condition is met when Date 1 and Date 2 point to the same J ava object REPOSITORY CLASS J Date AS java util Date WORKING STORAGE SECTION 01 Date l OB
71. note the following e Adapter class source and DLLs created by J DK 1 1 x can be used as they are in the Java2 environment e If an adapter class is recreated by Java2 a method name different from one created by JDK 1 1 x may be generated see Numbering names In this case the COBOL program using the J ava class must be modified To prevent this problem recreate an adapter class with J ava2 by using the generation name management file generated by JDK 1 1 x Chapter 4 Using the Generator Command This chapter explains how to use the generator command java2cob optional file and output result 32 Chapter 4 Using the Generator Command Starting the J Adapter Class Generator Command Syntax When the constructor method field is not specified java2cob classpath class path d output folder ov om oi c s u s n t class name interface name When the constructor method field is specified java2cob classpath class path d output folder ov oi c s u s 7 t r class name interface name gc constructor name parameter type gm method name parameter type 9f f eld name When the optional file is specified java2cob i optional file Notes on Describing the Command e The clause that is enclosed by square brackets can be omitted e Symbol of the curly brackets indicates selection of clause that is delimited by s Dot indicates r
72. nterface name Specifies a class name or interface name that is qualified by the package name When specifying an internal class name as the parameter type specify dollar instead of period of the internal class s constructor method field specifying option Specify a constructor method field using the format of gc option gm option and gf option of the java2cob command The constructor method field specifying option is valid when the Option GenOnlyUsed parameter specifies YES If constructor method field specifying option is not specified even though the Option GenOnlyUsed parameter specifies YES an adapter class without constructor method field is generated Option ClassPath Specification format Option ClassPath c ass path Specification contents Specify a search path of the J ava class interface When specifying two or more folders delimit the folders using semi colon When a blank is included in the class path enclose the entire class path with double quotation When this option is specified the environment variable CLASSPATH is ignored 38 Chapter 4 Using the Generator Command Option Code Specification format Option Code SJIS UNICODE Specification contents Specify a code system during execution time Specify the same code system as that of the COBOL program that uses the J ava class When omitted it is assumed that SJIS is specified Meaning of the parameter e SJIS Speci
73. ods The method name cross reference list file is generated when the oi option or the Option MethodTable parameter is specified in the adapter class output folder according to the following rules e Period or dollar used in the class name or interface name qualified by a package name is changed to hyphen s The extension is fixed to xt 44 Chapter 4 Using the Generator Command A method name cross reference list file is output in the following format Java java class name COBOL cobol external class name 1 Java type java method name argument type COBOL cobol external method name 2 Java type java method name argument type OVERRIDE COBOL None n Java type java method name COBOL cobol external method name java class name Class name or interface name qualified by a package name cobol external class name External class name of the adapter class corresponding to the Java class java method name Java class method type Return type of Java method argument type Argument type of Java method OVERRIDE Added when a super class method is overridden cobol method name External method name of the adapter class corresponding to the Java method None Indicated when no adapter class method corresponds to the Java method No method name cross reference list file is output for the following adapter class Array adapter class The following methods of the jav
74. olean Z The number of indicates the basic data number of dimensions For type instance Z is used for a 2 dimensional array byte B The number of indicates the number of dimensions char C The number of indicates the number of dimensions short S The number of indicates the number of dimensions int l The number of indicates the number of dimensions long U The number of indicates the number of dimensions float F The number of indicates the number of dimensions double D The number of indicates the number of dimensions Class interface array L package name The number of indicates the class name number of dimensions A class name fully qualified by a package name is enclosed between L and Execution time messages are output to the same destination as the COBOL DISPLAY statement Refer to the COBOL97 User s Guide for the output destination of the DISPLAY statement Java VM initialization failed Check the environment variables PATH COB NI_ CLASSPATH and J DK or J RE install environment The J DK J 2SDK J RE or J 2RE environment contains an error Check whether the environment variables PATH and COB NI_ CLASSPATH are correct or whether JDK J 2SDK J RE or J 2RE is installed properly 78 Chapter 6 Messages The current thread could not be connected to J ava VM Check whether the program properly invokes the J VM ATTACH method The current threa
75. onversion into uppercase s A parameter name exceeding 30 characters is truncated after the 30th character Example When the om option or the Option ReduceClass parameter is not specified adapter class source java io PrintStream cob of the java io PrintStream class becomes as shown below and the java io OutputStream class is required REPOSITORY CLASS J OUTPUTSTREAM AS java io OutputStream LINKAGE SECTION 01 PARA 1 OBJECT REFERENCE J OUTPUTSTREAM When the om option or the Option ReduceClass parameter is specified the parameter becomes the java lang Object type Therefore the java io OutputStream class is not required or generated 22 Chapter 3 Developing Programs REPOSITORY CLASS J OBJECT AS java lang Object LINKAGE SECTION 01 P1 OUTPUTSTREAM OBJECT REFERENCE J OBJECT Developing an Application That Uses an Adapter Class This section explains how to develop a program that uses an adapter class Outline The flow of program processing using the adapter class is as follows L 2 3 4 5 6 Initialization of the Java VM In the case of a multithreaded application connection of the current thread to the Java VM Generation of the object Calling the method In the case of a multithreaded application disconnection from the Java VM Termination of the Java VM Also be careful when performing the following operations Manipulating a variable Comparing object references Assign
76. parameter type with parenthesis and and enclose the entire option with double quotation to specify a parameter A parameter type can be specified with the data type name or with the class name that is modified by the package name When specifying an internal class name as the parameter type specify dollar instead of using period for the internal class This option is valid when the r option is specified This option is exclusive with the om option gf field name 1 Specify the field name generated as an adapter class for the last class name interface name specified before this option If the field name is omitted all of the fields within the corresponding class interface are generated When specifying more than one field they must be delimited by comma or a blank This option is valid when the r option is specified This option has exclusive relation with the om option gm method name parameter type Specify the method name generated as an adapter class for the last c ass name interface name specified before this option If the method name is omitted all of the methods within the corresponding class interface are generated When specifying more than one method they must be delimited by comma or a blank When more than one method of the same name exist only the method that matches the parameter type is generated by specifying the parameter type If a parameter type is omitted all of
77. property name METHOD ID SET PROPERTY property name LINKAGE SECTION 01 property value data description entry PROCEDURE DIVISION USING property value END METHOD property name Generation rules 1 The property name is used to identify the property The class user can identify the property with the property name 2 A property name is generated according to the following rules JF JavaFieldName nn F is followed by a J ava field name in uppercase Ifthe property name has already been assigned the second and subsequent property names are each suffixed with a hyphen followed by a two digit number 01 to 99 to prevent name duplication See Numbering names A name exceeding 30 characters is truncated after the 30th character 3 When FINAL is specified no property method with the SET specification is generated 4 The property value is a parameter used to transfer a property value The data description entry expands the COBOL description entry corresponding to the J ava field attribute See Data types for the correspondence of data types Generation rules The property method corresponding to the class variable out static final field of the java lang System class is generated as shown below METHOD ID GET PROPERTY JF OUT LINKAGE SECTION 01 GET VALUE OBJECT REFERENCE J PRINTSTREAM PROCEDURE DIVISION RETURNING GET VALUE END METHOD JF OUT 1 The property name is generated by adding
78. r Cannot Do The J adapter class generator cannot perform the following types of operation Inheriting a J ava class A COBOL class inheriting a Java class cannot be defined Even if a COBOL class inherits an adapter class the J ava class function cannot be overwritten Passing a COBOL object as a parameter No COBOL object can be passed as a parameter for invoking a method nor can a COBOL object be set for a J ava field Only an adapter object produced by wrapping a Java object can be passed to J ava 12 Chapter 1 Outline of J Adapter Class Generator Therefore the following restrictions apply to COBOL Listener Java registers a listener object in which event processing logic is written within an object that generates an event However since no COBOL object can be registered in a J ava object COBOL cannot be used to write listeners Collection class No COBOL object can be registered in a J ava collection class When using COBOL objects as a collection use a COBOL collection class e Class having aJ apanese name No class name field name and method name can include the J apanese character set e Invoking COBOL from Java No COBOL program can be invoked from Java A COBOL program invoked from Java can use no adapter class Preparation The following products are required for the development or execution environment for using the J adapter class generator Fujitsu NetCOBOL or Fujitsu NetCOBOL Runtime System Fujitsu NetCOB
79. r names are too long the method name cross reference list file can be used for identification This option is exclusive with the r option gc option gm option and gf option OV Specifies that any existing adapter class with the same name be overwritten If this parameter is omitted no adapter class is overwritten r Specify this option when specifying a constructor method field generated as an adapter class for the class name interface name specified right after this option By doing so the size of an adapter class can be reduced Refer to Specifying constructor method field Refer to the gc option for the procedure of specifying the constructor to the gm option for the procedure of specifying the method and to the gf option for the procedure of specifying the field respectively Specify the class name interface name right after this option When specifying constructor method field for more than one class names interface name specify the r option for each class name interface name If there is no single gc option or gm option or gf option that corresponds to this option the adapter class without constructor method field is generated This option has exclusive relation with the om option When this option is used be sure to create all of the adapters using the java2cob command only once If the adapter classes are generated by using the java2cob command two or more times a correct adapter class may not be
80. r uses the generation name management file to manage the correspondence of method names across classes or interfaces It then assigns numbers to methods with the same name according to the following rules 1 The adapter class generator searches the generation name management file for a method having the same name and parameter 2 If a matching method is found it uses the corresponding COBOL method name 3 If no matching method is found it generates a new COBOL method and adds it to the generation name management file 4 A COBOL method name is generated according to the following rule The COBOL method name that is first added is the same as the Java method name The second and subsequent COBOL method names are assigned number in ascending order from 01 Example The object methods corresponding to the read methods of the java io Objectinput interface java io InputStream class and java io Objectl nputStream class are assigned names as shown below Java method COBOL method 72 Chapter 5 Adapter Class Reference java io Objectlnput read java io Objectlnput read interface read byte class read 01 read byte int int read 02 java io InputStream read java io InputStream read class read byte class read 01 read byte int int read 02 java io ObjectinputStrea read java io read m class read bytel int int Eyes nputStream read 02
81. ration rules 1 The internal method name is internally used by the J adapter class generator and cannot be viewed from the class user 2 The external method name is used to identify the method The class user identifies the method with the external method name 3 An external method name is generated according to the following rules JavaMethodName nn AJava method name is used as is as a COBOL method name Ifa same method name has already been assigned the second and subsequent method names are each suffixed with a hyphen followed by a two digit number 01 to 99 to prevent name duplication See Numbering names A name exceeding 160 characters is truncated after the 160th character 4 When a parameter is declared for the method the corresponding parameter is generated See Data types for the correspondence between parameter data types 5 When a return value is declared for the method the corresponding return value is generated See Data types for the correspondence between return value data types 6 When an exception is declared for the constructor the RAISING specification is generated Chapter 5 Adapter Class Reference 61 Generation example The object method corresponding to instance method getTime of the java util Date class is generated as shown below METHOD ID JM GETTIME AS getTime LINKAGE SECTION 01 RTN VALUE PIC S9 18 COMP 5 PROCEDURE DIVISION RETURNING RTN VALUE
82. rations seine AEEA p s due ten EEEE lan rer dede 46 Fe AVA BASE Cass 47 FJ s AVASCONTROL ClaSS aina a meta ae matiere ea intense 48 FJ lt AVA ERRORClaSS rene eins satin trea dekadanse vred 50 Class or Interface Adapter Class sss eee 51 java lang String class 61 Array Adapter Class aan nei dah tennis eed 65 N mb ring Names tester nentarrenenenntanaimitnniennentnsite des ea a 69 Chapter 6 Messages r nanunnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnen 73 Java2cob Command Messages 74 Messages Output during Generation 74 NetCOBOL J Adapter Class Generator User s Guide 7 8 Messages Output during Execution UV 77 Chapter 7 Samples rrnnnnnunnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnvnnnnnnnnnnnnnnnnnnnnnnnnnen 81 Sample 1 Using Classes 81 Sample 2 Specifying Method 83 Appendix A Message LiSt aannnnnnnnunnnnnnnunnnnnnnnunnnnnnnunnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 85 Java2cob Command Messages 86 Messages Output during Generation 87 Messages Output during Execution sse eee eee 90 Appendix B Exception Type List nunnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnenn 93 T annnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 97 NetCOBOL J Adapter Class Generator User s Guide Chapter 1 Outline of J Adapter Class Generator This chapter explains the function and operating environment of the J adapter class gene
83. rator 10 Chapter 1 Outline of J Adapter Class Generator What is the Adapter Class Generator Taking advantage of the object oriented function Fujitsu NetCOBOL enables programming using class libraries The Fujitsu NetCOBOL also provides many useful foundation classes Meantime as Java becomes popular many J ava class libraries are also provided However the class structure varies from language to language and therefore J ava class libraries cannot normally be used from COBOL The J adapter class generator provides a framework that enables COBOL to use Java classes The J adapter class generator enables a COBOL program to s Use a Java class library e Call a Java application e Use an application program interface API provided for J ava The J adapter class generator enables COBOL to be used for systems that previously could only have been implemented in J ava Use of the J adapter class generator is recommended in the following situations e Constructing a COBOL system using Java common parts such as EJ B components e Constructing a COBOL system using whole J ava applications An outline of the J adapter class generator is given below Java class library Java application Java API J adapter class generator Figure 1 1 Chapter 1 Outline of J Adapter Class Generator 11 The J ava class interface must be converted into the COBOL interface for a COBOL program to use J ava classes The J a
84. rator and retry The J adapter class generator is not installed normally Reinstall the adapter class generator Messages Output during Generation This section explains the messages output during adapter class generation including the operator responses to the messages The message format is shown below Message type Message text The message types are shown below Message type Level Meaning Error Severe No adapter class is generated Warning Cautionary An adapter class is generated However the user must check whether it has been generated as expected Error An invalid option xxx was specified The option was ignored to continue processing lt lt Since processing continues should this not be a Warning gt gt Specify a valid option and retry Error A required class name or interface name was missing Generation was interrupted Specify a valid class name or interface name and retry Chapter 6 Messages 75 Error An invalid class name xxx was specified Specify a J ava class name or interface name qualified by a package name Specify a valid class name or interface name and retry Error A valid directory name was missing The option was ignored to continue processing lt lt Same as above gt gt Specify a valid directory name and retry Error An invalid directory name xxx was specified Generation was interrupted Specify a valid directory name and retry Wa
85. repository file for compilation Construct a program as follows 1 Create a new project using the project manager 2 Register the target executable program EXE 3 Create a COBOL source file folder and store the program source in it 4 Create a library file folder and store the adapter class LIB file and J adapter class generator runtime library F3BIJART LIB in it F3BIJART LIB exists in the LIB folder of the install folder 5 Specify compiler and link options For REPIN specify XXX REP XXX is the J adapter class generator install folder and the folder containing the adapter class repository Specify ALPHAL WORD or NOALPHAL Refer to the Fujitsu NetCOBOL User s Guide for other options 6 Execute build Running a Program The following file generated from the adapter class is required to run a program e Adapter class DLL file Before running the program add the folder containing the adapter class DLL file to environment variable PATH The program can be run in the same manner as any other COBOL application Refer to the Fujitsu NetCOBOL User s Guide for details Note The Java VM operating environment can be customized by specifying environment variables see VM INIT method factory method 30 Chapter 3 Developing Programs Conversion to J ava2 When using the resources execute form programs EXE DLLs adapter class source and program source using adapter classes created by JDK1 1 x
86. ring object consisting of three characters is generated GET STRI NG X method object method Explanation This method fetches the character string from the String object as an alphanumeric data item Syntax INVOKE anObject GET STRING X RETURNING string Value Parameter and return value e anObject Specifies the String object from which a character string is to be fetched e stringValue attribute PIC X ANY LENGTH Returns the character string fetched from the String object If the specified data item is shorter than the fetched character string it is truncated If the specified data item is longer than the fetched character string the trailing area is padded with blanks 64 Chapter 5 Adapter Class Reference GET STRING N method object method Explanation This method fetches the character string from the String object as a national data item Syntax INVOKE anObject GET STRING N RETURNING stringValue Parameter and return value e anObject Specifies the String object from which a character string is to be fetched e stringValue attribute PIC N ANY LENGTH Returns the character string fetched from the String object If the specified data item is shorter than the fetched character string it is truncated If the specified data item is longer than the fetched character string the trailing area is padded with blanks GET STRI NG LENGTH X method object method Explanation This method returns the length of the ch
87. rning The generation name management file could not be generated Check whether the correct folder name was specified in the d option or whether the generation name management file java2cob mgt is write protected then retry Error The serial number exceeded 99 lt lt Should be SUFFI X not SERIAL gt gt Generation was interrupted Decrease the number of classes fields variables or methods having the same name then retry Alternatively retry while specifying the om option Error The status of file xxx is invalid for generation Check the file status Check the file status whether the folder name specified in the d option is valid or whether the file is write protected then retry Error An error occurred during writing to file xxx Check whether the output destination has enough free space then retry Warning The name of class xxx exceeded 160 characters The characters after the first 160 characters were deleted Check whether deleting the characters after the first 160 characters results in an unusable name Warning The property name of field xxx exceeded 30 characters The characters after the first 30 characters were deleted Check whether deleting the characters after the first 30 characters results in an unusable name Warning The name of method xxx exceeded 160 characters The characters after the first 160 characters were deleted Check whether deleting the characters after the first 16
88. ror failure of the error detecting feature occurred Call the J adapter class generator supplier Response The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 18 Meaning The current thread could not be connected to Java VM Response Check whether the program normally invokes the VM INIT method or the J VM ATTACH method 19 Meaning The current thread could not be disconnected from J ava VM Response Check whether the program normally invokes the J VM TERMINATE method or the JVM DETACH method Index adapter class 14 34 46 51 adapter object 15 alphanumeric item 27 28 34 40 array 65 assign 25 C 32 54 63 class file 18 20 class method 11 26 57 class variable 11 25 26 56 classpath 35 37 classpath 32 constructor 32 34 37 51 54 55 57 70 constructors See constructor cross reference 33 39 42 43 58 d 32 Environment variable 48 exception 11 28 46 50 54 55 57 60 external class 21 53 external method 57 factory 11 23 54 55 57 70 gc 20 32 34 generation name 30 43 71 GET ARRAY ELEMENT 68 GET ARRAY LENGTH 68 GET CODE 50 GET EXCEPTION 51 GET MESSAGE 50 GET STRING LENGTH N 65 GET STRING LENGTH X 64 GET STRING N 64 GET STRING X 63 gf 33 gm 33 Inheriting a Java class 11 Initialization 22 instance method 11 24 60 instance object 11 instance variable 11 26 58
89. s are generated e Adapter class DLL file required for execution e Adapter class LIB file required for link edition e Adapter class repository file required for compilation Generating an Adapter Class When the Class File is Not Available The J adapter class generator references the following class information when generating an adapter class e Super class interface e Class interface specified in the public method constructor parameter or return value e Class interface specified in the public variable 20 Chapter 3 Developing Programs Therefore an adapter class cannot be generated normally without these class files These class files may not be available depending on the environment In this case to create an adapter class normally dummy class files having these file names must be prepared Prepare a dummy class file as follows 1 Create a folder corresponding to the package name For package name aaa bbb ccc for instance create a folder with name aaa bbb ccc 2 Create a Java source program satisfying the following Assign this file the name ClassName java package PackageName public class ClassName 3 Compile the source program with the J ava compiler c gt javac FolderName ClassName java 4 Enter the java2cob command c gt java2cob PackageName ClassName Note If a class file is referred to but does not exist when attempting to generate an adapter class processing is termina
90. s interface 12 Meaning Java VM initialization failed Check the environment variables PATH COB NI_ CLASSPATH and J DK or JRE install environment Response The J DK J 2SDK J RE or J ARE environment contains an error Check whether the environment variables PATH and COBJNI CLASSPATH are normal or whether J DK J2SDK JRE or J2RE is installed normally 13 Meaning The character string could not be fetched from the String object Call the adapter class generator supplier Response The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 14 Meaning Type conversion failed Check the parameter passed to the J NARROW method Response The object specified in the parameter is not a subclass or object of the class Check the parameter of the J NARROW method 96 Appendix B Exception Type List 15 Meaning An internal logical error inconsistency between the return value and object reference occurred Call the J adapter class generator supplier Response The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer 16 Meaning Java VM detected an error Remove the error cause exception name supplementary information Response The J ava VM detected an execution time error Determine the error cause from the exception name and supplementary information and remote it 17 Meaning An internal logical er
91. s or interface refers to other classes or interfaces the adapter classes corresponding those classes or interfaces are also generated This processing is recursive until the following conditions are met s No other classes or interfaces are referenced e Adapter classes corresponding to the referenced classes or interfaces have all been generated e A source file with the same name already exists in the output destination while overwriting is not specified The name of a generated source file is created from the class name or interface name qualified by the package name according to the following rules e Period and dollar are converted into hyphen e The extension is fixed to cob When the java2cob command is executed the names of the adapter classes being generated are displayed Chapter 4 Using the Generator Command 43 Figure 4 1 Generation Name Management File The J adapter class generator uses a generation name management file to manage the correspondence between the names used in Java classes and adapter classes The generation name management file is generated with the following name in the adapter class output folder java2cob mgt See Numbering names for information on how to use the generation name management file Method Name Cross Reference List File A method name cross reference list file is output so that the operator can check the correspondence between J ava class methods and adapter class meth
92. t at execution time Caution An error occurs when this method is invoked two or more times in one process J VM TERMI NATE Method factory method Explanation The current thread is isolated from the Java VM In the multithread applications the current thread must be isolated from J ava VM before the thread is terminated Also when it is called by the last thread in a process Java VM is terminated It is used when the adapter class is used no more Syntax INVOKE EI J AVA CONTROL JVM TERMINATE Caution An error occurs when this method is invoked two or more times in one process J VM ATTACH Method factory method Explanation The current thread is isolated from the Java VM In the multithread applications the current thread must be isolated from J ava VM before the thread is terminated Syntax INVOKE FJ JAVA CONTROL J VM ATTACH J VM DETACH method factory method Explanation This is equivalent to the J VM TERMINATE method Syntax INVOKE FJ JAVA CONTROL J VM DETACH 50 Chapter 5 Adapter Class Reference FJ JAVA ERROR class The adapter class generates the exception object when some error is detected during execution period The FJ JAVA ERROR class is the class of that exception object The exception message exception type and exception information of J ava can be acquired by using the FJ JAVA ERROR class method Refer to Fujitsu NetCOBOL User s Guide for details of the exception process
93. ted with message Class information was not found Generation was interrupted Reducing the Size of Adapter Class The adapter class source generated by the J adapter class generator may be simply compiled and linked before it is used Since however the adapter source class can include class files which are not used by the applications there might be cases where the size of the DLL file of the adapter class is significantly larger than necessary In a case like this the size of the adapter class can be reduced by the following methods e Specifying the constructor method field e Specifying the om option or the Option ReduceClass parameter Specifying the Constructor Method Field When the constructors methods and fields that are used in the application are known the number of the adapter classes generated can be reduced by specifying them The J adapter class generator generates only the adapter classes that are required by the specified constructors methods fields Refer to r option gc option gm option gf option and Class class name interface name parameters for details of the procedure of specifying the constructor method field Chapter 3 Developing Programs 21 Example When an application uses only the printin Object method of the java io PrintStream class specify as follows C gt java2cob r java io PrintStream gm println java lang Object J J Specifying the om Option or the Optio
94. the methods of the same name are generated When specifying a parameter type enclose the parameter type with parenthesis and enclose the entire option with double quotation to specify a parameter A parameter type can be specified by data type name or by the class name that is qualified by the package name When specifying an internal class name as the parameter type specify dollar instead of period for the internal class name This option is valid when the r option is specified This option has exclusive relation with the om option i optional file Specify an optional file When this option is specified other options in the command line are ignored oi Specifies that a method name cross reference list file listing adapter class methods corresponding to Java class methods be output The method name cross reference list file is output with name adapter class source file name txt for each J ava class 34 Chapter 4 Using the Generator Command om Specified to reduce the number of adapter classes generated When this parameter is specified the object reference types of all parameters excluding RETURNING become java lang Object Instead the parameter names are generated so that they include original type information see Specifying the om option or the Option ReduceClass parameter The class browser can identify almost every method If the class browser cannot identify methods such as because paramete
95. til Date INHERITS J OBJECT 1 REPOSITORY CLASS J OBJECT AS java lang Object 2 END CLASS J DATE 1 The name of the adapter class of the java util Date class is java util Date 2 The external name of J OBJECT in the INHERIT clause is java lang Object That is java util Date inherits java lang Object 54 Chapter 5 Adapter Class Reference Note Fujitsu NetCOBOL does not distinguish between uppercase and lowercase letters of a class name Therefore class names whose external class names are different only in uppercase and lowercase letters cannot be used concurrently Supplement When the adapter class of java lang String is generated the public method defined in the java lang String class is generated In addition a method for referencing or setting character string data is generated see ava lang String class Constructor Explanation A public constructor is mapped to a COBOL factory method Expansion format METHOD ID internal method name AS external method name DATA DIVISION LINKAGE SECTION 01 generated object OBJECT REFERENCE SELF parameter PROCEDURE DIVISION USING parameter RETURNING generated object RAISING exception class name END METHOD internal method name Generation rules 1 The internal method name is internally used by the J class method generator and are not viewed from the class user 2 The external method name is used to identify the method The class
96. ue is outside the range from 0 to element count 1 Specify a valid subscript The class of the set object is invalid Specify a subclass of the array element class An attempt was made to set an invalid class object in an array element Set an object of a valid class An object of the array element class or its subclass must be set An internal logical error inconsistency between the return value and object reference occurred Call the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer Java VM detected an error Remove the error cause exception name supplementary information The Java VM detected an execution time error Determine the error cause from the exception name and supplementary information and remove it An internal logical error failure of the error detecting feature occurred Call the J adapter class generator supplier The J adapter class generator failed Collect failure information and call your Fujitsu systems engineer Appendix B Exception Type List The exception types that can be acquired by the GET CODE method of the FJ J AVA ERROR class are described in this chapter 1 Meaning Java VM detected an error Remove the error cause Response The Java VM detected an execution time error Determine the error cause from the exception information returned by the GET EXCEPTION method of FJ JAVA ERROR class
97. user can identify the method with the external method name 3 An external method name is generated according to the following rules Create JavaClassName nn Create is followed by a J ava class name with a hyphen followed by a two digit number nn The Java class name does not include the package name nnisa serial number assigned in order from 01 to 99 to methods having the same J ava class name Ifa super class has classes having the same J ava class names serial numbers are assigned to such classes in order from the super class See Numbering names A name exceeding 160 characters is truncated after the 160th character 4 When a parameter is declared for the constructor the corresponding parameter is generated See Data types for the correspondence between parameter data types 5 The generated object is the unique object reference name used to store the object reference to the generated adapter object Chapter 5 Adapter Class Reference 55 6 When an exception is declared for the constructor the RAISING specification is generated Generation example The factory method corresponding to constructor Date of the java util Date class is generated as shown below METHOD ID CREATE 01 AS Create Date OL LINKAGE SECTION 01 CREATED OBJECT OBJECT REFERENCE SELF PROCEDURE DIVISION RETURNING CREATED OBJECT END METHOD CREATE 01 1 The factory method of java util Date is generate

Download Pdf Manuals

image

Related Search

Related Contents

Toshiba 32ZT29B CRT Television User Manual  Sony TV KF-50SX100K  Terratec Grabster AV 400  Samsung BQ1AD4T013/XEF manual de utilizador  K 座 御注意 \    Paradyne 8784 User's Manual  8月1日号 No.15(PDF文書)  Hamilton Beach 62695D User's Manual  Rapier Switch User Guide  

Copyright © All rights reserved.
DMCA: DMCA_mwitty#outlook.com.