Runnable sources, broken examples and captured transcripts for the ankurm.com JEP 512 article, including the measured launch order and a private-constructor difference between 25 and 27. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
17 lines
828 B
Java
17 lines
828 B
Java
// What did the compiler make of a compact source file? Ask the class itself.
|
|
import java.lang.reflect.Modifier;
|
|
import java.util.Arrays;
|
|
|
|
public class Reflect {
|
|
public static void main(String[] args) throws Exception {
|
|
Class<?> c = Class.forName("Hello");
|
|
IO.println("name : " + c.getName());
|
|
IO.println("final : " + Modifier.isFinal(c.getModifiers()));
|
|
IO.println("public : " + Modifier.isPublic(c.getModifiers()));
|
|
IO.println("package : '" + c.getPackageName() + "' (unnamed)");
|
|
IO.println("superclass : " + c.getSuperclass().getName());
|
|
IO.println("declared : " + Arrays.stream(c.getDeclaredMethods()).map(m -> m.toString()).sorted().toList());
|
|
IO.println("constructors: " + Arrays.toString(c.getDeclaredConstructors()));
|
|
}
|
|
}
|