Positions:
- Java full stack developer (UI testing, ...)
- Java Web developer (JSP, Servlet, ...)
- Java mobile app developer (Android, ...)
- Java EE developer (EJB, Spring, Hibernate, REST, ...)
- Java API developer (Spring Boot, ...)
- .java
- .class
- OS executable file
-
Definition:
- JRE is typically a program that can communicate with the class file provided to it.
- A runtime environment is typically a kind of physical operating system on which the software runs traditionally.
- JRE accepts your code, merges the different dependencies via a Java class loader, and passes it to JVM
- implementation of JVM
- The main job of JRE is to provide a runtime environment to Java
-
Components:
-
Class loader
-
searching and loading classes in memory
-
classes are not loaded at once in memory by the class loader; it is done on a demand basis
-
Types (where they load the classes dynamically?):
-
Bootstrap class loader
- loads jre/lib/rt.jar file which is a repository of all the system or internal classes in Java
- in the lib directory of JRE
- primordial class loader
- implemented by C or C++ libraries
-
Extension class loader
- child of the bootstrap class loader
- in the jre/lib/ext directory
- system property java.ext.dirs
-
System class loader (application)
- child of the extension class loader
- developer sets up the class path
- loads the classes from the class path
- CLASSPATH
-
-
Principles of functionality of a Java ClassLoader
- Delegation Hierarchy Algorithm (*reference)
- Visibility Principle
- Uniqueness Property
-
Custom Class Loaders (*reference)
- Use-Cases
- modify the existing bytecode -> e.g. weaving agents
- dynamic class loading -> e.g. in JDBC, switching between different driver
- implementing a class versioning mechanism -> URL class loader (load jars via URLs)
- CustomClassLoader -> Code
- Use-Cases
-
-
Bytecode verifier
-
JVM has a gatekeeper
-
verifications:
- The operand stack present in the frame should not get overflowed, and it should not be underflow or underutilized.
- The variables must be initialized before the usage.
- Private data from the class is not accessed from outside of the class.
- The proper references must be used for the method calls.
- The stack should not get overflowed.
- The final classes are not extended, and the final methods are not overridden.
- If the verifier finds that something is missing from the preceding list, the code execution is blocked for that file.
-
bytecode verifier along with compiler?
-
-
Interpreter
-
-
the heart of the entire Java ecosystem
-
a runtime environment provided by Java
-
The main task of JVM is to execute the bytecode, which is the platform-independent file format
-
platform-dependant
-
Architecture
-
Memory management in JVM
- all these segments get stored temporarily as long as the program is executing
- do not get stored at the same location in JVM
- get stored in to different logical compartments
-
types of memory areas:
- Method Area or Class
- class information like variables, method data, or runtime constant pool
- Heap
- fixed size memory
- store the object or arrays
- Stack
- stores the frames created during execution for each thread
- expandable at runtime
- local variable and references to object or arrays
- PC
- Every task that is being executed by JVM is executed within a thread
- Native Stack
- utilized by the native method if used in an application
- Method Area or Class
-
Exception
- OutOfMemoryException?
- heap memory size
- java Sample -Xms512m -Xmx1024m
- _JAVA_OPTIONS = -Xms512m -Xmx1024m
- java.lang.StackOverflowError
- recursive calls
- OutOfMemoryException?
-
JIT
- converts the bytecode to native code
- performance
- contrast to normal compilers
- dynamic in nature
- JIT and JVM are integrated together
- JIT comes bundled with JVM (not possible to separate)
-
JIT vs AoT(Ahead-of-Time Compilation)
-
Interpreter Story:
- jdk 1.0 -> C, infinite while loop
- jdk 1.2 -> C++, Hotspot VM
- zero-assembler
- template interpreter -> codelet, dispatch table
Truffle interpreter for GraalVM...
- one implementation of JIT technology that starts by running interpreted, and watches the actual performance of the app
- an implementation of the part of the JVM concept, originally developed by Sun, and now it is owned by Oracle
List of Java Virtual Machine Implementations
- OpenJ9
- is an alternative
- ...
Java SE > Java SE Specifications
- The Java Language Specification
- The Java Virtual Machine Specification
Java Development Kit
this is a developer’s bundle
is an open-source project that fully implements
- the Java Specifications,
- JSRs, -> Java Specification Requests
- and JEPs -> JDK Enhancement Proposals
that define the Java platform
Differences Between Oracle JDK and OpenJDK
install JDKs or SDKs
- sdkman.io (Link)
IDEs (Integrated development environment Software/java):
- IntelliJ IDEA
- Eclipse
- NetBeans
-
pure java project
- additional libs or frameworks:
-
Apache Groovy
- grails.org (an Open Source, full stack, web application framework for the JVM)
- Spock
- GPars
- Ratpack
- Griffon
- Geb
- Micronaut
- GraalVM (high-performance JDK distribution)
- Grape
-
Kotlin
- KotlinTest
- Spek
- Hamkrest
- Mockito-Kotlin
- Kodein
- jackson-module-kotlin
- GSON, Kotson
- Klaxon
- Retrofit
- OkHttp
- Spring Kotlin project
- vert.x
- Ktor
- Kara
- Wasabi
- Kovert
- Exposed
- RxJava
- funKTionale
- Kovenant
- TornadoFX
-
SQL support
- Amazon Redshift
- Apache
- Cassandra (NoSQL distributed database)
- Derby
- Hive
- Spark (multi-language engine for executing data engineering, data science, and machine learning on single-node machines or clusters)
- Azure SQL Database
- GCP BigQuery
- CockroachDB
- couchbase
- Exasol
- Greenplum
- ...
-
- additional libs or frameworks:
-
Maven
- project management
- comprehension tool
- Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
- builds a project using its project object model (POM) and a set of plugins
- multi module project (example)
- EAR (Enterprise ARchive),
- WAR (Web ARchive),
- JAR (Java ARchive)
-
Gradle
- DSL (Domain Specific Language)
-
Spring Initializer
-
Quarkus
-
Micronaut
-
MicroProfile
-
Ktor
-
Groovy
-
Grails App Forge
-
Kotlin
-
Web
-
Multi-module Project
-
JavaScript
-
Empty Project