SlideShare a Scribd company logo
1 of 35
Download to read offline
JVM Bytecodes
~ Anvay Patil
We spend 90% of our time in developing/maintaining
10% of code.
From the book:
Screenshot from Chapter 5
JVM=J+VM
Let’s get little curious here
What is VM?
A Virtual Machine is a high level abstraction on top of native operating system
that emulates a physical machine.
Two types of Virtual Machines:
1. Process Virtual Machine.
2. System Virtual Machine.
JVM -> Process Virtual Machine
A Process Virtual machine enables the same platform/environment for execution on
multiple operating systems and different hardware architectures.
They could be of two type:
1. Stack Based Process Virtual machine (HotSpot Virtual machine/ Primary JVM)
2. Register Based Process Virtual machine (Android’s Dalvik Virtual machine)
Stack Based
vs
Register based
Virtual Machine
Types
Now few questions?
1. Stack based vs register based Virtual machine, does it affect bytecodes which is
generated by Java Compiler ?
2. What makes Java achieve platform independency ?
3. Is platform independency, for only Java language or it is true for other JVM languages
too ?
Bytecodes
So what is the Magic behind the bytecodes?
What exactly are bytecodes?
Why should i be aware about it?
Bytecode?
JVM
➔ one byte instruction set
➔ 256 possible opcodes (unsigned bytecode)
➔ 200 in use on current
Instruction sets designed for efficient
execution by software interpreter which can
do suitable further compilation into
machine code may be at runtime.
Microsoft CLR
➔ 2 bytes instruction sets
➔ Stack based VM
Why know JVM Bytecodes?
1. Can give deep understanding about the
platform
2. Can read the byte code
3. Can modify the bytecode
4. Can build own language?
5. Use libraries which can generate bytecodes.
Java -VM
Android’s
Dalvik -VM
Jython VM
CPython
x=7,y=8
print x+y
Jython
Compiler
CPython
Compiler
Cpython
Interpreter
Jython
Interpreter15
CPython VM Java VM
CPython Bytecode Java Bytecode
Python source code
JVM Languages: < OMG :-O >
Jython
Mirah
JRuby
MicroFocus Visual COBOL
JScheme
Javascal/Pascal4J
Javascal
JTclJawk
JLua
Erjang
Jaskell
JPerl
JPerl Groovy
Clojure
Xtend Ceylon Kotlin
More than 800 implementations of JVM and more than 250 JVM languages
Scala
Fhatom
Gosu
Processing
Drools
Frink Open-XION
Redline SmallTalk
Ioke Nashorn JS
JudoScript
LolCode
NestVM JPC
PizzaNoop
jvm.go
JVM=Polyglot-VM
Simple Program
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}
> javac HelloWorld.java
> javap -c HelloWorld.class
> javap -verbose HelloWorld.class
javap
● Java Class File disassembler
● Basic operations and class structure
○ javap HelloWorld.class
● -c flag include bytecodes
○ javap -c HelloWorld.class
● -public -private -protected option
○ javap -private HelloWorld.class
○ javap -public HelloWorld.class
○ javap -protected HelloWorld.class
● -verbose for stack size, locals, args etc.
○ javap -verbose HelloWorld.class
Instruction set:
● Stack instruction, since stack based machine
● Basic operations
● Flow control
● Class structures
● Exception Handling
Stack Manipulation:
Typed Opcodes:
b byte
s short
c char
i int
l long
f float
d double
a reference
<type> <operation>
Constant Values
Local vars (load, store)
Array Operations (aload, astore)
Math ops (add, sub, mul, div)
Boolean bitwise
Comparisons
Conversions
Type
Operations
There is no instruction for boolean, and can play with 0 or 1
Constant Values:
Local variables:
Arrays:
Math Operations:
Boolean and Bitwise Operations:
Conversions:
Compare operations:
Flow Control:
More Flow Control:
Instructions for Classes
Instructions for Classes
Let’s execute HelloWorld
stack=2, locals=1, args_size=1
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3 // String Hello Java User Group
5: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: return
Q & A :)
References
● Java Virtual Machine Specification
● Inside JVM
● JVM Programming Languages
Thank you :)

More Related Content

What's hot

Why JVM will outlive java?
Why JVM will outlive java?Why JVM will outlive java?
Why JVM will outlive java?Ram Lakshmanan
 
Java interview questions
Java interview questionsJava interview questions
Java interview questionsJava2Blog
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaLevent YILDIZ
 
Migration Spring PetClinic to Quarkus
Migration Spring PetClinic to QuarkusMigration Spring PetClinic to Quarkus
Migration Spring PetClinic to QuarkusJonathan Vila
 
Scalable Real Time Chat (Text, Audio, Video) - Implemented using XMPP
Scalable Real Time Chat (Text, Audio, Video) - Implemented using XMPPScalable Real Time Chat (Text, Audio, Video) - Implemented using XMPP
Scalable Real Time Chat (Text, Audio, Video) - Implemented using XMPPUdaya Kiran
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOULucas Jellema
 
JVM ecosystem languages and the future of JVM
JVM ecosystem languages and the future of JVMJVM ecosystem languages and the future of JVM
JVM ecosystem languages and the future of JVMMizanur Rahman Khan
 
Jvm ecosystem languages and the future of jvm
Jvm ecosystem languages  and  the future of jvmJvm ecosystem languages  and  the future of jvm
Jvm ecosystem languages and the future of jvmJUGBD
 
JVM Ecosystem Languages And The Future of JVM
JVM Ecosystem Languages And The Future of JVMJVM Ecosystem Languages And The Future of JVM
JVM Ecosystem Languages And The Future of JVMSazzadur Rahaman
 
How to meets Async and Task
How to meets Async and TaskHow to meets Async and Task
How to meets Async and TaskKouji Matsui
 
Testing your app with Selenium on Travis CI
Testing your app with Selenium on Travis CITesting your app with Selenium on Travis CI
Testing your app with Selenium on Travis CIYusuke Ando
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovydeimos
 

What's hot (20)

Forseti driven javascript
Forseti driven javascriptForseti driven javascript
Forseti driven javascript
 
Why JVM will outlive java?
Why JVM will outlive java?Why JVM will outlive java?
Why JVM will outlive java?
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Linkedin Search_GK
Linkedin Search_GKLinkedin Search_GK
Linkedin Search_GK
 
Jvm
JvmJvm
Jvm
 
Class 3
Class 3Class 3
Class 3
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
2. hello java
2. hello java2. hello java
2. hello java
 
Migration Spring PetClinic to Quarkus
Migration Spring PetClinic to QuarkusMigration Spring PetClinic to Quarkus
Migration Spring PetClinic to Quarkus
 
Scalable Real Time Chat (Text, Audio, Video) - Implemented using XMPP
Scalable Real Time Chat (Text, Audio, Video) - Implemented using XMPPScalable Real Time Chat (Text, Audio, Video) - Implemented using XMPP
Scalable Real Time Chat (Text, Audio, Video) - Implemented using XMPP
 
Pryjs
PryjsPryjs
Pryjs
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
JVM
JVMJVM
JVM
 
JVM ecosystem languages and the future of JVM
JVM ecosystem languages and the future of JVMJVM ecosystem languages and the future of JVM
JVM ecosystem languages and the future of JVM
 
Jvm ecosystem languages and the future of jvm
Jvm ecosystem languages  and  the future of jvmJvm ecosystem languages  and  the future of jvm
Jvm ecosystem languages and the future of jvm
 
JVM Ecosystem Languages And The Future of JVM
JVM Ecosystem Languages And The Future of JVMJVM Ecosystem Languages And The Future of JVM
JVM Ecosystem Languages And The Future of JVM
 
How to meets Async and Task
How to meets Async and TaskHow to meets Async and Task
How to meets Async and Task
 
intoduction to java
intoduction to javaintoduction to java
intoduction to java
 
Testing your app with Selenium on Travis CI
Testing your app with Selenium on Travis CITesting your app with Selenium on Travis CI
Testing your app with Selenium on Travis CI
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
 

Similar to JVM Bytecodes

Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkMohit Belwal
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01Jay Palit
 
Java byte code presentation
Java byte code presentationJava byte code presentation
Java byte code presentationMahnoor Hashmi
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)mafffffe19
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderijaprr_editor
 
Simple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmSimple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmJamie Coleman
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machineNikhil Sharma
 
Simple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVMSimple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVMJamie Coleman
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...Mark West
 
javalightspeed-jakartatech-2023.pdf
javalightspeed-jakartatech-2023.pdfjavalightspeed-jakartatech-2023.pdf
javalightspeed-jakartatech-2023.pdfRichHagarty
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorialjackschitze
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaAmazon Web Services
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting StartedRakesh Madugula
 

Similar to JVM Bytecodes (20)

Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 
JVM.pptx
JVM.pptxJVM.pptx
JVM.pptx
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
 
Java byte code presentation
Java byte code presentationJava byte code presentation
Java byte code presentation
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Simple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmSimple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvm
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Simple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVMSimple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVM
 
What is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK TechnologiesWhat is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK Technologies
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Java Starting
Java StartingJava Starting
Java Starting
 
Why Java
Why JavaWhy Java
Why Java
 
javalightspeed-jakartatech-2023.pdf
javalightspeed-jakartatech-2023.pdfjavalightspeed-jakartatech-2023.pdf
javalightspeed-jakartatech-2023.pdf
 
Introduction to java programming tutorial
Introduction to java programming   tutorialIntroduction to java programming   tutorial
Introduction to java programming tutorial
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 

JVM Bytecodes

  • 2. We spend 90% of our time in developing/maintaining 10% of code.
  • 3. From the book: Screenshot from Chapter 5
  • 5. What is VM? A Virtual Machine is a high level abstraction on top of native operating system that emulates a physical machine. Two types of Virtual Machines: 1. Process Virtual Machine. 2. System Virtual Machine.
  • 6. JVM -> Process Virtual Machine A Process Virtual machine enables the same platform/environment for execution on multiple operating systems and different hardware architectures. They could be of two type: 1. Stack Based Process Virtual machine (HotSpot Virtual machine/ Primary JVM) 2. Register Based Process Virtual machine (Android’s Dalvik Virtual machine)
  • 8. Now few questions? 1. Stack based vs register based Virtual machine, does it affect bytecodes which is generated by Java Compiler ? 2. What makes Java achieve platform independency ? 3. Is platform independency, for only Java language or it is true for other JVM languages too ?
  • 9. Bytecodes So what is the Magic behind the bytecodes? What exactly are bytecodes? Why should i be aware about it?
  • 10. Bytecode? JVM ➔ one byte instruction set ➔ 256 possible opcodes (unsigned bytecode) ➔ 200 in use on current Instruction sets designed for efficient execution by software interpreter which can do suitable further compilation into machine code may be at runtime. Microsoft CLR ➔ 2 bytes instruction sets ➔ Stack based VM
  • 11. Why know JVM Bytecodes? 1. Can give deep understanding about the platform 2. Can read the byte code 3. Can modify the bytecode 4. Can build own language? 5. Use libraries which can generate bytecodes.
  • 14. JVM Languages: < OMG :-O > Jython Mirah JRuby MicroFocus Visual COBOL JScheme Javascal/Pascal4J Javascal JTclJawk JLua Erjang Jaskell JPerl JPerl Groovy Clojure Xtend Ceylon Kotlin More than 800 implementations of JVM and more than 250 JVM languages Scala Fhatom Gosu Processing Drools Frink Open-XION Redline SmallTalk Ioke Nashorn JS JudoScript LolCode NestVM JPC PizzaNoop jvm.go
  • 16. Simple Program public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world"); } } > javac HelloWorld.java > javap -c HelloWorld.class > javap -verbose HelloWorld.class
  • 17. javap ● Java Class File disassembler ● Basic operations and class structure ○ javap HelloWorld.class ● -c flag include bytecodes ○ javap -c HelloWorld.class ● -public -private -protected option ○ javap -private HelloWorld.class ○ javap -public HelloWorld.class ○ javap -protected HelloWorld.class ● -verbose for stack size, locals, args etc. ○ javap -verbose HelloWorld.class
  • 18. Instruction set: ● Stack instruction, since stack based machine ● Basic operations ● Flow control ● Class structures ● Exception Handling
  • 20. Typed Opcodes: b byte s short c char i int l long f float d double a reference <type> <operation> Constant Values Local vars (load, store) Array Operations (aload, astore) Math ops (add, sub, mul, div) Boolean bitwise Comparisons Conversions Type Operations There is no instruction for boolean, and can play with 0 or 1
  • 25. Boolean and Bitwise Operations:
  • 32. Let’s execute HelloWorld stack=2, locals=1, args_size=1 0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #3 // String Hello Java User Group 5: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V 8: return
  • 33. Q & A :)
  • 34. References ● Java Virtual Machine Specification ● Inside JVM ● JVM Programming Languages