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() {
250
250
}
251
251
252
252
void testInstanceInitializer () {
253
+ // Tests capture in the instance initializer ("<obinit>")
253
254
String s = source ("init" );
254
255
class MyLocal3 {
255
256
String f = s ;
@@ -259,4 +260,23 @@ void run() {
259
260
}
260
261
new MyLocal3 ().run ();
261
262
}
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
+ }
262
282
}
You can’t perform that action at this time.
0 commit comments