The document discusses Java bytecode and provides examples of decompiling a simple "Hello World" Java program to bytecode using the javap tool. It summarizes the structure of bytecode, including one-byte instructions, opcode taxonomy involving stack manipulation, flow control, and object models. The document demonstrates how javap can be used to disassemble a class file into bytecode instructions and interpret the constant pool references.
GeeCON 2017 - TestContainers. Integration testing without the hassleAnton Arhipov
TestContainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
JEEConf 2017 - The hitchhiker’s guide to Java class reloadingAnton Arhipov
In Java, a typical workflow involves restarting the application (almost) with every class change. For some applications it is not a problem at all, for some – it is a disaster.
From HotSwap to agent-based reloading. In this session, we are going to take a look at the options available for Java class reloading. There is plenty of tools that you can use for this task: rely on standard JVM HotSwap, redesign your application to rely on dynamic class loaders, to comprehend the Zen of OSGi, or to integrate a reloading agent. Every option has its own drawbacks and benefits and we’re going to take a deep dive on the subject.
Finally, there are also the conceptual challenges in reloading Java classes. What to do with the state? What should happen with the static initialisers? What if super class changes? Join this session to gain a better understanding of class reloading technologies and become more productive Java developer.
JEEConf 2017 - Having fun with JavassistAnton Arhipov
Javassist makes Java bytecode manipulation simple. At ZeroTurnaround we use Javassist a lot to implement the integrations for our tools.
In this talk we will go through the examples of how Javassist can be applied to alter the applications behavior and do all kind of fun stuff with it.
Why is it interesting? Because while trying to do unusual things in Java, you learn much more about the language and the platform itself and learning about Javassist will actually make you a better Java developer!
An overview how to realize code generation of languages on the JVM that implement other class layouts than the Java programming languages. As an example, the inline-mock-maker for Mockito is discussed which supports languages like Kotlin that make any property final by default.
Java agents are pluggable self contained components that run embedded in a JVM and intercept the classloading process. They were introduced in Java 5 along with the powerful java.lang.instrument package. Java agents can be loaded statically at startup or dynamically (programmatically) at runtime to attach to a running process.
Java agents were an awesome addition to the JVM as it opened a lot of opportunities for tool designers and changed Java tooling landscape quite drastically. In conjunction with Java bytecode manipulation libraries it is now possible to do amazing things to Java classes: we can experiment with programming models, redefine classes at runtime, record execution flow, etc.
I’d like to give an overview of Java agents’ functionality along with the usage examples and real world experiences. You will learn, how to implement an agent and apply Instrumentation API in combination with bytecode manipulation libraries to solve interesting tasks.
GeeCON 2017 - TestContainers. Integration testing without the hassleAnton Arhipov
TestContainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
JEEConf 2017 - The hitchhiker’s guide to Java class reloadingAnton Arhipov
In Java, a typical workflow involves restarting the application (almost) with every class change. For some applications it is not a problem at all, for some – it is a disaster.
From HotSwap to agent-based reloading. In this session, we are going to take a look at the options available for Java class reloading. There is plenty of tools that you can use for this task: rely on standard JVM HotSwap, redesign your application to rely on dynamic class loaders, to comprehend the Zen of OSGi, or to integrate a reloading agent. Every option has its own drawbacks and benefits and we’re going to take a deep dive on the subject.
Finally, there are also the conceptual challenges in reloading Java classes. What to do with the state? What should happen with the static initialisers? What if super class changes? Join this session to gain a better understanding of class reloading technologies and become more productive Java developer.
JEEConf 2017 - Having fun with JavassistAnton Arhipov
Javassist makes Java bytecode manipulation simple. At ZeroTurnaround we use Javassist a lot to implement the integrations for our tools.
In this talk we will go through the examples of how Javassist can be applied to alter the applications behavior and do all kind of fun stuff with it.
Why is it interesting? Because while trying to do unusual things in Java, you learn much more about the language and the platform itself and learning about Javassist will actually make you a better Java developer!
An overview how to realize code generation of languages on the JVM that implement other class layouts than the Java programming languages. As an example, the inline-mock-maker for Mockito is discussed which supports languages like Kotlin that make any property final by default.
Java agents are pluggable self contained components that run embedded in a JVM and intercept the classloading process. They were introduced in Java 5 along with the powerful java.lang.instrument package. Java agents can be loaded statically at startup or dynamically (programmatically) at runtime to attach to a running process.
Java agents were an awesome addition to the JVM as it opened a lot of opportunities for tool designers and changed Java tooling landscape quite drastically. In conjunction with Java bytecode manipulation libraries it is now possible to do amazing things to Java classes: we can experiment with programming models, redefine classes at runtime, record execution flow, etc.
I’d like to give an overview of Java agents’ functionality along with the usage examples and real world experiences. You will learn, how to implement an agent and apply Instrumentation API in combination with bytecode manipulation libraries to solve interesting tasks.
Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer. Java bytecode is the form of instructions that Java virtual machine executes. This knowledge is crucial when debugging and doing performance and memory usage tuning. The presenter will share his knowledge on what bytecode means for your platform and how to create compiler while using some awesome tools.
Let us explore Java 8 features and start using it in your day to day work. You will be surprised how Java has evolved to become so different yet easy & powerful. In this presentation, we discuss Java 8 Stream API.
어느덧 스무살이 된 자바. 좋든싫든 프로그래밍의 세계에 몸담고 있는 이상 부딪히지 않을 수 없는 언어인데요, 이 자바에 대한 올바른 모습의 이해화 앞으로 나아가야 할 방향을 모색해본다는 의미에서 "모던 자바의 역습"이라는 타이틀로 실시한 온라인 세미나의 슬라이드 자료입니다.
진행자: 김대우(http://lekdw.blogspot.kr/)
정도현(http://moreagile.net)
이번 세미나는 게임개발자이신 김대우님을 모시고 진행하게 되었는데요 자바 언어와 관련 하여 다음과 같은 주제로 두시간에 걸쳐 발표를 진행합니다.
- 간단히 살펴보는 자바20년의 발자취
- 자바를 둘러싼 진실 혹은 거짓(성능,생산성,품질)
- SI영역 이외에서 자바의 가치
- 모던자바의 역습: 자바8과 함수형 프로그래밍
- 자바 개발의 새로운 패러다임들
This is the support of a course to teach mainly Redux, and Redux with React for Java and C# programmers. It is the third part of the course to recycle programmers from desktop app programming to web app programming. This course covers from history of Redux, its origin, step by step what is a reducer, and later concepts like reducer splitting, action handling, async and many more.
You also can use repositories:
- https://github.com/drpicox/learn-redux-bytesting
- https://github.com/drpicox/learn-redux-zoo-bytesting
To improve your skills.
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
Are you bound to flaky, slow Robolectric Tests? Do you want to know a way out of it? This session shows ideas and concepts to replace Robolectric from your test code base
The Kotlin 101 presentation was the very first presentation of the Kotlin Usergroup Vienna (https://www.meetup.com/Kotlin-Vienna/), held at a meeting from the Java Student Usergroup in 2016 (https://www.meetup.com/Java-Vienna/). It explains the raw (syntactical) fundamentals of the language targeting a Java developer audience.
No dark magic - Byte code engineering in the real worldtcurdt
ften byte code engineering is perceived as "black magic" and considered too low level. This session will not bore you with all the details of the JVM specification but provide you with a practical overview of how this byte code "swizzling" can be used in the real world instead. Several projects have sucessfully leveraged this technique to achieve some amazing things (e.g. AOP). This session will go through some of these examples and try to outline the differences between the two major libraries (BCEL and ASM). Maybe your next project can then benefit from some of this "magic".
Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ programmer. Java bytecode is the form of instructions that Java virtual machine executes. This knowledge is crucial when debugging and doing performance and memory usage tuning. The presenter will share his knowledge on what bytecode means for your platform and how to create compiler while using some awesome tools.
Let us explore Java 8 features and start using it in your day to day work. You will be surprised how Java has evolved to become so different yet easy & powerful. In this presentation, we discuss Java 8 Stream API.
어느덧 스무살이 된 자바. 좋든싫든 프로그래밍의 세계에 몸담고 있는 이상 부딪히지 않을 수 없는 언어인데요, 이 자바에 대한 올바른 모습의 이해화 앞으로 나아가야 할 방향을 모색해본다는 의미에서 "모던 자바의 역습"이라는 타이틀로 실시한 온라인 세미나의 슬라이드 자료입니다.
진행자: 김대우(http://lekdw.blogspot.kr/)
정도현(http://moreagile.net)
이번 세미나는 게임개발자이신 김대우님을 모시고 진행하게 되었는데요 자바 언어와 관련 하여 다음과 같은 주제로 두시간에 걸쳐 발표를 진행합니다.
- 간단히 살펴보는 자바20년의 발자취
- 자바를 둘러싼 진실 혹은 거짓(성능,생산성,품질)
- SI영역 이외에서 자바의 가치
- 모던자바의 역습: 자바8과 함수형 프로그래밍
- 자바 개발의 새로운 패러다임들
This is the support of a course to teach mainly Redux, and Redux with React for Java and C# programmers. It is the third part of the course to recycle programmers from desktop app programming to web app programming. This course covers from history of Redux, its origin, step by step what is a reducer, and later concepts like reducer splitting, action handling, async and many more.
You also can use repositories:
- https://github.com/drpicox/learn-redux-bytesting
- https://github.com/drpicox/learn-redux-zoo-bytesting
To improve your skills.
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
Are you bound to flaky, slow Robolectric Tests? Do you want to know a way out of it? This session shows ideas and concepts to replace Robolectric from your test code base
The Kotlin 101 presentation was the very first presentation of the Kotlin Usergroup Vienna (https://www.meetup.com/Kotlin-Vienna/), held at a meeting from the Java Student Usergroup in 2016 (https://www.meetup.com/Java-Vienna/). It explains the raw (syntactical) fundamentals of the language targeting a Java developer audience.
No dark magic - Byte code engineering in the real worldtcurdt
ften byte code engineering is perceived as "black magic" and considered too low level. This session will not bore you with all the details of the JVM specification but provide you with a practical overview of how this byte code "swizzling" can be used in the real world instead. Several projects have sucessfully leveraged this technique to achieve some amazing things (e.g. AOP). This session will go through some of these examples and try to outline the differences between the two major libraries (BCEL and ASM). Maybe your next project can then benefit from some of this "magic".
This presentation is on advanced debugging using Java bytecodes (presented in Core Java meetup on 1st October in Accion Labs). If you are a Java developer and are interested in knowing advanced debugging techniques or understanding bytecodes, this presentation is for you.
Fast as C: How to Write Really Terrible JavaCharles Nutter
For years we’ve been told that the JVM’s amazing optimizers can take your running code and make it “fast” or “as fast as C++” or “as fast as C”…or sometimes “faster than C”. And yet we don’t often see this happen in practice, due in large part to (good and bad) development patterns that have taken hold in the Java world.
In this talk, we’ll explore the main reasons why Java code rarely runs as fast as C or C++ and how you can write really bad Java code that the JVM will do a better job of optimizing. We’ll take some popular microbenchmarks and burn them to the ground, monitoring JIT logs and assembly dumps along the way.
Why is Java relevant? New features of Java8 xshyamx
Presentation slides from ISDC2013 held on 16-mar-2013
http://www.siliconindia.com/events-overview/India--Software-Developer-Conference-Bangalore-ISDC_2013Blr.html
How to implement a simple dalvik virtual machineChun-Yu Wang
This slide is an introduction to Android Dalvik Virtual Machine on a short course.
We use two hand-made JVM and DVM which called Simple JVM and Simple DVM respectively, to tell student how they work. A Foo Class was provided as a target for verifying the execution results of those VM. We hope it will help student to understand JVM and DVM quickly.
This slide aims to describe the basic introduction about Java with the Eclipse platform. Many examples were applied in order to understand the main features of programing by using Java.
This slide aims to describe the basic introduction about Java with the Eclipse platform. Many examples were applied in order to understand the main features of programing by using Java
TeamCity is a great tool for Continuous Integration with a lot of advanced features provided out-of-the-box. In this session, we will go through how TeamCity helps the software development with the daily routine; what was added to the product in the latest releases; and what features are coming next.
You will learn why build pipelines are useful, and how the CI server can be optimized when properly configured. I will also demonstrate how to configure the builds using the special Kotlin DSL provided with TeamCity.
Devoxx Ukraine 2018 - Kotlin DSL in under an hourAnton Arhipov
Kotlin DSLLearn how to create type-safe and statically typed DSLs in Kotlin. Uncover the language features that make DSL creation possible. We’ll take a look at a few practical examples and create a simple DSL ourselves.
TestContainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
JavaOne 2017 - The hitchhiker’s guide to Java class reloadingAnton Arhipov
In Java, a typical workflow involves restarting the application with (almost) every class change. For some applications, it is not a problem at all; for others, it is a disaster, from HotSwap to agent-based reloading. This session takes a look at the options available for Java class reloading. There are plenty of tools you can use for this task: rely on standard JVM HotSwap, redesign your application to rely on dynamic class loaders, comprehend the Zen of OSGi, or integrate a reloading agent. Every option has its own drawbacks and benefits, and the presentation takes a deep dive into the subject. Come get a better understanding of class reloading technologies and become a more productive Java developer.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
31. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
}
32. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
}
33. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
34. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code: the default constructor
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
35. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code: push this to stack
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
36. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
invoke <init> on this
37. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
38. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3; //String Hello, World!
5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
39. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
get static field
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3; //String Hello, World!
5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
40. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3; //String Hello, World!
5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
load string to the stack
41. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3; //String Hello, World!
5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
invoke method with parameter
42. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3; //String Hello, World!
5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
43. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c
What’s #1,#2, etc ?
} Compiled from "Hello.java"
public class Hello extends java.lang.Object{
public Hello();
Code:
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3; //String Hello, World!
5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
44. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
}
45. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
}
46. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
} Compiled from "Hello.java“
public class Hello extends java.lang.Object
SourceFile: "Hello.java"
minor version: 0
major version: 50
Constant pool:
const #1 = Method #6.#20; // java/lang/Object."<init>":()V
const #2 = Field #21.#22; // java/lang/System.out:Ljava/io/PrintStream;
const #3 = String #23; // Hello, World!
const #4 = Method #24.#25; // java/io/PrintStream.println:(Ljava/lang/String;)V
const #5 = class #26; // Hello
const #6 = class #27; // java/lang/Object
const #7 = Asciz <init>;
const #8 = Asciz ()V;
47. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
} Compiled from "Hello.java“
public class Hello extends java.lang.Object
SourceFile: "Hello.java"
minor version: 0
major version: 50
Constant pool:
const #1 = Method #6.#20; // java/lang/Object."<init>":()V
const #2 = Field #21.#22; // java/lang/System.out:Ljava/io/PrintStream;
const #3 = String #23; // Hello, World!
const #4 = Method #24.#25; // java/io/PrintStream.println:(Ljava/lang/String;)V
const #5 = class #26; // Hello
const #6 = class #27; // java/lang/Object
const #7 = Asciz <init>;
const #8 = Asciz ()V;
48. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
} …
public Hello();
Code:
Stack=1, Locals=1, Args_size=1
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LHello;
49. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
} …
public Hello();
Code:
Stack=1, Locals=1, Args_size=1
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LHello;
50. public class Hello {
public static void main(String[] args) {
System.out.println ( “Hello, World!” );
}
C:workgeeconclasses>javap Hello -c -verbose
} …
public Hello();
Code:
Stack=1, Locals=1, Args_size=1
0: aload_0
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LHello;
54. Stack Machine
JVM is a stack-based machine
Each thread has a stack
55. Stack Machine
JVM is a stack-based machine
Each thread has a stack
Stack stores frames
56. Stack Machine
JVM is a stack-based machine
Each thread has a stack
Stack stores frames
Frame is created on method
invocation
57. Stack Machine
JVM is a stack-based machine
Each thread has a stack
Stack stores frames
Frame is created on method
invocation
Frame consists of:
Operand stack
Array of local variables
84. Local Variables
public int calculate(int value) {
return value + 42;
}
public int calculate(int);
Code:
Stack=2, Locals=2, Args_size=2
…
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LLocalVariables;
0 5 1 value I
85. Local Variables
public int calculate(int value) {
return value + 42;
}
public int calculate(int);
Code:
Stack=2, Locals=2, Args_size=2
…
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LLocalVariables;
0 5 1 value I
86. Local Variables
public int calculate(int value) {
return value + 42;
}
public int calculate(int);
Code:
Stack=2, Locals=2, Args_size=2
…
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LLocalVariables;
0 5 1 value I
87. Local Variables
public int calculate(int value) {
return value + 42;
}
The table
public int calculate(int);
Code:
maps
Stack=2, Locals=2, Args_size=2 numbers to
…
names
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LLocalVariables;
0 5 1 value I
88. Local Variables
public int calculate(int value) {
return value + 42;
}
public int calculate(int);
Code:
Stack=2, Locals=2, Args_size=2 Sized explicitly
…
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this LLocalVariables;
0 5 1 value I
89. Local Variables Stack
var value depth value
ldc "Hello"
0 0
astore_0
1 iconst_1 1
astore_1
2 aload_0 2
3 3
4 4
90. Local Variables Stack
var value depth value
ldc "Hello"
0 0 "Hello"
astore_0
1 iconst_1 1
astore_1
2 aload_0 2
3 3
4 4
91. Local Variables Stack
var value depth value
ldc "Hello"
0 "Hello" 0
astore_0
1 iconst_1 1
astore_1
2 aload_0 2
3 3
4 4
92. Local Variables Stack
var value depth value
ldc "Hello"
0 "Hello" 0 1
astore_0
1 iconst_1 1
astore_1
2 aload_0 2
3 3
4 4
93. Local Variables Stack
var value depth value
ldc "Hello"
0 "Hello" 0
astore_0
1 1 iconst_1 1
astore_1
2 aload_0 2
3 3
4 4
94. Local Variables Stack
var value depth value
ldc "Hello"
0 "Hello" 0 "Hello"
astore_0
1 1 iconst_1 1
astore_1
2 aload_0 2
3 3
4 4
98. Object Initialization: static {}
public class Initializer {
static int a;
static int b;
static { a = 1; }
static { b = 2; } static {};
Code:
} 0: iconst_1
1: putstatic #2; //Field a:I
4: iconst_2
5: putstatic #3; //Field b:I
8: return
99. Object Initialization: static {}
public class Initializer {
static int a;
static int b;
<clinit>
static { a = 1; }
static { b = 2; } static {};
Code:
} 0: iconst_1
1: putstatic #2; //Field a:I
4: iconst_2
5: putstatic #3; //Field b:I
8: return
100. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
}
}
101. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
}
102. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
103. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
1: invokespecial #1; //Method java/lang/Object."<init>":()V
104. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
105. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
5: new #2; //class java/lang/Object
8: dup
106. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
5: new #2; //class java/lang/Object
8: dup
9: invokespecial #1; //Method java/lang/Object."<init>":()V
12: putfield #3; //Field o:Ljava/lang/Object;
107. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
5: new #2; //class java/lang/Object
8: dup
9: invokespecial #1; //Method java/lang/Object."<init>":()V
12: putfield #3; //Field o:Ljava/lang/Object;
15: return
108. Object Initialization: new
public class Initializer {
Object o;
public Initializer() {
o = new Object();
public Initializer(); }
Code:
0: aload_0 }
1: invokespecial #1; //Method java/lang/Object."<init>":()V
4: aload_0
5: new #2; //class java/lang/Object
8: dup
9: invokespecial #1; //Method java/lang/Object."<init>":()V
12: putfield #3; //Field o:Ljava/lang/Object;
15: return
109. Object Initialization: {}
public class Initializer {
int a;
int b;
int c;
{ a = 1; }
public Initializer(int b) {
this.b = b;
}
{ c = 2; }
}
110. Object Initialization: {}
public class Initializer {
int a;
int b;
int c;
{ a = 1; }
public Initializer(int b) {
this.b = b;
}
{ c = 2; }
}
111. Object Initialization: {}
public class Initializer {
int a;
int b;
int c;
{ a = 1; }
public Initializer(int b) {
this.b = b;
}
{ c = 2; }
}
112. Object Initialization: {}
public class Initializer {
int a;
int b;
int c;
{ a = 1; }
public Initializer(int b) {
this.b = b;
}
{ c = 2; }
}
113. Object Initialization: {}
public class Initializer {
int a; public Initializer(int);
int b; Code:
int c; 0: aload_0
1: invokespecial #1; // ..<init>
4: aload_0
{ a = 1; } 5: iconst_1
6: putfield #2; //Field a:I
public Initializer(int b) { 9: aload_0
this.b = b; 10: iconst_2
} 11: putfield #3; //Field c:I
14: aload_0
{ c = 2; } 15: iload_1
} 16: putfield #4; //Field b:I
19: return
122. Java Method Invocation
invokestatic class A
invokespecial A/method1
A/method2
invokevirtual
invokeinterface
invokedynamic
123. Java Method Invocation
invokestatic class A
invokespecial A/method1
A/method2
invokevirtual
invokeinterface class B
invokedynamic
124. Java Method Invocation
invokestatic class A
invokespecial A/method1
A/method2
invokevirtual
invokeinterface class B
A/method1
invokedynamic B/method2
B/method3
125. Java Method Invocation
invokestatic class A
invokespecial A/method1
A/method2
invokevirtual
invokeinterface class B impl X
A/method1
invokedynamic B/method2
B/method3
X/methodX
126. Java Method Invocation
invokestatic class A
invokespecial A/method1
A/method2
invokevirtual
invokeinterface class B impl X
A/method1
invokedynamic B/method2
B/method3
X/methodX
class D impl X
D/method1
X/methodX
127. Java Method Invocation
invokestatic class A
invokespecial A/method1
A/method2
invokevirtual
invokeinterface class B impl X
A/method1
invokedynamic B/method2
B/method3
X/methodX
class D impl X
D/method1
X/methodX
128. Java Method Invocation
invokestatic
invokespecial
invokevirtual
invokeinterface
invokedynamic
Efficient Implementation of Java Interfaces:
Invokeinterface Considered Harmless, Bowen
Alpern, Anthony Cocchi, Stephen Fink, David
Grove, and Derek Lieber, OOPSLA’01
143. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
144. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
145. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
146. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
public final class Singleton$ extends java.lang.Object implements
scala.ScalaObject {
public static final Singleton$ MODULE$;
public static {};
Code:
0: new #9; //class Singleton$
3: invokespecial #12; //Method "<init>":()V
6: return
public void test();
private Singleton$();
}
147. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
public final class Singleton$ extends java.lang.Object implements
scala.ScalaObject {
public static final Singleton$ MODULE$;
public static {};
Code:
0: new #9; //class Singleton$
3: invokespecial #12; //Method "<init>":()V
6: return
public void test();
private Singleton$();
}
148. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
public final class Singleton$ extends java.lang.Object implements
scala.ScalaObject {
public static final Singleton$ MODULE$;
public static {};
Code:
0: new #9; //class Singleton$
3: invokespecial #12; //Method "<init>":()V
6: return
public void test();
private Singleton$();
}
149. public final class Singleton extends java.lang.Object {
public static final void test();
Code:
0: getstatic #11; //Field Singleton$.MODULE$:LSingleton$;
3: invokevirtual #13; //Method Singleton$.test:()V
6: return
}
public final class Singleton$ extends java.lang.Object implements
scala.ScalaObject {
public static final Singleton$ MODULE$;
public static {};
public void test();
private Singleton$();
Code:
0: aload_0
1: invokespecial #17; //Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #19; //Field MODULE$:LSingleton$;
8: return
151. public class Singleton {
public void test(){
Singleton$.MODULE$.test();
}
}
object Singleton {
def test={}
}
152. public class Singleton {
public void test(){
Singleton$.MODULE$.test();
}
}
public final class Singleton$
object Singleton { implements scala.ScalaObject {
def test={} public static final Singleton$ MODULE$;
} static { new Singleton$(); }
private Singleton$(){
MODULE$ = this;
}
public void test() {
}
}
154. Javassist
Bytecode manipulation made easy
Source-level and bytecode-level API
Uses the vocabulary of Java language
On-the-fly compilation of the injected code
http://www.jboss.org/javassist
155. for(int i = 0; i < 100; i++){
int a = 0;
try {
while (true) {
a++;
foo(a);
if(a > 1) break;
}
} catch (Exception e) {
}
}
156. Javassist
CtMethod method = …
method.setBody(“ for(int i = 0; i < 100; i++){
int a = 0;
try {
while (true) {
a++;
foo(a);
if(a > 1) break;
}
} catch (Exception e) {
}
}”);
157. -Xverify:all
Exception in thread "main" java.lang.VerifyError:
(class: zt/javassist/My, method: test signature:
()V) Inconsistent stack height 0 != 1