Java Reference
In-Depth Information
@Stub("2,12/21/2012,unassigned")
private Card[] cardsRemaining = new Card[52];
@Stub("3,12/21/2012,unassigned")
public Deck()
{
}
@Stub("4,12/21/2012,unassigned")
public void shuffle()
{
}
@Stub("5,12/21/2012,unassigned")
public Card[] deal(@Stub("5,12/21/2012,unassigned") int
cards)
{
return null;
}
}
Listing3-47 uses @Stub toannotatethe Deck class,the cardsRemaining field,
andthe ncards parameteraswellasannotatingtheconstructorandthetwomethods.
The first three application elements are inappropriate to annotate because they are not
stubs.
You can fix this problem by prefixing the Stub annotation type declaration with
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) so
that Stub onlyappliestomethodsandconstructors.Afterdoingthis,the javac com-
pilertoolwilloutputthefollowingerrormessageswhenyouattempttocompile Listing
3-47 :
Deck.java:1: error: annotation type not applicable to this
kind of declaration
@Stub("1,12/21/2012,unassigned")
^
Deck.java:4: error: annotation type not applicable to this
kind of declaration
@Stub("2,12/21/2012,unassigned")
^
Deck.java:15: error: annotation type not applicable to this
Search WWH ::




Custom Search