Five modules built with plain javac/java/jdeps/jlink on Temurin 25.0.5.1. Sources, broken/ cases, run.sh and captured transcripts in output/. README row added. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4XrpfdpsacrvqnrBM
24 lines
785 B
Java
24 lines
785 B
Java
package com.acme.mapper;
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* A twenty-line stand-in for Jackson, Hibernate or Spring: it reads every declared field of
|
|
* any object it is given, private ones included. That is exactly the kind of code that
|
|
* needs `opens` from the module that owns the object.
|
|
*/
|
|
public final class Mapper {
|
|
private Mapper() { }
|
|
|
|
public static Map<String, Object> toMap(Object o) throws ReflectiveOperationException {
|
|
Map<String, Object> m = new LinkedHashMap<>();
|
|
for (Field f : o.getClass().getDeclaredFields()) {
|
|
f.setAccessible(true); // <- the call that the module system polices
|
|
m.put(f.getName(), f.get(o));
|
|
}
|
|
return m;
|
|
}
|
|
}
|