1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
import java.util.regex.*;
// File reporttest.astub contains an annotation on
// the java.util.regex package.
// :: error: (usage)
class Package extends PatternSyntaxException {
public Package(String desc, String regex, int index) {
// :: error: (usage)
super(desc, regex, index);
}
@Override
@org.checkerframework.dataflow.qual.Pure
public String getPattern() {
// :: error: (usage)
return super.getPattern();
}
// :: error: (usage)
void m(Pattern p) {
// Access to a constant.
// :: error: (usage)
int i = Pattern.CANON_EQ;
// Use of inherited method.
// :: error: (usage)
String msg = getMessage();
// No report for use of overridden method -
// we get a message when we call super in the overriding method.
// TODO: Would we want "transitive" behavior? I.e. a few levels higher
// in the inheritance hierarchy we could see the class to report.
String pat = this.getPattern();
try {
// :: error: (usage)
p.compile("test(((");
} catch (Package pe) {
// We don't look at supertypes of the types we analyze.
// TODO: Should we?
System.out.println("OK!");
// :: error: (usage)
} catch (PatternSyntaxException pse) {
// We do get a report for direct uses.
System.out.println("Ha!");
}
}
}
|