<p>I'm trying to write rules for detecting some errors in <em>annotated</em> multi-threaded java programs.  As a toy example, I'd like to detect if any method annotated with @ThreadSafe calls a method without such an annotation, without synchronization.  I'm looking for a tool that would allow me to write such a test. </p>

<p>I've looked at source analyzers, like CheckStyle and PMD, and they don't really have cross-class analysis capabilities.  Bytecode analysers, like FindBugs and JLint seem rather difficult to extend.</p>

<p>I'd settle for a solution to something even simpler, but posing the same difficulty: writing a <em>custom</em> rule that checks whether each overriden method is annotated with @Override.  </p>

A simple tool to checkup on annotations is apt (
http://java.sun.com/j2se/1.5.0/docs/guide/apt/
also part of Java 6 api in javax.annotation.processing) however this only has type information (ie I couldn't find a quick way to get at the inheritance hierarchy using the javax.lang.model api, however if you can load the class you can get that information using reflection).