Тема: java
-
Модульный тест в JUnit 5 и xUnit.net: сравнение аннотаций, жизненного цикла и параметризованных случаев
JUnit Jupiter отмечает тесты через @Test, по умолчанию выполняет @BeforeEach и @AfterEach вокруг каждого теста на новом экземпляре и задаёт случаи по данным через @ParameterizedTest с аннотацией источника. xUnit.net использует [Fact], конструктор и IDisposable для подготовки и очистки каждого теста на новом экземпляре, [Theory] с [InlineData] для случаев и фикстуры для общего дорогостоящего контекста. Одинаковая форма тестов помогает команде с несколькими языками согласовать правила.
-
Sizing a JVM inside a container: heap percentage, non-heap memory and CPU count
The JVM reads cgroup limits by default (UseContainerSupport) and sizes the heap as a percentage of the container's memory, not the host's; heap is only part of the footprint, so set MaxRAMPercentage to leave room for metaspace, thread stacks, direct buffers and code cache, check the CPU count the JVM sees, and verify with -Xlog:os+container and native memory tracking before trusting a limit.
-
Maven versus Gradle: what a newcomer needs to build someone else's JVM project
Maven describes a project declaratively in pom.xml and runs fixed lifecycle phases (validate, compile, test, package, verify, install, deploy) with plugin goals bound to them; Gradle runs a graph of tasks configured by build.gradle(.kts) scripts and plugins. Both resolve transitive dependencies but with different conflict rules (Maven: nearest definition; Gradle: highest version), and both ship a wrapper script that pins the build tool version.
-
Java records, sealed types and pattern matching for switch
Records (JDK 16) are transparent, immutable data carriers with a generated canonical constructor, accessors, equals, hashCode and toString; sealed types (JDK 17) restrict which classes may extend or implement them so that a pattern switch (JDK 21) over the hierarchy can be checked for exhaustiveness. Together they give Java a lightweight sum type.
-
JVM garbage collection: the collectors, the defaults and the few flags worth setting
HotSpot ships Serial, Parallel, G1 and ZGC; it picks G1 on machines it considers server-class (two or more processors and at least 1792 MB) and Serial otherwise, with a default maximum heap of a quarter of memory. For most services the flags worth setting are the maximum heap, GC logging, and only after reading logs a collector or a pause-time goal.
-
Десериализация недоверенных данных: pickle и сериализация Java
Нативные форматы сериализации объектов предписывают получателю создавать произвольные объекты, а их создание выполняет код; документация Python прямо называет pickle небезопасным модулем. Никогда не десериализуйте такие форматы из недоверенного ввода; если устаревший интерфейс вынуждает это делать, ограничьте классы, которые может указывать поток, и подпишите данные.
-
After moving a JVM service to virtual threads, what changed in throughput, memory and pinning incidents, and what had to be rewritten?
Open question: JEP 444 states that pinning does not make an application incorrect but might hinder its scalability, and JEP 491, delivered in JDK 24, removes pinning for synchronized blocks; for services that switched request handling to virtual threads, what did the change do to throughput and memory, which pinning or pool-exhaustion incidents occurred, and which code and libraries had to change?
-
Java virtual threads in outline: what changes and what does not
JEP 444 (JDK 21) adds virtual threads: cheap threads scheduled by the JDK onto a small pool of carrier platform threads, which unmount while blocked on most JDK I/O so that thread-per-request code scales without an asynchronous style. They are not faster, must never be pooled, and until JEP 491 (JDK 24) blocking inside synchronized pinned the carrier.
-
Date and time format tokens: strftime, Java, Go, .NET and Moment/date-fns translated
The same letter means different things across formatting libraries: Java's uppercase Y is a week-based year rather than a calendar year, and D is a day of the year in Java and date-fns but a day of the month in Moment — a token table to check before trusting a generated format string.
-
Потоки Java и циклы: когда конвейер понятнее, а когда нет
Поток — ленивый конвейер промежуточных операций, завершаемый одной терминальной операцией. Он хорошо читается при фильтрации, преобразовании и сборе коллекции, но документация пакета не рекомендует побочные эффекты в лямбдах, поток нельзя использовать повторно, проверяемые исключения в него не вписываются, а для раннего выхода с состоянием, работы по индексам и изменений данных понятнее цикл.
-
Why applications ignore the OS trust store: Java cacerts, Python certifi, Node.js and curl
Adding a CA to the operating system's trust store does not make every application trust it. Java, many Python installs, Node.js and curl builds can carry their own CA bundle or keystore, each with its own file location and override environment variable, so a certificate error can persist after the OS-level fix.
Машиночитаемо: JSON