© 2015 IBM Corporation
© IBM Corporation 2011
Why are you so different?
Java for COBOL Developers
Tobias Leicher | CICS Client Technical Professional | [email protected]
© 2014 IBM Corporation
IBM
© 2014 IBM Corporation
IBMGoal of this Session
After running around and shouting „Java is just another language running on the mainframe“, it is now time to show you some lies about my fact.
Understand differences and reasons for them
See the advantages of different languages and also understand that there is no single language that rules the world
Get a feeling why problems in Java are different and a Dump in classical sense often leads you nowhere
Give Java another chance, that guy is now grown up and in his twenties, probably the time in life where you have enough experience to solve the important problems in life
© 2014 IBM Corporation
IBMBefore we compare, let us rethink what we know already
Today we will talk about COBOL, PLI or even Assembler (LE) and we will compare it to Java, as I am a CICS Person I will talk more about CICS than IMS or Batch
So how does a COBOL Program executes in zOS (only cover LE here):
» The first thing that happens is a load of the program:○ In CICS the LOADER will issue a BLDL or LLACOPY MACRO against MVS and the Program is
loaded into the storage
» If you then Call the Program a new LE Enclave is----------------○ Wait, what is this LE guy used for again?!
© 2014 IBM Corporation
IBMLE – The standardized Runtime Environment in zOS
Before LE all Languages brought their own Runtime Libraries
A Runtime library brings all the code that is provided by a language and not part of the user Program (Storage management, Math functions...)
A Runtime library has the advantage, that the code is always tied to the underlying hardware, without letting the compiler or the application do too much adaptions
Why now LE?
» When all the languages brought their own runtime, they expected to be alone in the world» Customers had problems to run different languages side by side
Back to our Topic!
© 2014 IBM Corporation
IBMBefore we compare, let us rethink what we know already
Today we will talk about COBOL, PLI or even Assembler (LE) and we will compare it to Java, as I am a CICS Person I will talk more about CICS than IMS or Batch
So how does a COBOL Program execute in zOS (only cover LE here):
» The first thing that happens is a load of the program:○ In CICS the LOADER will issue a BLDL or LLACOPY MACRO against MVS and the Program is
loaded into the storage
» If you then Call the Program a new LE Enclave is initialized○ initial storage is obtained○ condition handlers initialized○ active member language specific run-time is initialized
» Control is given to the application code» Once the application ends and 'returns' to LE
○ The LE environment is terminated○ System resources obtained during initialization and throughout the execution of the application are
cleaned up
© 2014 IBM Corporation
IBMHow does that look like?
= CICS Region
= CICS initial transaction
= Main Transaction Program or EC Linked Program
© 2014 IBM Corporation
IBMSo what does the storage in LE look like?
© 2014 IBM Corporation
IBM
CICS AS
How is a program dispatched then in CICS (abstracted)
zOSDispatcher
WEB
SWUQ
WEB WEB WEB
GlobalSRB
TCB
ASCB
CICS DFHSIP
TCBOTE
TCBOTE
LE Enclave LE Enclave
WEB
TCBQR
CICSDispatcher
LE Enclave LE EnclaveRTRQ
© 2014 IBM Corporation
IBMSo in CICS a Task has one or more LE Enclaves that are totally seperated from each other Task in the address space
What happened with this great concept?!
© 2014 IBM Corporation
IBMOnce upon a time...
© 2014 IBM Corporation
IBMEveryone knew where to put their application, but suddenly things were different...
© 2014 IBM Corporation
IBMSoon the workload starts spreading...
© 2014 IBM Corporation
IBMEveryone was confused...
© 2014 IBM Corporation
IBMAnd the new and shiny PC world was different to the Mainframe!
Less Users
Bad code has far more resources on its own
Coding Style Changed a lot
No LE, not even a unified Operating System (And Yes I know we have VM, VSE, TPF and Linux on the mainframe as well)
Backward Compatibility was not given anymore
...
© 2014 IBM Corporation
IBMHistory of programming languages
1954 1959 1964 1971
SmallTalk
PL/I
COBOL
Fortran
1983
C
C++
LISP
Basic
1989
Perl
1995
OAK Java
JavaScript
© 2014 IBM Corporation17 March 6, 2015
IBMWhat is Java and what makes it different from what we have today
Java is What makes Java differentJava differes in some parts quite a lot from traditional languages like assembler, PL/I or COBOL Java is NOT compiled to executable code, it is
compiled to bytecode, that runs in a virtual machine The virtual machine uses the just-in-time compiler (JIT)
to execute the code Java is not based on programs, it is based on classes Java uses a garbage collector, that removes unused
objects from the storage Java development is often based on exiting
programming patterns (Design Patterns) Most of the build in funtionality of Java is based of
class libraries, that are build in the Java Runtime (JRE) Java contains a library for user interface development Java has the ability to reflect about the runtime with
several methods Java has a type safe variable declaration Uses JNI for native system calls and JDBC for
database calls
Java is an object oriented, platform independent, broadly supported and prevalent an state of the art language [and an Island in Indonesia]
Something YOU should care about
Java is not something new and not reliable an error-prone language the only solution for good code independent on it's own something that the distributed world should care of easy and/or out of the box a composable workbox full of libraries
© 2014 IBM Corporation18 March 6, 2015
IBMJava on Mainframes - what is different and why here?
IBM uses its own implementation of a JVM on mainframes that uses the underlying platform architecture
The Java workload can be offloaded to a zAAP processor
The Java logic can be a bridge between the mainframe and the distributed world
Java is a common language on many platforms that can help to find a dialog between the departments
Java is a language that is well known by many new professionals and so a good common ground, when they start to develop for mainframe applications
The language encourages a good design and loose coupling of components
IBM JDK for z/OS
Standard JSE(JDK specification)
zOS Extensions
Just In Time Compiler (JIT)Exploitation of the Hardware Architecture
z/OS Operating System and System z Hardware
© 2014 IBM Corporation19 March 6, 2015
IBMJava packaging and class hierarchies
Java modularity:
–Classes contain data and logic–Packages contain these classes and organize them
• This is just a virtual form of organization
–Jar files contain the classes and are the base for enterprise applications
Java visibility settings:
–Private, protected, package private, public
At the runtime, there are just a lot of classes on a classpath
jar file
java packages
class files
There are some features missing: jar visibility, versioning, dependencies
© 2014 IBM Corporation20 March 6, 2015
IBMThe Classpath – What was called a load lib concatenation before
Java VM
log4j
barcode4j
axis
batik
commons
derby
fop
ezmorph
freemarker
httpunit
jakarta
jcl
json
jdbm
jdom
jenks
jpos18
jython
looks
lucene
mx4j
naming
jetty
poi
resolver
rome
serializer
servlets
tomcat
velocity
ws-commons
xalan
wsdl4j
xerces
xmlgraphics
xmlrpc
xmlapis
..
geronimo
bsh
bsf
guiapp
hhfacility
manufact.
marketing
minerva
accounting
assetmaint
base
bi
catalina
common
oagis
order
ebay
content
datafile
ecommerce
entity
googlebase
ofbiz
widget
minilang
party
pos.
product
workeffort
workflow
…
sunjce_prov.
plugin
jsse
jce
rt
dnsns
..
…
ClassNot
FoundException
BeginBeginHereHere
© 2014 IBM Corporation
IBMSpecialty CP operation
Eligible work moves to specialty CP under control of z/OS Provide more capacity for eligible workloads without a change in MSU Provides more capacity for non-eligible workloads Reduces software stack charges for non-eligible products on CEC
Eligiblework
Eligiblework
Eligiblework
Eligiblework
Eligiblework
Eligiblework
GCP zIIPGCP
© 2014 IBM Corporation
IBMIBM System z Application Assist Processor (zAAP)Dedicated to execution of Java workloads under z/OS® – e.g. Websphere®, CICS, IMS, DB2®
Available on all IBM zEnterprise systems, System z9 and z10 and zSeries z990 and z890
Used by any workload with Java cycles
Executes java code without any changes to the applications
Also used for XML parsing
Standard CP zAAP
WebSphere
Execute JAVA Code
z/OS Dispatcher
Suspend JVM task on z/OS standard logical processor
WebSphere
Java Application CodeExecuting on a zAAP
logical processorz/OS Dispatcher
JVM Switch to zAAP
JVMJVMSwitch to
z/OS Dispatcher
JVM
Dispatch JVM task on z/OS standard logical processor
JVM
z/OS Dispatcher
logical processor
z/OS Dispatcher
Dispatch JVM task on z/OS zAAP logical processor
JVMSwitch to standard processor
z/OS Dispatcher
Suspend JVM task on z/OS standard logical processor
© 2014 IBM Corporation
IBMSo now let us see what happens in Java
Everything in Java is executed within a virtual machine
Run Time Data Management is done by the virtual machine
The JVM will only stop if the last non-deamon thread finishes
Java is never compiled upfront, it is interpreted and compiled during runtime
» Do you remember HPJ?
Java is platform independent, so everything in Java is abstracted (including Datatypes
© 2014 IBM Corporation
IBMLets dive a bit deeper
Source: http://www.artima.com/insidejvm/ed2/jvmP.html
© 2014 IBM Corporation
IBMHow does a Java LE-Enclave look like
C main procedure (JVM)
LE ThreadNativeStack
LE Heap Storage
Java Heap
Java Stack Classes
JIT Data
© 2014 IBM Corporation
IBMIf we have a look at the LE Config for Java in CICS (DFHAXRO)
The LE Enclave is configured to always obtain new Heap Storage
» Bare in Mind that the JVM Heap Size is managed by the JVM, so a JVM can run out of memory
» initial 64-bit heap of 100MB » initial 31-bit heap of 4MB» Both areas allow incremental expansion to increase
The Files generated by the JVM are controlled by:
» DC C'ENVAR("_EDC_UMASK_DFLT=nnn")'
The output that is produced by the RPTO and RPTS options is written to the CESE transient data queue
© 2014 IBM Corporation
IBM
CICS AS
So how is Java now executed in CICS (abstracted)
zOSDispatcher
WEB
SWUQ
WEB WEB WEB
GlobalSRB
TCB
ASCB
CICS DFHSIP
TCBOTE
TCBOTE
Java LE Enclave
JVM Thread
WEB
TCBQR
CICSDispatcher
LE Enclave LE EnclaveRTRQ
JVM Thread
JVM Thread
pThread
pThread
© 2014 IBM Corporation
IBMWhat happens when a class got loaded
© 2014 IBM Corporation
IBMWhat happens in the different phases
Loading: A class is obtained from a file and loaded to the JVM memory. Verifying: Check whether or not the read class is configured as described in the
Java Language Specification and JVM specifications. This is the most complicated test process of the class load processes, and takes the longest time. Most cases of the JVM TCK test cases are to test whether or not a verification error occurs by loading wrong classes.
Preparing: Prepare a data structure that assigns the memory required by classes and indicates the fields, methods, and interfaces defined in the class.
Resolving: Change all symbolic references in the constant pool of the class to direct references.
Initializing: Initialize the class variables to proper values. Execute the static initializers and initialize the static fields to the configured values.
© 2014 IBM Corporation
IBMSo what happens higher above in the Compiler
The Java Bytecode for the following method:
Compiles to (javap -c):
public int sum(int a, int b) {int result = 0;result = a + b;return result;
}
public int sum(int, int); Code: 0: iconst_0 1: istore_3 2: iload_1 3: iload_2 4: iadd 5: istore_3 6: iload_3 7: ireturn
© 2014 IBM Corporation
IBMSome more details (javap -v):
public int sum(int, int); flags: ACC_PUBLIC Code: stack=2, locals=4, args_size=3 0: iconst_0 1: istore_3 2: iload_1 3: iload_2 4: iadd 5: istore_3 6: iload_3 7: ireturn LineNumberTable: line 12: 0 line 13: 2 line 14: 6 LocalVariableTable: Start Length Slot Name Signature 0 8 0 this Lorg/leicher/java/samples/HelloWorldSum; 0 8 1 a I 0 8 2 b I 2 6 3 result I
© 2014 IBM Corporation
IBMWhat happens now with this bytecode?
The JVM constructs for each Thread an execution engine In this engine the application now needs to be executed
» Problem?○ The JVM interpreting bytecodes can’t match the performance of native applications with machine
code○ Need to improve the performance of JVM startup (interpreting/compiling) and Java applications
over the life of JVM
» Solution!○ A compiler that will allow JVM to start reasonably quickly○ JIT code optimization processes○ Improve overall Java applications performance
The JIT Frontend is common in all IBM JVM Implementations, the Backend is specific to system z
© 2014 IBM Corporation
IBMA Glance at JIT and the Interpreter
Java Application
JVM
JITCompiler
J9Interpreter
© 2014 IBM Corporation
IBMThe Memory Management of the JVM
Heap Method Area Native Area
Young Generation Old Generation
Virt
ual
Fro
m
Sur
vivo
r 0
To
Sur
vivo
r 1
Ede
n
Tenu
red
Virt
ual
Permanent Generation
Runtime Constant Pool
Field & Method Data
Code
Virt
ual
Code Cache
Nat
ive
Com
pile
Threads (1..N)
Virt
ual
PC
Sta
ck NativeStack
-Xmx
Nr
GC
Eve
nts
© 2014 IBM Corporation
IBMSo where are now the data of an Object
Heap
● Object HelloWorld● Object SimpleDateFormat● Object String● Object LOGGER
Method Area
● Class SimpleDateFormat● …
● Class Logger● …
● Class HelloWorld● Method: sayHello()● ...
Native Area
● Parameter reference:“message” to Stringobject
● Variable references● “formatter”● “today”
© 2014 IBM Corporation37
IBMCompare Cobol to Java
Develop a COBOL program
Cobol does not know complex DataTypes or Objects Data Elements are usually shared, not hidden The compile is usually done after coding (no online
syntax checking) Compiler perform less static tests Debugging is done in Multiuser Environments
Runtime Behaviour of Cobol
LE does not check wether the loaded program is corrupt
The runtime can not check whether the data is assigned correctly and Problems can arise
Handlers get control if something went wrong Memory is defined upfront
Develop a Java program
Data is structured in complex Objects Variables are not shared, they are adressed by
methods of the object Compiles are executed everytime a class is saved
(while ongoing syntax check is performed) Compiler performs a lot of static testing Debugging is usually done locally Memory can NEVER be addressed directly
Runtime Behaviour of Java
The JVM checks the bytecode after loading the class Classes are checked during compilation and in
Runtime data is only assigned if types match Classes and methods can throw exceptions (also JNI)
if a problem occurs New Objects can be generated very dynamical
© 2014 IBM Corporation38
IBMUpdate Behavior – “Java, why can't I just phase you in?”
Update a COBOL Program in CICS
COBOL Program is compiled/linked into a PDSe that is concatinated into the RPL upfront the existing Load Library or replace the existing version
In CICS issue a NEWCOPY or PHASEIN to let CICS reload the Program from the Dataset
Use the new Program
Update a Java Program in CICS
In Java you can't replace runtime code (except via JDWP)
Frameworks like OSGi enables the exchange of bundles
You need to decouple the application desing (using micro Services in OSGi or accept a small outage
Problems with this Approach
Compatibility is a contract that is not checked until runtime
The connection is something the compiler is not aware of
Problems with this Approach
The simple Phasein/Newcopy is not possible A complex Build infrastructure is necessary Only bundles/services, not classes can be “phased in” A change in Application Development Architecture is
necessary
© 2014 IBM Corporation39
IBMQuestions
Tobias Leicher
Client Technical Professional & zChampion
– CICS & CICS Tools
IBM Allee 1D-71139 Ehningen
Mobil: 0151 – 15 16 24 89Mail: [email protected]
Foto
VIELEN DANK FÜR IHRE AUFMERKSAMKEIT.
What’s next…
More of my sessions
#ASZ-3983: CICS Java Real-Life Projects, Featuring Datev
#ASZ-3978: Why Is Java So Different?: A Session for Cobol/PLI/Assembler Developers
#ASZ-5927: Meet the Experts of Generation z—Driving Innovation on the Mainframe
More Cloud sessions
#ASZ-2829: Liberté, Égalité, Fraternité—Viva the CICS and WebSphere Mini Revolution
#ASZ-6481: Java and CICS—A Perfect Match
#ASZ-1841: WebSphere Liberty Profile Support for Java Batch and the JSR-352 Specification, Featuring Sicoob
Collect a z Passport sticker here, and at…
@IBM_CICS slideshare.net/IBM_CICSfacebook.com/IBMCICS ibm.com/cics
WIN!
Get a lightning start: Key InterConnect 2015 sessions
#2829 Mon 2:00-3:00 Liberté, Égalité, Fraternité—Viva the CICS and WebSphere Mini Revolution
#1670 Tue 3:30-4:30 IBM WebSphere Liberty z/OS Connect: A Technical Introduction
#4032 Wed 9:30-10:30 Meet the Winners of IBM’s Mainframe Mobile App Throwdown 2014
#6482 Thu 11:00-11:50 What is the Mainframe Mobile App Throwdown and How Do I Register?
Register now at
ibm.biz/mmathrowdownand submit your app by April 12th
Mobilize your mainframe in our fun app-building contest forz Systems clients & business partners!
The Mainframe Mobile App Throwdownis back for 2015!
Need expert help?
42
CICS Development Services, for worldwide services assistance CICS Development Services, for worldwide services assistance
Bringing CICS deve lopment expertise directly to your doors tep
Email us [email protected]
Bringing CICS deve lopment expertise directly to your doors tep
Email us [email protected]
Get a deep dive into your sys tems with a CICS hea lth checkGet a deep dive into your sys tems with a CICS hea lth check
Want to know more about CICS and Java? We offe r ta ilored Java educa tionWant to know more about CICS and Java? We offe r ta ilored Java educa tion
Move forward with mobile with our cus tomized mobile workshop Move forward with mobile with our cus tomized mobile workshop
Soar into the cloud with ourta ilored cloud workshopSoar into the cloud with ourta ilored cloud workshop
Need to optimize your sys tems? Then ask about a pe rformance optimiza tion engagement
Need to optimize your sys tems? Then ask about a pe rformance optimiza tion engagement
Get the low down on pe rformance with a CICS performance workshopsGet the low down on pe rformance with a CICS performance workshops
Need to modernise your workload in CICS? Ask about a integra tion and connectivity engagement
Need to modernise your workload in CICS? Ask about a integra tion and connectivity engagement
Need some he lp upgrading to the la tes t re lea se? Then ask about our upgrade workshop
Need some he lp upgrading to the la tes t re lea se? Then ask about our upgrade workshop
Need to reduce cos t by optimizing your sys tems? Then a pe rformance optimiza tion engagement may be for you
Need to reduce cos t by optimizing your sys tems? Then a pe rformance optimiza tion engagement may be for you
Need some thing diffe rent? Then we can build a customized workshop, jus t for you!
Need some thing diffe rent? Then we can build a customized workshop, jus t for you!
Availability a concern? Then try our High Ava ilability workshopAvailability a concern? Then try our High Ava ilability workshop
Vis it ibm.com/cics then click ‘Services’
Thank YouYour Feedback is
Important!
Access the InterConnect 2015 Conference CONNECT Attendee Portal to complete
your session surveys from your smartphone,
laptop or conference kiosk.
Notices and DisclaimersCopyright © 2015 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM.
U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM.
Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS document is distributed "AS IS" without any warranty, either express or implied. In no event shall IBM be liable for any damage arising from the use of this information, including but not limited to, loss of data, business interruption, loss of profit or loss of opportunity. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided.
Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice.
Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary.
References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business.
Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation.
It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law.
Notices and Disclaimers (con’t)
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM expressly disclaims all warranties, expressed or implied, including but not limited to, the implied warranties of merchantability and fitness for a particular purpose.
The provision of the information contained herein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right.
• IBM, the IBM logo, ibm.com, Bluemix, Blueworks Live, CICS, Clearcase, DOORS®, Enterprise Document Management System™, Global Business Services ®, Global Technology Services ®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, SoDA, SPSS, StoredIQ, Tivoli®, Trusteer®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
Top Related