10 questions
9 votes
1 answer
152 views
Primitive types in patterns: why doesn't Integer dominate byte?
JEP 455 introduced Primitive Types in Patterns, instanceof, and switch as a preview feature in JDK 23. It continues as a preview feature in JDK 24 and 25, so the feature is not detailed in the Java ...
1 vote
0 answers
51 views
DSU with Union Find for graph puzzle - JUnit test failing when trying to cover overlapping index in grid
I am using Disjoint Set Union (DSU) and Union Find to solve a graph problem. The entry point function takes an input string with coordinates defined by (line number, char number), starting at the top ...
1 vote
1 answer
93 views
Try to update java version from 22 to 23 and get this exception: Out of bound access on segment MemorySegment
I try to update java version from 22 to 23. We work with off-heap memory: val intVh = MemoryLayout .sequenceLayout( Long.MaxValue / ValueLayout.JAVA_INT.byteSize(), ValueLayout....
0 votes
0 answers
123 views
Fatal Error dependencyNamr: Already seen doctype
I have an old android project and I am on the process of shifting to AndordX and updated gradle. When I build the project I receive the below error for some dependency, what could possibly be the ...
21 votes
1 answer
1k views
Why does pattern matching with switch on InetAddress fail with 'does not cover all possible input values'?
In Java 21 and 23, java.net.InetAddress is declared public sealed class InetAddress implements Serializable permits Inet4Address, Inet6Address { However, the following code: switch (addr) { case ...
10 votes
1 answer
1k views
JRE 23 runs much faster than previous versions
I am trying the following code for performance checking. It is purely CPU-bound, doing lots of calculations on double types, single-threaded, and does not use any heap: public class PerfTestSampleJ { ...
10 votes
1 answer
867 views
Thread::startVirtualThread as Threadfactory
Why does this code lead to a java.lang.IllegalThreadStateException? newSingleThreadScheduledExecutor(Thread::startVirtualThread).scheduleWithFixedDelay( () -> System.out.println("Hello, ...
1 vote
1 answer
314 views
Unexpected behavior in Java 22 Stream Gatherer preview feature: last item in Stream omitted
I'm exploring Java Stream Gatherers, a preview feature introduced in Java 22, and I'm using Java 23 with preview features enabled for this purpose. My primary goal here is to better understand how the ...
4 votes
1 answer
179 views
Inner classes and garbage collection: behavior differences between Java 8 and latest Java
I had an interview today, and the interviewer presented the following code. They asked what the output would be in Java 8 and the latest version of Java. From my understanding, since B is an inner ...
8 votes
1 answer
694 views
Java 23 Markdown comments - external links
Java 23 now allows Markdown Documentation Comments I am experimenting with this feature right now in latest IntelliJ IDEA 2024.2.2 (community) and with GraalVM for JDK 23 as Java runtime. It seems the ...