Add jpms-basics module: JPMS for working developers, exports vs opens, split packages, automatic modules, jdeps and jlink on JDK 25
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
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
1fb1455734
commit
de2660e998
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user