Skip to content

Instantly share code, notes, and snippets.

View sormuras's full-sized avatar
Testing...

Christian Stein sormuras

Testing...
View GitHub Profile
@sormuras
sormuras / CompilerWarningsDemo.java
Last active November 14, 2025 10:08
Show javac warnings for unknown enum constants
Path lib = Path.of("lib");
void main() throws Exception {
step("Populate lib directory");
var guardian = get("org.apiguardian.api", "https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar");
var jspecify = get("org.jspecify", "https://repo.maven.apache.org/maven2/org/jspecify/jspecify/1.0.0/jspecify-1.0.0.jar");
var commons = get("org.junit.platform.commons", "https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/6.0.1/junit-platform-commons-6.0.1.jar");
step("Describe module org.junit.platform.commons");
run("jar", "--describe-module", "--file", commons);
@sormuras
sormuras / junit-on-ramp.md
Last active September 18, 2025 13:33
JUnit's On-Ramp

JUnit's on-ramp

This article is a guide for beginners in the early stages of their Java learning journey. It explores an introduction to JUnit using a minimal set of tools. Exploring a non-JDK API shouldn't be much harder to write and run then the typical "Hello World" Java program.

Prolog

In Paving the on-ramp Brian Goetz explains the goal and role of Java's on-ramp in great detail. You may want to read that design document first.

@sormuras
sormuras / TestNG-JUnit-Migration.md
Last active July 1, 2024 10:57
TestNG-JUnit-Migration Guide

jdk-junit-migration

Get sources of JDK

  • Fork openjdk/jdk
  • Clone my/jdk into jdk/
  • Check that jdk/test/jdk/TEST.ROOT exists

Get JTREG binaries

J:\jdks\jdk-22.0.1\bin\java.exe
-ea
-Didea.test.cyclic.buffer.size=1048576
"-javaagent:C:\Users\Sor\AppData\Local\Programs\IntelliJ IDEA Community Edition\lib\idea_rt.jar=56078:C:\Users\Sor\AppData\Local\Programs\IntelliJ IDEA Community Edition\bin"
--add-reads com.io7m.idstore.tests=ALL-UNNAMED
--add-opens com.io7m.idstore.tests/com.io7m.idstore.tests=ALL-UNNAMED
--add-opens com.io7m.idstore.tests/com.io7m.idstore.tests.integration=ALL-UNNAMED
--add-opens com.io7m.idstore.tests/com.io7m.idstore.tests.shell=ALL-UNNAMED
--add-opens com.io7m.idstore.tests/com.io7m.idstore.tests.server=ALL-UNNAMED
@sormuras
sormuras / cleanup-conversion.patch
Created October 10, 2023 13:23
Cleanup conversion
Subject: [PATCH] Cleanup conversion
---
Index: test/langtools/lib/combo/tools/javac/combo/ComboWatcher.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/langtools/lib/combo/tools/javac/combo/ComboWatcher.java b/test/langtools/lib/combo/tools/javac/combo/ComboWatcher.java
new file mode 100644
--- /dev/null (revision 7b1af0140a6819bc7837dfa18a39420f9ac1c8b6)
@sormuras
sormuras / long-stack-trace.log
Created April 26, 2023 09:20
Example for a long stack trace
org.opentest4j.AssertionFailedError: Run[stdOut=, stdErr=j:\github\sormuras\jdk\build\windows-x86_64-server-release\test-support\jtreg_test_langtools_tools_javac_launcher\tmp\junit10123584331460239903\Hello.java:3: error: cannot find symbol
System.out.println("Hello " + new World("Noname"));
^
symbol: class World
location: interface Hello
1 error
, exception=com.sun.tools.javac.launcher.Main$Fault: error: compilation failed] ==> expected: <null> but was: <com.sun.tools.javac.launcher.Main$Fault: error: compilation failed>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertNull.failNotNull(AssertNull.java:50)
@sormuras
sormuras / Program.java
Created August 16, 2022 14:29
Java program skeleton
class Program {
public static void main(String... args) {
new Program().printGreeting();
}
void printGreeting() {
// just scaffolded
throw new UnsupportedOperationException("Not implemented, yet");
// will be replaced
}
@sormuras
sormuras / Generator.java
Created August 16, 2022 14:25
Replace Program's printGreeting() method
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.UnaryOperator;
import java.util.regex.Pattern;
public class Generator extends Program {
public static void main(String... args) {
var program = loadString("Program.java");
var replacer = new Replacer(loadString("Generator.java"));
program = replacer.replace(
@sormuras
sormuras / upload-hashedrekord.json
Last active May 31, 2022 11:10
Playing with hashed rekords
{
"apiVersion": "0.0.1",
"kind": "hashedrekord",
"spec": {
"data": {
"hash": {
"algorithm": "sha256",
"value": "d32655126138500f04c8b02c229c1d2de80cec0f3a72b3aaf2c8f4898543e306"
}
},
jshell> Integer i = 5
i ==> 5
jshell> switch(i) {
...> case Integer i && i > 9 -> System.out.println(">9");
...> default -> System.out.println("...");
...> }
...
jshell> Integer i = 50