Things you need to know about JVM (that matter in Scala)
$29.00
Minimum price
$39.00
Suggested price

Things you need to know about JVM (that matter in Scala)

About the Book

Scala is not Java and Java is not Scala. This may sound obvious, as both languages have different goals and features. They might generate different byte code and even when they do something apparently the same, they might still generate byte code differently. What matters is that at the end of the day you need to understand JVM very well in order to get to the bottom of what is happening, or why something was implemented the way it was. Even in Scala.

This book isn't aiming to be an exhaustive list of what you should know about JVM - that topic is so extensive that you could write a whole book (or books) on that. To meet that requirement you're better of to grab a book on preparing for Java Programmer Certified Professional exam.

The goal of my book is to give you enough knowledge to understand why certain decisions were made by Scala creators and library writers. Why we can do certain things and cannot do other. How it affects functional programming. Give you some general ideas about how things work, so that if you wanted to learn more, you would at least know what to google for.

The book is available as an early access including all the intended content. The author is continuing its editing as he believes that improvements should be driven by the feedback. If you found something that you believe could be done better, feel free to contact the author to help him make the book better for everyone.

The "main" version is PDF while EPUB is experimental, so please consider it a bonus.

About the Author

Mateusz Kubuszok
Mateusz Kubuszok

Mateusz Kubuszok is a software developer. Driven by his long-life curiosity and love for math he specialized in Scala development co-authoring e.g. Chimney library for data transformation and blogging about his findings at his blog, Kubuszok.com. He is an active member of Polish Scala community.

Table of Contents

  1. What is JVM
    1. Primitives and references
    2. Operations
    3. More about memory
      1. Stack
      2. Heap
      3. Boxing and unboxing
      4. JVM types vs Scala type hierarchy
    4. Exceptions
    5. Classpath and ClassLoaders
      1. Classpath exception
  2. Classes
    1. What a normal class is made of
      1. Constructor
      2. Methods
      3. Inheritance
      4. Access control
    2. What are objects (modules)
    3. Parametric classes
      1. Type parameters and type erasure
      2. Issues with type erasure
      3. @specialized
    4. Functions vs methods
    5. case classes and case objects
    6. sealed hierarchies
    7. AnyVals
  3. Threads
    1. Parallel vs concurrent
      1. Concurrency
      2. Parallelism
      3. M:N threads
    2. JVM’s Threads
      1. Interruption and canceling
      2. synchronized and @volatile
      3. sleep, wait and notify
    3. Can we avoid concurrency pitfalls?
  4. Garbage collectors
    1. GC root
    2. How JVM cleans up memory
      1. Mark and sweep
      2. Memory fragmentation
      3. Generations, Serial GC and parallel GC
      4. Concurrent Mark-Sweep
      5. Garbage First (G1)
      6. Zero Garbage Collection (ZGC)
      7. No GC at all?
      8. GCs beyond HotSpot
    3. Value specially treated by memory management
    4. Memory leaks
    5. How does memory matter for Scala?
  5. Reflection
    1. What Class[_] knows?
    2. How to obtain Class[_]?
    3. Best thing since sliced bread?
    4. Reflection in Scala
    5. Why it matters that you understand reflection?
  6. Optimizations
    1. HotSpot
    2. C1 and C2
      1. Architecture Description (.ad files)
    3. Observing JIT at work
      1. Printing assembly
      2. Printing compilation and inlining
      3. JITWatch
    4. Microbenchmarks
      1. Example benchmark
      2. Flight Recorder and Java Mission Control
      3. async -profiler and flame graph
    5. Some of the optimizations done by HotSpot
      1. Inlining
      2. Loop unrooling
      3. Dead code elimination
      4. Escape analysis
      5. Mono-, Bi- and Megamorphism and devirtualization
      6. On Stack Replacement (OSR)
      7. Reflection and optimizations
      8. More about JVM optimizations
    6. Optimizations beyond JVM
      1. Memory alignment
      2. Branch prediction
    7. Why it matters to have some idea about JIT?
  7. Tooling and ecosystem
    1. Official tools
      1. javap and scalap
      2. jdb
      3. jps
      4. jstat and jstatd
      5. jstack
      6. jcmd
      7. Other official tools
    2. Third-party tools
      1. jEnv
      2. Dependency management and building
    3. Printing all JVM flags
  8. Summary
  9. Appendix: JVM flags
    1. GC and memory flags
      1. Generation-based memory layout and flags
      2. GC selection
      3. Memory debugging flags
    2. JIT flags
      1. Compilation mode selection
      2. Compilation options
      3. Compilation debugging

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub