47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... ·...

112
47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives administration and programming guidelines for JAVA_JVM7 software (GCOS 7/Open 7, Open for Java™). Special Instructions: This is the third version of the manual (Rev 02). Software Supported: Open 7 release 5.0 (or later) Java version 1.1.5 JAVA_JVM7 version 1.1.5.x.x Software/Hardware required: GCOS 7 version compatible with the above version of Open 7. Bull DPS 7000 Series Hardware. Date: May 2000 Bull S.A. CEDOC Atelier de reprographie 357,Avenue Patton BP20845 49008 ANGERS Cedex 01 FRANCE Bull HN Information Systems Inc. Publication Order Entry FAX: (800) 611-6030 MA30/415 300 Concord Rd. Billerica, MA 01821 U.S.A.

Transcript of 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... ·...

Page 1: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02

INTEROP 7

OPEN 7

JAVA 7 User's Guide

Subject: This manual gives administration and programming guidelinesfor JAVA_JVM7 software (GCOS 7/Open 7, Open for Java™).

Special Instructions: This is the third version of the manual (Rev 02).

Software Supported: Open 7 release 5.0 (or later)Java version 1.1.5JAVA_JVM7 version 1.1.5.x.x

Software/Hardware required: GCOS 7 version compatible with the above version of Open 7.Bull DPS 7000 Series Hardware.

Date: May 2000

Bull S.A.CEDOCAtelier de reprographie357,Avenue Patton BP2084549008 ANGERS Cedex 01FRANCE

Bull HN Information Systems Inc.Publication Order EntryFAX: (800) 611-6030MA30/415300 Concord Rd.Billerica, MA 01821U.S.A.

Page 2: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02

Copyright © Bull S.A., 1999, 2000

Bull acknowledges the rights of proprietors of trademarks mentioned herein.

Your suggestions and criticisms concerning the form, contents and presentation of this manual are invited.A form is provided at the end of this manual for this purpose.

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by anymeans, electronic, mechanical or otherwise without the prior written permission of the publisher.

Bull disclaims the implied warranties of merchantability and fitness for a particular purpose and makes noexpress warranties except as may be stated in its written agreement with and for its customer. In no event is Bullliable to anyone for any indirect, special, or consequential damages.The information and specifications in this document are subject to change without notice.Consult your Bull Marketing Representative for product or service availability.

Page 3: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 iii

Preface

The JAVA_JVM7 User's Guide provides information on the use of theGCOS 7/Open 7 implementation of Java software.

This software is hereafter referred to as the JAVA_JVM7 software.

This manual is intended for both the Java application developer and theadministrator of JAVA_JVM7 software.

None.

The manual is structured as follows:

Chapter 1 provides an overview of JAVA_JVM7 software.

Chapter 2 provides preliminary planning information for the use of theJAVA_JVM7 software.

Chapter 3 provides detailed information on deploying a Java application on theGCOS 7/Open 7 System.

Chapter 4 describes the special considerations for the Java application that wasdeveloped per the Remote Method Invocation (RMI) specification.

Chapter 5 provides information on the two means available for a Java applicationto access GCOS 7 legacy databases such as UFAS.

Chapter 6 provides information on user C Native Applications invoked through JNI(Java Native Interface).

Appendix A contains an example of RMI (Remote Method Invocation).

Appendix B describes a JTDS access to IOF or TDS from JAVA.

Appendix C describes UFAS access from JAVA.

Appendix D contains an example of Java JNI (Java Native Interface).

Scope andObjectives

IntendedReaders

Prerequisites

Structure

Page 4: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

iv 47 A2 38UT Rev02

GCOS 7 Documentation

The supporting GCOS 7 and Open 7 software documentation can be orderedthrough a Marketing and Sales Order Entry. Most of the GCOS 7 documents areavailable on Bull's CD-ROM product.

Contact your marketing representative for more information.

You can report documentation discrepancies using Software Technical ActionRequests (STARs) via the OSCAR system (depending on your local accountprocedures). All documentation corrections are transferred to the OSCARdatabase. Installations that use OSCAR should check regularly with their localcustomer support organization to determine if corrections have been added.

Java Documentation

The following Java documents are part of the Java series published by Addison-Wesley and Javasoft. These documents are readily available at most leadingbookstore chains and technical bookstores.

The Java Application Programming Interface, Volume 1The Java Application Programming Interface, Volume 2The Java Class LibrariesThe Java FAQThe Java Language SpecificationThe Java Programming LanguageThe Java TutorialThe Java Virtual Machine Specification

In addition, online Java documentation may be located on the World Wide Web viathe following Uniform Resource Locator (URL):

http://www.javasoft.com/

In command syntax, an item enclosed in square brackets ([optional-item]) isoptional.

In the examples, the standard C syntax is used.

This manual has generic references to Bull DPS 7000 hardware platforms. Suchreferences are applicable to all models of the Bull DPS 7000 Series large-systemcomputers. However, if information applies only to a specific model (for example,Bull DPS 7000/500), then the text states this.

For more information about the Bull DPS 7000 hardware models, contact your BullMarketing representative.

The standard Bull delivery conditions apply.

Bibliography

SyntaxNotation

DeliveryConditions

Page 5: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 v

Table of Contents

1. Introduction

1.1 JAVA_JVM7 Overview.................................................................................................... 1-1

1.2 JAVA_JVM7 Special Considerations .............................................................................. 1-3

1.3 Java Terminology............................................................................................................ 1-4

1.4 Related Documentation .................................................................................................. 1-6

1.4.1 GCOS 7 Documentation .................................................................................... 1-6

1.4.2 Java Documentation .......................................................................................... 1-6

2. Preliminary Planning

2.1 Software Required for JAVA_JVM7................................................................................ 2-1

2.2 JAVA_JVM7 Processing Limits....................................................................................... 2-1

2.3 Area for Administrator-to-Programmer Coordination ...................................................... 2-2

3. Deploying a Java Application on GCOS 7

3.1 Develop the Java Application.......................................................................................... 3-2

3.2 Transfer Java Application to GCOS 7............................................................................. 3-3

3.3 Execute the Application .................................................................................................. 3-4

4. JAVA_JVM7 Applications Developed Using RMI

5. Access to Bull Legacy Databases

5.1 Using the JTDS Package................................................................................................ 5-1

5.2 Using the UFAS Package ............................................................................................... 5-2

Page 6: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

vi 47 A2 38UT Rev02

6. User C Native Applications Invoked Through JNI (Java Native Interface)

6.1 What is JNI?.................................................................................................................... 6-1

6.2 Files in the JNIfactory Directory ...................................................................................... 6-3

6.3 JNI Example.................................................................................................................... 6-3

A. Example of RMI Connection

B. JTDS Access From Java

B.1 Introduction .....................................................................................................................B-1

B.2 Constructors Supplied with the Class .............................................................................B-2

B.2.1 For an 8-parameter Call.....................................................................................B-2

B.2.2 For a 7-parameter Call.......................................................................................B-2

B.2.3 For a 6-parameter Call.......................................................................................B-2

B.2.4 For a 5-parameter Call (Missing Password) ......................................................B-4

B.2.5 For a 4-parameter Call (Missing User and Password) ......................................B-4

B.2.6 For a 3-parameter Call (Missing Mailbox, User and Password)........................B-4

B.2.7 For a 2-parameter Call (Missing System, Mailbox, User and Password)..........B-4

B.2.8 For a 1-parameter Call (Missing Port, System, Mailbox, User and Password) .B-4

B.2.9 For a 0-parameter Call (Missing OPEN 7 Name, Port, System, Mailbox,User and Password) ..........................................................................................B-4

B.3 PUBLIC Methods Supplied .............................................................................................B-7

B.3.1 read....................................................................................................................B-7

B.3.2 write ...................................................................................................................B-9

B.3.3 Break................................................................................................................B-10

B.3.4 return_error_msg .............................................................................................B-10

B.3.5 is_open ............................................................................................................B-11

B.3.6 is_turn ..............................................................................................................B-11

B.3.7 disconnect........................................................................................................B-12

C. UFAS Access From Java

C.1 Introduction .....................................................................................................................C-1

C.2 Restrictions .....................................................................................................................C-1

C.3 GCOS7 Visibility..............................................................................................................C-1

Page 7: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 vii

C.4 Public Methods Supplied ................................................................................................C-2

C.4.1 Contructors ........................................................................................................C-2

C.4.2 open...................................................................................................................C-3

C.4.3 close...................................................................................................................C-6

C.4.4 get ......................................................................................................................C-7

C.4.5 getBeg................................................................................................................C-8

C.4.6 getInd.................................................................................................................C-9

C.4.7 getRel...............................................................................................................C-10

C.4.8 getIndCond ......................................................................................................C-11

C.4.9 getIndSecKey ..................................................................................................C-13

C.4.10 put ....................................................................................................................C-14

C.4.11 putRel...............................................................................................................C-15

C.4.12 update..............................................................................................................C-16

C.4.13 updateInd.........................................................................................................C-17

C.4.14 updateRel ........................................................................................................C-19

C.4.15 pointInd ............................................................................................................C-20

C.4.16 pointRel............................................................................................................C-22

C.4.17 pointBeg...........................................................................................................C-24

C.4.18 pointIndSecKey................................................................................................C-25

C.4.19 delete ...............................................................................................................C-27

C.4.20 deleteInd ..........................................................................................................C-28

C.4.21 deleteRel..........................................................................................................C-29

C.4.22 editG4 ..............................................................................................................C-30

C.4.23 asciiToEbcdic...................................................................................................C-31

C.4.24 ebcdicToAscii...................................................................................................C-32

C.4.25 decimalToString, decimalToDouble, decimalToInt, decimalToLong ...............C-33

C.4.26 stringToDecimal, doubleToDecimal, intToDecimal, longToDecimal ...............C-35

C.5 Principal Return Codes .................................................................................................C-38

C.5.1 Abnormal Return Codes – Catalog, File Assign, File Open ............................C-38

C.5.2 Normal Return Codes – UFAS Access Method ..............................................C-38

C.5.3 Abnormal Return Codes – UFAS Access Method...........................................C-39

C.6 Example – Copying UFAS File .....................................................................................C-41

D. Example for JavaJNI

Glossary

Index

Page 8: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

viii 47 A2 38UT Rev02

Table of Graphics

B-1. Positional Parameters - DSAconnect..............................................................................B-3B-2. Error Handling Facilities - DSAconnect...........................................................................B-5B-3. Error Handling Facilities - read .......................................................................................B-8B-4. Positional Parameter - write............................................................................................B-9B-5. Error Handling Facilities - write .......................................................................................B-9B-6. Error Handling Facilities - Break ...................................................................................B-10B-7. Error Handling Facilities - return_error_msg.................................................................B-10B-8. Error Handling Facilities - is_open ................................................................................B-11B-9. Error Handling Facilities - is_turn..................................................................................B-11B-10. Error Handling Facilities - disconnect ...........................................................................B-12

Tables

Page 9: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 1-1

1. Introduction

GCOS 7/Open 7 provides an implementation of Java™, that is called JAVA_JVM7,and which is described in this document.

NOTE:Java and all Java-based trademarks and logos trademarks are registeredtrademarks of Sun Microsystems Inc. (in the United States and other countries).

This chapter of the document provides an introduction to JAVA_JVM7, includingthe following topics:

• Overview of JAVA_JVM7 functionality

• Special considerations associated with use of JAVA_JVM7 software

• Glossary of Java terms

• Related GCOS 7/Open 7 and Java documentation

1.1 JAVA_JVM7 Overview

JVM (Java Virtual Machine)

JAVA_JVM7 software provides a Java Virtual Machine (JVM) on theGCOS 7/Open 7 System. The JVM is Java's "virtual" machine or interpreter,which executes a specific set of instructions called bytecodes.

The JVM is also responsible for certain fundamental capabilities of Java such asobject creation and garbage collection.

The GCOS 7/Open 7-ported JVM is based on the Java Developer's Kit (JDK)Version 1.1.5.

The JDK is a set of Java core packages that provide a Java programmingenvironment.

Page 10: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

1-2 47 A2 38UT Rev02

JDK Packages

The GCOS 7/Open 7-ported JVM includes all of the JDK Version 1.1.5 packagesexcept the awt and security classes.

For a complete list of the packages included in JDK Version 1.1.5 , refer to the Javadocuments listed in subsection 1.4.

JAVA_JVM7 software enables customers to download existing Java applicationsfrom any Java development platform and deploy them on the GCOS 7/Open 7System. This ability is limited, however, by the packages that are not supported.

How Java Applications Execute on GCOS 7

On the GCOS 7/Open 7 System, the Java application is loaded and executed by theJVM, which executes as a standard Open 7 process. The Java application to beexecuted, as well as configuration options for the JVM, are specified via commandline parameters in the JVM execution command line. The JVM terminates after theJava application completes execution. Java applications executed on the Open 7System can access the GCOS 7 file system to create, structure, read, and write files.

Access to Legacy Databases

Read and write access to GCOS 7 legacy databases such as UFAS, or thesubsystems (TDS or IOF), are provided via classes such as the ufas.class or theJTDS.class that are delivered separately from JAVA_JVM7. Using thesepackages, a Java application may, for example, execute a call to a TDS application(TPR) to access GCOS 7 databases.

Page 11: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Introduction

47 A2 38UT Rev02 1-3

1.2 JAVA_JVM7 Special Considerations

Based on the Java core packages that have been implemented in the JAVA_JVM7software, the following considerations regard its use:

• The following capabilities are not available on the GCOS 7 System:

− Java compilation (javac, javap, javah, …) and Java archiving (jar)

− Java graphics

− Java command shell processing

• JAVA_JVM7 cannot presently take advantage of the GCOS 7 multiprocessormode of operation. However, multiple JVMs may execute concurrently.

• All files input to or output by JAVA_JVM7 software must adhere to theGCOS 7/Open 7 file naming conventions (maximum of 14 characters; caninclude letters of the alphabet, digits 0-9, period, dash, or ASCII underscore). Inaddition, it should be noted that while UNIX file names are case-sensitive,GCOS 7 and PC file names are not case-sensitive.

− If the file name is longer than 14 characters, the JAVA_JVM7 softwaretruncates the file name to the first 14 characters when the file is opened (eitherfor input or output).

− If the file pathname contains two or more consecutive slashes ("//"), as ispermitted on some UNIX Systems, the JAVA_JVM7 software deletes all butone of the slashes.

Page 12: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

1-4 47 A2 38UT Rev02

1.3 Java Terminology

The following is a list of Java terms used in this document. For more informationon any of these terms, refer to the Java documents referenced in subsection 1.4.

Applet A Java program that can run only inside a Web pagedisplayed by a Java-capable browser such as HotJavaor Netscape.

Java Application A stand-alone Java program.

Bytecode Set of instructions, similar to machine code, that aregenerated when the Java compiler processes a Javaapplication. The bytecode, unlike machine code, canbe executed on any platform and any operating systemthat has a Java interpreter (Java Virtual Machine).

Java Class file Result of the Java compilation process (denoted by a.class suffix to the original file name). The class filecontains the bytecodes required to implement aspecific object in the Java programming language.

Java An object-oriented programming language developedby Sun Microsystems. Modeled on C++, the Javalanguage is designed to be small, simple, and portableacross hardware platforms and operating systems.

Java Developer’s Kit (JDK)A set of Java core packages that enable thedevelopment of Java applets and applications.

Java Virtual Machine The Java interpreter, which executes Java bytecodes.

JDBC Standard SQL-based database access API that is partof the JDK. JDBC, which is commonly referred to asJava Database Connectivity, provides uniform accessto a wide range of relational databases.

Method Functions defined within a class and operating oninstances of those classes.

Package Java term for a group of related classes and interfaces.Packages enable modular groups of classes to beavailable only if they are needed and eliminatepotential conflicts between class names in differentgroups of classes.

Page 13: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Introduction

47 A2 38UT Rev02 1-5

Remote Method Invocation (RMI)Object world's equivalent of Remote Procedure Calls(RPCs). RMI enables the creation of distributed Java-to-Java applications, in which the methods of Javaobjects can be invoked from other Java applications,even on different platforms.

Java Native Interface The Java Native Interface (JNI) defines a standardnaming and calling convention so that the Java VirtualMachine can locate and invoke your native methods inother languages, such as C.

Page 14: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

1-6 47 A2 38UT Rev02

1.4 Related Documentation

The following documentation is subdivided into GCOS 7 documentation and Javadocumentation.

1.4.1 GCOS 7 Documentation

The supporting GCOS 7 and Open 7 software documentation can be orderedthrough a Marketing and Sales Order Entry. Contact your Bull MarketingRepresentative for further information.

1.4.2 Java Documentation

The following Java documents are part of the Java series published by Addison-Wesley and Javasoft. These documents are readily available at most leadingbookstore chains and technical bookstores.

The Java Application Programming Interface, Volume 1The Java Application Programming Interface, Volume 2The Java Class LibrariesThe Java FAQThe Java Language SpecificationThe Java Programming LanguageThe Java TutorialThe Java Virtual Machine Specification

In addition, online Java documentation may be located on the World Wide Web viathe following Uniform Resource Locator (URL):

http://www.javasoft.com/

Page 15: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 2-1

2. Preliminary Planning

Suggested planning activities for JAVA_JVM7 software include an evaluation ofthe following:

• Software required for JAVA_JVM7 (Open 7 software and GCOS 7 software).

• JAVA_JVM7 processing limits.

• Areas for administrator-to-programmer coordination.

2.1 Software Required for JAVA_JVM7

JAVA_JVM7 software executes in association with:

• Open 7 software version 5.0 or later, and

• GCOS 7 software compatible with the Open 7 version.

2.2 JAVA_JVM7 Processing Limits

As previously indicated in Chapter 1, JAVA_JVM7 software cannot presently takeadvantage of the GCOS 7 multiprocessor system.

However, multiple JAVA_JVM7 JVMs may be executed concurrently.

Page 16: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

2-2 47 A2 38UT Rev02

2.3 Area for Administrator-to-Programmer Coordination

The primary area for administrator-to-programmer coordination is GCOS 7 file-naming conventions.

All files input to or output by JAVA_JVM7 software must adhere to GCOS 7 file-naming requirements, that is:

• A maximum of 14 characters are taken into account.

• The name may include letters of the alphabet, digits 0-9, period, dash, or ASCIIunderscore.

NOTE:If the file name is longer than 14 characters, JAVA_JVM7 software truncates thefile name to the first 14 characters when the file is opened (either for input oroutput).

In addition, it should be noted that while UNIX file names are case-sensitive,GCOS 7and PC file names are not case-sensitive.

Page 17: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 3-1

3. Deploying a Java Application on GCOS 7

This chapter lists the steps required to deploy a Java application onGCOS 7/Open 7 System.

The information presented assumes that all required software, which has beenidentified in Chapter 2, has been installed and is operational.

The steps are:

1. Develop the Java application.

2. Package the Java application class files.

3. Transfer the Java application to the GCOS 7/Open 7 System.

4. Execute the Java application on the GCOS 7/Open 7 System.

Each of these steps is described in detail in the following subsections.

Page 18: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

3-2 47 A2 38UT Rev02

3.1 Develop the Java Application

Java applications may be built on any hardware platform that has a Javadevelopment environment (e.g., a PC executing Microsoft Windows).

Any available Integrated Development Environment (IDE) such as Java Workshop,Symantec Café, or Borland Jbuilder, may be used to build the application.

These applications may have been developed specifically for the GCOS 7/Open 7execution environment or they may be applications from another executionenvironment.

The following guidelines exist for developing a Java application that can beexecuted on the GCOS 7 System:

1. All file names must comply with GCOS 7 file-naming conventions. Refer to"Area for Administrator-to-Programmer Coordination" in Chapter 2 for moreinformation on these conventions.

2. Source files cannot include any of the JDK 1.1.5 packages that are not yetsupported on the GCOS 7/Open 7 System. Refer to Chapter 1 for a completelist of these packages. If these packages are not removed, the Java exception"ClassNotFoundException" is thrown when the application is executed.

After the appropriate Java source code has been built, the source code is thencompiled into the Java bytecode format. In addition, application debugging usingvarious desktop tools may also be performed at this time.

Page 19: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Deploying a Java Application on GCOS 7

47 A2 38UT Rev02 3-3

3.2 Transfer Java Application to GCOS 7

The next step is to transfer the class files to the GCOS 7/Open 7 System forexecution by JAVA_JVM7 Virtual Machine. Any file transfer software that iscompatible with the Java development platform and GCOS 7/Open 7 may be used.

Note that the class files must be transferred using the bin mode.

The Java core package named classes.zip is contained in a single GCOS 7/Open 7class database which is defined to the Java Virtual Machine at execution time viathe command line option -classpath.

JAVA_JVM7 installation copies classes.zip to the /usr/java/lib directory.

Native GCOS 7/Open 7 classes, such as Ufas or JTDS classes are delivered in ajava archive file named nativ7.jar.

User-developed Java application packages are contained in separate class databasesand also identified to the Java Virtual Machine at execution time via the commandline. (Note that class files are processed in the order in which they are specifiedafter the -classpath option).

If a CLASSPATH keyword is defined in the user environment, the –classpathoption is not mandatory in the java command.

As explained in paragraph 2.3, GCOS 7/Open 7 limits file names to 14 characters.To avoid this uncomfortable limitation in class naming, users may archive theirclasses in a .jar file.

Note that as for compilation, the Java archive tool (jar) is not available onGCOS 7/Open 7. The .jar files must be created on the Java development platform(PC) and then transferred to GCOS 7/Open 7.

However, it should be noted that the full path to this jar file has to be given inCLASSPATH or in the -classpath option (see the following text and theexample).

EXAMPLE: CLASSPATH

CLASSPATH =

/usr/java/lib/classes.zip:/usr/java/classes/nativ7.jar:/usr/java/classes:

/usr/java/classes/usrXXX.jar:

Failure to find a specific requested class from both the GCOS 7/Open 7 classdatabase and any user-provided class databases results in the exception:

ClassNotFoundException

being issued (“thrown”).

Page 20: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

3-4 47 A2 38UT Rev02

3.3 Execute the Application

At this point, the Java application is ready for execution on the GCOS 7 System.

The java executable is installed in the directory:

/usr/java/bin

The application is executed by placing the JAVA_JVM7 Virtual Machine intoexecution, which is accomplished via the Open 7 java command.

java [-options] class

Standard java options must be entered exactly as shown (i.e., options are case-sensitive).

where the options supported are:

-help Print out this message.

-version Print out the Java build version.

-v or –verbose Turn on verbose mode.

-debug Enable remote JAVA debugging.

-noasyncgc Do not allow asynchronous garbage collection.

-verbosegc Print a message when garbage collection occurs.

-noclassgc Disable class garbage collection.

-cs or –checksource Check if source is newer when loading classes.

-ss<number> Set the maximum native stack size for any thread.

-oss<number> Set the maximum Java stack size for any thread.

-ms<number> Set the initial Java heap size.

-mx<number> Set the maximum Java heap size.

-D<name>=<value> Set a system property.

-classpath <directories separated by colons>List directories in which to look for classes.

Page 21: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Deploying a Java Application on GCOS 7

47 A2 38UT Rev02 3-5

-prof[:<file>] Output profiling data to ./java.prof or ./<file>.

-verify Verify all classes when read in.

-verifyremote Verify classes read in over the network [default].

-noverify Do not verify any class.

JAVA_JVM7 defined java options are:

-JAVA_JVM7version Print out the Java build version and the JAVA_JVM7:

java version = 1.1.5

JAVA_JVM7 version = 115.x.y

x: functionality change versiony: maintenance version.

Page 22: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

3-6 47 A2 38UT Rev02

Page 23: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 4-1

4. JAVA_JVM7 Applications DevelopedUsing RMI

This chapter discusses the considerations that are unique to a Java application thatwas developed in accordance with the Remote Method Invocation (RMI)specification.

Java Application Developed According to the RMI Specification

Remote Method Invocation (RMI) enables the creation of distributed Java-to-Javaapplications, in which the methods of Java objects can be invoked from other Javaapplications, possibly on different hosts.

The Java application can make a call on a remote object after it obtains a referenceto the remote object, either by looking up the remote object in the service providedby RMI or by receiving the reference as an argument or a return value.

A java code example of RMI is given in Appendix A.

Page 24: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

4-2 47 A2 38UT Rev02

Page 25: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 5-1

5. Access to Bull Legacy Databases

This chapter describes access to Bull legacy data bases from Java.

As previously indicated, a Java application that is executed on the GCOS 7 Systemmay directly access Bull legacy databases (such as UFAS files), and connect toapplications (such as TDS or IOF) on the GCOS 7 System.

This is accomplished via a Java application that uses either of the followingclasses:

• JTDS package

• UFAS package

Both of these techniques execute on behalf of a Java application and give directaccess to the legacy data.

This chapter describes these two techniques for accessing GCOS 7 legacy data.

5.1 Using the JTDS Package

This paragraph describes Java applications that use the JTDS package tocommunicate with TDS and IOF applications.

Using the JTDS package, that is delivered separately from the JAVA_JVM7software, Java applications can invoke the functionality supplied by the JTDSSession class and the supporting input and output data streams.

An example of such an application is a TDS application (TPR) that executes onbehalf of an initiating Java application. The JTDS Session class provides thenecessary abstraction of a JTDS session, providing the properties and methods tomanage a JTDS session.

The JTDS package is described in Appendix B.

Page 26: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

5-2 47 A2 38UT Rev02

5.2 Using the UFAS Package

This paragraph describes Java applications that use the UFAS package to accessdata in UFAS files.

Using the UFAS package, that is delivered separately from the JAVA_JVM7software, Java applications can invoke the functionality supplied by the ufas classand the supporting input and output sequential files.

The UFAS package is described in Appendix C.

Page 27: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 6-1

6. User C Native Applications InvokedThrough JNI (Java Native Interface)

This chapter describes the use of JNI (Java Native Interface).

It contains a description of:

• What is JNI?

• Files in the JNIfactory Directory

• JNI Example

6.1 What is JNI?

The Java Native Interface (JNI) is the native programming interface for Java that ispart of JAVA_JVM7. By writing programs using the JNI, you ensure that yourcode is completely portable across all platforms.

The JNI allows Java code that runs within a JVM to operate with applications andlibraries written in another native language. In addition, the Invocation API allowsyou to embed the Java Virtual Machine in your native applications.

Programmers use the JNI to write native methods to handle those situations whenan application cannot be written entirely in the Java programming language. Forexample, you may need to use native methods and the JNI in the followingsituations:

• The standard Java class library may not support the platform-dependent featuresneeded by your application.

• You may already have a library or application written in another programminglanguage and you wish to make it accessible to Java applications.

• You may want to implement a small portion of time-critical code in a lower-level programming language, such as assembly, and then have your Javaapplication call these functions.

Page 28: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

6-2 47 A2 38UT Rev02

For example, the following figure shows how a legacy C program can:

• use the JNI to link with Java libraries (java.a and java_u.o),

• call Java methods,

• use Java classes,

• and so on.

Func tio ns

L ib ra ries

E xcep tions

C lasses

VM

JNI

C Side Java Side

Application

Page 29: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

User C Native Applications Invoked Through JNI (Java Native Interface)

47 A2 38UT Rev02 6-3

6.2 Files in the JNIfactory Directory

For static linking with C user’s functions, the following files are included in thedelivered directory JNIfactory:

user_fct_nam.cMakefile and include directoryjava.ajava_u.oJNImake

where the files are used as follows:

user_fct_nam.c is a source file that contains a table that has to be filledby the user’s functions to be linked with the javaexecutable.

Makefile has to be completed by the user’s functions.

The user’s functions and user_fct_nam.c have thento be compiled using this completed Makefile.

java.a and java_u.o The delivered java.a archive file and java_u.o filehave then to be linked with user_fct_nam.o and thecompiled user functions by launching the deliveredmake file JNImake.

The resulting javaJNI file is an executable java file that will perform the standardJAVA_JVM7 functions, enhanced by the user’s functions.

The JNI interface is described in Appendix D.

6.3 JNI Example

As an example, a C test file extracted from the JCK (Java Compatibility Kit) isgiven in Appendix D. This source file alob00101.c and the associated javasource files alob00101.java and alob00101_1.java can be used tofamiliarize the reader with the JNI mechanism.

See Appendix D.

Page 30: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

6-4 47 A2 38UT Rev02

Page 31: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 A-1

A. Example of RMI Connection

This Appendix contains an example of RMI (Remote Method Invocation).

/* RMIGetAlias.java */

import java.rmi.*;

import java.rmi.server.*;

import java.io.*;

import java.io.PrintStream;

import java.rmi.registry.*;

import java.util.*;

class NameAlias

{

String Name;

String Alias;

public NameAlias (String Name, String Alias)

{

this.Name = Name;

this.Alias = Alias;

}

}

public interface RMIGetAlias extends java.rmi.Remote

{

public String LookupAlias(String Name)

throws java.rmi.RemoteException;

}

Page 32: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

A-2 47 A2 38UT Rev02

class RMIGetAliasImpl extends UnicastRemoteObject implements RMIGetAlias

{

static NameAlias DataBase[] = {

new NameAlias("JVM","Java Virtual Machine"),

new NameAlias("JDK","Java Development Kit"),

new NameAlias("RMI","Remote Method Invocation "),

new NameAlias("JNI","Java Native Interface"),

new NameAlias("JDBC","Standard SQL-based database access API"),

new NameAlias(null, "Couldn't match name : JVM, JDK, RMI, JNI, JDBC")

};

public static void main (String args[]) {

int registryPort=1098;

String host;

Registry registry;

if (args.length != 0)

registryPort = Integer.parseInt(args[0]);

try {

host = java.net.InetAddress.getLocalHost().getHostName();

System.out.println("Server (main) >>>>> local host = " + host);

}

catch (Exception e)

{

System.out.println("Server (main) getLocalHost : Exception raised

is " + e.toString() );

return;

}

try {

/* Create a Registry for the remote object */

registry = new sun.rmi.registry.RegistryImpl(registryPort);

System.out.println("ABServer (main) >>>>> registryImpl with port = " + registryPort);

}

catch (Exception e)

{

System.out.println("registry : Exception raised is " + e.toString() );

}

try

{

RMIGetAliasImpl obj = new RMIGetAliasImpl();

System.out.println("Server (main) >>>>> Naming.rebind, port = " + registryPort);

String name = "rmi://" + host + ":" + registryPort + "/RMIGetAliasServer";

System.out.println("Server (main) >>>>> name = " + name);

Naming.rebind(name,obj);

}

Page 33: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Example of RMI Connection

47 A2 38UT Rev02 A-3

catch (Exception e)

{

System.out.println("rebind : Exception raised is " + e.toString() );

}

}

public RMIGetAliasImpl() throws java.rmi.RemoteException

{

}

public String LookupAlias(String Name) throws java.rmi.RemoteException

{

int i = 0;

while (DataBase[i].Name != null) {

if (DataBase[i].Name.equals(Name))

{

break;

}

i++;

}

System.out.println("Server (LookupAlias) >>>>> Alias=" + DataBase[i].Alias);

return DataBase[i].Alias;

}

}

/* RMIClient.java */

import java.rmi.*;

class RMIClient

{

public static void main (String args[]) {

String name = "JVM";

String alias;

int port = 1098;

String host = "cloe182";

if (args.length != 0)

host = args[0];

if (args.length >1 )

name = args[1];

if (args.length >2)

port = Integer.parseInt(args[2]);

Runtime env = Runtime.getRuntime();

env.traceMethodCalls(true);

System.out.println("Client : host = " + host + " name = " + name + " port = " + port);

RMIGetAlias Server;

String url = "rmi://" + host + ":" + port;

Page 34: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

A-4 47 A2 38UT Rev02

System.out.println("Client : before Naming.lookup, url = " + url);

try

{

System.out.println("Client : Naming.lookup with string = " + url + "/RMIGetAliasServer");

Server = (RMIGetAlias) Naming.lookup (url + "/RMIGetAliasServer");

System.out.println("Client : before Server.LookupAlias ");

alias = Server.LookupAlias(name);

System.out.println("The alias for " + name + " is " + alias);

}

catch (Exception e)

{

System.out.println("Client : Exception raised is " + e.toString() );

}

}

}

Page 35: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 B-1

B. JTDS Access From Java

This Appendix describes a JTDS access to IOF or TDS from Java.

B.1 Introduction

The access is based on the Java class DSAconnect, which makes use of the socket-handling facilities of Java to connect to the OPEN 7 gateway module (op7gwV6.0.0). We then use the gateway to connect to any mailbox (IOF or TDS) usingthe PTQ mechanisms incorporated in op7gw.

Once connection has been made to the mailbox, data can be sent to or read fromthe mailbox using specific methods supplied in the DSAconnect class. This classhandles the notion of "turn". We can only send data to the required mailbox whenwe have the turn.

These methods, together with the other public methods of the class are described inthe following sub-sections.

Some exception and error recuperation mechanisms have been incorporated in theclass. In all cases of error detection or exception recuperation, an exception(belonging to the class DSAexception) is thrown. These exceptions may all beintercepted by the caller under the general class DSAexception.

An example of use of the DSAconnect class is provided in Appendix A. The testprogramme DSAtest provided makes use of the Threads facility of Java in order tohandle the passage of break signals to the DSA mailbox.

Restriction

No encryption is provided for the password to be supplied in the DSA test programprovided.

Page 36: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-2 47 A2 38UT Rev02

B.2 Constructors Supplied with the Class

The following valid constructors are supplied with the DSAconnect class:

B.2.1 For an 8-parameter Call

public DSAconnect (home, port, system, mailbox, user, password, project, billing) throws DSAexception, DSAexcep_inparm

B.2.2 For a 7-parameter Call

public DSAconnect (home, port, system, mailbox, user, password, project) throws DSAexception, DSAexcep_inparm

B.2.3 For a 6-parameter Call

public DSAconnect (home, port, system, mailbox, user, password) throws DSAexception, DSAexcep_inparm

Note that the above positional parameters are outlined in Table 1 below. The firstsix parameters are obligatory, while the seventh (project) and eighth (billing) areoptional.

This method is used to effect a DSA connection from Java to an IOF or TDSmailbox.

Page 37: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-3

Table B-1. Positional Parameters - DSAconnect

Name Type Length CommentHome String 12 The name of OPEN 7 on which the gateway is

to be accessed.

Port String 4 The port number on which the gateway islistening.

System String 4 The GCOS 7 system for which DSA access isto be effected.

Mailbox String 8 The Mailbox on which the connection is to bemade.

User String 12 The name of the user for whom theconnection is to be made.

Password String 12 The Password for the given user.

Project String 12 The (optional) project for which theconnection is to be made. If omitted, thedefault project for the user is assumed.

Billing String 12 The (optional) billing for which theconnection is to be made. If omitted, thedefault billing for the user is assumed.

The first two parameters are required for access to the OPEN 7 gateway on thetarget DPS 7. The others are used to effect the JTDS connection to the requiredmailbox.

The connection is made by the constructor for the DSAconnect class. Severalconstructors are defined to allow for connection with a variable number ofparameters (project and billing being optional).

Since connection is carried out by the constructor (which returns void), anadditional method (is_open) is supplied. This method (described later) allows us totest whether the connection is valid.

In addition, constructors with from 0 to 5 parameters are defined. Theseconstructors do not result in connection, but edit an appropriate error message (orset of error messages) indicating that an insufficient number of parameters has beensupplied. These special constructors are defined below.

Page 38: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-4 47 A2 38UT Rev02

B.2.4 For a 5-parameter Call (Missing Password)

public DSAconnect (home, port, system, mailbox, user) throws DSAexception, DSAexcep_nopwd

B.2.5 For a 4-parameter Call (Missing User and Password)

public DSAconnect (home, port, system, mailbox) throws DSAexception, DSAexcep_nousr

B.2.6 For a 3-parameter Call (Missing Mailbox, User and Password)

public DSAconnect (home, port, system) throws DSAexception, DSAexcep_nombx

B.2.7 For a 2-parameter Call (Missing System, Mailbox, User and Password)

public DSAconnect (home, port) throws DSAexception, DSAexcep_nosys

B.2.8 For a 1-parameter Call (Missing Port, System, Mailbox, User and Password)

public DSAconnect (home) throws DSAexception, DSAexcep_noport

B.2.9 For a 0-parameter Call (Missing OPEN 7 Name, Port, System, Mailbox, Userand Password)

public DSAconnect () throws DSAexception, DSAexcep_nohome

Whenever one of these constructors is executed, one or more error messages isedited to indicate which obligatory parameters are missing.

For example, execution of DSAconnect () leads to the edition of the following setof error messages:

The 1st parameter (OPEN7 name of up to 12 characters) is requiredThe 2nd parameter (port number of up to 4 characters) is requiredThe 3rd parameter (system of up to 4 characters) is requiredThe 4th parameter (mailbox of up to 8 characters) is requiredThe 5th parameter (username of up to 12 characters) is requiredThe 6th parameter (password of up to 12 characters) is requiredToo few parameters*************************************************Anomaly detected in DSAconnect*************************************************

Page 39: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-5

See the following Table for more details on the error handling facilities suppliedwith this method.

Table B-2. Error Handling Facilities - DSAconnect

Exception Cause Action TakenDSAexception Exception occurred

during execution ofthe constructor

prints the current stack if available

DSAexcep_inparm an input parameter istoo long (more thanthe specified length)

edits an error message to indicatewhich parameter value is too long(see Example 1 below)

DSAexcep_nbpar the number ofparameters supplied isinsufficient

edits the following message :"Too few parameters"

DSAexcep_nopwd the password has beenomitted from theparameter list

edits the following message :"The 6th parameter (password ofup to 12 characters) is required"throws DSAexcep_nbpar

DSAexcep_nousr the user has beenomitted from theparameter list

edits the following message :"The 5th parameter (username ofup to 12 characters) is required"throws DSAexcep_nopwd

DSAexcep_nombx the mailbox has beenomitted from theparameter list

edits the following message :"The 4th parameter (mailbox of upto 8 characters) is required"throws DSAexcep_nousr

DSAexcep_nosys the system has beenomitted from theparameter list

edits the following message :"The 3rd parameter (system of upto 4 characters) is required"throws DSAexcep_nombx

DSAexcep_noport the port number hasbeen omitted from theparameter list

edits the following message :"The 2nd parameter (port numberof up to 4 characters) is required"throws DSAexcep_nosys

DSAexcep_nohome the target OPEN 7 hasbeen omitted from theparameter list

edits the following message :"The 1st parameter (OPEN 7 nameof up to 12 characters) is required"throws DSAexcep_noport

Page 40: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-6 47 A2 38UT Rev02

EXAMPLE: OPEN 7 NAME TOO LONG

DSAconnect (333333333333333, 9003, bc06, iof, user1, password1)

results in edition of the following text :

Parameter 1 (Open7 name) is limited to 12 charactersException caught during parameter controlsException : DSAexcep_inparmDSAexcep_inparm at DSAconnect.control_parm(DSAconnect.java:461) at DSAconnect.<init>(DSAconnect.java:107) at DSAtest.main(DSAtest.java:99)**************** Connection error ****************End of processing

Page 41: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-7

B.3 PUBLIC Methods Supplied

The following public methods are available with the DSAconnect class:

read to read from a DSA mailbox

write to write to a DSA mailbox

Break to effect a break

return_error_msg to obtain details on an error code

is_open to test whether or not a connection is open

is_turn to test whether or not we have the « turn » to write

disconnect to terminate a DSA connection (for error treatment)

These methods are outlined in detail below. In addition, a sample client sourceprogram to illustrate the use of the DSAconnect class is provided below.

Note that this program may be modified by the user and no guarantee is providedthat it will function on all types of client machine.

B.3.1 read

This method is used to read from a DSA mailbox. The read method has noparameters, but returns a String (the data read) to the caller. It is the caller'sresponsability to loop on reading until he is given the turn, indicating that there isnothing left to read.

Read in a Multi-Thread Context

In a multi-thread context, if the read is performed while you have the turn, then thethread that performs the read remains blocked until another thread unblocks it byperforming a write.

Read in a Mono-Thread Context

In a mono-thread context, if the read is performed while you have the turn, then thethread that performs the read remains blocked. In this case, you must test the turnbefore performing a read.

public String read () throws DSAexception, DSAexcep_read, DSAexcep_endsession, DSAexcep_abnormalend

Page 42: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-8 47 A2 38UT Rev02

See the Table below for details of the error handling facilities supplied with thismethod.

Table B-3. Error Handling Facilities - read

Exception Cause Action TakenDSAexception Exception occurred

during execution ofthis method

prints the current stack,together with an errormessage

DSAexcep_read error detectedduring attempt toread from mailbox

edits the error message:"Error during read frommailbox : user disconnected"

DSAexcep_endsession the end of the DSAsession has beendetected

edits the error message:"Normal end of session"

DSAexcep_abnormalend an abnormal end ofthe DSA session hasbeen detected

edits the error message:"Abnormal end of session"

Page 43: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-9

B.3.2 write

This method is used to write to a DSA mailbox. The write method has a singleinput parameter, a string giving the data to be sent to the mailbox.

public void write (String strin) throws DSAexception, DSAexcep_write

The input parameter is described in the following Table.

Table B-4. Positional Parameter - write

Name Type Length Commentstrin String Variable the data to be sent to the mailbox

See the following Table for details of the error handling facilities supplied with thismethod.

Table B-5. Error Handling Facilities - write

Exception Cause Action TakenDSAexception Exception occurred during

execution of this methodprints the current stack

DSAexcep_write error detected duringattempt to write to mailbox

edits the error message:"Error during write tomailbox : user disconnected"

Page 44: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-10 47 A2 38UT Rev02

B.3.3 Break

This method is used to send a break signal to a DSA mailbox. The Break methodhas no parameters.

public void Break () throws DSAexception, DSAexcep_break

See the following Table for details of the error handling facilities supplied with thismethod.

Table B-6. Error Handling Facilities - Break

Exception Cause Aaction TakenDSAexception Exception occurred

during execution of thismethod

Prints the current stack

DSAexcep_break Error detected duringattempt to send breaksignal to mailbox

Edits the error message:"Error during break handling :user disconnected"

B.3.4 return_error_msg

This method is used to obtain information on an error condition.

public String return_error_msg () throws DSAexception

See the following Table for details of the error handling facilities supplied with thismethod.

Table B-7. Error Handling Facilities - return_error_msg

Exception Cause Action TakenDSAexception Exception occurred during

execution of this methodPrints the current stack

Page 45: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-11

B.3.5 is_open

This method is used to test whether a connection has been successfully made. Ithas no parameters, but returns a boolean whose value is :

true if the connection is open

false if the connection could not be made

public boolean is_open () throws DSAexception

See the following Table for details of the error handling facilities supplied with thismethod.

Table B-8. Error Handling Facilities - is_open

Exception Cause Action TakenDSAexception exception occurred during

execution of this methodprints the current stack

B.3.6 is_turn

This method is used to test whether it is your turn (to write). It has no parameters,but returns a boolean whose value is:

true if it is your turn to write

false if it is not your turn to write

public boolean is_turn () throws DSAexception

See the following Table for details of the error handling facilities supplied with thismethod.

Table B-9. Error Handling Facilities - is_turn

Exception Cause Action TakenDSAexception exception occurred during

execution of this methodprints the current stack

Page 46: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-12 47 A2 38UT Rev02

B.3.7 disconnect

This method is used to disconnect from a DSA mailbox. It has no parameters andreturns void. It is not always necessary for the user to effect the disconnection. If aread is effected after disconnection, the exception DSAendsession is thrown. Theuser should therefore provide a catch clause for this condition.

Note that the OPEN 7 gateway acts merely as a tube for the passage of data to andfrom the mailbox. No interpretation of the data is carried out by the gatewaymodule.

public void disconnect () throws DSAexception

See the following Table for details of the error handling facilities supplied with thismethod.

Table B-10. Error Handling Facilities - disconnect

Exception Cause Action TakenDSAexception exception occurred during

execution of this methodprints the current stack

EXAMPLE: JAVA ACCESS TO A DSA MAILBOX

Note that this extract indicates how to use the DSAconnect class with a 6-parameter constructor (project and billing take the default values for the givenuser).

The DSAtest program provided uses the Threads facility of Java to allowsimultaneous reading from and writing to a DSA mailbox. In this way we canhandle the passage of « break » signals to the mailbox.

In DSAtest, the string « $*$BRK » is used to indicate a break, but this may ofcourse be modified by the user for his own specific needs.

We do NOT guarantee that this sample program will run on any platform.

Page 47: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-13

import java.io.*;

import java.net.*;

import java.util.*;

import java.lang.*;

// ===========================================================

class DSAtest extends Thread

{

static Thread t;

static DSAconnect cnx;

// main entry point

public static void main(String args[]) throws InterruptedException

{

try

{

String Strin = "";

String arg_home = "";

String arg_port = "";

String arg_site = "";

String arg_mbx = "";

String arg_user = "";

String arg_pw = "";

char C;

boolean online = true;

// boolean online = false;

Exception exc = new Exception();

if (! online)

{

System.out.println("*************** DSAtest execution ***************");

System.out.println("");

// ************* OPEN7 name ******************

String Prompt1 = "OPEN7 name : ";

System.out.print(Prompt1);

while ((C = (char)System.in.read()) != '\n')

{

arg_home = arg_home + C;

}

// ************* Port number ******************

String Prompt2 = "Port number : ";

System.out.print(Prompt2);

while ((C = (char)System.in.read()) != '\n')

{

arg_port = arg_port + C;

}

// ************* GCOS7 site ******************

String Prompt3 = "GCOS7 site : ";

System.out.print(Prompt3);

while ((C = (char)System.in.read()) != '\n')

{

arg_site = arg_site + C;

}

Page 48: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-14 47 A2 38UT Rev02

// ************* Mailbox ******************

String Prompt4 = "Mailbox : ";

System.out.print(Prompt4);

while ((C = (char)System.in.read()) != '\n')

{

arg_mbx = arg_mbx + C;

}

// ************* User ******************

String Prompt5 = "User : ";

System.out.print(Prompt5);

while ((C = (char)System.in.read()) != '\n')

{

arg_user = arg_user + C;

}

// ************* Password ******************

String Prompt6 = "Password : ";

System.out.print(Prompt6);

while ((C = (char)System.in.read()) != '\n')

{

arg_pw = arg_pw + C;

}

// *****************************************

}

else

{

// ************* OPEN7 name ******************

arg_home = args[0];

System.out.println("OPEN7 name : " + arg_home);

// ************* Port number ******************

arg_port = args[1];

System.out.println("Port number : " + arg_port);

// ************* GCOS7 site ******************

arg_site = args[2];

System.out.println("GCOS7 name : " + arg_site);

// ************* Mailbox ******************

arg_mbx = args[3];

System.out.println("Mailbox name: " + arg_mbx);

// ************* User ******************

arg_user = args[4];

System.out.println("User name : " + arg_user);

// ************* Password ******************

arg_pw = args[5];

System.out.println("Password : " + arg_pw);

}

System.out.println("");

boolean end_of_test = false;

Page 49: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JTDS Access From Java

47 A2 38UT Rev02 B-15

cnx = new DSAconnect(arg_home,arg_port,arg_site,arg_mbx,arg_user, arg_pw);

if (cnx.is_open())

{

t = new Thread(new readMBX(cnx));

t.setPriority(Thread.currentThread().getPriority() + 1);

t.start();

}

else

{

String errStr = cnx.return_error_msg();

System.out.println("**************** Connection error ****************");

System.out.println(errStr);

}

while (cnx.is_open())

{

Strin = "";

while ((C = (char)System.in.read()) != '\n')

{

Strin = Strin + C;

}

if (Strin.compareTo("$*$BRK") == 0)

{

cnx.Break();

}

else

{

if (cnx.is_turn())

cnx.write(Strin);

}

}

}

catch (DSAexcep_endsession e)

{

System.out.println("End of session");

System.out.println("*************************************************");

System.out.flush();

}

catch (DSAexception e)

{

System.out.println("");

System.out.println("*************************************************");

System.out.println("");

System.out.println("Anomalie detected in DSAconnect");

System.out.println("*************************************************");

System.out.flush();

}

Page 50: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

B-16 47 A2 38UT Rev02

catch (Exception e)

{

System.out.println("");

System.out.println("*************************************************");

System.out.println("");

System.out.println("Exception recovered in DSAtest");

System.out.println("Exception : " + e.toString());

e.printStackTrace();

System.out.println("");

System.out.println("*************************************************");

System.out.flush();

}

}

}

class readMBX implements Runnable

{

private DSAconnect cnx;

public readMBX(DSAconnect cnt) throws DSAexception, DSAexcep_endsession, DSAexcep_read

{

cnx = cnt;

}

public void run()

{

try

{

while (cnx.is_open())

{

Thread.currentThread().yield();

String Strout = cnx.read();

System.out.print(Strout);

System.out.flush();

}

cnx.disconnect();

System.exit(0);

}

catch (DSAexcep_endsession e)

{

System.out.println("End of session detected");

}

catch (DSAexception e)

{

System.out.println("Exception in readMBX");

}

}

}

Page 51: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 C-1

C. UFAS Access From Java

C.1 Introduction

This Appendix describes a UFAS access from JAVA.

The access is based on the JAVA class Ufas. Data can be written to or read from aUFAS file using specific methods supplied in the Ufas class. The UFAS file mustbe cataloged (and the catalog must be auto-attachable) or resident. The file may besequential, relative or sequential indexed.

The Ufas class can only be executed by the JVM on OPEN7.

C.2 Restrictions

The current version of the Ufas class permits access only to cataloged or residentUFAS files.

The use of UFAS files monitored by GAC is restricted, see the open method.Journalized UFAS files are not supported, but such files may be used in read mode.

C.3 GCOS7 Visibility

The file may be shared between:

• Two java applications (the java applications may be on the same OPEN 7, or ontwo different ones).

• One java application and one GCOS 7 application (batch or TDS).

• One java application and one GCOS 7 application running on a DPS 7000coupled system.

JCL statements POOLSIZE, BUFPOOL and NBBUF are not used; default valuesare used.

Page 52: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-2 47 A2 38UT Rev02

C.4 Public Methods Supplied

The following public methods are available:

C.4.1 Contructors

The following valid constructors are supplied with the Ufas class:

Format 1: Ufas (String efn, String ifn, String user, Stringpassword, String billing, String project)

Format 2: Ufas (String efn, String user, String password, Stringbilling, String project)

Format 3: Ufas (String efn, String ifn, String user, Stringpassword)

Format 4: Ufas (String efn, String user, String password)

Format 5: Ufas (String efn, String ifn)

Format 6: Ufas (String efn)

Efn String of up to 44 characters.External File Name.

Ifn String of up to 8 characters.Internal File Name

User String of up to 12 characters.User name

Password String of up to 12 characters.User password.

Billing String of up to 12 characters.User billing.

Project String of up to 12 characters.User project.

The ifn may be omitted, in which case, the default ifn used is "FILE". Specifyingifn may be useful because the file opening is made at the process group level, andwe cannot simultaneously open several files with the same ifn in the process group(two java processes executing at the same time may belong to the same processgroup). Of course, a program opening two files at the same time, will need to givetwo different ifns to the constructor (see the example at the end of this chapter).

The user/password/billing/project are used to check the project access rights on thefile, and a check is performed to verify that the user is known for the project. Ifomitted, the OPEN7 project is used. If billing/project are omitted, the default userproject and billing are used.

Page 53: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-3

C.4.2 open

SYNOPSIS:

int open (String share, String access, String pmd,String accmode)

DESCRIPTION:

Open a UFAS file, the file may be sequential, relative, or sequential indexed.

This method performs a dynamic file assign followed by a file opening.

PARAMETERS:

share Two-character string.Dynamic file assign parameter.This parameter may have the following values:

NO Normal (n readers or one writer).OW Onewrite (n readers and one writer).FR Free (not advisable).UN Unspecified.

The share value set to unspecified means that the sharevalue recorded in the catalog will be used. If the shareparameter in the catalog is also set to unspecified, ashare set to normal will be used by dynamic assign.

If a UFAS file is used by a TDS with share set tomonitor, the Ufas class restricts access in read modewith share parameter set to normal.

If the UFAS file is only used by a java application inwrite mode, the other applications can only use it inread mode (share set to one write).

Page 54: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-4 47 A2 38UT Rev02

access Two-character string.Dynamic file assign parameter.This parameter may have the following values:

WR Write.EW Exclusive write.RD Read.ER Exclusive read.AR All read.

pmd Two-character string.File opening parameter (processing mode).This parameter may have the following values:

IN Input mode.UP Update mode.OU Output mode.

The first put method writes at the beginningof the file (previous contents are lost afteropen).

AP Append mode.The first put method writes after the lastrecord of the file, whose previous contentsare saved. If the file is empty, AP isequivalent to OU.

accmode Two-character string.File opening parameter (access mode).This parameter may have the following values:

SE The file is accessed in sequential mode.DI The file is accessed in direct mode.

RETURN VALUE:

On successful completion, returns 0. Otherwise a value of -1 is returned and publicinteger attribute g4 is set to indicate the error.

Page 55: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-5

ERRORS:

The GCOS 7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

Return codes set by the open method are:

ARGERR One of the share, access, or accmode parameters iswrong (pmd parameter is checked during file opening).

BILLUNKN Invalid billing.

PROJUNKN Invalid project.

PSWVIOL Invalid password.

WRONGORG The file is not a UFAS file.

The open method first calls the catalog to check the user access rights, then itperforms a dynamic file assign (GPL primitive $H_ASSIGN) and a file opening(GPL primitive $H_OPEN). The document 47 A2 34UL GPL System Primitivesdescribes the different return codes that can be set by these primitives. Theprincipal return codes are described at the end of this chapter.

Page 56: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-6 47 A2 38UT Rev02

C.4.3 close

SYNOPSIS:

int close ()

DESCRIPTION:

Close a UFAS file.

Close is not performed at process termination. It is therefore necessary to performa close at the end of your program to release resources. If a close has been omitted,the java program can no longer be executed because the ifn is still assigned and, asseen previously, it is impossible for the same process group to open two files withthe same ifn (two OPEN7 processes may belong to the same process group). Inthis case, the abnormal return code IFNSTRU is returned at the next open, and anOPEN7 restart is necessary. In the java program, it is necessary to recover theexceptions and to perform a close in the catch or finally block (see the example atend of this chapter).

PARAMETERS:

None.

RETURN VALUE:

On successful completion, returns 0. Otherwise a value of -1 is returned and thepublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the close method is:

NOTOPEN File is not open.

The close method performs a file close (GPL primitive $H_CLOSE) followed by afile de-assign (GPL primitive $H_DEASSIGN). The document 47 A2 34UL GPLSystem Primitives describes the different return codes that can be set by theseprimitives. The principal return codes are described at the end of this chapter.

Page 57: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-7

C.4.4 get

SYNOPSIS:

int get (byte[] buffer, int length)

DESCRIPTION:

Get the next record of a file. The file may be sequential, relative or sequentialindexed.

The get method may be used after a pointRel, pointInd, pointBeg orpointIndSecKey method.

PARAMETERS:

buffer Byte array.The input buffer to be filled with data.

length Integer.Amount of input data to be read.

RETURN VALUE:

On successful completion, returns the number of bytes actually read. Otherwise, avalue of -1 is returned and public integer attribute g4 is set to indicate the error.

The end-of-file is detected by the normal return code DATALIM, and not by areturn value set to 0 (zero) because UFAS records of size 0 may exist.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the get method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The get method uses the $H_GET GPL primitive. The document 47 A2 34UL GPLSystem Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 58: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-8 47 A2 38UT Rev02

C.4.5 getBeg

SYNOPSIS:

int getBeg (byte[] buffer, int length)

DESCRIPTION:

Get the first record in the file. The file may be sequential, relative, or sequentialindexed.

PARAMETERS:

buffer Byte array.The input buffer to be filled with data.

length Integer.Amount of input data to be read.

RETURN VALUE:

On successful completion, returns the number of bytes actually read. Otherwise, avalue of -1 is returned and the public integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the getBeg method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The getBeg method uses the $H_GET GPL primitive. The document 47 A2 34ULGPL System Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 59: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-9

C.4.6 getInd

SYNOPSIS:

int getInd (byte[] buffer, int length, byte[] key)

DESCRIPTION:

Get, in direct access mode, a record with a specified primary key. Used forsequential indexed files only.

PARAMETERS:

buffer Byte array.The input buffer to be filled with data.

length Integer.Amount of input data to be read.

key Byte array.Primary key value of the record to retrieve. The sizeof the key depends on the file.

RETURN VALUE:

On successful completion, returns the number of bytes actually read. Otherwise, avalue of -1 is returned and the public integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the getInd method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The getInd method uses the $H_GET GPL primitive. The document 47 A2 34ULGPL System Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 60: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-10 47 A2 38UT Rev02

C.4.7 getRel

SYNOPSIS:

int getRel (byte[] buffer, int length, int address)

DESCRIPTION:

Get a record with a specified address. Used for relative files.

PARAMETERS:

buffer Byte array.The input buffer to be filled with data.

length Integer.Amount of input data to be read.

address Integer.Record number of the record to retrieve (startingfrom 1).

RETURN VALUE:

On successful completion, returns the number of bytes actually read. Otherwise, avalue of -1 is returned and the public integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the getRel method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

FUNCNAV The file is not a relative file.

The getRel method uses the $H_GET GPL primitive. The document 47 A2 34ULGPL System Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 61: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-11

EXAMPLE:

recordSize = ufasFile.getRel (buffer, buffer.length, 3) ; /* get the third record of a relative file */

C.4.8 getIndCond

SYNOPSIS:

int getIndCond (byte[] buffer, int length, String condition)

DESCRIPTION:

Get a record in a sequential indexed file with a conditional get condition. Used forsequential indexed files only.

PARAMETERS:

buffer Byte array.The input buffer to be filled with data.

length Integer.Amount of input data to be read.

condition Two-character string.The condition that must be verified by the recordselected is given by one of the following values:

FI First.Get the record with the first key value in thefile.

LA Last.Get the record with the last key value in thefile.

PR Prior.Get the record with the prior existing key valuein the file.

NX Next.Get the record with the next existing key valuein the file.

Page 62: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-12 47 A2 38UT Rev02

RETURN VALUE:

On successful completion, returns the number of bytes actually read. Otherwise, avalue of -1 is returned and the public integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the getIndCond method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The getIndCond method uses the $H_GET GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 63: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-13

C.4.9 getIndSecKey

SYNOPSIS:

int getIndSecKey (byte[] buffer, int length, byte[] key,int keyid)

DESCRIPTION:

Get in direct access mode a record with a specified secondary key. Used forsequential indexed files only.

PARAMETERS:

buffer Byte array.The input buffer to be filled with data.

length Integer.Amount of input data to be read.

key Byte array.Secondary key value of the record to retrieve. The sizeof the key depends on the file.

keyid Integer.Offset (from 0) in the record of the secondary key.

RETURN VALUE:

On successful completion, returns the number of bytes actually read. Otherwise, avalue of -1 is returned and public integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

Return codes set by the getIndsecKey method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The getIndSecKey method uses the $H_GET GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 64: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-14 47 A2 38UT Rev02

C.4.10 put

SYNOPSIS:

int put (byte[] buffer, int length)

DESCRIPTION:

Put a record in a file. The file may be sequential, relative, or sequential indexed.

Primary keys must be given in increasing order if the sequential indexed file isopen in output or append mode.

PARAMETERS:

buffer Byte array.The input buffer of data to be written.

length Integer.Amount of input data to be written.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the put method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The put method uses the $H_PUT GPL primitive. The document 47 A2 34UL GPLSystem Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 65: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-15

C.4.11 putRel

SYNOPSIS:

int putRel (byte[] buffer, int length, int address)

DESCRIPTION:

Put a record to a relative file with a specified address.

PARAMETERS:

buffer Byte array.The input buffer of data to be written.

length Integer.Amount of input data to be written.

address Integer.Record number of the record to write (starting from 1).

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by putRel method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The putRel method uses the $H_PUT GPL primitive. The document 47 A2 34ULGPL System Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 66: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-16 47 A2 38UT Rev02

C.4.12 update

SYNOPSIS:

int update (byte[] buffer, int length)

DESCRIPTION:

Update a record in a file.

The file may be sequential, relative or sequential indexed.

The current record pointer must be valid, the update method must be used after aget, getBeg, getInd, getRel, getIndCond, getIndSecKey method.

PARAMETERS:

buffer Byte array.The input buffer of data to be written.

length Integer.Length of the record that is to be updated.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the update method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The update method uses the $H_PUTX GPL primitive. The document 47 A2 34ULGPL System Primitives describes the different return codes that can be set by thisprimitive. The principal return codes are described at the end of this chapter.

Page 67: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-17

EXAMPLE:

if (ufasFile.pointInd (key, "EQ") == 0) { ufasFile.get (…) ; ufasFile.update (buffer, recordSize) ;}

C.4.13 updateInd

SYNOPSIS:

int updateInd (byte[] buffer, int length, byte[] key)

DESCRIPTION:

Update a record in a sequential indexed file with a specified primary key.

PARAMETERS:

buffer Byte array.The input buffer of data to be written.

length Integer.Length of the record that is to be updated.

key Byte array.Primary key value of the record to update. The size ofthe key depends on the file. Note that key value is alsospecified in the buffer.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

Page 68: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-18 47 A2 38UT Rev02

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return codes set by the updateInd method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The updateInd method uses the $H_PUTX GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 69: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-19

C.4.14 updateRel

SYNOPSIS:

int updateRel (byte[] buffer, int length, int address)

DESCRIPTION:

Update a record in a relative file with a specified address.

PARAMETERS:

buffer Byte array.The input buffer of data to be written.

length Integer.Length of the record that is to be updated.

address Integer.Record number of the record to update (startingfrom 1).

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in public integer attribute g4. A return value of -1corresponds to an abnormal return code. The return code may be edited using theeditG4 method.

The return codes set by the updateRel method are:

NOTOPEN File is not open.

LNERR The length parameter is negative.

The updateRel method uses the $H_PUTX GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 70: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-20 47 A2 38UT Rev02

C.4.15 pointInd

SYNOPSIS:

int pointInd (byte[] key, String condition)

DESCRIPTION:

Sets the current record to the one specified with the primary key in a sequentialindexed file.

PARAMETERS:

key Byte array.Primary key value used to establish the current recordpointer. The size of the key depends on the file.

condition Two-character string.The condition that must be verified by the record to bepointed to is given by one of the following values:

EQ Equal.First record whose key is equal to the inputkey.

GE Greater or equal.First record whose key is greater than or equalto the input key.

GT GreaterFirst record whose key is greater than theinput key.

LE Lower or equal.First record whose key is lower than or equalto the input key.

LT LowerFirst record whose key is lower than the inputkey.

Page 71: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-21

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the pointInd method is:

NOTOPEN File is not open.

The pointInd method uses the $H_POINT GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 72: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-22 47 A2 38UT Rev02

C.4.16 pointRel

SYNOPSIS:

int pointRel (int address, String condition)

DESCRIPTION:

Sets the current record to the one specified with the address value in a relative file.

PARAMETERS:

address Integer.Record number (starting from 1).

condition Two-character string.The condition that must be verified by the record to bepointed to is given by one of the following values:

EQ Equal.First record whose address is equal to the inputaddress.

GE Greater or equal.First record whose address is greater than orequal to the input address.

GT GreaterFirst record whose address is greater than theinput address.

Page 73: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-23

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned and thepublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the pointRel method is:

NOTOPEN File is not open.

FUNCNAV The file is not a relative file.

The pointRel method uses the $H_POINT GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 74: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-24 47 A2 38UT Rev02

C.4.17 pointBeg

SYNOPSIS:

int pointBeg ()

DESCRIPTION:

Sets the current record to the first one of the file. The file may be sequential,relative, or sequential indexed.

PARAMETERS:

None.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the pointBeg method is:

NOTOPEN File is not open.

The pointBeg method uses the $H_POINT GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 75: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-25

C.4.18 pointIndSecKey

SYNOPSIS:

int pointIndSecKey (byte[] key, int keyid, String condition)

DESCRIPTION:

Sets the current record to the one specified with the secondary key in a sequentialindexed file.

PARAMETERS:

key Byte array.Secondary key value used to establish the currentrecord pointer. The size of the key depends on the file.

keyid Integer.Offset (from 0) in the record of the secondary key.

condition Two-character string.The condition that must be verified by the recordselected to be pointed to is given by one of thefollowing values:

EQ Equal.First record whose key is equal to input key.

GE Greater or equal.First record whose key is greater than or equalto the input key.

GT GreaterFirst record whose key is greater than the inputkey.

LE Lower or equal.First record whose key is lower than or equal tothe input key.

LT LowerFirst record whose key is lower than the inputkey.

Page 76: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-26 47 A2 38UT Rev02

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned and thepublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in public integer attribute g4. A return value of -1corresponds to an abnormal return code. The return code may be edited using theeditG4 method.

The return code set by the pointIndSecKey method is:

NOTOPEN File is not open.

The pointIndSecKey method uses the $H_POINT GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 77: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-27

C.4.19 delete

SYNOPSIS:

int delete ()

DESCRIPTION:

Logically deletes the current record in a file. The file may be sequential, relative,or sequential indexed.

The current record pointer must be valid, the delete method must be used after aget, getBeg, getInd, getRel, getIndCond, getIndSecKey method.

PARAMETERS:

None.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned andpublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the delete method is:

NOTOPEN File is not open.

The delete method uses the $H_DELETE GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes which canbe set by this primitive. The principal return codes are described at the end of thischapter.

EXAMPLE:

if (ufasFile.pointInd (key, "EQ") == 0) { ufasFile.get (…) ; ufasFile.delete () ;}

Page 78: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-28 47 A2 38UT Rev02

C.4.20 deleteInd

SYNOPSIS:

int deleteInd (byte[] key)

DESCRIPTION:

Deletes the record specified with the primary key of a sequential indexed file.

PARAMETERS:

key Byte array.Primary key value of the record to delete. The size ofthe key depends on the file.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned and thepublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the deleteInd method is:

NOTOPEN File is not open.

The deleteInd method uses the $H_DELETE GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 79: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-29

C.4.21 deleteRel

SYNOPSIS:

int deleteRel (int address)

DESCRIPTION:

Deletes the record specified by the address value in a relative file.

PARAMETERS:

address Integer.Record number of the record to delete (startingfrom 1).

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned and thepublic integer attribute g4 is set to indicate the error.

ERRORS:

The GCOS7 return code is set in the public integer attribute g4. A return value of-1 corresponds to an abnormal return code. The return code may be edited usingthe editG4 method.

The return code set by the deleteRel method is:

NOTOPEN File is not open.

The deleteRel method uses the $H_DELETE GPL primitive. The document47 A2 34UL GPL System Primitives describes the different return codes that can beset by this primitive. The principal return codes are described at the end of thischapter.

Page 80: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-30 47 A2 38UT Rev02

C.4.22 editG4

SYNOPSIS:

String editG4 ()

DESCRIPTION:

Edit the most recently set GCOS7 return code.

Example of an edited return code:

RC=B3910027->XUFAS 81,DATALIM

The two leftmost bytes are the signature, the two others are the return code itself.A return code set to 0 means a successful completion, a return code between 1 to255 corresponds to a marginal condition (DATALIM for example), a return codegreater or equal to 256 means an unsuccessful completion, in which case, eachprevious method sets the return value to -1.

PARAMETERS:

None.

RETURN VALUE:

Returns a string containing in an edited form, the most recently set GCOS7 returncode.

ERRORS:

No error is set.

Page 81: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-31

C.4.23 asciiToEbcdic

SYNOPSIS:

int asciiToEbcdic (byte[] buffer, int offset, int length)

DESCRIPTION:

Convert a byte array from ASCII to EBCDIC on a specified length.

PARAMETERS:

buffer Byte array.The input buffer of data to be converted.

offset Integer.Offset (from 0) in the buffer of the first byte to beconverted.

length Integer.Length in bytes that is to be converted.

RETURN VALUE:

On successful completion, returns 0. Otherwise a value of -1 is returned.

ERRORS:

A return value set to -1 means that at least one of offset or length parameters iswrong.

Page 82: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-32 47 A2 38UT Rev02

C.4.24 ebcdicToAscii

SYNOPSIS:

int ebcdicToAscii (byte[] buffer, int offset, int length)

DESCRIPTION:

Convert a byte array from EBCDIC to ASCII on a specified length.

PARAMETERS:

buffer Byte array.The input buffer of data to be converted.

offset Integer.Offset (from 0) in the buffer of the first byte to beconverted.

length Integer.Length in bytes that is to be converted.

RETURN VALUE:

On successful completion, returns 0. Otherwise, a value of -1 is returned.

ERRORS:

A return value set to -1 means that at least one of offset or length parameters iswrong.

Page 83: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-33

C.4.25 decimalToString, decimalToDouble, decimalToInt, decimalToLong

SYNOPSIS:

String decimalToString (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed)double decimalToDouble (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed)int decimalToInt (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed)long decimalToLong (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed)

DESCRIPTION:

These methods convert a decimal number into a string, a double, an integer or along. The decimal number may be a signed packed decimal number, a signedunpacked decimal number, an unsigned packed decimal number or an unsignedunpacked decimal number.

PARAMETERS:

buffer Byte array.The input buffer containing the decimal number.

offset Integer.Offset (from 0) in the buffer of the decimal number.

digitNumber Integer.Number of digits of the decimal number. digitNumbermay be from one to thirty one. The limit of thirty oneis a firmware limit, however COBOL may impose alower limit.Example: for a packed decimal declared in COBOLPIC 9999, digitNumber is 4.

pointPos Integer.Number of digits before the point. If the decimalnumber is an integer, pointPos may be set todigitNumber value or -1.

packed boolean.Indicates if the decimal number is packed or unpacked.

Page 84: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-34 47 A2 38UT Rev02

signed boolean.Indicates if the decimal number is signed or unsigned.

RETURN VALUE:

On successful completion, decimalToString returns the decimal number convertedto a string. Otherwise the empty string is returned.

On successful completion, decimalToDouble returns the decimal number convertedto a double. Otherwise -1 is returned.

On successful completion, decimalToInt returns the decimal number converted toan integer. Otherwise -1 is returned.

On successful completion, decimalToLong returns the decimal number converted toa long. Otherwise -1 is returned.

ERRORS:

The public integer attribute error characterises the error as described below:

error description0 No error occurred.1 Invalid digitNumber parameter.2 Invalid offset parameter.3 Invalid pointPos parameter.5 The decimal number cannot be contained in the buffer.7 Invalid decimal number.8 The decimal number cannot be converted to an integer or a long

(overflow).9 An exception has occurred.

The return value of the methods does not completely characterise either an error ora successful completion. The error attribute must be used to distinguish an errorfrom a successful completion. A typical error treatment is detailed below :

number = ufasFile.decimalToInt (buffer, offset, ... ) ;if (ufasFile.error != 0) { // error treatment ...}

EXAMPLE :

A signed packed decimal number declared in COBOL : PIC S999V99 USAGECOMP will be converted to a string in the following manner :

numberStr = ufasFile.decimalToString (buffer, offset, 5, 3, true, true) ;

Page 85: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-35

C.4.26 stringToDecimal, doubleToDecimal, intToDecimal, longToDecimal

SYNOPSIS:

int stringToDecimal (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed, String number)int doubleToDecimal (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed, double number)int intToDecimal (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed, int number)int longToDecimal (byte[] buffer, int offset, int digitNumber, int pointPos, boolean packed, boolean signed, long number)

DESCRIPTION:

These methods convert a string, a double, an integer or a long to a decimal number.The decimal number may be a signed packed decimal number, a signed unpackeddecimal number, an unsigned packed decimal number or an unsigned unpackeddecimal number.

If L is the number of digits of the decimal number, the number of bytes occupied isdetermined in the following manner :

L even L oddunsigned unpacked decimal L L

signed unpacked decimal L L

unsigned packed decimal L / 2 (L + 1) / 2

signed packed decimal L / 2 + 1 (L + 1) / 2

PARAMETERS:

buffer Byte array.The output buffer where the decimal number will bestored.

offset Integer.Offset (from 0) in the buffer of the decimal number tobe stored.

Page 86: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-36 47 A2 38UT Rev02

digitNumber Integer.Number of digits of the decimal number. digitNumbermay be from one to thirty one. The limit of thirty oneis a firmware limit, however COBOL may impose alower limit.Example: for a packed decimal declared in COBOLPIC 9999, digitNumber is 4.

pointPos Integer.Number of digits before the point. If the decimalnumber is an integer, pointPos may be set todigitNumber value or -1.

packed boolean.Indicates if the decimal number is packed or unpacked.

signed boolean.Indicates if the decimal number is signed or unsigned.

number Number to be converted.Depending on the method used, number is a string, adouble, an integer or a long.In the case of stringToDecimal, the input string iscomprised of a sign (the positive sign is optional)followed by digits corresponding to the integer partand if a decimal part exist followed by a pointfollowed by digits. Spaces are not allowed. Examples :-123, 0.1234, +123.4567

RETURN VALUE:

On successful completion, returns the number of bytes used to store the decimalnumber. Otherwise -1 is returned.

ERRORS:

The public integer attribute error characterises the error as described below:

error description0 No error occurred.1 Invalid digitNumber parameter.2 Invalid offset parameter.3 Invalid pointPos parameter.4 number is negative and signed parameter is set to false.5 The decimal number cannot be contained in the buffer.6 Invalid number parameter (string case).9 An exception has occurred.

Page 87: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-37

EXAMPLE :

An integer will be converted to a signed unpacked decimal number declared inCOBOL : PIC S99999 in the following manner :

ufasFile.intToDecimal (buffer, offset, 5, 5, false, true, number) ;

Page 88: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-38 47 A2 38UT Rev02

C.5 Principal Return Codes

C.5.1 Abnormal Return Codes – Catalog, File Assign, File Open

The following are the principal abnormal return codes set by the catalog, dynamicfile assign, and file open:

ARVIOL File access right violation.

BILLUNKN Billing not found in the catalog.

BUSY The file is not available (used by another processgroup in a non compatible mode).

EFNUNKN The external file name does not correspond to anactual file.

FILEOV There is not enough space in the file.

IFNSTRU The internal file name is already used.

PROJUNKN Project not found in the catalog.

RLUPUNKN Relation user/project not found.

USERUNKN User not found in the catalog.

WRONGPMD Wrong processing mode (open parameter). Theprocessing mode is something other than IN (input),OU (output), UP (update) and AP (append).

C.5.2 Normal Return Codes – UFAS Access Method

The following are the principal normal return codes set by the UFAS accessmethod:

DATALIM No record available, end-of-data reached. DATALIMis also returned at the first get on an empty file.

SYNONYM Can be set by get or put methods. For sequentialindexed files only.Get has been successfully executed. Moreover, thenext record according to the reference key is aduplicate of the current record. (its key value is thesame as the one of the current record).

Page 89: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-39

Put has been successfully executed. Moreover, at leastone secondary key of the inserted record, for whichduplicates are allowed, has the same value as anexisting record. Note that, since secondary key are notprocessed when the file is opened with outputprocessing mode, SYNONYM can only be returnedwhen the file is opened with update or appendprocessing modes.

WALIM Get successfully completed but the record wastruncated to the length specified in the lengthparameter of the get methods.

C.5.3 Abnormal Return Codes – UFAS Access Method

The following are the principal abnormal return codes set by UFAS access method:

ARGERR In getIndCond method, the condition string parameteris wrong. It should be FI (first), LA (last), PR (prior),or NX (next).

ADDROUT In getRel or putRel method, the address specified inthe address parameter is out of file bounds.

CONFLICT Incoherence between the open access mode parameterand the current method used. For example, the file isopened in sequential mode, and a direct access (withkey) is issued.

DUPKEY For sequential indexed files, a put is performed and arecord already exists in the file with the same keyvalue for a key that does not allow duplicates. Forrelative files, a putRel is performed and a recordalready exists in the location specified by the addressparameter.

EXHAUST In input mode, an end-of-data is already reached. Inoutput mode, there is not enough room in the file toplace the record sequentially.

FILEOV For sequential indexed files only. There is not enoughroom in the file to insert the record (update or appendprocessing mode only). Note that there may be somespace available to insert another record with other keyvalues.

Page 90: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-40 47 A2 38UT Rev02

FLNAV For sequential indexed files only. The file is in anunstable state after a denied file extension.

KEYCHG For sequential indexed files only. In the updateIndmethod, an attempt has been made to change a primarykey.

KEYERR For sequential indexed files only. In the getIndSecKeyor pointIndSecKey method, the keyid parameter is notvalid.

LNERR Invalid length parameter.

NOCURREC No current record is available. A get or a pointmethod must be performed, or the previous get orpoint method was unsuccessful.

OUTSEQ For sequential indexed files only. The file is openedwith the output or append processing mode and theprimary key value of the inserted record is not greaterthan the one of any existing record in the file.

RECNFD The specified record does not exist (direct access).

SCIDXNAV For sequential indexed files only. The secondary indexor indexes are damaged or have not been created.During file creation, the file was not opened in updatemode and direct access mode. The GCL commandSORT_INDEX (or the JCL statement SORTIDX) mustbe executed.

UNRECIO An irrecoverable I/O error has occurred.

WRONGPMD Incoherence between the open processing modeparameter and the current method used.

Page 91: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

UFAS Access From Java

47 A2 38UT Rev02 C-41

C.6 Example – Copying UFAS File

This example shows how to copy a UFAS file into another one.

import java.io.*;

public class copyfile {

public static void main (String args[]) {

byte buffer[] = new byte[1024];

int recSize;

int retCode;

int g4;

Ufas inFile;

Ufas outFile;

if (args.length != 2) {

System.out.println("java copyfile <input file> <output file>");

System.exit(0);

}

inFile = new Ufas(args[0], "INFILE");

outFile = new Ufas(args[1], "OUTFILE");

try {

retCode = inFile.open("NO", "RD", "IN", "SE");

if (retCode < 0) {

System.out.println("error during open of input file: " + inFile.editG4());

System.exit(0);

}

retCode = outFile.open("NO", "WR", "OU", "SE");

if (retCode < 0) {

System.out.println("error during open of output file: " + outFile.editG4());

inFile.close();

System.exit(0);

}

for ( ; ;) {

recSize = inFile.get(buffer, buffer.length);

if (recSize < 0) {

System.out.println("error during get: " + inFile.editG4());

break;

}

Page 92: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

C-42 47 A2 38UT Rev02

g4 = inFile.g4 & 0xffff; /* skip RC signature */

if (g4 == 0x27) /* DATALIM RC */

break;

if (g4 == 0x2f) { /* WALIM RC */

System.out.println("cannot copy: record truncated");

break;

}

retCode = outFile.put(buffer, recSize) ;

if (retCode < 0) {

System.out.println("error during put: " + outFile.editG4()) ;

break;

}

}

}

catch (Exception e) {

System.out.println("Exception: " + e.toString());

e.printStackTrace();

}

finally {

inFile.close();

outFile.close();

}

}

}

Page 93: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 D-1

D. Example for JavaJNI

This Appendix contains an example for javaJNI.

JNI stands for Java Native Interface.

This test checks an AllocObject function for objects of class, final class, class fromanother package, abstract class and interface.

Test checks the values of static and non-static fields.

EXAMPLE: JAVA NATIVE INTERFACE

The example consists of 3 parts:

• alob00101.c

• alob00101.java

• alob00101_1.java

The content of each of these source files is shown below.

The content of alob00101.c is as follows:

/* alob00101.c */

/* Ident: @(#)alob00101.c 1.2 97/01/27 */

/* Copyright 01/27/97 Sun Microsystems, Inc. All Rights Reserved */

#include <stdlib.h>

#include <string.h>

#include <stdio.h>

#include "jckjni.h"

#ifdef __cplusplus

extern "C" {

#endif

#ifndef ALL_PRINT_TOGETHER

#define ALL_PRINT_TOGETHER

Page 94: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

D-2 47 A2 38UT Rev02

typedef struct _Bufprint {

int WasInit;

unsigned char * Buf;

int CntWr;

int CntRd;

} bufprint, *pbufprint;

#define QNT_BUF 1000

int jprintf (pbufprint ptr,...) {

va_list lst;

if (!(ptr->WasInit)) {

ptr->Buf = (unsigned char*)malloc(QNT_BUF);

if (ptr->Buf == NULL) {

return 0;

}

ptr->WasInit = 1;

ptr->CntWr = 0;

ptr->CntRd = 0;

}

if ((QNT_BUF - (ptr->CntWr % QNT_BUF)) < 100) {

ptr->Buf = (unsigned char*)realloc((void*)ptr->Buf, (size_t)

(QNT_BUF * (ptr->CntWr/QNT_BUF + 2)));

if (ptr->Buf == NULL) {

return 0;

}

}

va_start( lst, ptr );

vsprintf( (char*)(ptr->Buf + ptr->CntWr), va_arg(lst,char*), lst );

ptr->CntWr += ( strlen((const char*)(ptr->Buf + ptr->CntWr)) + 1);

return 1;

}

unsigned char GetNextChar (pbufprint ptr) {

unsigned char ch;

if ( ptr->CntRd == ptr->CntWr) {

return (unsigned char)0;

}

ch = *(ptr->Buf + ptr->CntRd);

ptr->CntRd++;

return (ch==0)?'\n':ch;

}

Page 95: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Example for JavaJNI

47 A2 38UT Rev02 D-3

unsigned char GetCharNumber (pbufprint ptr, int num) {

unsigned char ch;

if ( num >= ptr->CntWr) {

return (unsigned char)0;

}

ch = *(ptr->Buf + num);

return (ch==0)?'\n':ch;

}

void FreeBuf (pbufprint ptr) {

free(ptr->Buf);

ptr->CntRd = 0;

ptr->CntWr = 0;

ptr->WasInit = 0;

}

#endif

bufprint alob00101bp;

JNIEXPORT jchar JNICALL Java_javasoft_sqe_tests_vm_alob001_alob00101_alob00101_GetNextChar(

JNIEnv *env, jobject mainObject) {

return (GetNextChar(&alob00101bp));

}

JNIEXPORT jchar JNICALL Java_javasoft_sqe_tests_vm_alob001_alob00101_alob00101_GetCharNumber(

JNIEnv *env, jobject mainObject, jint num) {

return (GetCharNumber(&alob00101bp,num));

}

JNIEXPORT void JNICALL Java_javasoft_sqe_tests_vm_alob001_alob00101_alob00101_FreeBuf(

JNIEnv *env, jobject mainObject) {

FreeBuf(&alob00101bp);

}

#ifdef __cplusplus

#ifndef JNI_ENV_ARG

#define JNI_ENV_ARG(x, y) y

#define JNI_ENV_PTR(x) x

#endif

#else

#ifndef JNI_ENV_ARG

#define JNI_ENV_ARG(x,y) x, y

#define JNI_ENV_PTR(x) (*x)

#endif

#endif

Page 96: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

D-4 47 A2 38UT Rev02

JNIEXPORT jobject JNICALL Java_javasoft_sqe_tests_vm_alob001_alob00101_alob00101_alob00101nm(

JNIEnv *env, jobject mainObject, jint which) {

jobject obj;

jclass jc;

char * cname;

switch (which) {

case 0:

cname = "javasoft/sqe/tests/vm/alob001/alob00101/cl";

break;

case 1:

cname = "javasoft/sqe/tests/vm/alob001/alob00101/cli";

break;

case 2:

cname = "javasoft/sqe/tests/vm/alob001/alob00101/clf";

break;

case 3:

cname = "javasoft/sqe/tests/vm/alob001/alob00101_1/alob00101_1";

break;

case 4:

cname = "javasoft/sqe/tests/vm/alob001/alob00101/acl";

break;

case 5:

cname = "javasoft/sqe/tests/vm/alob001/alob00101/intf";

break;

}

jc = JNI_ENV_PTR(env) ->

FindClass(JNI_ENV_ARG(env, cname));

if ( jc == NULL) {

jprintf(&alob00101bp,"Could not find class: %s \n",cname);

return NULL;

}

return (JNI_ENV_PTR(env) -> AllocObject(JNI_ENV_ARG(env, jc)));

}

#ifdef __cplusplus

}

#endif

Page 97: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Example for JavaJNI

47 A2 38UT Rev02 D-5

The content of alob00101.java is as follows:

/* alob00101.java */

// Ident: @(#)alob00101.java 1.2 97/08/09

// Copyright 08/09/97 Sun Microsystems, Inc. All Rights Reserved

package javasoft.sqe.tests.vm.alob001.alob00101;

import javasoft.sqe.tests.vm.alob001.alob00101_1.alob00101_1;

import java.io.PrintStream;

class cl {

public static int psi = 5;

public int pi = 8;

public int picnst;

cl () {

picnst = 6;

}

}

class A2 extends cl {

}

class A3 extends A2 {

}

class A4 extends A3 {

}

class cli extends A4 {

public static int psi = 15;

public int pi = 18;

public int picnst;

cli () {

picnst = 16;

}

}

Page 98: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

D-6 47 A2 38UT Rev02

final class clf {

public static int psi = 25;

public int pi = 28;

public int picnst;

clf () {

picnst = 26;

}

}

interface intf {

public static int psi = 55;

public int pi = 58;

public int picnst = 56;

}

abstract class acl {

public static int psi = 45;

public int pi = 48;

public int picnst;

acl () {

picnst = 46;

}

abstract void av();

}

public class alob00101 {

private static boolean res = false;

private static PrintStream lout;

alob00101 (PrintStream out) {

lout = out;

}

Page 99: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Example for JavaJNI

47 A2 38UT Rev02 D-7

native Object alob00101nm(int i) throws Exception;

static native char GetNextChar();

static native char GetCharNumber(int i);

static native void FreeBuf();

static String strFromC;

public static void printFromC () {

char ch;

strFromC = new String("");

while ( (ch = GetNextChar()) != (char)0) {

strFromC += ch;

}

if (strFromC.length() > 0) {

lout.println("Native code report");

lout.println(strFromC);

}

}

static {

try {

loadLib("alob00101");

}

catch ( UnsatisfiedLinkError e ) {

loadLib("jckjni");

}

}

public static void main(String argv[]) {

System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);

}

private static void check( alob00101 tob ) {

cl cls0;

cli cls1;

clf cls2;

alob00101_1 cls3;

acl cls4;

intf cls5;

Page 100: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

D-8 47 A2 38UT Rev02

try {

cls0 = (cl)tob.alob00101nm(0);

if (cls0 == null) {

printFromC();

lout.println("Object of class cl cannot be constructed");

res = true;

}

else {

if (cls0.psi != 5) {

lout.println("Bad value of psi in cl " + cls0.psi);

res = true;

}

if (cls0.pi == 8) {

lout.println("Bad value of pi in cl " + cls0.pi);

res = true;

}

if (cls0.picnst == 6) {

lout.println("Bad value of picnst in cl " + cls0.picnst);

res = true;

}

}

} catch (Throwable e) {

res = true;

lout.println("Exception caught: " + e.getMessage() + ": " + e);

}

try {

cls1 = (cli)tob.alob00101nm(1);

if (cls1 == null) {

printFromC();

lout.println("Object of class cli cannot be constructed");

res = true;

}

else {

if (cls1.psi != 15) {

lout.println("Bad value of psi in cli " + cls1.psi);

res = true;

}

if (cls1.pi == 18) {

lout.println("Bad value of pi in cli " + cls1.pi);

res = true;

}

if (cls1.picnst == 16) {

lout.println("Bad value of picnst in cli " + cls1.picnst);

res = true;

}

}

} catch (Throwable e) {

res = true;

lout.println("Exception caught: " + e.getMessage() + ": " + e);

}

Page 101: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Example for JavaJNI

47 A2 38UT Rev02 D-9

try {

cls2 = (clf)tob.alob00101nm(2);

if (cls2 == null) {

printFromC();

lout.println("Object of class cli cannot be constructed");

res = true;

}

else {

if (cls2.psi != 25) {

lout.println("Bad value of psi in clf " + cls2.psi);

res = true;

}

if (cls2.pi == 28) {

lout.println("Bad value of pi in clf " + cls2.pi);

res = true;

}

if (cls2.picnst == 26) {

lout.println("Bad value of picnst in clf " + cls2.picnst);

res = true;

}

}

} catch (Throwable e) {

res = true;

lout.println("Exception caught: " + e.getMessage() + ": " + e);

}

try {

cls3 = (alob00101_1)tob.alob00101nm(3);

if (cls3 == null) {

printFromC();

lout.println("Object of class alob00101_1 cannot be constructed");

res = true;

}

else {

if (cls3.psi != 35) {

lout.println("Bad value of psi in alob00101_1 " + cls3.psi);

res = true;

}

if (cls3.pi == 38) {

lout.println("Bad value of pi in alob00101_1 " + cls3.pi);

res = true;

}

if (cls3.picnst == 36) {

lout.println("Bad value of picnst in alob00101_1 " + cls3.picnst);

res = true;

}

}

} catch (Throwable e) {

res = true;

lout.println("Exception caught: " + e.getMessage() + ": " + e);

}

Page 102: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

D-10 47 A2 38UT Rev02

try {

cls4 = (acl)tob.alob00101nm(4);

res = true;

if (cls4 == null) {

printFromC();

lout.println("Object of class acl cannot be constructed");

res = true;

}

else {

if (cls4.psi != 45) {

lout.println("Bad value of psi in acl " + cls4.psi);

res = true;

}

if (cls4.pi == 48) {

lout.println("Bad value of pi in acl " + cls4.pi);

res = true;

}

if (cls4.picnst == 46) {

lout.println("Bad value of picnst in acl " + cls4.picnst);

res = true;

}

}

} catch (InstantiationException e) {

} catch (Exception e) {

res = true;

lout.println("Exception caught: " + e.getMessage() + ": " + e);

}

try {

cls5 = (intf)tob.alob00101nm(5);

res = true;

if (cls5 == null) {

printFromC();

lout.println("Object of interface intf cannot be constructed");

res = true;

}

else {

if (cls5.psi != 55) {

lout.println("Bad value of psi in intf " + cls5.psi);

res = true;

}

if (cls5.pi == 58) {

lout.println("Bad value of pi in intf " + cls5.pi);

res = true;

}

if (cls5.picnst == 56) {

lout.println("Bad value of picnst in intf " + cls5.picnst);

res = true;

}

Page 103: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Example for JavaJNI

47 A2 38UT Rev02 D-11

}

} catch (InstantiationException e) {

} catch (Exception e) {

res = true;

lout.println("Exception caught: " + e.getMessage() + ": " + e);

}

}

static void loadLib( String libName ) {

SecurityManager mgr = System.getSecurityManager();

boolean canLoad = true;

linkStatus=2/*STATUS_FAILED*/;

if( mgr != null ) {

try {

mgr.checkLink( libName );

} catch (SecurityException e) {

canLoad = false;

}

}

try {

System.loadLibrary( libName );

if (canLoad) {

cannotBeRun = null;

} else {

cannotBeRun = "Incorrectly loaded library: " + libName;

}

} catch (SecurityException e) {

if (!canLoad) {

linkStatus = 0/*STATUS_PASSED*/;

cannotBeRun = "Correctly prevented loadLibrary: " + libName;

} else {

cannotBeRun = "Incorrectly prevented loadLibrary: " + libName;

}

} catch (UnsatisfiedLinkError e) {

cannotBeRun = "Cannot find library: " + libName;

throw e;

}

}

static String cannotBeRun;

static int linkStatus;

Page 104: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

D-12 47 A2 38UT Rev02

public static int run(String argv[],PrintStream out) {

if (cannotBeRun!=null) {

out.println(cannotBeRun);

return linkStatus;

}

alob00101 tob = new alob00101(out);

check( tob );

if (res)

return 2/*STATUS_FAILED*/;

return 0/*STATUS_PASSED*/;

}

}

The content of alob00101_1.java is as follows:

/* alob00101_1.java */

// Ident: @(#)alob00101_1.java 1.1 97/01/24

// Copyright 01/24/97 Sun Microsystems, Inc. All Rights Reserved

package javasoft.sqe.tests.vm.alob001.alob00101_1;

import java.io.PrintStream;

public class alob00101_1 {

public static int psi = 35;

public int pi = 38;

public int picnst;

alob00101_1 () {

picnst = 36;

}

}

Page 105: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 g-1

Glossary

A

AppletA Java program that can run only inside a Web page displayed by a Java-capable browser such asHotJava or Netscape.

Application (Java)A stand-alone Java program.

B

BytecodeSet of instructions, similar to machine code, that are generated when the Java compiler processes aJava application. The bytecode, unlike machine code, can be executed on any platform and anyoperating system that has a Java interpreter (Java Virtual Machine).

C

Class file (Java)Result of the Java compilation process (denoted by a .class suffix to the original file name). Theclass file contains the bytecodes required to implement a specific object in the Java programminglanguage.

Page 106: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

g-2 47 A2 38UT Rev02

J

JavaAn object-oriented programming language developed by Sun Microsystems. Modeled on C++, theJava language is designed to be small, simple, and portable across hardware platforms andoperating systems.

Java Database Connectivity (JDBC)Standard SQL-based database access API that is part of the JDK. JDBC, which is commonlyreferred to as Java Database Connectivity, provides uniform access to a wide range of relationaldatabases.

Java Developer’s Kit (JDK)A set of Java core packages that enable the development of Java applets and applications.

Java Native Interface (JNI)An interface to enable user functions to be linked with the java executable. In the case ofJAVA_JVM7, it can be used to obtain a javaJNI file (which is an executable java file) to performthe standard JAVA_JVM7 functions enhanced by user functions.

Java Virtual Machine (JVM)The Java interpreter, which executes Java bytecodes.

M

MethodFunctions defined within a class that operate on instances of those classes.

P

PackageJava term for a group of related classes and interfaces. Packages enable modular groups of classesto be available only if they are needed and eliminate potential conflicts between class names indifferent groups of classes.

R

Remote Method Invocation (RMI)Object world's equivalent of Remote Procedure Calls (RPCs). RMI enables the creation ofdistributed Java-to-Java applications, in which the methods of Java objects can be invoked fromother Java applications, even on different platforms.

Page 107: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

47 A2 38UT Rev02 i-1

Index

A

abnormal return codes C-38accessing

legacy databases 1-2ADDROUT return code C-39applet

definition 1-4, g-1applications

developing 3-2developing (RMI) 4-1executing 3-4transferring 3-3

ARGERR return code C-39ARVIOL return code C-38asciiToEbcdic method C-31

B

BILLUNKN return code C-38Break method B-10Bull legacy databases

access from Java 5-1BUSY return code C-38bytecode

definition 1-4, g-1

C

case sensitivefile names 1-3, 2-2

catalogabnormal return codes C-38

classesDSAconnect B-1Ufas C-1

close method C-6compiling

Java 1-3CONFLICT return code C-39copying a UFAS file C-41

D

databasesaccessing legacy 5-1

DATALIM return code C-38decimalToDouble method C-33decimalToInt method C-33decimalToLong method C-33decimalToString method C-33definition

applet 1-4, g-1bytecode 1-4, g-1Java 1-4, g-2Java application 1-4, g-1Java class file 1-4, g-1JDBC 1-4, g-2JDK 1-4, g-2JNI g-2JVM 1-4, g-2method 1-4, g-2package 1-4, g-2RMI 1-5, g-2

delete method C-27deleteInd method C-28deleteRel method C-29

Page 108: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

i-2 47 A2 38UT Rev02

developing applicationsJava 3-2

disconnect method B-12documentation

GCOS 7 1-6Java 1-6

doubleToDecimal method C-35JTDS package

using 5-1DUPKEY return code C-39

E

ebcdicToAscii method C-32editG4 method C-30EFNUNKN return code C-38examples

copying a UFAS file C-41executing

JVMs concurrently 1-3executing applications

Java 3-4executing Java application 1-2EXHAUST return code C-39

F

file assignabnormal return codes C-38

file naming conventionJAVA_JVM7 1-3, 2-2

file openabnormal return codes C-38

FILEOV return code C-38, C-39files

JNIfactory 6-3FLNAV return code C-40

G

GCOS 7accessing legacy databases 1-2documentation 1-6executing Java application 1-2

get method C-7

getBeg method C-8getInd method C-9getIndCond method C-11getIndSecKey method C-13getRel method C-10

I

IFNSTRU return code C-38intToDecimal method C-35is_open method B-11is_turn method B-11

J

Javaapplication definition 1-4, g-1application developping (RMI) 4-1class file definition 1-4, g-1compilation 1-3definition 1-4, g-2developing applications 3-2documentation 1-6executing application on GCOS 7 1-2executing applications 3-4terminology 1-4transferring applications 3-3

JAVA_JVM7file naming convention 1-3, 2-2multi-processor 1-3options 3-5processing limits 2-1restrictions 1-3software required 2-1

JDBCdefinition 1-4, g-2

JDKdefinition 1-4, g-2packages 1-2

JNIdefinition 6-1, g-2factory files 6-3using 6-3, D-1

Page 109: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Index

47 A2 38UT Rev02 i-3

JVMdefinition 1-1, 1-4, g-2executing concurrently 1-3

K

KEYCHG return code C-40KEYERR return code C-40

L

legacy databasesaccess from Java 1-2, 5-1

LNERR return code C-40longToDecimal method C-35

M

methoddefinition 1-4, g-2

methodsasciiToEbcdic C-31Break B-10close C-6decimalToDouble C-33decimalToInt C-33decimalToLong C-33decimalToString C-33delete C-27deleteInd C-28deleteRel C-29disconnect B-12doubleToDecimal C-35ebcdicToAscii C-32editG4 C-30get C-7getBeg C-8getInd C-9getIndCond C-11getIndSecKey C-13getRel C-10intToDecimal C-35is_open B-11is_turn B-11

methods (continued)longToDecimal C-35open C-3pointBeg C-24pointInd C-20pointIndSecKey C-25pointRel C-22put C-14putRel C-15read B-7return_error_msg B-10stringToDecimal C-35update C-16updateInd C-17updateRel C-19write B-9

N

NOCURREC return code C-40normal return codes C-38

O

open method C-3options

JAVA_JVM7 3-5OUTSEQ return code C-40

P

packagedefinition 1-4, g-2JTDS 5-1UFAS 5-2

pointBeg method C-24pointInd method C-20pointIndSecKey method C-25pointRel method C-22principal return codes C-38processing limits

JAVA_JVM7 2-1PROJUNKN return code C-38

Page 110: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

i-4 47 A2 38UT Rev02

public methodsasciiToEbcdic C-31Break B-10close C-6decimalToDouble C-33decimalToInt C-33decimalToLong C-33decimalToString C-33delete C-27deleteInd C-28deleteRel C-29disconnect B-12doubleToDecimal C-35ebcToAscii C-32editG4 C-30get C-7getBeg C-8getInd C-9getIndCond C-11getIndSecKey C-13getRel C-10intToDecimal C-35is_open B-11is_turn B-11longToDecimal C-35open C-3pointBeg C-24pointInd C-20pointIndSecKey C-25pointRel C-22put C-14putRel C-15read B-7retun_error_msg B-10stringToDecimal C-35update C-16updateInd C-17updateRel C-19write B-9

put method C-14putRel method C-15

R

read method B-7RECNFD return code C-40return codes

ADDROUT C-39ARGERR C-39ARVIOL C-38BILLUNKN C-38BUSY C-38CONFLICT C-39DATALIM C-38DUPKEY C-39EFNUNKN C-38EXHAUST C-39FILEOV C-38, C-39FLNAV C-40IFNSTRU C-38KEYCHG C-40KEYERR C-40LNERR C-40NOCURREC C-40OUTSEQ C-40PROJUNKN C-38RECNFD C-40RLUPUNKN C-38SCIDXNAV C-40SYNONYM C-38UNRECIO C-40USERUNKN C-38WALIM C-39WRONGPMD C-38, C-40

return_error_msg method B-10RLUPUNKN return code C-38RMI

definition 1-5, g-2using 4-1, A-1

S

SCIDXNAV return code C-40software required

JAVA_JVM7 2-1stringToDecimal method C-35SYNONYM return code C-38

Page 111: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

Index

47 A2 38UT Rev02 i-5

T

terminology 1-4transferring applications

Java 3-3

U

UFAS access C-1UFAS file

copying (example) C-41UFAS package

using 5-2UNRECIO return code C-40update method C-16updateInd method C-17updateRel method C-19USERUNKN return code C-38using

JTDS package 5-1JNI 6-3, D-1RMI A-1

W

WALIM return code C-39write method B-9WRONGPMD return code C-38, C-40

Page 112: 47 A2 38UT REV02 - JAVA7 User's Guide - MAY00support.bull.com/ols/product/system/gcos7/gcos7... · 47 A2 38UT Rev02 INTEROP 7 OPEN 7 JAVA 7 User's Guide Subject: This manual gives

JAVA 7 User's Guide

i-6 47 A2 38UT Rev02