File tree Expand file tree Collapse file tree 2 files changed +106
-33
lines changed
java/ql/test/library-tests/dataflow/capture Expand file tree Collapse file tree 2 files changed +106
-33
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,7 @@ void run() {
250250 }
251251
252252 void testInstanceInitializer () {
253+ // Tests capture in the instance initializer ("<obinit>")
253254 String s = source ("init" );
254255 class MyLocal3 {
255256 String f = s ;
@@ -259,4 +260,23 @@ void run() {
259260 }
260261 new MyLocal3 ().run ();
261262 }
263+
264+ void testConstructorIndirection () {
265+ // Tests capture in nested constructor call
266+ String s = source ("init" );
267+ class MyLocal4 {
268+ String f ;
269+ MyLocal4 () {
270+ this (42 );
271+ }
272+ MyLocal4 (int i ) {
273+ f = s ;
274+ }
275+ String get () {
276+ return this .f ;
277+ }
278+ }
279+ sink (new MyLocal4 ().get ()); // $ hasValueFlow=init
280+ sink (new MyLocal4 (1 ).get ()); // $ hasValueFlow=init
281+ }
262282}
You can’t perform that action at this time.
0 commit comments