@@ -17,8 +17,8 @@ class Test {
1717 public static void main (String [] args ) throws Exception {
1818 AtomicReference <String > reference = new AtomicReference <>(); // uninteresting (parameterless constructor)
1919 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
2222 }
2323
2424 public static void callSupplier (Supplier <String > supplier ) {
@@ -27,43 +27,43 @@ public static void callSupplier(Supplier<String> supplier) {
2727
2828 public static void copyFiles (Path source , Path target , CopyOption option ) throws Exception {
2929 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)
3232 option // no candidate (not modeled, but source and target are modeled)
3333 ); // $ sourceModel=copy(Path,Path,CopyOption[]):ReturnValue
3434 }
3535
3636 public static InputStream getInputStream (Path openPath ) throws Exception {
3737 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
3939 ); // $ sourceModel=newInputStream(Path,OpenOption[]):ReturnValue
4040 }
4141
4242 public static InputStream getInputStream (String openPath ) throws Exception {
4343 return Test .getInputStream ( // the call is not a source candidate (argument to local call)
4444 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
4646 ) // $ sourceModel=get(String,String[]):ReturnValue
4747 );
4848 }
4949
5050 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
5454 }
5555
5656 public static void FilesWalkExample (Path p , FileVisitOption o ) throws Exception {
5757 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
5959 o , // the implicit varargs array is a candidate, annotated on the last line of the call
6060 o // not a candidate (only the first arg corresponding to a varargs array
6161 // is extracted)
6262 ); // $ sourceModel=walk(Path,FileVisitOption[]):ReturnValue sinkModel=walk(Path,FileVisitOption[]):Argument[1]
6363 }
6464
6565 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)
6767 }
6868}
6969
@@ -88,16 +88,16 @@ class MoreTests {
8888 public static void FilesListExample (Path p ) throws Exception {
8989 Files .list (
9090 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
9393 ); // $ sourceModel=list(Path):ReturnValue
9494
9595 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
9898
9999 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
102102 }
103103}
0 commit comments