|
| 1 | +# java.evolved |
| 2 | + |
| 3 | +**Java has evolved. Your code can too.** |
| 4 | + |
| 5 | +A collection of 86 side-by-side code comparisons showing old Java patterns next to their clean, modern replacements — from Java 8 all the way to Java 25. |
| 6 | + |
| 7 | +🔗 **[javaevolved.github.io](https://javaevolved.github.io)** |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## What is this? |
| 12 | + |
| 13 | +Every snippet shows two panels: |
| 14 | + |
| 15 | +- **✕ Old** — the traditional way (Java 7/8 era) |
| 16 | +- **✓ Modern** — the clean, idiomatic replacement (Java 9–25) |
| 17 | + |
| 18 | +Each comparison includes an explanation of *why* the modern approach is better, which JDK version introduced it, and links to related patterns. |
| 19 | + |
| 20 | +## Categories |
| 21 | + |
| 22 | +| Category | Examples | |
| 23 | +|---|---| |
| 24 | +| **Language** | Records, sealed classes, pattern matching, switch expressions, var, unnamed variables | |
| 25 | +| **Collections** | Immutable factories, sequenced collections, unmodifiable collectors | |
| 26 | +| **Strings** | Text blocks, `isBlank()`, `strip()`, `repeat()`, `formatted()`, `indent()` | |
| 27 | +| **Streams** | `toList()`, `mapMulti()`, `takeWhile()`/`dropWhile()`, gatherers | |
| 28 | +| **Concurrency** | Virtual threads, structured concurrency, scoped values, `ExecutorService` as `AutoCloseable` | |
| 29 | +| **I/O** | `Files.readString()`, `writeString()`, `Path.of()`, `transferTo()`, HTTP Client | |
| 30 | +| **Errors** | `requireNonNullElse()`, record-based errors, deserialization filters | |
| 31 | +| **Date/Time** | `java.time` basics, `Duration`/`Period`, `DateTimeFormatter`, instant precision | |
| 32 | +| **Security** | TLS defaults, `SecureRandom`, PEM encoding, key derivation functions | |
| 33 | +| **Tooling** | JShell, single-file execution, JFR profiling, compact source files, AOT | |
| 34 | + |
| 35 | +## Tech stack |
| 36 | + |
| 37 | +Plain HTML, CSS, and JavaScript — no frameworks, no build step. Hosted on GitHub Pages. |
| 38 | + |
| 39 | +## Run locally |
| 40 | + |
| 41 | +```bash |
| 42 | +cd modern-java |
| 43 | +python3 -m http.server 8090 |
| 44 | +# Open http://localhost:8090 |
| 45 | +``` |
| 46 | + |
| 47 | +## Modernize with GitHub Copilot |
| 48 | + |
| 49 | +GitHub Copilot can help you migrate legacy Java codebases automatically: |
| 50 | + |
| 51 | +- [App Modernization](https://github.com/solutions/use-case/app-modernization) |
| 52 | +- [Modernize Java Applications with Copilot](https://docs.github.com/en/enterprise-cloud@latest/copilot/tutorials/modernize-java-applications) |
| 53 | + |
| 54 | +## Contributing |
| 55 | + |
| 56 | +Contributions are welcome! If you'd like to add a new snippet, fix an inaccuracy, or improve the site: |
| 57 | + |
| 58 | +1. Fork the repo |
| 59 | +2. Add or edit snippets in `data/snippets.json` |
| 60 | +3. Create the corresponding `.html` article page |
| 61 | +4. Update `index.html` with the new card |
| 62 | +5. Open a pull request |
| 63 | + |
| 64 | +Please ensure JDK version labels only reference the version where a feature became **final** (non-preview). |
| 65 | + |
| 66 | +## Author |
| 67 | + |
| 68 | +**Bruno Borges** |
| 69 | + |
| 70 | +- GitHub: [@brunoborges](https://github.com/brunoborges) |
| 71 | +- X/Twitter: [@brunoborges](https://x.com/brunoborges) |
| 72 | +- LinkedIn: [brunocborges](https://www.linkedin.com/in/brunocborges) |
| 73 | + |
| 74 | +## License |
| 75 | + |
| 76 | +This project is licensed under the [MIT License](LICENSE). |
0 commit comments