
How to Write a Custom Annotation in Java With Reflection
Define a custom Java annotation with retention, target and parameters, read it with reflection, build a validator and see where processors fit.
Everything you need to level up your coding skills.

Define a custom Java annotation with retention, target and parameters, read it with reflection, build a validator and see where processors fit.

See what generic type erasure removes at runtime, why new T and instanceof List of String fail, and the type token pattern that works around it.

Tell ClassNotFoundException from NoClassDefFoundError, then find the missing jar, the wrong scope or the failed static initializer behind each.

Write a logging aspect with Spring AOP: add the starter, define pointcuts for services, log arguments, results and failures, and avoid leaking data.

Write a correct Java microbenchmark with JMH: project setup, state classes, Blackhole, warmup, forks, avoiding dead code elimination and reading the results.

Why native Java deserialization is dangerous, how gadget chains work, how to filter with ObjectInputFilter and what to use instead.

Use Kafka exactly once semantics in Java: the idempotent producer, transactions for consume transform produce, isolation level and what it cannot cover.

Why exactly once delivery is hard: the Two Generals problem, at-least-once and at-most-once semantics, and how Kafka and idempotence give effectively once.

Handle duplicate and out of order messages: a processed message table, natural keys, versioning and a design that ignores delivery order.

Use PESSIMISTIC_WRITE and SKIP LOCKED in JPA and Spring Data, set lock timeouts, handle lock exceptions and know when optimistic locking is the better choice.

Publish events reliably with the outbox pattern: write an outbox row in the same transaction and stream it to Kafka with Debezium change data capture.

Test a Spring Kafka consumer against a real broker in Testcontainers: send a record, wait for the effect, and cover retries and the dead letter topic.
We send one email when a new post is published. No spam.