Selectively replace legacy load module programs with classes for execution in JAVA virtual machines
By replacing Java programs with loaders and preconfiguring the JVM, the interoperability of running compiled applications on different hardware platforms and operating systems is achieved, solving the problem of running difficulties in existing technologies, reducing migration risks and improving performance .
Patent Information
- Application Number
- CN201980081717.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-11-02
- Filing Date
- 2019-10-24
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies make it difficult to run compiled applications on different hardware platforms and operating systems, often requiring recompilation or the use of emulation methods, resulting in performance degradation and increased management complexity.
Load the first load module through the loader, detect and replace the associated Java program, insert ENC instructions, pre-configure the JVM, and execute the native program in the LAE to call Java methods to achieve application interoperability on different platforms .
There is no need to rewrite or recompile source code, which significantly reduces migration business risks, promotes the introduction of new features and capabilities, and improves the efficiency of applications running on new platforms.
Smart Images

Figure CN113168320B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to techniques and systems for executing a program compiled for a source architecture on a machine having a different target architecture. Background Art
[0002] An executable application (sometimes called a program) is compiled from source code. A limitation of a computer system is that a given executable application can only run under the operating system and machine instruction set for which it was compiled or assembled. This is true because executable programs target a specific instruction set (i.e., instructions that the system recognizes and can execute), have a known set of registers, and the program's ability to perform input / output operations is usually referenced to available calls to a known operating system. For example, Figure 1a As shown in , a compiled application (10) is configured to execute on a specific legacy platform including a specific legacy operating system (20) and a legacy hardware platform (30). Such operating system (20) and hardware platform (30) can have varying degrees of complexity. One can also refer to a platform for which software has been compiled to run on it as a "legacy" system. A legacy system does not require any particular age. More specifically, legacy refers to the system for which the compiled application has been compiled. In order to run the compiled application in a non-legacy system that implements a different hardware instruction set or under an operating system with different function calls, such as a system that does not include a legacy operating system, a legacy platform, or both, the application must typically be recompiled. This constraint limits the ability of the compiled application to operate in heterogeneous environments (including non-legacy systems).
[0003] The hardware instructions supported natively by a particular computer or processor form part of the architecture of the computer or processor. A processor or computer of one platform may have a different architecture, thus allowing native execution of different instructions compared to a processor or computer on another platform. In a mainframe environment, a relocatable load module generally refers to all or part of an executable application that is compiled to run a mainframe computing environment. A compiler (such as a Cobol compiler) translates a source code program consisting of one or more source code files into an object code comprising one or more machine language program files. These object code files, in some cases together with additional object files, can be linked and assembled into an executable program.
[0004] A load module refers to all or part of an executable computer program, typically prepared to be loaded into the main memory of a legacy computer platform (such as an S / 370, S / 390, or z / OS mainframe). Typically, a load module includes object code compiled for a legacy platform, and may include assembler code for the same legacy program, which has been linked by a link editor to be loaded and executed on the legacy platform. Because the object code and / or assembler code in a load module is compiled for the target legacy platform, legacy load modules typically cannot be run on different platforms.
[0005] One way to enable legacy load modules to run on different platforms is emulation. For example, an emulation platform that can include a non-legacy operating system, non-legacy hardware, or both can be built to emulate legacy operating systems and hardware, thereby providing applications with a virtual container that presents the appearance of a legacy environment. The disadvantage of emulation is that it often reduces system performance and generally does not provide support for legacy memory protection schemes. However, system performance can be improved by implementing an optimized native application programming interface (API) to replace the emulation of operating system function calls. Protection key memory management can be implemented by the memory management system described in "Protection Key Management and Prefixing in Virtual Address Space Legacy Emulation System" WO2017 / 103,651, which is incorporated herein by reference in its entirety.
[0006] In another method of enabling an application to run on different hardware platforms, a compiler or cross-compiler can be used to recompile the program so that it is expressed using the native hardware instructions of the new target hardware platform. However, in many cases, recompiling the source code is undesirable. Recompiling can lead to errors, changes in system performance, or changes in system behavior. Solving these problems may require changing the original source code, which can lead to code base fragmentation and increase management complexity. In addition, the source code for a specific application may not always be available, which further limits the ability to operate a given program on different platforms.
[0007] A decompiler is a program that reverses the process of a compiler, translating a computer program written in a high-level, usually human-readable language into a machine language program. In other words, a decompiler takes a program written in machine language as input and translates the program into an equivalent program written in a high-level language. A decompiler can be used to create a source code file that can be edited by a programmer and then recompiled or cross-compiled to be executed on a platform with a different machine architecture. However, decompilation does not generate source code that is exactly the same as the original source code that originally generated the machine language code or object code. In particular, in the case of using an optimizing compiler to improve executable performance, information that cannot be fully recovered using a decompiler is often lost. In addition, decompiling the object code is complicated because it is difficult to separate the computer code from the data. However, decompilation has found applications in algorithm extraction and analysis, in malware detection, and to a limited extent for source code recovery, with the goal of modifying or translating the object code from one environment to another.
[0008] A disassembler receives an executable program as input and converts the program into a machine-independent assembly code representation. Assembly languages typically have a one-to-one correspondence between assembly instructions and the underlying machine instructions. The disassembled program can be reassembled into an executable program by an assembler.
[0009] In the case of interdependent software programs, converting code from one computer architecture to another usually introduces changes, which interrupts the interface between previously interoperable programs. For example, in the case where the address of a routine or function is passed as a parameter to allow the receiving program to call a callback program of a routine in the calling program, the translation to different target architectures by decompiling and recompiling usually changes the address, and the size of the address operand can be changed, thereby destroying the ability of the receiving program to call a remote routine. Convert data between the EBCDIC format commonly used in legacy mainframe systems and the ASCII format used by newer platforms. A load module compiler that can receive a compiled legacy load module (such as a Cobol load module compiled for a System 390 mainframe) as input and generate an executable program running on a 64-bit x86 platform as output while continuing to make external references accessible has been described in "Load Module Compiler" WO2017 / 153815, which is incorporated herein by reference as a whole. The load module compiler enables selective decompilation and recompilation of executable load modules for a new target native environment, including providing a mechanism for correctly handling addressing and data formatting changes. However, a computer program that is migrated to a new computing environment using a load module compiler cannot take advantage of programming functionality provided by the new programming environment.
[0010] In one example of a load module compiler, a load module decompiler is provided, which is operable to receive a relocatable load module previously compiled to run on a 32-bit mainframe computer as input, and generates an executable program compiled to run on a 64-bit computer as output. By selecting an input executable program that cannot be self-modified and whose data and instructions can be separated, because the operation of the known compiler and its settings separate data from instructions, it is possible to design a decompiler that translates the input executable program into an intermediate code representation, and the intermediate code representation can be compiled to run on a processor that supports different instruction sets. The Cobol load module compiled using the Cobol compiler is an example of this type of program. In order to maintain the interoperability of other programs with the external reference address of the original program, the load module compiler generates an index of the address that can potentially be referenced from the program outside, and generates an output object code in conjunction with a 32-bit index position to replace the 64-bit address of those addresses. In operation, the runtime environment provides an exception handler to translate the 32-bit index position into the correct 64-bit memory address of the indexed position. In one embodiment, the intermediate code generated by decompiling the load module represents a file or a collection of files, which is structured so that each instruction of the Cobol load module is represented by a macro according to the rules of the C programming language. Then, the intermediate code of the load module is received by the load module compiler and executed in the legacy application environment (LAE) operating on the x86 platform supporting 64-bit instruction sets. The C compiler is called by the load module compiler to translate the C macro instructions into 64-bit X86 instructions. The load module compiler combines the index into the output machine language program so that the external reference to the memory location of the executable output program can be resolved. The load module compiler can also call the library of the operating system function to translate the operating system function call into the native X86 instruction. The load module compiler converts the intermediate code representation into an X86 machine language program, which is assembled into an executable file.
[0011] Load module compiler can be constructed to realize different instruction formats, and develop different intermediate code representations before compiling intermediate expressions for new target platforms. Although x86 target platform is described above, different hardware architectures can be used, such as ARM or other architectures. Similarly, although translation to 64-bit address space is described above, other address spaces can also be used. The decompiler of load module compiler can be written to operate load module with multiple passes or single pass. Load module can call known Binder API to obtain information about Cobol load module for decompiling module. Alternatively, information about Cobol load module used for decompiling can be obtained from load module itself. Information such as exit list, return code, CSECT information, relocation dictionary entry or external symbol directory entry can be obtained in other ways to enable the decompiling of load module. Load module compiler can include a collection of scripted macros to process intermediate code representation and indexing by calling compiler and library to generate x86 code. Alternatively, compiled program can perform equivalent functions.
[0012] Java is an object-oriented programming language developed to facilitate the creation of programs whose purpose is to run in a portable runtime environment called the JVM (JVM). Although the JVM is written for a variety of different underlying hardware and operating system platforms, the intention of the JVM is to provide a portable runtime so that Java programs written for one runtime environment can operate in another runtime environment. Partly due to the fact that it is licensed under a public license, the adoption of Java has been widespread. Programs written in the Java programming language for the JVM are compiled into an intermediate representation called Java bytecode, rather than an instruction set specific to the native hardware.
[0013] The JVM provides memory management features, including providing a shared memory heap that is available to all threads running within the JVM, and a private memory stack allocated to an individual thread running in the JVM, whose memory is inaccessible to programs running outside that thread. The JVM automates the memory management process, in part by simplifying programming by removing the responsibility of memory management from the Java application programmer. Programs running in threads within the JVM can create objects and rely on the JVM's implicit memory allocation and deallocation processes to create space for such objects within the stack. The allocation of per-thread stack space within the JVM is typically controlled by operating system settings in default mode, but can be adjusted through dynamic settings set at JVM initialization time.
[0014] The JVM includes a security manager object that can be adapted to define a security policy for applications running in the JVM. By default, the security policy of the JVM is permissive, but it is possible to implement a policy that identifies certain actions as unsafe and causes the JVM to throw a SecurityException if the security policy does not allow any action.
[0015] The Java Native Interface is a programming framework designed to allow programs written in the Java programming language and running on the JVM to call and be called by programs running outside the JVM that have been compiled to run natively on the host hardware and operating system. Figure 2 The JVM is illustrated. Typically, JNI is used to allow Java programs to access functionality not available in the Java class library, to leverage pre-existing libraries written in other languages, or to call assembler routines written to optimize the performance of Java applications on a particular platform. Because the JVM uses a different data representation than the native environment, translation between data representations is a problem. Furthermore, Java programs that call JNI methods to access resources outside the JVM are not portable because they cannot execute correctly in a JVM that cannot access such external resources.
[0016] When a Java program calls a native method, the JNI provides the native method with a JNIEnv pointer, a reference to the calling object or class, and any arguments or parameters required by the called method. The JNIEnv pointer (210) includes a reference to a function table that points to the available functions of the JNI interface and is Figure 2 . The first argument (220) of JNIEnv is a pointer to a pointer table (240), each of which indicates an interface function of the JNI. The second argument (230) is a reference to an object or class. JNI functions allow the caller to interact with the native C / C++ program to obtain version information, operations on classes, responses to exceptions, reference objects, data fields, obtain object identifiers, perform calls, access data fields, perform string and array operations through translation between Java and C / C++ data types, register methods, monitor operations, and obtain JVM interface pointers. Although the interface can be used to communicate with programs written in other languages, the JNI functions are not written to interact with legacy mainframe environments, such as those that may be used for batch processing, CICS, IMS, VSAM. When a program running in the JVM uses JNI to call an external program, it passes the JNIEnv pointer, the jobject pointer, and any Java arguments declared by the Java method. The env pointer is a structure that contains the interface to the JVM. It includes all the functions required to interact with the JVM and work with Java objects.
[0017] Typically, a JVM is instantiated and a Java program is launched by passing the classpath, class name, and optionally a byte string including input parameters to the JVM via a command line, which passes the byte string to the main() subroutine of the class.
[0018] Application developers who wish to introduce the flexibility provided by Java programming into legacy Cobol systems can rewrite their code using object-oriented Cobol, which is a modified version of the Cobol programming language that introduces the ability to define classes, encapsulated objects, methods for classes and objects, inheritance, polymorphism, and method overriding, as well as the ability to create and manage objects and call methods on objects. Object Cobol Program can communicate with Java Object by creating a COBOL proxy object in the Object Cobol runtime environment. Moreover, objects compiled in Object Cobol as classes that inherit java interface classes can be encapsulated in Java wrapper classes, which makes it possible to call them from Java objects. However, migrating legacy Cobol applications to object-oriented Cobol requires rewriting the code to take advantage of the new features and recompiling the application.
[0019] Another approach to introduce Java into the legacy environment is to introduce a server and JVM within the CICS region and allow the CICS programs to communicate with the Java programs within the CICS region. The disadvantage of this approach is that it requires rewriting and recompiling the CICS programs to make them aware of the JVM. Another problem with this approach is that the CICS environment does not allow processes that are not considered thread-safe to be exported to JAVA, which further limits the ability to selectively replace older CICS programs with JAVA programs.
[0020] It would be desirable to provide an environment that allows selective replacement of portions of legacy applications (such as legacy Cobol applications) by replacing individual load modules, or individual executable programs within load modules, with Java programs that can run in a virtual machine without modifying other executable programs or load modules, either by rewriting or recompiling the legacy code. Such a system would significantly reduce the business risk associated with migrating applications to new environments, since portions of the original code would remain unchanged, and would greatly facilitate the introduction of new features and capabilities into legacy applications that can be easily implemented in newer platforms. In the case of CICS, it would also be advantageous to enable replacement of older programs that were not written to be thread-safe into the JVM. Summary of the invention
[0021] According to one embodiment, the present invention provides a computer-implemented method for executing an application on a machine having a target architecture, the application comprising a first load module, the first load module calling a second load module for a source architecture, the method comprising:
[0022] The loader loads a first load module, wherein the first load module includes an object code that calls a second load module in the LAE;
[0023] detecting, by the loader, that at least one CSECT in the second load module has an associated replacement Java program;
[0024] Inserting, by the loader, a CSECT including ENC instructions corresponding to the replacement Java program into the memory of the LAE;
[0025] identifying a signature type indicating the number and structure of input and output parameters of the replacement Java program and inserting a signature type identifier in the memory area for each replacement Java program;
[0026] Provision the JVM;
[0027] A native program associated with the ENC instruction is executed in the LAE, wherein the native program: (a) attaches its thread to the JVM; (b) adds the classpath and method name of the replacement Java program to the memory of the JVM; (c) uses the classpath in the JVM to load the replacement Java program class corresponding to the replacement Java program; (d) constructs a signature in the memory of the JVM, the signature including input parameters structured according to the signature type and memory allocation of output parameters appropriate for the signature type; (e) calls a method of the replacement Java program class corresponding to the method name; and (d) detaches itself from the JVM.
[0028] According to further embodiments, it is possible to combine with the above-described methods and with one another or any other element of this specification, unless clearly mutually exclusive:
[0029] The detecting includes determining that the second load module has been replaced by checking metadata of the second load module;
[0030] The detecting includes performing a table lookup by the loader to determine whether an individual CSECT within the second load module has been replaced;
[0031] The at least one replacement Java program comprises two or more Java programs, and wherein the loader writes a default entry point into the memory of the LAE;
[0032] The loader inserts the classpath and class name into the memory of the LAE;
[0033] The loader inserts the method name into the memory of the LAE;
[0034] The native program loads an interface class into a heap of the JVM, wherein private methods of the interface class implement a native interface to the LAE, and wherein public methods of the interface class allow access to resources of the LAE by calling one or more of the private methods;
[0035] The replacement Java program class uses the public method of the interface class to call the first loading module, and the interface class calls one or more private methods of its private methods to access the resources of the LAE;
[0036] The replacement Java program class calls the third load module in the LAE by using the public method of the interface class, and the interface class calls one or more private methods of its private methods to access the resources of the LAE;
[0037] The native program calls a method of the interface class to overwrite one or more memory areas of the JVM;
[0038] The private methods of the interface class include functions for: writing to the LAE log, initiating a program call to a program executing in the LAE, obtaining or releasing storage, opening or closing a file, setting or clearing an error setting, placing or getting a string, byte, or other data to or from a file of an LAE data type, conversion from partitioned to packed, packed to partitioned, integer to partitioned, integer to packed, packed to integer, packed to partitioned, ASCII to EBCDIC, EBCDIC to ASCII data formats;
[0039] The pre-configuration also includes setting a lock on the JVM startup instruction, determining by the native program that the JVM is not executed, initiating the LAE resource manager, and releasing the lock after loading the interface class;
[0040] Preconfiguring the JVM includes performing a first attempt at execution, determining that a memory error has occurred, and then performing a second attempt at execution;
[0041] performing the first attempt when executed includes using a first memory protection key and performing the second attempt when executed includes using a second memory protection key;
[0042] performing the first attempt when executed includes using the first address and performing the second attempt when executed includes using the second address;
[0043] After the execution step is completed, detect an uncaught exception and terminate without providing the output of the execution step to the LAE;
[0044] The target architecture is the same architecture as the source architecture;
[0045] The target architecture is different from the source architecture;
[0046] The method also includes configuring the security manager to prohibit stop and exit operations and to prohibit loading of classes capable of interfacing with the LAE;
[0047] The step of configuring the security manager is performed by a method of the interface class;
[0048] The LAE includes a binary interface, and wherein, upon completion of executing the called method of the replacement Java class to produce output, the binary interface calls a method of the SDM class to format the output according to the signature type and returns the output to the LAE;
[0049] Native programs access memory controlled by protection keys established by the LAE.
[0050] According to a second embodiment, which may be used independently or in combination with any of the above methods, in particular as a way to preconfigure a JVM, the present invention provides a computerized method of configuring a JVM to respond to a caller in a LAE, the method comprising:
[0051] Set a lock on the JVM startup instruction;
[0052] The calling program determines that the JVM is not executing;
[0053] Instantiate the JVM;
[0054] Load the first class into the heap of the JVM;
[0055] wherein the private methods of the first class implement a native interface to the LAE, and wherein the public methods of the first class allow access to resources of the LAE by calling one or more of the private methods;
[0056] activating a security manager, the security manager being configured to prevent loading of any additional classes comprising a native interface to the LAE;
[0057] Release the lock;
[0058] attaching a thread operating in the LAE to the JVM;
[0059] Load the second class; and
[0060] Calling the method of the second class by the thread;
[0061] wherein the method of the second class provides a memory key and parameters to a public method of the first class to call a legacy program in a legacy program environment.
[0062] According to further embodiments, it is possible to combine with the above-described methods and with one another or any other element of this specification, unless clearly mutually exclusive:
[0063] The method also includes redirecting the standard output of the JVM to a log in the LAE;
[0064] The method also includes setting implicit diagnostic and tracing options of the JVM based on settings associated with the LAE;
[0065] The method also includes setting dynamic settings for the JVM;
[0066] The method also includes initiating a resource manager in the LAE, the resource manager being operable to limit a number of JVMs that can respond to a caller in the LAE.
[0067] According to a third embodiment, which may be used independently or in combination with any of the above methods, the present invention provides a method for establishing a secure interface between two runtime environments running on a common operating system, the method comprising:
[0068] initiating execution of a first program in a first thread in a first runtime environment, the first program including instructions for loading and executing a second program in a thread within a second runtime system;
[0069] storing in memory allocated to the second runtime environment a first class comprising a library of native interface routines for communicating with the first runtime environment; the library being contained in a collection of private methods of the first class, wherein the first class also comprises a collection of public methods for providing access to resources of the first runtime environment;
[0070] activating a security manager routine in the second runtime environment, the security manager routine configured to prohibit loading of additional code that has access to the first runtime environment without calling the first class;
[0071] associating the first thread with the second runtime environment;
[0072] Loading a second program in the second runtime environment by the first program;
[0073] The second program accesses resources in the first runtime environment, wherein the access includes calling a public method of the first class.
[0074] According to further embodiments, it is possible to combine with the above-described methods and with one another or any other element of this specification, unless clearly mutually exclusive:
[0075] The first runtime environment is LAE;
[0076] The first runtime environment is a LAE adapted to support execution of a load module on a platform of a second instruction architecture, the load module comprising object code compiled for execution in a first instruction architecture;
[0077] The second runtime system is the JVM;
[0078] The associating includes calling, by the first program, an AttachCurrentThread() routine.
[0079] According to a fourth embodiment, the present invention also provides a system, including hardware, an operating system and a LAE, the system being operable to execute a first program compiled for different hardware, operating systems or environments and to perform any of the above methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] For a more complete understanding of the embodiments of the present invention and its features and advantages, reference is now made to the following description in conjunction with the accompanying drawings, in which:
[0081] Figure 1a is a schematic diagram of a software application or program running on a legacy hardware and operating system platform as known in the art;
[0082] Figure 1b is a schematic diagram of a legacy application executing on a legacy application engine, wherein a native API is called to execute ENC instructions;
[0083] Figure 2 is a schematic diagram of a JNI interface pointer structure known in the art for pointing to a JNI interface function;
[0084] Figure 3 is a schematic diagram of a legacy application executing on a legacy application engine, wherein a binary interface between a legacy environment and a JVM resides in the LAE;
[0085] Figure 4 is a flow chart depicting a process for constructing and loading a replacement module in a JVM or other environment;
[0086] Figure 5 is depicted by element A and Figure 4A flowchart of a process for constructing and loading a replacement module in other environments of associated exemplary signature types; and
[0087] Figure 6 is a flow diagram depicting the instantiation and configuration of a JVM for use with a binary interface. DETAILED DESCRIPTION
[0088] In at least one embodiment, the present invention provides a binary interface to enable a legacy load module operating in a legacy environment to interoperate with methods of a Java class operating in a JVM without rewriting or recompiling the legacy source code and legacy load module. In one embodiment, one or more programs that may constitute one or more individual program target files within one or more complete load modules or relocatable load modules are replaced with one or more Java methods without modifying other executable program files or load modules including the application. The LAE identifies that one or more executable programs are replaced by corresponding Java methods and constructs a load module that calls one or more ENC instructions to call the Java method running in the JVM. The "ENC" or "Execute Native Command" instruction is an instruction of the target platform that does not run in simulation, but causes the runtime environment to execute a native API to replace the original instruction, call, subroutine, or program.
[0089] Figure 1b Depicted is a simulation system designed to enable operation of a legacy load module (160), which may be, for example, a relocatable Cobol load module configured to operate on a mainframe platform under a S / 390 operating system, on a different target platform. In the illustrated example, the target platform hardware includes an x86 computer (110), and the target operating system (120) is Linux. Although load modules and mechanisms for selectively replacing a load module (160) or an executable program within such a load module (160) with a Java method running in a JVM are described in the context of a program running in an LAE module (150), which operates as a container for executing legacy workloads on different target platforms, aspects of the inventive technology for enabling selective replacement of legacy programs with Java may also be applied to the legacy environment itself, such as utilizing execution in an LAE of a program running on a legacy platform.
[0090] like Figure 1bAs depicted in , one option for operating a load module compiled to run in a legacy hardware and operating system environment in a different target environment is an emulation system. The load module (160) can instead be configured to execute in a LAE ("LAE") (150), which operates as a container and execution environment for the load module (160). Preferably, the load module (160) is processed to replace legacy system calls and other instructions with execute native commands ("ENC") calls that call native APIs (140), which are programs written to optimize performance in the target platform. In the example shown, the host OS (120) of the target platform is Linux, and the hardware platform (110) is an x86 computer system. Other operating systems, such as Windows, macOS, iOS, Android, or other operating systems, can be used, or other hardware platforms, such as blade servers, ARM, RISC, or other computer platforms can also be used. The load module (160) executed in the LAE (150) can call legacy hardware functions provided by the legacy hardware environment module (130). In one embodiment, the legacy hardware environment module (130) includes a collection of functions, each function corresponding to a hardware instruction to provide emulation functionality corresponding to an instruction set (such as the System / 360, ESA / 390, or z / Architecture mainframe instruction set). Alternatively, a selected subset of such instructions may be supported, or a mixed support of instructions from more than one legacy hardware platform. In another embodiment, support for macro instructions or other API calls may also be included in the hardware environment module (130). Although one load module (160) is shown, multiple load modules including one or more applications may be run in the LAE (150). In addition, one or more legacy load modules (160) may be replaced by load module compiled applications (not shown) that are generated as output of the load module compiler. Such load module compiled applications may operate in the container and runtime environment provided by the LAE (150), but typically will not call functions of the legacy hardware environment (130) because they have been modified to directly call native hardware (110) functions. Alternatively, the LAE (150) may include a runtime environment that runs natively on a legacy platform, in which case the legacy hardware environment (130) and native API (140) may be omitted.
[0091] An important function of the memory management unit (MMU) is to prevent a process or task from executing instructions in memory that have not been allocated to that process or task. Attempting to execute instructions in memory that has not been allocated results in a hardware fault that is intercepted by the operating system, often called a segmentation fault (SEGV), which generally results in the termination of the process.
[0092] In an embodiment implemented on an x86 machine running an instance of the Linux operating system, the MMU of the processor responds to attempts to access instructions at the lowest address of these user spaces that are not allocated to the program, and causes the Linux operating system to generate a SEGV signal that calls an exception handler. In one embodiment, the exception handler is configured to access an index of a 32-bit address and translate the 32-bit address into a corresponding 64-bit address used by the executable program. The exception handler can also be configured to perform additional verifications, such as to support protection key management of memory addresses. The exception handler and prefix scheme described in PCT application PCT / IB2015 / 059646 entitled "Protection Key Management and Prefixing in Virtual Address Space Application" can be used.
[0093] Figure 3 Depicted in Figure 1b A JVM running on a native hardware and operating system platform in an environment of a native hardware environment is provided, and an instance of a JVM (370) is added, which is configured to operate a Java class (380) that has been written to replace one or more load modules (260) or to replace one or more executable programs contained in a load module (360). As shown, the load module (360) operates in the LAE (350), and in operation can call legacy hardware functions provided by the legacy hardware environment module (330), or system and other calls invoked by ENC instructions that call the native API (340). Figure 3 The exemplary system of runs on a host OS (320), which is preferably Linux and is different from the legacy operating system (such as S / 390) of the legacy environment for which the legacy load module is intended to execute. Furthermore, Figure 3 The exemplary system of operates on an x86 server platform, whose architecture and native instructions differ from the hardware platform on which the legacy load module is intended to execute. Figure 3 Also depicted is a binary JVM interface (355) that allows a legacy load module (360) or a legacy compiled load module program operating in the LAE (350) to call Java code running in the JVM (370) or respond to calls from Java code running in the JVM (370).
[0094] In one embodiment, the legacy hardware environment module (330), native API (340), LAE (350), binary JVM interface (355), and JVM (370) are deployed in a Docker container in a cloud-based deployment. The cloud-based deployment can allow the computer resources required by the system (such as server capacity and network storage) to be provided. Preferably, the native API (340) is implemented by a compiler with switchable settings designed to optimize performance depending on whether they are compiled to execute on an x86 platform or an ARM platform. In another embodiment, the stack is deployed on x86 server hardware (310) and runs under Linux as the host OS (320).
[0095] Figure 4 Describes the system (such as Figure 34. The system loader of claim 406 is a system loader that is used to perform various aspects of the operation of the system (described in step (406). When a program operating in the LAE (350) depends on another load module, the system loader examines the program and its metadata, as described in step (405). In one embodiment, a load module whose executable program code has been replaced by Java includes a two-byte identifier indicating that the load module is a replacement for a legacy load module. Other types of identifiers may also be used, or data structures or objects located outside the load module may be used, or other types of signals may be sent to the loader to notify the loader of the modified state of a particular load module. In step (410), the loader determines whether the load module is a conventional legacy module whose executable code has not been replaced by Java or other code. In the case of a conventional load module, the loader next determines whether it is intended to run in a 24-bit, 31-bit, or 64-bit address space step (412), and establishes appropriate storage to receive the load module. In order to allow for the possibility that an individual CSECT within a load module may have been replaced, in one embodiment, the loader performs a table lookup in step (414) to determine whether such a replacement has occurred. Next, if the CSECT has not been replaced, then based on the metadata in the load module, the loader loads the program into memory (420). If the CSECT has been replaced, then the loader will find the appropriate ENC instruction and insert it into the load module (415), insert the classpath, class, method name and optional JVM parameters and optional entry point into the memory associated with the CSECT at step (416), and then identify and insert the appropriate signature type at step (417). In the case of multiple Java programs replacing a single CSECT in the load module, the entry point for each such program is preferably inserted to enable access at the corresponding entry point. Preferably, the classpath is provided as a uniform resource identifier (URI) that enables a class to reside at any address accessible to the JVM. Alternatively, in the case of a dedicated ENC instruction for program replacement, the classpath, class name, method and optional JVM parameters will be known to the native API called by the ENC instruction and do not need to be inserted at step (416). If there are additional CSECTS in the load module, the loader advances to the next CSECT at step (422), and if the last CSECT has been brought into memory, relocation is performed by resolving the address constant to the appropriate virtual address (425), and the parameters are passed to the load module (430). The memory location and entry point (433) are then identified so that it can be transferred to the calling program. At this point, in the case of loading, control is not passed to the load module, but its address (entry point) is returned in register zero at step (445). In the case of linking, program execution begins at step (447), as shown.
[0096] In the event that the loader detects at step (410) that the load module is not a regular load module, the loader checks the program metadata to indicate the type of replacement. If the metadata indicates a Java replacement (450), then according to one embodiment, the loader constructs a new load module (455) configured to execute one or more ENC instructions within the LAE (350). In one embodiment, each ENC instruction includes parameters indicating the legacy program it has replaced, and a separate ENC instruction is used for each such program. In another embodiment, an array of parameters indicates the replacement of the program. When constructing the load module, the loader first checks the program metadata to determine whether 24-bit, 31-bit, or 64-bit addressing is applied, and establishes appropriate storage to insert the new load module. Then, at step (460), the loader inserts the classpath, class name, method name, and any optional JVM parameters associated with the load module in memory. In the case of using multiple ENC instructions, a default entry point is set for the first class so that the correct instruction sequence will be followed if the caller does not specify which ENC instruction should be called first. Preferably, the classpath is provided as a uniform resource identifier (URI) that enables classes to reside at any address accessible to the JVM. Alternatively, where a dedicated ENC instruction is assigned to a single program replacement, the classpath, class name, method, and optional JVM parameters will be known to the native API called by the ENC instruction and do not need to be inserted as part of the process of loading the replacement load module at step (460). In another embodiment particularly suitable for frequently called applets, the replacement Java class is inserted within the load module and the classpath parameter indicates the internal location of the class.
[0097] Because the Java program that has replaced the legacy program (such as the executable Cobol program in the legacy load module) must be able to receive parameters that have been processed by the replaced Cobol program, and must return output in the format expected by the calling program, the inventive system checks the structure of the parameters passed from the calling program and returned to the calling program, and associates the parameters with signature types. In one embodiment, and in the case of special structures of input and output parameters, the signature type is determined when the replacement program is written. In another embodiment, the structure of the input and output parameters can vary with the program of the caller, or if the caller is an assembler, PL / 1, Cobol, Java or other program, the structure of the input and output parameters can vary, and different signature types can be inserted according to the caller. In another embodiment, instead of using different signature types in the case of different caller programs or program environments, different ENC instructions can be used to handle the need for different input / output data formatting. Regardless of the method of identifying the signature type, at step (465), the loader inserts the signature type identifier into the memory associated with the load module. In the case where the replacement Java program has a dedicated ENC instruction, if the identification and insertion of the signature is provided as part of the native API called by the dedicated ENC instruction, then the identification and insertion of the signature can be omitted at step (465). At step (470), if there are more ENC instructions, the loader returns to step (460) for subsequent classes. The loader next passes the parameters of the Java replacement load module at step (430), as shown.
[0098] According to one embodiment, the signature is implemented as an enumerated data type corresponding to the typical pattern of input and output parameters of the legacy application. A common method of calling a Java program from outside a virtual machine using the Java Native Interface (JNI) is to provide a single text string to convey the bytecode input. Legacy program calls that take a single register argument (e.g., register 1) or return a single register value (e.g., register 15) have corresponding signatures. Signatures that present a byte array of 16 bytes or 16 register settings are also common. In the case of CICS program calls, it is typical to provide a signature of multiple strings.
[0099] In cases where a batch program is replaced, the signatures ASV, ASI, SV, and SI are typically used. The ASV signature is used when the input parameters are passed as a collection of separate strings. The ASI signature is used when the input parameters are passed as a collection of separate strings and the expected return value is in register 15 of the legacy hardware for which the load module was originally created. The SV signature is used when the input parameters are passed as a single string. The SI signature is used when the input parameters are passed as a single string and the expected return value is in register 15 of the legacy hardware for which the load module was originally created. The ABV signature is used when the input parameters are passed as an array of bytes. The ABI signature is used when the input parameters are passed as an array of bytes and the expected return value is in register 15 of the legacy hardware for which the load module was originally created. The AIV signature is used when the input parameters are passed as an array of 16 integers containing the contents of legacy system registers R0..R15 on entry. The AII signature is used when the input parameters are passed as an array of 16 integers containing the contents of legacy system registers R0..R15 on entry, and the expected return value is in register 15 of the legacy hardware for which the load module was originally created. The IV signature is used when the input parameters contain the contents of legacy system register R1. The II signature is used when the input parameters contain the contents of legacy system register R1 and the expected return value is in register 15 of the legacy hardware for which the load module was originally created. The PIV signature is used when the input parameters consist of an array of integers containing a standard parameter list on entry, for which the last parameter is high-terminated. The PII signature is used when the input parameters contain a standard parameter list on entry (the last parameter is high-terminated) and the expected return value is in register 15 of the legacy hardware for which the load module was originally created.
[0100] Traditionally, when a Cobol application (such as an application written in Object Cobol) attempts to call a class using the JVM, it does so by instantiating the JVM and providing the name of the class and a string argument through a command line interface. This arrangement is inflexible because it requires rewriting the COBOL application in Object Cobol, and because calling a class using a public static method voidmain(String[]) restricts the call to the main() function of the specified class.
[0101] like Figure 6As shown in , after execution, the ENC instruction will call the native API of the calling Java program. Next, the binary interface checks whether the JVM is running at step (610). If the JVM is not running, the binary interface thread running on the LAE initiates an instance of the JVM by obtaining a process-wide lock (e.g., a pthread mutex lock) on the instruction (615) that initiates the JVM, then checking whether the JVM is running at step (618) (because it may have been started by another process before obtaining the lock), setting implicit options (620) and redirecting the standard output (623) of the JVM to the LAE log. Next, at step (625), the binary interface thread initiates interception of abort and exit by disabling exit and suspend operations in the security manager. Examples of implicit options (620) include settings related to tracing, diagnostics, or performance of the environment. For example, in the case where the calling program is a CICS program running in tracing mode, it would be desirable to configure the JVM to perform tracing. Preferably, the security manager is configured with extensions to check for the existence and suspension of methods, and to check permissions, prohibit the loading of JNI, and restrict program calls by programs other than LAE SDM classes. Next, at step (628), the binary interface thread identifies options, such as CICS specifications, tracing and logging settings, and then sets dynamic settings (630) accordingly (such as the amount of memory, maximum stack size, garbage collection parameters). In the case where the system is deployed in a microservice container, memory allocation and stack size can be adjusted in a smaller configuration than in a more general server-based deployment. Once the settings are set, the binary interface thread instantiates a JVM (635) and initiates execution of the LAE resource manager (640) so that when the LAE stops executing, the LAE resource manager will terminate the JVM, clear and release memory previously assigned to the JVM, and release other resources associated with the JVM. Then, at step (645), the thread loads a class called the LAE SDM class into the shared heap of the JVM so that it can be accessed by threads running in the JVM.
[0102] According to a preferred embodiment, the LAE SDM class loads a JNI interface, which is preferably implemented by the LAE SDM class as a collection of private methods. As such, and in view of the fact that the operation of the security manager prevents any other process from loading the JNI alone, access to external programs and to memory and programs running in the LAE (350) is generally limited to the LAE SDM class itself. In this way, the LAE SDM class is used as an interface class by limiting the available methods for Java programs running in the JVM to access SDM resources. In order to enable execution of replacement programs, or access to memory, programs or other resources of the LAE, the LAE SDM preferably implements public methods or function calls. Examples of such public function calls include calls to open, close, read or write legacy data sets, read or write logs, execute CICS, IMS, Cobol or PL / 1 functions, attach additional threads, read legacy register contents, perform type conversions, activate or deactivate tracking of legacy environments, manipulate legacy environments, obtain legacy date / time data, perform legacy wait or release operations, or obtain legacy system job ID data.
[0103] The LAE SDM class redirects the JVM's standard system output and system error calls to the SDM log or another SDM data set. The LAE SDM class also instantiates the Java Security Manager. By default, the JVM Security Manager is permitted. Before releasing control of the JVM after initialization is complete, the LAE SDM class configures the security manager to prevent process calls from pausing or exiting, and can be configured to restrict access to external functions, legacy data sets, and the ability to load other java classes. The security manager prevents loading other classes that can access the LAE (350) except through SDM's own methods.
[0104] The JNI implementation described above differs significantly from the standard TNI because its support for numerous legacy system functions, its methods for converting data formats, and its ability to interact with external memory controlled using protection keys and to respond correctly to legacy system errors in a manner that allows a Java program running in the JVM to react gracefully to such errors are not found in the standard TNI.
[0105] In one embodiment, the TNI includes functions such as writing to the LAE log, initiating a program call to a program executing in the LAE, obtaining or releasing storage, opening or closing a file, setting or clearing an error setting, placing or obtaining strings, bytes or other data to or from a file of an LAE data type, such as converting from partitioned to packed, packet to partitioned, integer to partitioned, integer to packed, packed to integer, packed to partition, ... to name a few of the functions of the TNI. Exemplary functions included in the TNI include:
[0106] private static native void lz_log(int level,String message);
[0107] private static native int lz_wto(String message);
[0108] private static native int lz_mlwto(String[]messages);
[0109] private static native int LLE_pgmcall(String epname,int parm,intflags,int dcb,int lang,int type);
[0110] private static native int LLE_syncall(int epa,int parm,int flags,intdcb,int lang,int type);
[0111] private static native int LLE_storage_obtain(int size,int subpool,intflags);
[0112] private static native int LLE_storage_release(int addr,int size,intsubpool,int flags);
[0113] private static native long lzfopen(String[]args,int lrecl);
[0114] private static native int lzfclose(long file);
[0115] private static native int lzfeof(long file);
[0116] private static native int lzferror(long file);
[0117] private static native void lzclearerr(long file);
[0118] private static native int lzfputs(String str,long file);
[0119] private static native int lzputs(String str);
[0120] private static native String lzfgets(int len,long file);
[0121] private static native String lzgets(int len);
[0122] private static native byte[]lzfread(int len,long file);
[0123] private static native int lzfwrite(byte[]v,int len,long file);
[0124] private static native byte[]convert_zoned_to_packed(int packed_len,byte[]zoned,int zoned_len);
[0125] private static native byte[]convert_packed_to_zoned(int zoned_len,byte[]packed,int packed_len);
[0126] private static native byte[]convert_uint64_to_zoned(int zoned_len,long uint64);
[0127] private static native byte[]convert_int64_to_zoned(int zoned_len,longint64);
[0128] private static native byte[]convert_uint64_to_packed(int packed_len,long uint64);
[0129] private static native byte[]convert_int64_to_packed(int packed_len,long int64);
[0130] private static native long convert_zoned_to_uint64(byte[]zoned,intlen);
[0131] private static native long convert_zoned_to_int64(byte[]zoned,intlen);
[0132] private static native long convert_packed_to_uint64(byte[]packed,intlen);
[0133] private static native long convert_packed_to_int64(byte[]packed,intlen);
[0134] private static native int LAE_storage_obtain(int size,int subpool,intflags);
[0135] private static native int LAE_storage_release(int addr,int size,intsubpool,int flags);
[0136] private static native int LAE_rfetch(int r);
[0137] private static native void LAE_rstore(int r,int v);
[0138] private static native byte LAE_vfetchb(int a);
[0139] private static native void LAE_vstoreb(byte v,int a);
[0140] private static native short LAE_vfetch2(int a);
[0141] private static native void LAE_vstore2(short v,int a);
[0142] private static native int LAE_vfetch4(int a);
[0143] private static native void LAE_vstore4(int v,int a);
[0144] private static native byte[]LAE_vfetchc(int a,int l);
[0145] private static native void LAE_vstorec(byte[]v,int a,int l);
[0146] According to one embodiment, functions that perform input or output, such as lzfopen, lzfclose, various string functions, read, write, get, and store functions, take as arguments, in addition to data arguments, data definition names, string modes, and legacy record formats. The string mode setting indicates whether data is converted from EBCDIC format to ASCII format, ASCII format to EBCDIC format, and whether to convert between little endian and big endian formats, or to retain the data in the format presented by the calling program. Alternatively, a separate function for performing such data format conversions may be implemented separately.
[0147] An embodiment of the JNI of the system according to the present invention may include support for commands such as / TEST MFS, / TES MFS, / TEST MFSNODE LTEM, / FORMAT, / DISPLAY, / START TRAN, / STA PROG, / STA DB, / STOP TRAN, / STOPROG, / STO DB, / DBRECOVERY, / DBR, / RESTART, / END in to enable invocation of IMS operator commands. JNI can make database calls (such as CLSE, DEQ, GU, GHU, GUR, GN, GHN, GNP, GHNP, DLET, REPL, ISRT, FLD, POS), message calls (such as AUTH, GU, GN, ISRT, CHNG, CMD, GCMD, PURG, SETO), and service calls (such as PCB, CHKP, INIT, INQY, ICAL, GMSG, GSCD, ICMD, RCMD, JAVA, LOG, APSB, DPSB, ROLB, ROLL, ROLS, SETS, SETU, SNAP, STAT, SYNC, TERM, and XRST). Similarly, JNI may include CICS command interfaces, including, for example, Abend support, APPC basic and mapped conversation calls, authentication, batch data exchange, BMS messaging, BIF, CICS business transaction services, channel commands, console support, diagnostic services (e.g., DUMP TRANSACTION, ENTER TRACENUM), document services, environmental services (e.g., ADDRESS, ADDRESS SET, ASSIGN), event handling, exception support, file control services, interval control services, logging, monitoring, named counter server commands, program control commands (e.g., INVOKE APPLICATION, LINK, LOAD, RELEASE, RETURN, XCTL), scheduling services, security services, storage control (e.g., GETMAIN, FREEMAIN), SYNCPOINT and SYNCPOINT ROLLBACK, task control services, terminal control, transient data, CICS Web support commands, and other CICS command interfaces. Similarly, JNI may include commands corresponding to VSAM macro instructions, including:
[0148] int LAE_vsam_get(VADR rpladdr,REGS*regs);
[0149] int LAE_vsam_put(VADR rpladdr,REGS*regs);
[0150] int LAE_vsam_point(VADR rpladdr,REGS*regs);
[0151] int LAE_vsam_endreq(VADR rpladdr,REGS*regs);
[0152] int LAE_vsam_erase(VADR rpladdr,REGS*regs);
[0153] int LAE_vsam_idalkadd(VADR rpladdr,REGS*regs);
[0154] If the JVM is running, the thread of the native API executing step (405) attaches itself to the JVM using the AttachCurrentThread() call at step (655). Using the AttachCurrentThread() call, the native thread can attach itself to the virtual machine and obtain a JNI interface pointer. Once attached, the native thread operates like a regular Java thread running in a native method and remains attached until it calls DetachCurrentThread() to detach itself. Once attached, the native API thread receives the classpath, class name, method, signature type, and parameter list at step (657), adds the classpath to the thread stack (660), and loads the class in step (665). Next, at step (670), the binary interface thread calls the method of the SDM class to construct the appropriate signature in the thread stack, inserts the received parameters into the object as needed to enable the Java replacement method to access them as the legacy program would do. Next, at step (675), the binary interface routine calls the method specified in the input parameter list at step (605).
[0155] When the method completes execution, control returns to the native API program, which uses the signature to structure the output in the form required by the calling program.
[0156] This method need not be the main() routine of the class that implements the Java replacement program, because it is called by the LAE routine associated with the thread rather than from outside the JVM. The method operates on the signature constructed in step (670), which contains the parameters passed by the calling program. As discussed above, the calling program can be a load module constructed to run in a legacy platform, a legacy load module that has been adapted to run in LAE (350) but has not yet been compiled or otherwise realized that the called program has been replaced with a Java program. The calling program can also be another Java program running in the JVM. After completing the execution of the method, control returns to the LAE native API, which uses the signature created in step 670 to format the output for return (670).
[0157] A Java program running within the JVM communicates with the LAE (350) by calling methods in the SDM class. These communications may involve memory access controlled by the protection key mechanism described in WO2017 / 103,651, which generates memory exceptions when the wrong storage key is used or other memory access errors occur. Similarly, communications may involve accessing legacy programs, which may generate any of the countless exceptions that may occur due to program loading or execution. The binary JVM interface communicates exceptions that occur in the LAE (350) to the Java program because they can be handled by the Java program as part of its normal operation. After the execution of the Java program is completed, control returns to the LAE thread, which uses the signature to structure the output in the manner required by the calling program. Then, at step (677), the LAE separates the thread from the JVM. In the event that the exception is not caught by the Java program, the JVM's exception handler may throw an exception at step (679), thereby generating an ABEND. The OC4 memory exception is translated into a Java illegal access exception. The OC7 packaged decimal error exception is translated into a Java number format exception. The divide by zero exception is translated into a Java arithmetic exception. General exceptions such as those that would occur if a thread could not be started are translated into illegal state exceptions. After execution of the called method is complete, the binary interface calls a method of the SDM class at step (680) to format the output according to the signature type, including any required ASCII to EBCDIC and endianness conversions, and the SDM calls a private method that implements the JNI to return the output to the calling program in the LAE.
[0158] In the case of CICS applications, the LAE (350) schedules thread-safe and non-thread-safe jobs for execution. This is because, in legacy CICS, all applications run in the same thread and are inherently serialized. When CICS began to allow multi-threaded operation, some programs were written to be thread-safe and others were not. Traditionally, CICS did not allow Java calls to non-thread-safe processes. In the case of non-thread-safe CICS programs, the LAE (350) sets the locks rather than the CICS application to ensure that two non-thread-safe CICS applications do not cause illegal resource contention or deadlock. Because the scheduling of CICS applications is controlled within the LAE (350), a CICS load module or a CICS program within a load module that is not thread-safe can be replaced by a Java program without the risk that the operation of replacing the Java program within the JVM will produce erroneous behavior.
[0159] like Figure 5As shown in , if the replaced load module is not Java, then at step (510), the loader checks whether it has been replaced by a Python script. In the case of a Python script, the loader constructs a load module to execute the ENC instructions corresponding to the execution of the Python script, puts the input parameters into the memory allocated to the Python execution (520), and at step (525) the LAE (350) executes the Python script. Upon completion, and / or in the case of an exception, the LAE issues an appropriate return and / or exception to the caller at step (530). If the replacement program is not a Python script, the loader checks at step (535) whether the load module is replaced by Rexx EXEC, and if so, constructs the load module to execute the corresponding ENC, writes the parameters into the memory allocated to the Rexx execution (545), and executes Rexx EXEC (550). Upon completion, and / or in the case of an exception, the LAE issues an appropriate return and / or exception to the caller at step (555). In the case where the replacement program is not Rexx EXEC, the loader checks at step (560) whether the load module has been replaced by a C-Shell script, and if so, builds the load module to execute the corresponding ENC (565), writes the parameters to the memory allocated for tsch execution (570), and executes the tsch script (575). Upon completion, and / or in the case of an exception, the LAE issues an appropriate return and / or exception to the caller at step (580). The loader can be configured to similarly recognize that the legacy load module has been replaced by another interpreted or JIT-compiled program, and can construct a corresponding load module, configure memory with input parameters, execute the replacement program, and return the results to the calling program. In some embodiments, interpreted instructions of Python, Rexx, C-shell / tsch or other scripts can be inserted into the load module, and the corresponding interpreter points to the script instead of including the script in the native API that implements the ENC instructions.
[0160] Although not shown, load module can be replaced with more than one Python, Rexx, C-Shell or other script. In that case, the system will create a load module comprising a plurality of ENC instructions, and will iteratively insert the process of corresponding parameters in the memory assigned to perform the corresponding script. As in the Java example, the system will or assign the entry point of the acquiescent ENC instruction sequence so as to set up the implicit acquiescence entry point for the replacement program. In certain embodiments, identical ENC instruction can be used to realize a plurality of Python, Rexx or C-shell / tsch scripts, and identifier is provided as an independent variable so that corresponding script is associated with instruction. If the loader has exhausted available options, and does not find the corresponding replacement program for the load module, the loader returns and is abnormal so.
[0161] Computer readable instructions for implementing the LAE (350), binary JVM interface (JVM), legacy hardware environment module (330), native API (340), Java class (380), JVM (370), or other aspects of the invention may be loaded from a hard drive, floppy disk, flash memory, optical disk, tape library, or other non-volatile storage medium, or from a plurality of such storage mediums. The hardware platform (310) or other hardware platform may include an x86, ARM, or other platform, and the host OS (320) may include Linux, Unix, Windows, or other operating systems. The system may be deployed on a single computer, a network of computers, a networked cluster of computers, in a cloud deployment, or in a microservices deployment involving Docker or other container technologies.
[0162] The instructions for executing the inventive systems and methods described herein may be computer assembler instructions, instructions for a particular hardware architecture, machine instructions, microcode, firmware, and source code or object code. The processes described in the figures and flow charts of this patent may be implemented by computer program instructions executed on computer hardware, which may be a general-purpose computer, a special-purpose computer, or other data processing machines suitable for executing such instructions. The boxes or steps depicted in the figures may be implemented by program fragments, functions, or modules. Program modules may include routines, program codes, logic, data structures, objects, components that perform tasks when executed on various platforms.
[0163] The Java classes and objects discussed above may be implemented in other arrangements of classes, and may incorporate subclasses and sub-subclasses to inherit or override features to implement the behaviors described herein. Discussions of Java objects in the JVM are understood to refer to computer program instructions and data, and references to public or private methods of such objects or classes are understood to refer to portions of computer instructions in an object executed in a computer platform, such as a JVM running on a computer platform. Other programming languages and virtual machine environments may be used with the systems and methods of the present invention described herein.
[0164] The components can be installed on different platforms, which can be an exemplary x86 platform, on which the system described herein is installed. Alternatively, within the spirit of the invention described herein, the various parts of the system can be distributed on multiple platforms. When using more than one platform to install and operate the different parts of the inventive system, the different platforms are coupled by a computer network, which can include a wired, optical or wireless local area network, a wide area network, a satellite or other telecommunications network. In operation, the system can be loaded from a non-volatile storage medium (such as a disk, a tape, a hard drive, a flash drive or other non-volatile storage medium) so that part or all of the components of the system reside simultaneously in the volatile memory of one or more computers that make up the system.
[0165] Many examples are provided herein. These examples may be modified without departing from the spirit of the present invention. The examples and embodiments described herein are provided as examples, and other components, routines or modules may also be used.
Claims
1. A computer-implemented method for executing an application on a machine having a target architecture, the application comprising a first load module, the first load module calling a second load module for a source architecture, the source architecture being a mainframe architecture, the method comprising: Loading a first load module by a loader, the first load module including object code for calling a second load module in a legacy application environment LAE, the LAE corresponding to a legacy mainframe environment executed on the target architecture; Detecting, by the loader, that at least one CSECT in the second load module has an associated replacement Java program, wherein the detecting comprises: determining that the second load module has been replaced by examining metadata of the second load module, and performing, by the loader, a table lookup to determine whether an individual CSECT within the second load module has been replaced; The loader inserts the CSECT including the instruction to execute the native command ENC corresponding to the replacement Java program into the memory of the LAE; identifying a signature type indicating the number and structure of input and output parameters of the replacement Java program and inserting a signature type identifier in the memory area for each replacement Java program; Pre-configure the Java virtual machine JVM to execute on the target platform; A native program associated with the ENC instruction is executed from the LAE using a binary JVM interface, wherein the binary JVM interface allows the program of the first loading module to make calls to or respond to calls from Java code running in the JVM, wherein the native program: (a) attaches its thread to the JVM; (b) adds the classpath and method name of the replacement Java program to the memory of the JVM; (c) loads the replacement Java program class corresponding to the replacement Java program using the classpath in the JVM; (d) constructs a signature in the memory of the JVM, the signature including input parameters structured according to the signature type and memory allocation for output parameters appropriate to the signature type; (e) calls a method of the replacement Java program class corresponding to the method name; and (f) detaches itself from the JVM.
2. The method of claim 1, wherein the replacement Java program comprises two or more Java programs, and wherein the loader writes a default entry point into the memory of the LAE.
3. The method of claim 1, wherein the loader inserts the classpath and class name into a memory of the LAE.
4. The method of claim 1 , wherein the native program loads a binary JVM interface class into a heap of the JVM, wherein private methods of the binary JVM interface class implement a native interface to the LAE, and wherein public methods of the binary JVM interface class allow access to resources of the LAE by calling one or more of the private methods.
5. The method of claim 4, wherein the replacement Java program class calls the first loading module using a public method of the interface class, and the interface class calls one or more of its private methods to access the resources of the LAE.
6. The method of claim 4, wherein the replacement Java program class calls a third loading module in the LAE by using a public method of the binary JVM interface class, and the binary JVM interface class calls one or more of its private methods to access resources of the LAE.
7. The method of claim 4, wherein the native program calls a method of an interface class to overwrite one or more memory areas of the JVM.
8. The computer-implemented method of claim 4, wherein the private methods of the binary JVM interface class include functions for: writing to the LAE log, initiating a program call to a program executing in the LAE, obtaining or releasing storage, opening or closing a file, setting or clearing an error setting, placing or getting a string, byte, or other data to or from a file of an LAE data type, conversion from partitioned to packed, packed to partitioned, integer to partitioned, integer to packed, packed to integer, packed to partitioned, ASCII to EBCDIC, EBCDIC to ASCII data formats.
9. The method of claim 4, wherein the preconfiguration further comprises setting a lock on a JVM startup instruction, determining by the native program that the JVM is not executed, initiating a LAE resource manager, and releasing the lock after loading the binary JVM interface class.
10. The method of claim 4, wherein preconfiguring the JVM comprises performing a first attempt at execution, determining that a memory error has occurred, and then performing a second attempt at execution.
11. The method of claim 10, wherein when executed, performing the first attempt comprises using a first memory protection key and when executed, performing the second attempt comprises using a second memory protection key.
12. The method of claim 10, wherein when executed, performing the first attempt comprises using a first address and when executed, performing the second attempt comprises using a second address.
13. The method of claim 10, wherein: After the execution step is completed, an uncaught exception is detected and the execution step is terminated without providing the output of the execution step to the LAE.
14. The method of claim 1, wherein the target architecture is the same architecture as the source architecture.
15. The method of claim 1, wherein the target architecture is different from the source architecture.
16. The method of claim 1, further comprising configuring a security manager to prohibit stop and exit operations and to prohibit loading of classes capable of interfacing with the LAE.
17. The method of claim 16, wherein the step of configuring a security manager is performed by a method of the binary JVM interface class.
18. The method of claim 1, wherein the LAE comprises a binary interface, and wherein, After executing the called method of the replacement Java class to generate output, the binary interface calls the method of the SDM class to format the output according to the signature type and returns the output to the LAE.
19. The method of claim 1, wherein the native program accesses memory controlled by a protection key established by the LAE.
20. A computer-implemented system for executing an application on a machine having a target architecture, the system comprising hardware, an operating system and a LAE, the system being operable to execute a first program compiled for a different hardware, operating system or environment and to perform a method as claimed in any one of claims 1-19.
