🔥 Burn Fat Fast. Discover How! 💪

Java Tech News

Logo of telegram channel java_tech_news — Java Tech News J
Logo of telegram channel java_tech_news — Java Tech News
Channel address: @java_tech_news
Categories: Technologies , Apps
Language: English
Subscribers: 558
Description from channel

The channel is dedicated to Java developers who are passionate about learning how the whole Java Platform works. Every post in this channel is a digest of a quality article or reference doc. No bewitched water. Straight to the point.
Dirs: TGDIR

Ratings & Reviews

2.00

3 reviews

Reviews can be left only by registered users. All reviews are moderated by admins.

5 stars

0

4 stars

0

3 stars

1

2 stars

1

1 stars

1


The latest Messages 4

2021-10-13 12:00:00
JEP 413: Code Snippets in Java API Documentation
#jep #javadoc #documentation
This JEP introduces a @snippet tag for JavaDoc's Standard Doclet, to simplify the inclusion of example source code in API documentation. Especially, the best feature in this JEP is "external snippets". External snippets are useful because they allow the example code to be written in separate files that can be directly edited in an IDE, and which can be shared between multiple related snippets. Up until Java 18 you have to update every {@code ..,} snippet manually. With this change you can create a reference like that:
/**
* {@snippet file="ShowOptional.java" region="example"}
*/
where ShowOptional.java is a file containing:
public class ShowOptional {
void show(Optional v) {
// @start region="example"
if (v.isPresent()) {
System.out.println("v: " + v.get());
}
// @end
}
}
https://openjdk.java.net/jeps/413
256 viewsVladislav Chernogorov, 09:00
Open / Comment
2021-10-13 00:00:00
You don't need to call save on @Transcational method
#hibernate #spring #jpa
When you retrieve an entity from the persistence context (e.g. EntityManager.find() or CrudRepository.findById()), it is automatically marked as managed by the persistence provider (e.g. Hibernate). From the JPA standpoint every modification to the managed entity should be reflected in the underlying DataSource with one remark: any changes to persistent state will be persisted when the Session is flushed. Also we know that @Transactional commits all the changed all together after successful completion, and flushing is always happening as a part of committing. Hence, every successful transaction updates managed entity in the database regardless of CrudRepository.save() or EntityManager.merge() invocations.
https://stackoverflow.com/questions/46708063/springboot-jpa-need-no-save-on-transactional#
262 viewsVladislav Chernogorov, 21:00
Open / Comment
2021-10-12 00:00:09
Performance testing various Embedded Web Servers
#web #profiling #spring
Since SpringBoot comes with support for Tomcat, Undertow, Reactor-Netty, Jetty, Jersey web servers, you can compare performance between them.
• Test Scenario: 400k requests with 50 connections and 20 concurrent streams
• All instances were run with -Xms512m -Xmx512m using Java 11.
• Machine Spec: 2.3 GHz Dual-Core Intel Core i5, 16 GB 2133 MHz LPDDR3

For a read-only test case, the following are the standings by various metrics:
• By Throughput: Reactor-Netty, Tomcat, Undertow, Jetty
• By Max Memory: Reactor-Netty, Jetty, Undertow, Tomcat
• By CPU: Reactor-Netty, Undertow, Tomcat, Jetty
• By Threads: Reactor-Netty, Undertow, Tomcat, Jetty

From this experiment, the absolute leader is the Reactor-Netty. Suited for Microservices Architecture, this web server offers backpressure-ready network engines.
https://medium.com/@skhatri.dev/springboot-performance-testing-various-embedded-web-servers-7d460bbfdb1b
277 viewsVladislav Chernogorov, edited  21:00
Open / Comment
2021-10-11 12:00:00
JobRunr — an Easy Job Scheduler
#scheduling #lib
JobRunr is a JVM job scheduling tool, allows developers to schedule a job using just a one-line Java lambda that can manage delayed and recurring jobs. It stores the job details for each job using a StorageProvider interface and supports all major SQL databases and NoSQL databases, so you can safely restart your application and continue running jobs.

Although JobRunr supports integration with Spring Boot, Micronaut, and Quarkus, its main idea is to bring scheduling capabilities from these heavy frameworks in the lightweight library. JobRunr does some magic with #asm (which is also used by Spring, Hibernate and a lot of other frameworks) to analyze the job lambda.
https://www.jobrunr.io/en/
277 viewsVladislav Chernogorov, 09:00
Open / Comment
2021-10-10 12:00:10
You actually CAN access generic type at runtime
#generics #corelibs #runtime
Generics are used to provide compilation checks for type-safety. They are faded, however, after the compilation and transformed to type casts:
List list = new ArrayList();
list.add("Hi");
String x = list.get(0);
is compiled into
List list = new ArrayList();
list.add("Hi");
String x = (String) list.get(0);

So, how do you identify a type of the compiled List? Turns out you can — by using reflection. Metadata of erased super type is accessible in runtime:
this.entityBeanType = ((Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]);

This trick is only possible if your generic class has a superclass, which is a parametrized type.
https://xebia.com/blog/acessing-generic-types-at-runtime-in-java/
291 viewsVladislav Chernogorov, 09:00
Open / Comment
2021-10-09 12:00:00
JEP 408: Simple Web Server
#web #jep
JEP 408 was proposed to provide a command-line tool to start a minimal web server. The goals of this JEP is to offer an out-of-the-box static HTTP file server with easy setup and minimal functionality as a part of OpenJDK distribution. The default implementation will be working via CLI tool.
$ java -m jdk.httpserver
Default bind address loopback. For all interfaces use "-b 0.0.0.0" or "-b ::".
Serving /current/directory (and subdirectories) on
URL http://127.0.0.1:8000/ ...
This simple server is intended for testing, development, and debugging purposes only. It is not a goal of this JEP to provide a feature-rich or commercial-grade server with authentication, access control, or encryption.
https://openjdk.java.net/jeps/408
285 viewsVladislav Chernogorov, 09:00
Open / Comment
2021-10-09 00:00:13
JMX: RMI vs. JMXMP
#jmx #rmi
Java Management Extensions (JMX) Messaging Protocol (MP) and Remote Method Invocation (RMI) connectors are both used to directly transfer serialized Java classes where the transport protocol is based on TCP.

RMI
• Uses random port for exporting objects, unless it's explicitly specified
• Security issues need to be monitored more closely.
• Was introduced in JDK 1.02 and is a part of OpenJDK

JMXMP
• Uses specified port
• Has better security
• Is not a part of OpenJDK distribution, so you need to download it from somewhere

All profilers (e.g. jconsole, VisualVM) are able to connect with both connectors, because they are implementing the same JMX Remote API standart. Although JMXMP is more preferable.
https://stackoverflow.com/questions/5100793/difference-between-jmx-and-rmi
286 viewsVladislav Chernogorov, 21:00
Open / Comment
2021-10-08 12:00:13
10 Things Java Web Developers Mustn’t Avoid learning In 2021
#web
1. DevOps — senior Java developer must be able to single-handedly setup CI/CD for the Web App.
2. Git — the most popular version control system nowadays, and GitHub is a place for 190 mil projects worldwide.
3. ML — enterprises are very enthusiastic about using machine learning in their projects, even if they don't need it.
4. Java 17 LTS — new LTS version is already adopted in most tech companies.
5. Android — the most popular mobile OS with extensive Java SDK.
6. Spring — 95% of all enterprises use Spring in their Java projects.
7. Angular/ReactJS — fullstack developers are hired like crazy for their flexibility.
8. RESTful — don't skip the basics!
9. Kubernetes — orchestration tool designed for coordinating clusters of nodes in production efficiently.
10. Cloud — public clouds proved to be very resilient, efficient, and cheap for scaling large enterprises.
https://habr.com/en/post/558016/
304 viewsVladislav Chernogorov, 09:00
Open / Comment
2021-10-07 12:00:14
Compilation Levels
#compilation #jvm #jit
Even though the JVM works with only one interpreter and two JIT compilers, there are five possible levels of compilation:
0. Interpreted Code
1. Simple C1 Compiled Code —
no profiling, trivial method compilation
2. Limited C1 Compiled Code — C1 compiler with light profiling
3. Full C1 Compiled Code — default compilation path with full profiling
4. C2 Compiled Code — compiled code is considered fully optimized, the JVM stops collecting profiling information

In summary, the JVM initially interprets a method during Tier0 until its invocations reach the Tier3. Then, it compiles the method using the C1 compiler while profiling information continues to be collected. Finally, the JVM compiles the method using the C2 compiler when its invocations reach the Tier4. Eventually, the JVM may decide to deoptimize the C2 compiled code. That means that the complete process will repeat from Tier0
https://www.baeldung.com/jvm-tiered-compilation
303 viewsVladislav Chernogorov, 09:00
Open / Comment
2021-10-07 00:00:16
Tiered Compilation in JVM
#compilation #jvm #jit
Before Java 7 you had to choose between to JIT compilers: C1 and C2. C1 (client compiler) was optimized for faster start-up time and C2 (server compiler) was optimized for better overall performance. The Tiered Compilation feature changes the premise by allowing JIT to have multiple compilations at runtime based on the profiling metrics.

An additional benefit of tiered compilation is more accurate profiling information. Before tiered compilation, the JVM collected profiling information only during interpretation. With tiered compilation enabled, the JVM also collects profiling information on the C1 compiled code.

Even though C2 compiled code is highly optimized, it can be deoptimized. As a result, the JVM would temporarily roll back to bytecode from the code cache. Deoptimization happens when the compiler’s optimistic assumptions are proven wrong.
https://www.baeldung.com/jvm-tiered-compilation
315 viewsVladislav Chernogorov, 21:00
Open / Comment