@@ -17,8 +17,8 @@ class Test {
17
17
public static void main (String [] args ) throws Exception {
18
18
AtomicReference <String > reference = new AtomicReference <>(); // uninteresting (parameterless constructor)
19
19
reference .set ( // $ sinkModel=set(Object):Argument[this]
20
- args [0 ] // $ negativeExample =set(Object):Argument[0] // modeled as a flow step
21
- ); // $ negativeExample =set(Object):ReturnValue // return type is void
20
+ args [0 ] // $ negativeSinkExample =set(Object):Argument[0] // modeled as a flow step
21
+ ); // $ negativeSourceExample =set(Object):ReturnValue // return type is void
22
22
}
23
23
24
24
public static void callSupplier (Supplier <String > supplier ) {
@@ -27,43 +27,43 @@ public static void callSupplier(Supplier<String> supplier) {
27
27
28
28
public static void copyFiles (Path source , Path target , CopyOption option ) throws Exception {
29
29
Files .copy (
30
- source , // $ positiveExample =copy(Path,Path,CopyOption[]):Argument[0](path-injection)
31
- target , // $ positiveExample =copy(Path,Path,CopyOption[]):Argument[1](path-injection)
30
+ source , // $ positiveSinkExample =copy(Path,Path,CopyOption[]):Argument[0](path-injection)
31
+ target , // $ positiveSinkExample =copy(Path,Path,CopyOption[]):Argument[1](path-injection)
32
32
option // no candidate (not modeled, but source and target are modeled)
33
33
); // $ sourceModel=copy(Path,Path,CopyOption[]):ReturnValue
34
34
}
35
35
36
36
public static InputStream getInputStream (Path openPath ) throws Exception {
37
37
return Files .newInputStream (
38
- openPath // $ sinkModel=newInputStream(Path,OpenOption[]):Argument[0] positiveExample =newInputStream(Path,OpenOption[]):Argument[0](path-injection) // sink candidate because "only" ai-modeled, and useful as a candidate in regression testing
38
+ openPath // $ sinkModel=newInputStream(Path,OpenOption[]):Argument[0] positiveSinkExample =newInputStream(Path,OpenOption[]):Argument[0](path-injection) // sink candidate because "only" ai-modeled, and useful as a candidate in regression testing
39
39
); // $ sourceModel=newInputStream(Path,OpenOption[]):ReturnValue
40
40
}
41
41
42
42
public static InputStream getInputStream (String openPath ) throws Exception {
43
43
return Test .getInputStream ( // the call is not a source candidate (argument to local call)
44
44
Paths .get (
45
- openPath // $ negativeExample =get(String,String[]):Argument[0] // modeled as a flow step
45
+ openPath // $ negativeSinkExample =get(String,String[]):Argument[0] // modeled as a flow step
46
46
) // $ sourceModel=get(String,String[]):ReturnValue
47
47
);
48
48
}
49
49
50
50
public static int compareFiles (File f1 , File f2 ) {
51
- return f1 .compareTo ( // $ negativeExample =compareTo(File):Argument[this]
52
- f2 // $ negativeExample =compareTo(File):Argument[0] // modeled as not a sink
53
- ); // $ negativeExample =compareTo(File):ReturnValue // return type is int
51
+ return f1 .compareTo ( // $ negativeSinkExample =compareTo(File):Argument[this]
52
+ f2 // $ negativeSinkExample =compareTo(File):Argument[0] // modeled as not a sink
53
+ ); // $ negativeSourceExample =compareTo(File):ReturnValue // return type is int
54
54
}
55
55
56
56
public static void FilesWalkExample (Path p , FileVisitOption o ) throws Exception {
57
57
Files .walk (
58
- p , // $ negativeExample =walk(Path,FileVisitOption[]):Argument[0] // modeled as a flow step
58
+ p , // $ negativeSinkExample =walk(Path,FileVisitOption[]):Argument[0] // modeled as a flow step
59
59
o , // the implicit varargs array is a candidate, annotated on the last line of the call
60
60
o // not a candidate (only the first arg corresponding to a varargs array
61
61
// is extracted)
62
62
); // $ sourceModel=walk(Path,FileVisitOption[]):ReturnValue sinkModel=walk(Path,FileVisitOption[]):Argument[1]
63
63
}
64
64
65
65
public static void WebSocketExample (URLConnection c ) throws Exception {
66
- c .getInputStream (); // $ sinkModel=getInputStream():Argument[this] positiveExample =getInputStream():ReturnValue(remote) // not a source candidate (manual modeling)
66
+ c .getInputStream (); // $ sinkModel=getInputStream():Argument[this] positiveSourceExample =getInputStream():ReturnValue(remote) // not a source candidate (manual modeling)
67
67
}
68
68
}
69
69
@@ -88,16 +88,16 @@ class MoreTests {
88
88
public static void FilesListExample (Path p ) throws Exception {
89
89
Files .list (
90
90
Files .createDirectories (
91
- p // $ positiveExample =createDirectories(Path,FileAttribute[]):Argument[0](path-injection)
92
- ) // $ sourceModel=createDirectories(Path,FileAttribute[]):ReturnValue negativeExample =list(Path):Argument[0] // modeled as a flow step
91
+ p // $ positiveSinkExample =createDirectories(Path,FileAttribute[]):Argument[0](path-injection)
92
+ ) // $ sourceModel=createDirectories(Path,FileAttribute[]):ReturnValue negativeSinkExample =list(Path):Argument[0] // modeled as a flow step
93
93
); // $ sourceModel=list(Path):ReturnValue
94
94
95
95
Files .delete (
96
- p // $ sinkModel=delete(Path):Argument[0] positiveExample =delete(Path):Argument[0](path-injection)
97
- ); // $ negativeExample =delete(Path):ReturnValue // return type is void
96
+ p // $ sinkModel=delete(Path):Argument[0] positiveSinkExample =delete(Path):Argument[0](path-injection)
97
+ ); // $ negativeSourceExample =delete(Path):ReturnValue // return type is void
98
98
99
99
Files .deleteIfExists (
100
- p // $ sinkModel=deleteIfExists(Path):Argument[0] positiveExample =deleteIfExists(Path):Argument[0](path-injection)
101
- ); // $ negativeExample =deleteIfExists(Path):ReturnValue // return type is boolean
100
+ p // $ sinkModel=deleteIfExists(Path):Argument[0] positiveSinkExample =deleteIfExists(Path):Argument[0](path-injection)
101
+ ); // $ negativeSourceExample =deleteIfExists(Path):ReturnValue // return type is boolean
102
102
}
103
103
}
0 commit comments