This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The problem is that the above code does not compile. The compiler does not resolve the type of Test to Searchable. I thought by just putting the annotation @Searchable would automatically make Test to be of that type. Am I wrong?
With annotations, a class does not extend nor implement it. Therefore, there is no IS-A relationship between the Searchable annotation and the Test class. In fact, no class at all can ever implement the Searchable annotation, so nothing can have an IS-A relationship with Searchable (well, except sub annotations).
In your case, Searchable should be a regular interface instead.
Also, I don't think Searchable should be a marker interface at all. Once you have your List<Searchable>, what are you going to do with its contents? Searchable has no methods, so there is not a lot you can do without casting.