Practice ยท 1 of 3
Class-initialization triggers
Implement static List<String> triggerTrace():
1. static String touch() โ references Marker.class (a literal) and returns "literal";
it must NOT cause Marker's static initializer to run.
2. static String force() โ calls Class.forName("Solution$Marker") and returns "forName";
it MUST cause Marker's static initializer to run.
3. public static class Marker with static { trace.add("Marker<clinit>"); } where trace is a static final List<String> you own.
4. triggerTrace() calls touch() then force() then returns the trace โ which must show the literal did NOT initialize the class but forName did.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: JVM observable drills