Why Commented-Out Interfaces Still Work: Class Files, Retention, and the Art of Proving a Build
Every Java developer who has debugged "changed code but it didn't take effect" needs this: the artifact, not the source, is the ground truth. Knowing how to inspect class files and timestamps turns a long argument into a five-minute check.
A Java developer hit a classic phantom bug: commenting out a whitelist entry in a ShiroConfig class, running mvn compile, and still seeing the endpoint accessible in a test environment. The project wasn't under git, so there was no diff to prove the change ever reached the artifact. The root cause is that javac strips comments from source, so a comment in source says nothing about the class file. If the string still appears in the constant pool, the class was either built before the comment or never recompiled.
Annotation strings only appear in class files depending on @Retention. Runtime-retained annotations like @RestController and @RequestMapping land in RuntimeVisibleAnnotations and are searchable. SOURCE-level ones like @Override don't survive. A subtle trap: method-level annotation strings often remain in the constant pool even after the class-level annotation is removed, but Spring only registers handlers based on class-level @Controller or @RequestMapping. So you must check the class-level annotation string, not the method-level one.
Standard search tools mislead here: grep and ripgrep skip binary files by default, producing false negatives. Reading the .class as raw bytes and searching the constant pool works. Timestamps add context: after a full build, the class mtime must be newer than the source mtime; otherwise you're staring at stale target output. The author's hard rule: after changing config or annotations, always run mvn clean package, because incremental compilation leaves old classes behind. The most reliable proof is starting the service and testing the endpoint; byte-stream search plus timestamps is second-best; source text inspection is worthless.
The scenario highlights a failure mode that git-based workflows hide: without version control, you can't diff what changed, so you have no way to prove what got compiled. The byte-stream check becomes the only arbiter.
Spring's class-level annotation detection is a source of confusion: method-level annotation strings persist in the constant pool, and developers who don't know the framework's lookup logic draw the wrong conclusion from string presence.
The advice to always run clean package is a blunt counter to incremental build tools: they optimize for speed but silently produce stale artifacts when annotations or configs change.
The author's ranking of verification methods—live test > byte search + timestamps > compile output > source text—is a practical checklist that applies to any language where artifacts diverge from source.