J Adapter Class Generator User’s Guide
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. © 1996-2005 Fujitsu Limited. All Rights Reserved.
Preface The "NetCOBOL J 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 Java 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 Java classes.
Chapter 5. Adapter Class Reference Chapter 5 provides detailed information on the FJ-JAVA-BASE, FJ-JAVA-CONTROL and FJ-JAVA-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.
Registered Trademarks The registered trademarks appearing in this manual are 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.
NetCOBOL J Adapter Class Generator User's Guide
Contents Chapter 1. Outline of J Adapter Class Generator .........................................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 ...................................................11 Preparation ...............................................................................................
Messages Output during Execution .....................................................................77 Chapter 7. Samples ....................................................................................81 Sample 1 – Using Classes...................................................................................81 Sample 2 – Specifying Method............................................................................83 Appendix A. Message List............................................................
Chapter 1. Outline of J Adapter Class Generator This chapter explains the function and operating environment of the J adapter class generator.
Chapter 1. Outline of J Adapter Class Generator What is the J 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 Java class libraries are also provided. However, the class structure varies from language to language and therefore Java class libraries cannot normally be used from COBOL.
Chapter 1. Outline of J Adapter Class Generator 11 The Java class interface must be converted into the COBOL interface for a COBOL program to use Java classes. The J adapter class generator generates an adapter class that converts the Java 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 Java. To COBOL programs, Java objects seem to be COBOL objects.
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 Java object, COBOL cannot be used to write listeners. - Collection class No COBOL object can be registered in a Java collection class. When using COBOL objects as a collection, use a COBOL collection class.
Chapter 2. Adapter Class Generator Framework This chapter explains the framework of the J adapter class generator.
Chapter 2. Adapter Class Generator Framework Adapter Class To make Java classes available to COBOL, a mechanism for converting the Java 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.
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: • Holds the pointer to the corresponding Java instance object. • Calls the corresponding Java method of the corresponding Java instance object Only the adapter object can be seen from the COBOL program. Every operation on the adapter object is transmitted to the corresponding Java object.
Chapter 2.
Chapter 3. Developing Programs This chapter explains how to develop programs that use Java classes.
Chapter 3. Developing Programs Creating Adapter Classes This section explains how to generate an adapter class from a Java class. Investigating the Java Class First investigate the specifications of the Java 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.
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.
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.
Chapter 3. Developing Programs 21 Example: When an application uses only the println (Object) method of the java.io.PrintStream class, specify as follows: C:\> java2cob -r java.io.PrintStream -gm "println(java.lang.Object)" Specifying the -om Option or the "Option ReduceClass" Parameter Specifying the -om option or the "Option ReduceClass" parameter can reduce the number of adapter classes generated.
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: 1. Initialization of the Java VM. 2. In the case of a multithreaded application, connection of the current thread to the Java VM . 3.
Chapter 3. Developing Programs 23 Terminating the Java 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).
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: • Since the adapter class name is very long, it is recommended that an alias be assigned by specifying AS in the REPOSITORY paragraph.
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.
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.
Chapter 3. Developing Programs 27 … 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 J-DateFormat AS "java-text-DateFormat" 01 01 01 …WORKING-STORAGE SECTION aDateFormat OBJECT REFERENCE J-DateFormat. aDate OBJECT REFERENCE J-Date. dateValue PIC X(30).
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.
Chapter 3. Developing Programs 29 DISPLAY "Error Code: " errCode. DISPLAY "Error Message: " errMessage(1: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 (JMP0104I-U) occurs due to the occurrence of the exception object.
Chapter 3. Developing Programs Conversion to Java2 When using the resources (execute-form programs (EXE), DLLs, adapter class source, and program source using adapter classes) created by JDK1.1.x, note the following: • Adapter class source and DLLs created by JDK 1.1.x can be used as they are in the Java2 environment. • 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").
Chapter 4. Using the Generator Command This chapter explains how to use the generator command (java2cob), optional file and output result.
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[n]] [t] –r class-name/interface-name [-gc ["constructor-name [(parameter-type)] [,...
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. If a parameter type is omitted, all of the constructors of the same name are generated.
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.
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 Java class/interface search path. When -classpath is specified, the CLASSPATH environment variable is ignored. Notes: • When specifying constructor/method/field, be sure to specify the -r option, classname/interface-name, -gc option, -gm option and -gf option successively.
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 accomplished by creating the optional file.
Chapter 4. Using the Generator Command 37 Notes on describing the optional file: • Clauses enclosed by square brackets can be omitted. • Curly brackets indicate selection of clause that is delimited by ”| ”. • Italic type indicates a variable character string. Class class-name/interface-name Specification format Class class-name/interface-name [ = constructor/method/field-specifyingoption ] Specification contents Specify the Java class name or interface name that generates an adapter class.
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 Java class. When omitted, it is assumed that SJIS is specified. Meaning of the parameter • SJIS Specify it when the code system during execution time is native code. • UNICODE Specify it when the code system during execution time is Unicode.
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 (list of adapter class methods that correspond to the Java 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 Java class.
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 include the original type information instead. (Refer to "Specifying the -om option or "Option ReduceClass" parameter.
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 strings, 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 • YES Generate an adapter class in which the end character string setting is made.
Chapter 4. Using the Generator Command Output The generator outputs the following files: • Adapter class source file • Generation name management file • Method name cross-reference list file Adapter Class Source File The adapter class source file corresponding to the specified Java class or interface is generated. If the specified class or interface refers to other classes or interfaces, the adapter classes corresponding those classes or interfaces are also generated.
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.
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...
Chapter 5. Adapter Class Reference This chapter provides detailed information on the FJ-JAVA-BASE, FJ-JAVA-CONTROL and FJ-JAVA-ERROR classes provided by the J adapter class generator, and adapter classes generated by the J adapter class generator.
Chapter 5. Adapter Class Reference Class Configuration The figure below shows the hierarchical relationships among the FJ-JAVA-BASE, FJJAVA-CONTROL and FJ-JAVA-ERROR classes provided by the J adapter class generator, and adapter classes generated by the J adapter class generator. Figure 5.0.1 Class Hierarchy • FJ-JAVA-BASE: Super class of every adapter class • FJ-JAVA-CONTROL: Initializes or terminates the Java VM, or connects or disconnects a thread to the Java VM.
Chapter 5. Adapter Class Reference 47 FJ-JAVA-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 Java objects indicated by two adapter objects are equal. J-NARROW Method (factory method) Explanation This method assigns an adapter object to a subclass.
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 "J-EQUALS" USING object-2 RETURNING result Parameter and return value • object-1, object-2 (attribute: OBJECT REFERENCE FJ-JAVA-BASE) Specifies the adapter objects to be compared. • result (attribute: PIC 1) Returns B'1' if a match occurs; otherwise, returns B'0'.
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.
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 Java can be acquired by using the FJ-JAVA-ERROR class method. Refer to "Fujitsu NetCOBOL User's Guide" for details of the exception processing. The FJ-JAVA-ERROR class has the following methods.
Chapter 5. Adapter Class Reference 51 GET-EXCEPTION method (object method) Explanation The Java exception information is returned. Syntax INVOKE EXCEPTION-OBJECT "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 Java exception message. • messageLength (attribute: PIC S9(9) COMP-5) Length (number of bytes) of Java exception message is returned.
Chapter 5. Adapter Class Reference Data types The Java data types are mapped to the COBOL data types as shown below: Java data type COBOL data type boolean PIC 1 byte PIC X char PIC X(2) • When an ANK character is stored, the first byte is used and the second byte is X'00'. • When a Japanese character is stored, two bytes are used. • Data is mapped when code option -cs (native code) or no code option is specified.
Chapter 5. Adapter Class Reference 53 Expansion format CLASS-ID. internal-class-name-1 AS "external-class-name" INHERITS internalclass-name-2. ... FACTORY. ... <> <> <> END FACTORY. OBJECT. ... <> <
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.
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-01". ... LINKAGE SECTION. 01 CREATED-OBJECT OBJECT REFERENCE SELF. PROCEDURE DIVISION RETURNING CREATED-OBJECT. ... END METHOD CREATE-01. [1] 1.
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 property-name. METHOD-ID. SET PROPERTY property-name. ... LINKAGE SECTION. 01 property-value data-description-entry PROCEDURE DIVISION USING property-value. ...
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.
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] 1. Since more than one "abs" method is declared, a method with name "abs-01" is generated for abs (long) that is declared second.
Chapter 5. Adapter Class Reference - - 59 If a 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.
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. Generation rules 1.
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. ... END METHOD JM-GETTIME. [1] 1. Since there is only one method with name "getTime," a method with name "getTime" is generated with no number assigned.
Chapter 5. Adapter Class Reference Parameter and return value • class-name Specifies the internal class name of the java-lang-String class declared in the REPOSITORY paragraph. • initialValue (attribute: PIC X ANY LENGTH) Specifies an alphanumeric data item as the initial value of the String object. • 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.
Chapter 5. Adapter Class Reference • 63 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. ...
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 • anObject Specifies the String object from which a character string is to be fetched. • stringValue (attribute: PIC N ANY LENGTH) Returns the character string fetched from the String object.
Chapter 5. Adapter Class Reference 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 • anObject Specifies the String object whose character length is to be checked. • stringLength (attribute: PIC S9(9) COMP-5) Returns character string length.
Chapter 5. Adapter Class Reference Expansion format CLASS-ID. internal-class-1 AS "external-class-name" INHERITS internalclass-name-2. ... FACTORY. ... <> END FACTORY. OBJECT. ... <> <> <> END OBJECT. END CLASS internal-class-name-1. 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.
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. ... END CLASS CLASS-ID. ... END CLASS CLASS-ID. ... END CLASS JA-3-INT AS "JA-3-int" INHERITS J-OBJECT. [1] JA-3-INT. JA-2-INT AS "JA-2-int" INHERITS J-OBJECT. [2] JA-2-INT. JA-1-INT AS "JA-1-int" INHERITS J-OBJECT. [3] JA-1-INT. 1.
Chapter 5. Adapter Class Reference ... REPOSITORY. CLASS JA-2-INT AS "JA-2-int" CLASS JA-1-INT AS "JA-1-int" ... 01 anArray OBJECT REFERENCE JA-2-INT. 01 wArray OBJECT REFERENCE JA-1-INT. ... INVOKE JA-2-INT "NEW-ARRAY" USING n RETURNING anArray. PERFORM VARYING I FROM 0 BY 1 UNTIL I >= 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. [1] [2] [3] 1.
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 inx elemValue Parameter and return value • anObject Specifies the array object in which an element is to be set. • inx (attribute: PIC S9(9) COMP-5) Specifies the subscript of the element to be set. The subscript begins from 0.
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 Java 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.
Chapter 5. Adapter Class Reference 71 the J adapter class generator. For instance, the java.io.ObjectInputStream class inherits the java.io.ObjectInput interface and java.io.InputStream class (see the figure below). Figure 5.2 Relationships among java.io.ObjectInput interface, java.io.InputStream class, and java.io.ObjectInputStream 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.
Chapter 5. Adapter Class Reference java.io.ObjectInput interface read() read(byte[]) java-io-ObjectInput class read(byte[], int, int) java.io.InputStream class read() read(byte[]) read() read(byte[], int, int) read-01 read-02 java-io-InputStream class read(byte[], int, int) java.io.ObjectInputStrea m class read read read-01 read-02 java-ioObjectInputStream class read read-02 Note: The way of assigning numbers may be different depending on the order adapter classes are generated.
Chapter 6. Messages This chapter explains the messages output by the J adapter class generator, including the operator responses to the messages.
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 JDK environment definition (PATH, CLASSPATH) and JDK installation.
Chapter 6. Messages 75 Error: An invalid class name "xxx" was specified. Specify a Java 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.<> 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.
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").
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/ ...
Chapter 6. Messages The current thread could not be connected to Java VM. Check whether the program properly invokes the JVM-ATTACH method. The current thread could not be disconnected from Java VM. Check whether the program properly invokes the JVM-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.
Chapter 6. Messages 79 No Java field is found. Check whether the Java class/interface was changed after execution of the J adapter class generator. The Java class/interface was probably changed after generation of an adapter class. Check the Java class/interface. Java class initialization failed. Call the J adapter class generator supplier. The J adapter class generator failed. Collect failure information and call your Fujitsu systems engineer. No Java method is found.
Chapter 6.
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 Java are used from COBOL. Outline Generate an instance of the java.util.Date class and place the content on the standard output (class variable out of the java.lang.System class).
Chapter 7. Samples Generating adapter classes Generate adapter classes using the java2cob command. java2cob java. lang. Object java2cob java.lang. System java2cob java. until. Data [1] [2] [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.
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.
Chapter 7. Samples Generating adapter classes Generate adapter classes using the java2cob command. java2cob -r java.lang.System -gf out \ -r java.io.PrintStream -gm "println(java.lang.Object)" \ -r java.util.Date -gc "Date()" [1] [2] [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. 2. Generate an adapter class of the java.io.PrintStream class that contains the println(java.lang.
Appendix A. Message List This chapter explains the messages output by the J adapter class generator, including the operator responses to the messages.
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 JDK environment definition (PATH, CLASSPATH) and JDK installation.
Appendix A. Message List 87 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.
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.
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.
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.
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. A same name is used for a parent and its child in the Java class/interface definition. Use different names for the parent and child. The Java class/interface definition contains an error. Check the Java class/interface.
Appendix A. Message List No Java method is found. Check whether the Java class/interface was changed after execution of the J adapter class generator. The Java class/interface was probably changed after generation of an adapter class. Check the Java 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.
Appendix B. Exception Type List The exception types that can be acquired by the GET-CODE method of the FJ-JAVAERROR 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, and remote it. 2 Meaning No Java method is found.
Appendix B. Exception Type List 5 Meaning No Java field is found. Check whether the Java class/interface was changed after execution of the J adapter class generator. Response The Java class/interface was probably changed after generation of an adapter class. Check the Java 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.
Appendix B. Exception Type List 95 10 Meaning A required Java class/interface definition is not found. Check the environment variable (COBJNI_CLASSPATH). Response No Java class/interface is found on the search path. Check whether the value of the environment variable (COBJNI_CLASSPATH) is valid. 11 Meaning No Java interface/abstract class instance can be generated. Check whether the Java class/interface was changed after the J adapter class generator was executed.
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 Java VM detected an execution-time error.
Index adapter class, 14, 34, 46, 51 Inheriting a Java class, 11 adapter object, 15 Initialization, 22 alphanumeric item, 27, 28, 34, 40 instance method, 11, 24, 60 array, 65 instance object, 11 assign, 25 instance variable, 11, 26, 58 -c, 32, 54, 63 interface name, 34, 37, 42, 53 class file, 18, 20 internal class, 53 class method, 11, 26, 57 Invoking COBOL from Java, 12 class variable, 11, 25, 26, 56 Japanese, 12, 35 classpath, 35, 37 Java class, 11, 14, 18, 34, 37, 51 -classpath, 32 Ja
Index -r, 20, 33, 34, 58 source file, 19, 29, 42 ReduceClass, 40 String class, 26, 44, 54, 61 restrictions, 12 -t, 34 return value, 57 Termination, 22 Runtime, 12 Unicode, 35, 38 -s[n], 34 unique name, 69 SET-ARRAY-ELEMENT, 69 98