Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/concurrency/concurrent-http-virtual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ related:
tags:
- virtual-threads
- concurrency
- http
docs:
- title: "Virtual Threads (JEP 444)"
href: "https://openjdk.org/jeps/444"
Expand Down
1 change: 0 additions & 1 deletion content/concurrency/executor-try-with-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ related:
- "concurrency/virtual-threads"
- "concurrency/thread-sleep-duration"
tags:
- virtual-threads
- concurrency
docs:
- title: "ExecutorService"
Expand Down
1 change: 1 addition & 0 deletions content/datetime/date-formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ related:
- "datetime/hex-format"
tags:
- datetime
- formatting
docs:
- title: "DateTimeFormatter"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/format/DateTimeFormatter.html"
1 change: 1 addition & 0 deletions content/enterprise/mdb-vs-reactive-messaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ related:
tags:
- enterprise
- reactive
- async
docs:
- title: "MicroProfile Reactive Messaging Specification"
href: "https://download.eclipse.org/microprofile/microprofile-reactive-messaging-3.0/microprofile-reactive-messaging-spec-3.0.html"
Expand Down
1 change: 1 addition & 0 deletions content/enterprise/spring-null-safety-jspecify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ related:
tags:
- null-safety
- spring
- enterprise
docs:
- title: "Spring Framework 7 — Null Safety"
href: "https://docs.spring.io/spring-framework/reference/core/null-safety.html"
Expand Down
1 change: 1 addition & 0 deletions content/errors/helpful-npe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ related:
- "errors/require-nonnull-else"
tags:
- null-safety
- exceptions
docs:
- title: "Helpful NullPointerExceptions (JEP 358)"
href: "https://openjdk.org/jeps/358"
1 change: 1 addition & 0 deletions content/errors/optional-orelsethrow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ related:
tags:
- optional
- null-safety
- exceptions
docs:
- title: "Optional.orElseThrow()"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Optional.html#orElseThrow()"
2 changes: 0 additions & 2 deletions content/errors/record-based-errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ related:
- "errors/multi-catch"
tags:
- records
- exceptions
- sealed-classes
docs:
- title: "Records (JEP 395)"
href: "https://openjdk.org/jeps/395"
Expand Down
1 change: 0 additions & 1 deletion content/errors/require-nonnull-else.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ related:
- "errors/optional-chaining"
tags:
- null-safety
- optional
docs:
- title: "Objects.requireNonNullElse()"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Objects.html#requireNonNullElse(T,T)"
Expand Down
1 change: 1 addition & 0 deletions content/io/deserialization-filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ related:
tags:
- security
- serialization
- io
docs:
- title: "ObjectInputFilter"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/ObjectInputFilter.html"
Expand Down
2 changes: 2 additions & 0 deletions content/io/file-memory-mapping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ related:
- "io/writing-files"
tags:
- io
- foreign-function-api
- performance
docs:
- title: "MemorySegment (Java 22)"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/foreign/MemorySegment.html"
Expand Down
1 change: 1 addition & 0 deletions content/io/http-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ related:
- "io/try-with-resources-effectively-final"
tags:
- http
- io
docs:
- title: "HttpClient (JEP 321)"
href: "https://openjdk.org/jeps/321"
Expand Down
1 change: 1 addition & 0 deletions content/language/compact-canonical-constructor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ related:
- "errors/record-based-errors"
tags:
- records
- constructors
docs:
- title: "Record (Java 21)"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Record.html"
Expand Down
1 change: 0 additions & 1 deletion content/language/default-interface-methods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ related:
- "language/sealed-classes"
tags:
- interfaces
- functional
docs:
- title: "Evolving Interfaces (dev.java)"
href: "https://dev.java/learn/interfaces/examples/"
1 change: 0 additions & 1 deletion content/language/guarded-patterns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ related:
tags:
- pattern-matching
- switch
- records
docs:
- title: "Pattern Matching for switch (JEP 441)"
href: "https://openjdk.org/jeps/441"
1 change: 1 addition & 0 deletions content/language/text-blocks-for-multiline-strings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ related:
- "language/exhaustive-switch"
tags:
- text-blocks
- strings
docs:
- title: "Text Blocks (JEP 378)"
href: "https://openjdk.org/jeps/378"
Expand Down
2 changes: 1 addition & 1 deletion content/security/random-generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ related:
- "security/key-derivation-functions"
- "concurrency/virtual-threads"
tags:
- security
- random-number-generation
docs:
- title: "RandomGenerator"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/random/RandomGenerator.html"
Expand Down
1 change: 1 addition & 0 deletions content/security/strong-random.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ related:
tags:
- security
- cryptography
- random-number-generation
docs:
- title: "SecureRandom"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/security/SecureRandom.html"
1 change: 1 addition & 0 deletions content/security/tls-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ related:
- "security/strong-random"
tags:
- security
- cryptography
docs:
- title: "SSLContext"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/javax/net/ssl/SSLContext.html"
Expand Down
2 changes: 1 addition & 1 deletion content/streams/stream-of-nullable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ related:
- "streams/stream-gatherers"
tags:
- streams
- optional
- null-safety
docs:
- title: "Stream.ofNullable()"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/stream/Stream.html#ofNullable(T)"
1 change: 1 addition & 0 deletions content/strings/string-formatted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ related:
- "strings/string-indent-transform"
tags:
- strings
- formatting
docs:
- title: "String.formatted()"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html#formatted(java.lang.Object...)"
1 change: 1 addition & 0 deletions content/strings/string-indent-transform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ related:
- "strings/string-lines"
tags:
- strings
- formatting
docs:
- title: "String.indent()"
href: "https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html#indent(int)"
Expand Down
1 change: 1 addition & 0 deletions content/tooling/aot-class-preloading.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ related:
- "tooling/multi-file-source"
tags:
- performance
- tooling
docs:
- title: "Ahead-of-Time Command-Line Ergonomics (JEP 514)"
href: "https://openjdk.org/jeps/514"
Expand Down
1 change: 1 addition & 0 deletions content/tooling/compact-object-headers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ related:
- "tooling/multi-file-source"
tags:
- performance
- tooling
docs:
- title: "Compact Object Headers (JEP 519)"
href: "https://openjdk.org/jeps/519"
1 change: 1 addition & 0 deletions content/tooling/junit6-with-jspecify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ related:
tags:
- testing
- null-safety
- tooling
docs:
- title: "JUnit 6 Assertions API"
href: "https://docs.junit.org/current/api/org.junit.jupiter.api/org/junit/jupiter/api/Assertions.html"
Expand Down
10 changes: 6 additions & 4 deletions html-generators/generate.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void buildLocale(String locale, Templates templates, SequencedMap<String, Snippe

// Generate index.html from template
var tipCards = allSnippets.values().stream()
.map(s -> renderIndexCard(templates.indexCard(), resolveSnippet(s, locale), locale, strings))
.map(s -> renderIndexCard(templates.indexCard(), resolveSnippet(s, locale), locale, strings, true))
.collect(Collectors.joining("\n"));

var indexTokens = new LinkedHashMap<String, String>();
Expand Down Expand Up @@ -397,7 +397,8 @@ String renderNavArrows(Snippet snippet, String locale) {
return prev + "\n " + next;
}

String renderIndexCard(String tpl, Snippet s, String locale, Map<String, String> strings) {
String renderIndexCard(String tpl, Snippet s, String locale, Map<String, String> strings,
boolean initiallyHidden) {
var cardHref = locale.equals("en")
? "/%s/%s.html".formatted(s.category(), s.slug())
: "/%s/%s/%s.html".formatted(locale, s.category(), s.slug());
Expand All @@ -407,6 +408,7 @@ String renderIndexCard(String tpl, Snippet s, String locale, Map<String, String>
Map.entry("catDisplay", s.catDisplay()), Map.entry("title", escape(s.title())),
Map.entry("oldCode", escape(s.oldCode())), Map.entry("modernCode", escape(s.modernCode())),
Map.entry("jdkVersion", s.jdkVersion()), Map.entry("cardHref", cardHref),
Map.entry("initialCardState", initiallyHidden ? " filter-hidden" : ""),
Map.entry("tags", tagsValue),
Map.entry("cards.old", strings.getOrDefault("cards.old", "Old")),
Map.entry("cards.modern", strings.getOrDefault("cards.modern", "Modern")),
Expand Down Expand Up @@ -522,7 +524,7 @@ void generateTopicPages(Templates templates, SequencedMap<String, Snippet> allSn

// Render cards for snippets in this topic
var topicCards = snippetsForTag.stream()
.map(s -> renderIndexCard(templates.indexCard(), s, locale, strings))
.map(s -> renderIndexCard(templates.indexCard(), s, locale, strings, false))
.collect(Collectors.joining("\n"));

var canonicalUrl = "%s/topics/%s.html".formatted(BASE_URL, tag);
Expand Down Expand Up @@ -551,7 +553,7 @@ void generateTopicPages(Templates templates, SequencedMap<String, Snippet> allSn
tokens.put("topics.backToAll", strings.getOrDefault("topics.backToAll", "← All patterns"));
tokens.put("topicSnippetCount", topicSnippetCount);
tokens.put("topicCards", topicCards);
tokens.put("topicBasePrefix", "../../");
tokens.put("topicBasePrefix", "../");
tokens.put("i18nScript", i18nScript);

var html = replaceTokens(templates.topicPage(), tokens);
Expand Down
1 change: 1 addition & 0 deletions html-generators/tags.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ constructors=Constructors
collectors=Collectors
formatting=Formatting
math=Math
random-number-generation=Random Number Generation
2 changes: 2 additions & 0 deletions site/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/* ---------- Browser Locale Auto-Redirect ---------- */
const autoRedirectLocale = () => {
// Topic pages are canonical English-only pages.
if (document.body.dataset.page === 'topic') return;
if (locale !== 'en') return; // already on a non-English locale
const available = (window.i18n && window.i18n.availableLocales) || [];
if (available.length <= 1) return;
Expand Down
2 changes: 1 addition & 1 deletion templates/index-card.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="{{cardHref}}" class="tip-card filter-hidden" data-category="{{category}}" data-jdk="{{jdkVersion}}" data-tags="{{tags}}">
<a href="{{cardHref}}" class="tip-card{{initialCardState}}" data-category="{{category}}" data-jdk="{{jdkVersion}}" data-tags="{{tags}}">
<div class="tip-card-body">
<div class="tip-card-header">
<div class="tip-badges"><span class="badge {{category}}">{{catDisplay}}</span></div>
Expand Down