Annotations in Java work through metadata stored in the class bytecode, which the compiler or JVM reads using reflection.