Java Puzzlers NG S02: Down the Rabbit Hole
summary
Quick, concrete takeaways and gotchas with code examples: Semaphore.drainPermits(-42) yields 0 not -42, Stream.empty() is not a singleton because streams carry per-instance state/callbacks, Arrays.setAll can produce two empty Lists with different backing capacities, a functional interface can compile by method-signature merging of overloads but not with default-method clashes, HashSet order is stable inside one JVM run yet Java 9 randomizes iteration across runs, module use requires adding module-info and still keeping classpath deps, and nested iterator removal behavior depends on the concrete collection.
AI-written summary · about
chapters (14)
- 0:00Java Puzzlers NG S02 intro
- 1:03Origins and format
- 3:53Rules and voting setup
- 8:13Puzzle: Russian hackers and semaphores
- 13:38Puzzle: Singleton empty collections
- 15:44Streams and Splitterator
- 20:06Puzzle: Empty lists and setAll
- 25:16Puzzle: Single person functional interface
- 29:40Puzzle: Russian hackers strike back
- 33:35Java 9 set ordering changes
- 37:00Java 9 modules and dependencies
- 41:13Puzzle: Killing iterators
- 47:02Puzzle: Filtering Spock
- 51:18Conclusions








