CHAPTER 6
ENUMS AND ANNOTATIONS
182
The
Test
annotations have no direct effect on the semantics of the
Sample
class. They serve only to provide information for use by interested programs.
More generally, annotations don’t change the semantics of the annotated code but
enable it for special treatment by tools such as this simple test runner:
// Program to process marker annotations
import java.lang.reflect.*;
public class RunTests {
public static void main(String[] args) throws Exception {
int tests = 0;
int passed = 0;
Class> testClass = Class.forName(args[0]);
for (Method m : testClass.getDeclaredMethods()) {
if (
Do'stlaringiz bilan baham: