Java - Java Virtual Machine

The JVM is a stack-based interpreted machine. This means that rather than having registers (like a physical hardware CPU), it uses an execution stack of partial results and performs calculations by operating on the top value (or values) of that stack.

.

# Class file structure

.

  • 0xCAFEBABE
  • constant pool
  • access flag
    • Access flags are used to determine the modifiers applied to the class. The first part of the flag identifies general properties, such as whether a class is public, followed by whether it is final and cannot be subclassed. The flag also determines whether the class file represents an interface or an abstract class. The final part of the flag indicates whether the class file represents a synthetic class that is not present in source code, an annotation type, or an enum.

# Operators

  • aload_0 places this references onto the first place position in the stack.
  • invokespecial invokes an instance method that has specific handling for calling superconstructors and creating objects.

# GC

# G1GC

# Quotes

# Optimizing Java

# GC logs

High numbers of application threads will also have an impact on GC times, as they represent more stack frames to scan and more time needed to reach a safepoint. They also exert more pressure on thread schedulers in both bare metal and virtualized environments.

# How to

# Compile JDK on Macos

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# clone the repository
git clone [email protected]:openjdk/jdk.git
# install xcode & configure for xcrun
## simply install xcode from app store

## configure for xcrun (also agree with the license)
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license

# follow the build instructions from openjdk
bash configure
# better set JAVA_HOME = jdk21
make images

# test build image
./build/macosx-aarch64-server-release/images/jdk/bin/java -version

# References

Licensed under CC BY-NC-SA 4.0
Get Things Done
Built with Hugo
Theme Stack designed by Jimmy