SlideShare a Scribd company logo
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Bytecode Verification
The Hero That Java Needs
David Buck
Principal Member of Technical Staff
Java SE Sustaining Engineering
September, 2016
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
4
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
About Me
David Buck
• Java SE Sustaining Engineering
• Mostly JRockit fixes
• OpenJDK 8 Updates
Project Maintainer
• Hobbies: Programming
5
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction
Dangers
Demo
Implementation
Importance
Usage
Conclusions
1
2
3
4
5
6
6
7
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Introduction
7
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
What Is It?
• Analysis of bytecode
• Syntax check
• Symantec check
• Ensures stability / security of runtime
8
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
When does it happen?
• Analysis done during class loading
• Sometimes delayed until right before method execution
• But only done at most once per loaded method
9
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Traditional Interpreted Language
Source Code Interpreter
10
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Traditional Interpreted Language
Source Code Interpreter
11
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Traditional Compiled Language
Source Code ExecutableCompile
12
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Traditional Compiled Language
Source Code ExecutableCompile
13
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java
Source Code BytecodeCompile
14
JVM
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java
Source Code BytecodeCompile
15
JVM
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java
Source Code BytecodeCompile
16
JVM
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java
Source Code BytecodeCompile
17
JVM
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
What Does It Do?
18
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
What Does It Do?
• Protects runtime from bad people
"Why the verifier is so important…. write once and crack anywhere“
-Keith McGuigan
19
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
What Does It Do?
• Protects runtime from bad people
"Why the verifier is so important…. write once and crack anywhere“
-Keith McGuigan
• Protects runtime from you
20
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Why learn about it?
• The best technologies are invisible…
• Victim of its own success
21
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Dangers
22
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Class Metadata
23
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Class Metadata
• Has a direct superclass
24
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Class Metadata
• Has a direct superclass
• Superclass is not marked final
25
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Class Metadata
• Has a direct superclass
• Superclass is not marked final
• No final methods are overridden
26
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Class Metadata
• Has a direct superclass
• Superclass is not marked final
• No final methods are overridden
27
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Overflow
stack=2, locals=1, args_size=1
0: iconst_0
1: iconst_1
2: iconst_2
28
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Overflow
stack=2, locals=1, args_size=1
0: iconst_0
1: iconst_1
2: iconst_2
29
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Overflow
stack=2, locals=1, args_size=1
0: iconst_0
1: iconst_1
2: iconst_2
0
LIMIT
30
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Overflow
stack=2, locals=1, args_size=1
0: iconst_0
1: iconst_1
2: iconst_2
0
LIMIT
1
31
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Overflow
stack=2, locals=1, args_size=1
0: iconst_0
1: iconst_1
2: iconst_2
0
LIMIT
1
2
32
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Overflow
stack=2, locals=1, args_size=1
0: iconst_0
1: iconst_1
2: iconst_2
0
LIMIT
1
2
33
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Underflow
stack=3, locals=1, args_size=1
0: iadd
1: iadd
2: iadd
0
LIMIT
1
2
START
34
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Underflow
stack=3, locals=1, args_size=1
0: iadd
1: iadd
2: iadd
0
LIMIT
3
START
35
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Underflow
stack=3, locals=1, args_size=1
0: iadd
1: iadd
2: iadd
3
LIMIT
START
36
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Underflow
stack=3, locals=1, args_size=1
0: iadd
1: iadd
2: iadd
?
LIMIT
START
37
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Operand Stack Underflow
stack=3, locals=1, args_size=1
0: iadd
1: iadd
2: iadd
?
LIMIT
START
38
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Type Checking
• Each operation is checked
– Correct types on the stack
– Correct types in local variable “slots”
• Specification uses Prolog to define requirements
39
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Prolog?!
• Predicate logic of type system are described by Prolog well
• Java is probably the first of this kind of use by a mainstream programming
language
40
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Prolog?!
Facts:
cat(tom).
41
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Prolog?!
Facts:
parent_child(sally, bob).
42
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Prolog?!
Rules:
Head :- Body.
43
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Prolog?!
Rules:
sibling(X, Y) :- parent_child(Z, X),
parent_child(Z, Y).
44
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
The Specification
45
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java Bytecode
Expressive Power
Java Language
46
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo
47
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
ClassA
public class ClassA {
public int doSomething(int i1, int i2, int i3)
{
return i1+i2+i3;
}
}
48
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
ClassB
public class ClassB {
public Integer doSomethingElse(int i1, int i2, int i3)
{
return new Integer(i1+i2+i3);
}
}
49
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
ClassC
public class ClassC extends ClassA {}
50
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo
public class Demo {
public static void main(String[] args) {
ClassA obj = new ClassC();
System.out.println(obj.doSomething(1,2,3));
}
}
51
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Object
ClassA ClassB
ClassC
Demo
52
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
It works…
$ java Demo
6
$
53
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Lets do something bad…
public class ClassC extends ClassB {}
54
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Lets do something bad…
public class ClassC extends ClassB {}
55
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Object
ClassA ClassB
ClassC
Demo
56
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Object
ClassA ClassB
ClassC
Demo
57
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Object
ClassA ClassB
ClassC
Demo
58
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo
public class Demo {
public static void main(String[] args) {
ClassA obj = new ClassC();
System.out.println(obj.doSomething(1,2,3));
}
}
59
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
$ java Demo
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Demo.main([Ljava/lang/String;)V @15: invokevirtual
Reason:
Type 'ClassC' (current frame, stack[1]) is not assignable to 'ClassA'
Current Frame:
bci: @15
flags: { }
locals: { '[Ljava/lang/String;', 'ClassC' }
stack: { 'java/io/PrintStream', 'ClassC', integer, integer, integer }
Bytecode:
0x0000000: bb00 0259 b700 034c b200 042b 0405 06b6
0x0000010: 0005 b600 06b1
60
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
As expected, the verifier protects us from ourselves.
61
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
As expected, the verifier protects us from ourselves.
What if we disable it…
62
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
We reap what we sow…
$ java -Xverify:none Demo
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fa93be7991c, pid=22925, tid=140364857087744
#
# JRE version: OpenJDK Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14)
# Java VM: OpenJDK 64-Bit Server VM (25.91-b14 mixed mode linux-amd64 compressed
oops)
# Problematic frame:
# V [libjvm.so+0x46391c]
63
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo Takeaways
• No obvious evidence that bad bytecode was root cause of crash
• A class is only valid in the context of previously loaded classes
• No malicious intent / 3rd party tools used
64
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Optional 2nd Demo
$ java -Xverify:none Crack
=============== DEBUG MESSAGE: illegal bytecode sequence -
method not verified ================
Exception in thread "Thread-0"
java.lang.NullPointerException
at Pointer.deref(Pointer.jasm)
at Crack.breakLock(Crack.java:13)
at Crack$1.run(Crack.java:29)
Thread Thread[main,5,main] leaving monitor
$
65
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Implementation
66
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Type Inference Verifier
– AKA the Old Verifier
Type Checking Verifier
– AKA Split Verifier
– AKA The New Hotness
67
A Tale of Two Verifiers…
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Type Inference Verifier
– AKA the Old Verifier
Type Checking Verifier
– AKA Split Verifier
– AKA The New Hotness
68
A Tale of Two Verifiers…
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Type Inference Verifier
• Class files <= 49 (JDK 5)
• Requires CFG construction
• Worst case scenario can require
many passes
Diagram by JMP EAX - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=34222288
69
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
When We Do Syntactic / Semantic checking
Source Code BytecodeCompile
70
JVM
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Type Checking Verifier (AKA Split Verifier)
• Class files >= 50 (JDK 6)
• Depends on StackMapTable Attribute
• Transfers much of the responsibility to javac
Source Code BytecodeCompile JVM
StackMap
Tables
71
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
StackMapTable
• Identifies the type of each stack position / local variable
• One needed for every instruction that is the target of a jump
– Methods without branches will not have them
• Are stored as deltas to save space
• Allow single pass verification
72
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Importance
73
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
3rd Party Tools
• Non-Java languages
• Bytecode obfuscators
• Bytecode optimizers
• 3rd party Java compilers
• Bytecode assemblers
– Oolong
– Jasmin
– JASM
74
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Runtime Mischief
• Runtime Code Generation
• Runtime Code Modification
• Usual suspects:
– BCEL
– ASM
– AOP
– Instrumentation tools / agents
75
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Compatibility Issues
• A serious limitation for bytecode manipulation
• Tools like instrumentation agents may not know the rules of more recent
classfile versions
76
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
r/programminghorror
try {
new OraclePKIProvider();
} catch (Throwable t) { ; }
77
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
r/programminghorror
• Verification enabled
– VerifyError silently eaten by catch clause
– Application runs fine
• Verification disabled
– Broken bytecode loaded, environment breaks
78
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Usage
79
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
options
• -Xverify:
– none
• disables all verification. Only use for debugging!
– remote
• default. Verifies all classes not loaded by boot class path.
– all
• Verifies everything.
• -noverify
• Same as –Xverify:none
80
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Xverify:remote
• Has nothing to do with remote / local
• Horribly named
• Our own documentation was wrong for well over a decade
81
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Cost of Verification
• Classloading could be CPU-bound in the 90s
• Skipping verification could speed up class loading, giving a faster startup
82
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Cost of Verification
83
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Cost of Verification
• On modern hardware, class loading is no longer CPU-bound, it is IO-bound
– Even on SSD hardware
• Verification is more or less free
84
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Development Usage
• Verification is just as important in Development as in Production (if not
more!)
• Some products explicitly disable verification by default in “Developer”
configurations!
• Previously unseen verify errors thrown when code is moved into
production
85
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Verification Support by Class File Version
• <= class file version 49 (JDK 5)
– Only type inference supported
• class file version 50 (JDK 6)
– Type checking w/ fallback to type inference
• >= class file version 51 (JDK 7)
– only type checking supported
– (JDK 7 only) force use type inference w/ -XX:-UseSplitVerifier
86
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Conclusions
87
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Summary
• Always use verification
– Even in development
– Even with trusted code
– Even when startup time is important
• Verification depends on already loaded classes
• Split Verifier is here to stay
88
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
References
[ Cracking the Hotspot JVM ]
https://blogs.oracle.com/kamg/entry/cracking_the_hotspot_jvm
[ 4.10. Verification of class Files ]
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.10
89
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The preceding is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
90
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 91
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]

More Related Content

What's hot (20)

PDF
Nashorn in the future (English)
Logico
 
PPTX
Functional programming with_jdk8-s_ritter
Simon Ritter
 
PDF
Nashorn: JavaScript Running on Java VM (English)
Logico
 
PPTX
Project Jigsaw in JDK9
Simon Ritter
 
PDF
CompletableFuture уже здесь
Dmitry Chuyko
 
PDF
Compile ahead of time. It's fine?
Dmitry Chuyko
 
PDF
Hotspot & AOT
Dmitry Chuyko
 
PDF
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Oracle Keynote from JMagghreb 2014
Simon Ritter
 
PDF
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
JSONB introduction and comparison with other frameworks
Dmitry Kornilov
 
PDF
Jigsaw modularity
Srinivasan Raghavan
 
PPTX
Java 101
javafxpert
 
PPTX
JDK 9: Big Changes To Make Java Smaller
Simon Ritter
 
PDF
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
C4Media
 
PDF
Java 12 - New features in action
Marco Molteni
 
PPTX
The latest features coming to Java 12
NexSoftsys
 
PDF
JavaOne 2017 - Collections.compare:JDK, Eclipse, Guava, Apache... [CON1754]
Leonardo De Moura Rocha Lima
 
PDF
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
Leonardo De Moura Rocha Lima
 
PDF
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Leonardo De Moura Rocha Lima
 
Nashorn in the future (English)
Logico
 
Functional programming with_jdk8-s_ritter
Simon Ritter
 
Nashorn: JavaScript Running on Java VM (English)
Logico
 
Project Jigsaw in JDK9
Simon Ritter
 
CompletableFuture уже здесь
Dmitry Chuyko
 
Compile ahead of time. It's fine?
Dmitry Chuyko
 
Hotspot & AOT
Dmitry Chuyko
 
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Oracle Keynote from JMagghreb 2014
Simon Ritter
 
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JSONB introduction and comparison with other frameworks
Dmitry Kornilov
 
Jigsaw modularity
Srinivasan Raghavan
 
Java 101
javafxpert
 
JDK 9: Big Changes To Make Java Smaller
Simon Ritter
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
C4Media
 
Java 12 - New features in action
Marco Molteni
 
The latest features coming to Java 12
NexSoftsys
 
JavaOne 2017 - Collections.compare:JDK, Eclipse, Guava, Apache... [CON1754]
Leonardo De Moura Rocha Lima
 
JavaOne 2017 - Choosing a NoSQL API and Database to Avoid Tombstones and Drag...
Leonardo De Moura Rocha Lima
 
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
Leonardo De Moura Rocha Lima
 

Similar to Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500] (20)

PDF
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
David Buck
 
PPTX
GOTO Night with Charles Nutter Slides
Alexandra Masterson
 
PPTX
CS8392 OOP
DhanalakshmiVelusamy1
 
PDF
10 Reasons Why Java Now Rocks More Than Ever
Geert Bevin
 
PPTX
oop unit1.pptx
sureshkumara29
 
PPT
Oop lecture2
Shahriar Robbani
 
PPTX
Java byte code & virtual machine
Laxman Puri
 
PPTX
Java dev mar_2021_keynote
Suyash Joshi
 
PPT
JavaTutorials.ppt
Khizar40
 
PPT
A begineers guide of JAVA - Getting Started
Rakesh Madugula
 
PDF
Basic object oriented approach
Jigarthacker
 
PPT
Java tutorials
saryu2011
 
ODP
Synapseindia reviews.odp.
Tarunsingh198
 
PPT
Java basic
Arati Gadgil
 
PDF
Exciting Features and Enhancements in Java 23 and 24
Ana-Maria Mihalceanu
 
PDF
Java Debuggers: A Peek Under the Hood [JavaOne 2016 CON1503]
David Buck
 
PPT
Java Fundamentals.pptJava Fundamentals.ppt
yatakonakiran2
 
PDF
FTD JVM Internals
Felipe Mamud
 
PDF
[FREE PDF sample] Object Oriented Programming and Java Second Edition Danny P...
ackeylocusr5
 
InvokeDynamic for Mere Mortals [JavaOne 2015 CON7682]
David Buck
 
GOTO Night with Charles Nutter Slides
Alexandra Masterson
 
10 Reasons Why Java Now Rocks More Than Ever
Geert Bevin
 
oop unit1.pptx
sureshkumara29
 
Oop lecture2
Shahriar Robbani
 
Java byte code & virtual machine
Laxman Puri
 
Java dev mar_2021_keynote
Suyash Joshi
 
JavaTutorials.ppt
Khizar40
 
A begineers guide of JAVA - Getting Started
Rakesh Madugula
 
Basic object oriented approach
Jigarthacker
 
Java tutorials
saryu2011
 
Synapseindia reviews.odp.
Tarunsingh198
 
Java basic
Arati Gadgil
 
Exciting Features and Enhancements in Java 23 and 24
Ana-Maria Mihalceanu
 
Java Debuggers: A Peek Under the Hood [JavaOne 2016 CON1503]
David Buck
 
Java Fundamentals.pptJava Fundamentals.ppt
yatakonakiran2
 
FTD JVM Internals
Felipe Mamud
 
[FREE PDF sample] Object Oriented Programming and Java Second Edition Danny P...
ackeylocusr5
 
Ad

More from David Buck (20)

PDF
JDK 13 New Features [MeetUp with Java Experts! @Gaienmae/Dojima 2019]
David Buck
 
PDF
JDK Mission Control: Where We Are, Where We Are Going [Groundbreakers APAC 20...
David Buck
 
PDF
Java Bytecode Crash Course [Code One 2019]
David Buck
 
PDF
CSI (Crash Scene Investigation) HotSpot: Common JVM Crash Causes and Solution...
David Buck
 
PDF
invokedynamic for Mere Mortals [Code One 2019]
David Buck
 
PDF
Hangs, Slowdowns, Starvation—Oh My! A Deep Dive into the Life of a Java Threa...
David Buck
 
PDF
JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]
David Buck
 
PDF
Java Concurrency, A(nother) Peek Under the Hood [Code One 2019]
David Buck
 
PDF
Z Garbage Collector
David Buck
 
PDF
Valhalla Update JJUG CCC Spring 2019
David Buck
 
PDF
Var handles jjug_ccc_spring_2018
David Buck
 
PDF
JDK 10 へようこそ
David Buck
 
PDF
Java SE 8におけるHotSpotの進化 [Java Day Tokyo 2014 C-2]
David Buck
 
PDF
HotSpot のロック: A Peek Under the Hood [JJUG ナイトセミナ JVM 特集 2015年8月]
David Buck
 
PDF
Java Concurrency, A(nother) Peek Under the Hood [JavaOne 2016 CON1497]
David Buck
 
PDF
Lambda: A Peek Under The Hood [Java Day Tokyo 2015 6-3]
David Buck
 
PDF
Java Concurrency, A(nother) Peek Under the Hood [Java Day Tokyo 2016 3-C]
David Buck
 
PDF
Ahead-of-Time Compilation with JDK 9 [Java Day Tokyo 2017 D1-A1]
David Buck
 
PDF
HotSpot Synchronization, A Peek Under the Hood [JavaOne 2015 CON7570]
David Buck
 
PDF
Let’s Write Our Own Chip-8 Interpreter! [JavaOne 2017 CON3584]
David Buck
 
JDK 13 New Features [MeetUp with Java Experts! @Gaienmae/Dojima 2019]
David Buck
 
JDK Mission Control: Where We Are, Where We Are Going [Groundbreakers APAC 20...
David Buck
 
Java Bytecode Crash Course [Code One 2019]
David Buck
 
CSI (Crash Scene Investigation) HotSpot: Common JVM Crash Causes and Solution...
David Buck
 
invokedynamic for Mere Mortals [Code One 2019]
David Buck
 
Hangs, Slowdowns, Starvation—Oh My! A Deep Dive into the Life of a Java Threa...
David Buck
 
JDK Mission Control: Where We Are, Where We Are Going [Code One 2019]
David Buck
 
Java Concurrency, A(nother) Peek Under the Hood [Code One 2019]
David Buck
 
Z Garbage Collector
David Buck
 
Valhalla Update JJUG CCC Spring 2019
David Buck
 
Var handles jjug_ccc_spring_2018
David Buck
 
JDK 10 へようこそ
David Buck
 
Java SE 8におけるHotSpotの進化 [Java Day Tokyo 2014 C-2]
David Buck
 
HotSpot のロック: A Peek Under the Hood [JJUG ナイトセミナ JVM 特集 2015年8月]
David Buck
 
Java Concurrency, A(nother) Peek Under the Hood [JavaOne 2016 CON1497]
David Buck
 
Lambda: A Peek Under The Hood [Java Day Tokyo 2015 6-3]
David Buck
 
Java Concurrency, A(nother) Peek Under the Hood [Java Day Tokyo 2016 3-C]
David Buck
 
Ahead-of-Time Compilation with JDK 9 [Java Day Tokyo 2017 D1-A1]
David Buck
 
HotSpot Synchronization, A Peek Under the Hood [JavaOne 2015 CON7570]
David Buck
 
Let’s Write Our Own Chip-8 Interpreter! [JavaOne 2017 CON3584]
David Buck
 
Ad

Recently uploaded (20)

PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 

Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]

  • 3. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Bytecode Verification The Hero That Java Needs David Buck Principal Member of Technical Staff Java SE Sustaining Engineering September, 2016
  • 4. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 4
  • 5. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | About Me David Buck • Java SE Sustaining Engineering • Mostly JRockit fixes • OpenJDK 8 Updates Project Maintainer • Hobbies: Programming 5
  • 6. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction Dangers Demo Implementation Importance Usage Conclusions 1 2 3 4 5 6 6 7
  • 7. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Introduction 7
  • 8. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What Is It? • Analysis of bytecode • Syntax check • Symantec check • Ensures stability / security of runtime 8
  • 9. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | When does it happen? • Analysis done during class loading • Sometimes delayed until right before method execution • But only done at most once per loaded method 9
  • 10. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Traditional Interpreted Language Source Code Interpreter 10
  • 11. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Traditional Interpreted Language Source Code Interpreter 11
  • 12. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Traditional Compiled Language Source Code ExecutableCompile 12
  • 13. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Traditional Compiled Language Source Code ExecutableCompile 13
  • 14. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Java Source Code BytecodeCompile 14 JVM
  • 15. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Java Source Code BytecodeCompile 15 JVM
  • 16. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Java Source Code BytecodeCompile 16 JVM
  • 17. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Java Source Code BytecodeCompile 17 JVM
  • 18. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What Does It Do? 18
  • 19. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What Does It Do? • Protects runtime from bad people "Why the verifier is so important…. write once and crack anywhere“ -Keith McGuigan 19
  • 20. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What Does It Do? • Protects runtime from bad people "Why the verifier is so important…. write once and crack anywhere“ -Keith McGuigan • Protects runtime from you 20
  • 21. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Why learn about it? • The best technologies are invisible… • Victim of its own success 21
  • 22. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Dangers 22
  • 23. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Class Metadata 23
  • 24. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Class Metadata • Has a direct superclass 24
  • 25. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Class Metadata • Has a direct superclass • Superclass is not marked final 25
  • 26. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Class Metadata • Has a direct superclass • Superclass is not marked final • No final methods are overridden 26
  • 27. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Class Metadata • Has a direct superclass • Superclass is not marked final • No final methods are overridden 27
  • 28. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Overflow stack=2, locals=1, args_size=1 0: iconst_0 1: iconst_1 2: iconst_2 28
  • 29. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Overflow stack=2, locals=1, args_size=1 0: iconst_0 1: iconst_1 2: iconst_2 29
  • 30. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Overflow stack=2, locals=1, args_size=1 0: iconst_0 1: iconst_1 2: iconst_2 0 LIMIT 30
  • 31. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Overflow stack=2, locals=1, args_size=1 0: iconst_0 1: iconst_1 2: iconst_2 0 LIMIT 1 31
  • 32. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Overflow stack=2, locals=1, args_size=1 0: iconst_0 1: iconst_1 2: iconst_2 0 LIMIT 1 2 32
  • 33. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Overflow stack=2, locals=1, args_size=1 0: iconst_0 1: iconst_1 2: iconst_2 0 LIMIT 1 2 33
  • 34. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Underflow stack=3, locals=1, args_size=1 0: iadd 1: iadd 2: iadd 0 LIMIT 1 2 START 34
  • 35. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Underflow stack=3, locals=1, args_size=1 0: iadd 1: iadd 2: iadd 0 LIMIT 3 START 35
  • 36. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Underflow stack=3, locals=1, args_size=1 0: iadd 1: iadd 2: iadd 3 LIMIT START 36
  • 37. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Underflow stack=3, locals=1, args_size=1 0: iadd 1: iadd 2: iadd ? LIMIT START 37
  • 38. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Operand Stack Underflow stack=3, locals=1, args_size=1 0: iadd 1: iadd 2: iadd ? LIMIT START 38
  • 39. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Type Checking • Each operation is checked – Correct types on the stack – Correct types in local variable “slots” • Specification uses Prolog to define requirements 39
  • 40. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Prolog?! • Predicate logic of type system are described by Prolog well • Java is probably the first of this kind of use by a mainstream programming language 40
  • 41. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Prolog?! Facts: cat(tom). 41
  • 42. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Prolog?! Facts: parent_child(sally, bob). 42
  • 43. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Prolog?! Rules: Head :- Body. 43
  • 44. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Prolog?! Rules: sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). 44
  • 45. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | The Specification 45
  • 46. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Java Bytecode Expressive Power Java Language 46
  • 47. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Demo 47
  • 48. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | ClassA public class ClassA { public int doSomething(int i1, int i2, int i3) { return i1+i2+i3; } } 48
  • 49. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | ClassB public class ClassB { public Integer doSomethingElse(int i1, int i2, int i3) { return new Integer(i1+i2+i3); } } 49
  • 50. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | ClassC public class ClassC extends ClassA {} 50
  • 51. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Demo public class Demo { public static void main(String[] args) { ClassA obj = new ClassC(); System.out.println(obj.doSomething(1,2,3)); } } 51
  • 52. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Object ClassA ClassB ClassC Demo 52
  • 53. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | It works… $ java Demo 6 $ 53
  • 54. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Lets do something bad… public class ClassC extends ClassB {} 54
  • 55. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Lets do something bad… public class ClassC extends ClassB {} 55
  • 56. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Object ClassA ClassB ClassC Demo 56
  • 57. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Object ClassA ClassB ClassC Demo 57
  • 58. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Object ClassA ClassB ClassC Demo 58
  • 59. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Demo public class Demo { public static void main(String[] args) { ClassA obj = new ClassC(); System.out.println(obj.doSomething(1,2,3)); } } 59
  • 60. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | $ java Demo Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.VerifyError: Bad type on operand stack Exception Details: Location: Demo.main([Ljava/lang/String;)V @15: invokevirtual Reason: Type 'ClassC' (current frame, stack[1]) is not assignable to 'ClassA' Current Frame: bci: @15 flags: { } locals: { '[Ljava/lang/String;', 'ClassC' } stack: { 'java/io/PrintStream', 'ClassC', integer, integer, integer } Bytecode: 0x0000000: bb00 0259 b700 034c b200 042b 0405 06b6 0x0000010: 0005 b600 06b1 60
  • 61. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | As expected, the verifier protects us from ourselves. 61
  • 62. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | As expected, the verifier protects us from ourselves. What if we disable it… 62
  • 63. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | We reap what we sow… $ java -Xverify:none Demo # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00007fa93be7991c, pid=22925, tid=140364857087744 # # JRE version: OpenJDK Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14) # Java VM: OpenJDK 64-Bit Server VM (25.91-b14 mixed mode linux-amd64 compressed oops) # Problematic frame: # V [libjvm.so+0x46391c] 63
  • 64. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Demo Takeaways • No obvious evidence that bad bytecode was root cause of crash • A class is only valid in the context of previously loaded classes • No malicious intent / 3rd party tools used 64
  • 65. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Optional 2nd Demo $ java -Xverify:none Crack =============== DEBUG MESSAGE: illegal bytecode sequence - method not verified ================ Exception in thread "Thread-0" java.lang.NullPointerException at Pointer.deref(Pointer.jasm) at Crack.breakLock(Crack.java:13) at Crack$1.run(Crack.java:29) Thread Thread[main,5,main] leaving monitor $ 65
  • 66. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Implementation 66
  • 67. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Type Inference Verifier – AKA the Old Verifier Type Checking Verifier – AKA Split Verifier – AKA The New Hotness 67 A Tale of Two Verifiers…
  • 68. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Type Inference Verifier – AKA the Old Verifier Type Checking Verifier – AKA Split Verifier – AKA The New Hotness 68 A Tale of Two Verifiers…
  • 69. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Type Inference Verifier • Class files <= 49 (JDK 5) • Requires CFG construction • Worst case scenario can require many passes Diagram by JMP EAX - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=34222288 69
  • 70. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | When We Do Syntactic / Semantic checking Source Code BytecodeCompile 70 JVM
  • 71. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Type Checking Verifier (AKA Split Verifier) • Class files >= 50 (JDK 6) • Depends on StackMapTable Attribute • Transfers much of the responsibility to javac Source Code BytecodeCompile JVM StackMap Tables 71
  • 72. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | StackMapTable • Identifies the type of each stack position / local variable • One needed for every instruction that is the target of a jump – Methods without branches will not have them • Are stored as deltas to save space • Allow single pass verification 72
  • 73. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Importance 73
  • 74. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 3rd Party Tools • Non-Java languages • Bytecode obfuscators • Bytecode optimizers • 3rd party Java compilers • Bytecode assemblers – Oolong – Jasmin – JASM 74
  • 75. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Runtime Mischief • Runtime Code Generation • Runtime Code Modification • Usual suspects: – BCEL – ASM – AOP – Instrumentation tools / agents 75
  • 76. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Compatibility Issues • A serious limitation for bytecode manipulation • Tools like instrumentation agents may not know the rules of more recent classfile versions 76
  • 77. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | r/programminghorror try { new OraclePKIProvider(); } catch (Throwable t) { ; } 77
  • 78. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | r/programminghorror • Verification enabled – VerifyError silently eaten by catch clause – Application runs fine • Verification disabled – Broken bytecode loaded, environment breaks 78
  • 79. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Usage 79
  • 80. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | options • -Xverify: – none • disables all verification. Only use for debugging! – remote • default. Verifies all classes not loaded by boot class path. – all • Verifies everything. • -noverify • Same as –Xverify:none 80
  • 81. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Xverify:remote • Has nothing to do with remote / local • Horribly named • Our own documentation was wrong for well over a decade 81
  • 82. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Cost of Verification • Classloading could be CPU-bound in the 90s • Skipping verification could speed up class loading, giving a faster startup 82
  • 83. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Cost of Verification 83
  • 84. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Cost of Verification • On modern hardware, class loading is no longer CPU-bound, it is IO-bound – Even on SSD hardware • Verification is more or less free 84
  • 85. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Development Usage • Verification is just as important in Development as in Production (if not more!) • Some products explicitly disable verification by default in “Developer” configurations! • Previously unseen verify errors thrown when code is moved into production 85
  • 86. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Verification Support by Class File Version • <= class file version 49 (JDK 5) – Only type inference supported • class file version 50 (JDK 6) – Type checking w/ fallback to type inference • >= class file version 51 (JDK 7) – only type checking supported – (JDK 7 only) force use type inference w/ -XX:-UseSplitVerifier 86
  • 87. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Conclusions 87
  • 88. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Summary • Always use verification – Even in development – Even with trusted code – Even when startup time is important • Verification depends on already loaded classes • Split Verifier is here to stay 88
  • 89. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | References [ Cracking the Hotspot JVM ] https://blogs.oracle.com/kamg/entry/cracking_the_hotspot_jvm [ 4.10. Verification of class Files ] https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.10 89
  • 90. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 90
  • 91. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 91