Manuel d'utilisation / d'entretien du produit J Adapter Class Generator du fabricant Fujitsu
Aller à la page of 98
J Adapter Class Generator User’s Guide.
Seventh Edition: August 2005 The contents of this manual may be revised withou t 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 writte n permission of Fujitsu Limited.
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 inst alled to execute the generator or the adapter class generated.
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 th e J adapter class generator, and adapter classes generated by the J adapter class generator. Appendix A.
Registered Trademarks The registered trademarks appearin g in this manual are as follows: Microsoft, Windows, and Windows NT ar e registered trademarks of Microsoft Corporation in the U.S. and other countries. Java and other trademarks including Java are trademarks of Sun Microsystems, Inc.
6 NetCOBOL J Adapter Class Generator User's Guide.
NetCOBOL J Adapter Class Generat or User's Guide 7 Contents Chapter 1. Outline of J Adapter Class Generator ......................................... 9 What is the J Adapte r Class Gene rator? .....................................................
8 NetCOBOL J Adapter Class Generator User's Guid e Messages Output duri ng Execut ion .....................................................................77 Chapter 7. Samples .....................................................................
Chapter 1. Outline of J Adapter Class Generator This chapter explains the function and op erating environment of the J adapter class generator..
10 Chapter 1. Outline of J Adapter Class Generator What is the J Adapter Class Generator? Taking advantage of the object-oriente d function, Fujitsu NetCOBOL enables programming using class libraries . The Fuji tsu NetCOBOL also provides many useful foundation classes.
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.
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 Java object, CO BOL cannot be used to write listeners.
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 Java classes available to COBOL, a mechanism for converting the Java class interface into the COBOL interface is requ ired. The J adapter class generator works as an interface converting mechanism to generate adapter classes corresponding to Java classes.
Chapter 2. Adapter Class Generator Framework 15 Adapter Object At execution time, an adapter class genera tes the adapter object corresponding to a Java instance object.
16 Chapter 2. Adapter Class Generator Framework.
Chapter 3. Developing Programs This chapter explains how to develo p programs that use Java classes..
18 Chapter 3. Developing P rograms Creating Adapter Classes This section explains how to generate an adapter class from a Java class. Investigating the Java Class First investigate the specifications .
Chapter 3. Developi ng 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 ad apter class source to create an adapter class library (DLL).
20 Chapter 3. Developing P rograms 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.
Chapter 3. Developi ng Programs 21 Example: When an application uses only the println (O bject) method of the java.io.PrintStream class, specify as follows: C:> java2cob -r java.
22 Chapter 3. Developing P rograms ... 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.
Chapter 3. Developi ng 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: ...
24 Chapter 3. Developing P rograms 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.
Chapter 3. Developi ng 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.
26 Chapter 3. Developing P rograms 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" .
Chapter 3. Developi ng 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.
28 Chapter 3. Developing P rograms If an adapter class is generated by specifying the -t option or the "Option Terminal" parameter, the character string that is sh orter than the data item l.
Chapter 3. Developi ng 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.
30 Chapter 3. Developing P rograms 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.
Chapter 4. Using the Generator Command This chapter explains how to use the ge nerator command (java2cob), optional file and output result..
32 Chapter 4. Using the Generat or 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 .
Chapter 4. Using the Generat or 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 sa me name exist, only the constructor that matches the parameter type is generated by specifying the parameter-type.
34 Chapter 4. Using the Generat or Command -om Specified to reduce the number of adapter cl asses generated. When this parameter is specified, the object reference types of all parameters excluding RETURNING become java-lang-Object.
Chapter 4. Using the Generat or 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.
36 Chapter 4. Using the Generat or 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.
Chapter 4. Using the Generat or 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.
38 Chapter 4. Using the Generat or 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.
Chapter 4. Using the Generat or 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).
40 Chapter 4. Using the Generat or Command Option ReduceClass Specification format Option ReduceClass = { YES | NO } Specification contents Specify whether or not to reduce the number of adapter classes.
Chapter 4. Using the Generat or 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.
42 Chapter 4. Using the Generat or 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.
Chapter 4. Using the Generat or Command 43 Figure 4.1 Generation Name Management File The J adapter class generator uses a gene ration name management file to manage the correspondence between the names used in Java classes and adapter classes.
44 Chapter 4. Using the Generat or 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 informatio n on the FJ-JAVA-BASE, FJ-JAVA-CONTROL and FJ-JAVA-ERROR classes provided by th e J adapter class generator, and adapter classes generated by the J adapter class generator.
46 Chapter 5. Adapter Class Ref erence Class Configuration The figure below shows the hierarchical re lationships among the FJ-JAVA-BASE, FJ- JAVA-CONTROL and FJ-JAVA-ERROR classe s provided by the J adapter class generator, and adapter classes generated by the J adapter class generator.
Chapter 5. Adapter Class Ref erence 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.
48 Chapter 5. Adapter Class Ref erence J-EQUALS Method (object method) Explanation This method checks whether the Java objects indicated by two adapter objects are equal.
Chapter 5. Adapter Class Ref erence 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.
50 Chapter 5. Adapter Class Ref erence FJ-JAVA-ERROR class The adapter class generates the exception object when some error is detected during execution period.
Chapter 5. Adapter Class Ref erence 51 GET-EXCEPTION method (object method) Explanation The Java exception information is returned. Syntax INVOKE EXCEPTION-OBJECT "GET-EXCEPTION" USING messa.
52 Chapter 5. Adapter Class Ref erence 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 PIC X(2) • When an ANK character is stored, the first byte is used and the second byte is X'00'.
Chapter 5. Adapter Class Ref erence 53 Expansion format CLASS-ID. internal-class-name-1 AS " external-class-name " INHERITS internal- class-name-2 .
54 Chapter 5. Adapter Class Ref erence Note: Fujitsu NetCOBOL does not distingu ish between uppercase and lowercase letters of a class name. Therefore, cl ass names whose external class names are different only in uppercase and lowercas e letters cannot be used concurrently.
Chapter 5. Adapter Class Ref erence 55 6. When an exception is declared for the constructor, the RAISING specification is generated. Generation example The factory method corresponding to construc tor Date() of the java.util.Date class is generated as shown below: METHOD-ID.
56 Chapter 5. Adapter Class Ref erence Class variable Explanation A public class variable (static field) is ma pped to a COBOL property method (factory). Expansion format METHOD-ID. GET PROPERTY property-name. ... LINKAGE SECTION. 01 property-value data-description-entry.
Chapter 5. Adapter Class Ref erence 57 2. "out" is mapped to J-PRINTSTREAM (interna l 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.
58 Chapter 5. Adapter Class Ref erence 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". [1] ... LINKAGE SECTION. 01 RTN-VALUE PIC S9(18) COMP-5.
Chapter 5. Adapter Class Ref erence 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.
60 Chapter 5. Adapter Class Ref erence Instance Method Explanation A non-public instance method (non-stati c method) is mapped to a COBOL object method. Expansion format METHOD-ID. internal-method-name AS "external-method-name" [OVERRIDE]. .
Chapter 5. Adapter Class Ref erence 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". [1] ... LINKAGE SECTION. 01 RTN-VALUE PIC S9(18) COMP-5.
62 Chapter 5. Adapter Class Ref erence 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.
Chapter 5. Adapter Class Ref erence 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.
64 Chapter 5. Adapter Class Ref erence GET-STRING-N method (object method) Explanation This method fetches the character string fr om the String object as a national data item.
Chapter 5. Adapter Class Ref erence 65 GET-STRING-LENGTH-N method (object method) Explanation This method returns the length of the char acter string of the String object as the length (number of characters) of the national data item.
66 Chapter 5. Adapter Class Ref erence Expansion format CLASS-ID. internal-class-1 AS "external-class-name" INHERITS internal- class-name-2. .
Chapter 5. Adapter Class Ref erence 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.
68 Chapter 5. Adapter Class Ref erence ... 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.
Chapter 5. Adapter Class Ref erence 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.
70 Chapter 5. Adapter Class Ref erence Name that is always unique according to generation rules A class name is generated from a class na me or interface name qualified by a Java package name. Since the qualified name is unique, the COBOL name generated from it is always unique.
Chapter 5. Adapter Class Ref erence 71 the J adapter class generator. For instance, the java.io.ObjectInputStream class inherits the java.io.ObjectInput interfac e and java.io.InputStream class (see the figure below). Figure 5.2 Relationships among java.
72 Chapter 5. Adapter Class Ref erence read() read read(byte[]) read-01 java.io.ObjectInput interface read(byte[], int, int) java-io-ObjectInput class read-02 read() read read(byte[]) read-01 java.io.InputStream class read(byte[], int, int) java-io-InputStream class read-02 read() read java.
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. Messa ges 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.
Chapter 6. Messa ges 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.
76 Chapter 6. Messa ges 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.
Chapter 6. Messa ges 77 Messages Output during Execution This section explains the messages output during execution of programs using adapter classes, including the oper ator responses to the messages.
78 Chapter 6. Messa ges 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.
Chapter 6. Messa ges 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 ch anged after generation of an adapter class. Check the Java class/interface.
80 Chapter 6. Messa ges.
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.
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).
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.
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 "println(java.lang.Object)" [2] -r java.util.Date -gc "Date()" [3] Note: “” shows the continuance line.
Appendix A. Message List This chapter explains the messages output by the J adapter class generator, including the operator responses to the messages..
86 Appendix A. Message Li st 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.
Appendix A. Message Li st 87 Messages Output during Generation This section explains the messages output during adapter class generation, including the operator responses to the messages.
88 Appendix A. Message Li st Error: The suffix number exceeded 99. Generation was interrupted. Retry while specifying –r option, -gc opti on, -gm option, -gf option, -om option, constructor/method/f.
Appendix A. Message Li st 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.
90 Appendix A. Message Li st Messages Output during Execution This section explains the messages output during execution of programs using adapter classes, including the oper ator responses to the messages.
Appendix A. Message Li st 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. Co llect failure information and call your Fujitsu systems engineer.
92 Appendix A. Message Li st 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 ch anged after generation of an adapter class. Check the Java class/interface.
Appendix B. Exception Type List The exception types that can be acquired by the GET-CODE method of the FJ-JAVA- 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 e rror.
94 Appendix B. Excepti on Type List 5 Meaning No Java field is found. Check whether th e 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.
Appendix B. Excepti on 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.
96 Appendix B. Excepti on 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.
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.
98 Index 98 -r, 20, 33, 34, 58 ReduceClass , 40 restrictions, 12 return value, 57 Runtime, 12 -s[n], 34 SET-ARRAY-ELEMENT, 69 source file, 19, 29, 42 String class, 26, 44, 54, 61 -t, 34 Termination, 2.
Un point important après l'achat de l'appareil (ou même avant l'achat) est de lire le manuel d'utilisation. Nous devons le faire pour quelques raisons simples:
Si vous n'avez pas encore acheté Fujitsu J Adapter Class Generator c'est un bon moment pour vous familiariser avec les données de base sur le produit. Consulter d'abord les pages initiales du manuel d'utilisation, que vous trouverez ci-dessus. Vous devriez y trouver les données techniques les plus importants du Fujitsu J Adapter Class Generator - de cette manière, vous pouvez vérifier si l'équipement répond à vos besoins. Explorant les pages suivantes du manuel d'utilisation Fujitsu J Adapter Class Generator, vous apprendrez toutes les caractéristiques du produit et des informations sur son fonctionnement. Les informations sur le Fujitsu J Adapter Class Generator va certainement vous aider à prendre une décision concernant l'achat.
Dans une situation où vous avez déjà le Fujitsu J Adapter Class Generator, mais vous avez pas encore lu le manuel d'utilisation, vous devez le faire pour les raisons décrites ci-dessus,. Vous saurez alors si vous avez correctement utilisé les fonctions disponibles, et si vous avez commis des erreurs qui peuvent réduire la durée de vie du Fujitsu J Adapter Class Generator.
Cependant, l'un des rôles les plus importants pour l'utilisateur joués par les manuels d'utilisateur est d'aider à résoudre les problèmes concernant le Fujitsu J Adapter Class Generator. Presque toujours, vous y trouverez Troubleshooting, soit les pannes et les défaillances les plus fréquentes de l'apparei Fujitsu J Adapter Class Generator ainsi que les instructions sur la façon de les résoudre. Même si vous ne parvenez pas à résoudre le problème, le manuel d‘utilisation va vous montrer le chemin d'une nouvelle procédure – le contact avec le centre de service à la clientèle ou le service le plus proche.