@inponomarev
Ivan Ponomarev, Synthesized.io/MIPT
![]() |
|
Lectures
Labs
Homework
Labs and homework marks will define your final mark
https://bit.ly/java21-join (Telegram MIPT. Java-2021)
![]() | ![]() | ![]() |
Cay S. Horstmann. Core Java vol 1 & 2
Raoul-Gabriel Urma et al. Modern Java in Action
![]() | ![]() |
Joshua Bloch Effective Java
Brian Goetz et al. Java Concurrency in Practice
number of search engine results for queries containing the name of the language
covers searches in Google, Google Blogs, MSN, Yahoo!, Baidu, Wikipedia and YouTube
reflects the number of skilled engineers, courses and jobs worldwide
GitHub & StackOverflow
JDK 1.0 (January 23, 1996) | -- 6-monthly release cadence --
JDK 1.1 (February 19, 1997) | Java SE 10 (March 20, 2018)
J2SE 1.2 (December 8, 1998) | Java SE 11 LTS (September 25, 2018)
J2SE 1.3 (May 8, 2000) | Java SE 12 (March 19, 2019)
J2SE 1.4 (February 6, 2002) | Java SE 13 (September 17, 2019)
J2SE 5.0 (September 30, 2004) | Java SE 14 (March 17, 2020)
Java SE 6 (December 11, 2006) | Java SE 15 (September 15, 2020)
-- Sun acquisition by Oracle-- | Java SE 16 (March 16, 2021)
Java SE 7 (July 28, 2011) | Java SE 17 LTS (September 14, 2021)
Java SE 8 (March 18, 2014) | Java SE 18 (March 22, 2022)
Java SE 9 (September 21, 2017) | Java SE 19 (September 20, 2022)
| Java SE 20 (due to in March 2023)
| Java SE 21 LTS (due to in September 2023)
Cay Horstmann Feature evolution in Java 13 and beyond
![]() |
|
Q&A with James Gosling, June 2020: https://www.youtube.com/watch?v=XThhlihqTXI
How would you implement WORA?
Endianness…
Register size…
Applets
Built-in security
But security turned out to be a tricky thing
Applets died (JavaScript won)
Desktop (?)
Embedded Systems
Server-side (backend)
Mobile Devices (Android) — a separate story (see Google vs. Oracle case)
WORA + two dependant tasks:
Safety
No fatal faults on server
Byte code generation and execution in a safe environment
int i = 2;
i = ++i + ++i + ++i;
Java — 12,
C — undefined behaviour
(https://stackoverflow.com/questions/3879176/i-i-i-in-java-vs-c)
NullPointerException
ArrayIndexOutOfBoundsException
Reference implementation: Oracle HotSpot
~ 20 implementations
Byte code, interpretation and JIT-compilation.
Garbage Collection
MultiThreading & Memory Model
Loading and running code in runtime
Reflection API
Standard library
There are no operand stack overflows or underflows.
All local variable uses and stores are valid.
The arguments to all the Java Virtual Machine instructions are of valid types.
The developer does not need to worry about freeing up memory
Garbage collection when there are no references to the object
Advantages:
Less code
There are no invalid links (to destroyed objects)
Fewer memory leaks
Disadvantages:
We do not control the operating time of the GC
STW-pauses (sometimes at the inappropriate time)
Reference counting — cycles?
Mark & sweep
Generational hypothesis
Serial (for single-threaded, client environments)
Parallel (default)
CMS (Concurrent mark and Sweep — shorter pauses, share processor resources, deprecated in Java 9)
G1 (Garbage First — big heaps)
Shenandoah (submillisecond pauses)
Epsilon (no GC)
The ability to run parallel threads of execution is built into the language from the first version (Thread
, Runnable
etc)
JDK 1.5: significant improvements (executor, semaphore, mutex, barrier, latches, concurrent collections, blocking queues)
JDK 1.7: ForkJoinPool
(work-stealing technique)
JDK 1.8: CompletableFuture
Future: Project Loom: lightweight user-mode threads (fibers)
Memory Model: Part of the VM specification: a model of how the memory works
Answers the question: "what values can we possibly seen when we read a variable?"
class DumbWayToFallAsleep implements Runnable {
private boolean asleep;
public void setAsleep(boolean asleep){
this.asleep = asleep;
}
@Override
public void run() {
while (!asleep){
//countSomeSheep
//WILL WE FALL ASLEEP?
}
}
}
class NotSoDumbWayToFallAsleep implements Runnable {
private volatile boolean asleep;
public void setAsleep(boolean asleep){
this.asleep = asleep;
}
@Override
public void run() {
while (!asleep){
//countSomeSheep
//...
}
}
}
Compiled class bytecode can be delivered to any system in the runtime (most often by saving a file to the file system).
Recompilation/linking is not required.
An idea that seemed very good at first!
Explore information about classes, fields, methods, etc. at run time
Read/modify fields (including private!) and dynamically call methods (including private!)
Proxy and AOP
Cay Horstmann Feature evolution in Java 13 and beyond
System-independent part
Data structures
Mathematics
System-dependent part
Date and time
File system access
Network access
User Interface
Any .jar file compiled many years ago can be run on any modern JVM
A gift or a curse?
lambdas & functional programming,
modules,
compact strings,
type inference,
switch expressions,
pattern matching,
records…
Project Amber: productivity-oriented features
Project Loom: fibers & continuators
Project Valhalla: value types & generic specialization
Graal, Panama, Kulla, Sumatra…
Alexey Shipilev, 2015: The Lord of the Strings: Two Scours
Tagir Valeev, 2018: Pattern matching and his imaginary friends
Sergey Kuksenko, 2020: Valhalla is coming
Sergey Kuksenko, 2020: Java threads are losing weight, performance review of Project Loom
There is a virtual machine: you can compile to the byte code from any language!
20-30 languages
Specially created for JVM: Groovy, Scala, Kotlin…
Re-implemented for JVM: JRuby, Nashorn/Graal.js…
https://jaxenter.com/wp-content/uploads/2017/03/Pirates-of-the-JVM-JAXenter-768x4245.png
Libraries and frameworks (including testing)
Integrated Development Environments (IDEs)
Build systems
CI
unit testing and test automation
DI container and application framework,
|
|
|
XML configuration, Maven project layout, Maven Central
Groovy/Kotlin DSL
JUGs (Moscow, St. Petersburg, Novosibirsk)
Conferences (Joker, JPoint)
Come to Moscow JUG (when the pandemic is over)
OCA/OCP
Build and run the jar file