-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consider invoke dynamic calls when detecting static initializer only …
…methods
- Loading branch information
Showing
6 changed files
with
148 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
pitest-entry/src/test/java/com/example/staticinitializers/EnumWithLambdaInConstructor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.staticinitializers; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
public enum EnumWithLambdaInConstructor { | ||
A(asList("a","b")), | ||
B(asList("a","b", "c")); | ||
|
||
private String s; | ||
|
||
EnumWithLambdaInConstructor(List<String> ss) { | ||
this.s = ss.stream() | ||
.peek(this::doStuff) | ||
.collect(Collectors.joining()); | ||
} | ||
|
||
private void doStuff(String s) { | ||
System.out.println(s); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...src/test/java/com/example/staticinitializers/NestedEnumWithLambdaInStaticInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.staticinitializers; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class NestedEnumWithLambdaInStaticInitializer { | ||
private String name = "Toto"; | ||
|
||
public NestedEnumWithLambdaInStaticInitializer(){} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public enum TOYS { | ||
BALL("his_ball"), | ||
MONKEY("his_monkey"); | ||
|
||
private static final String[] toys = Stream.of(TOYS.values()).map(TOYS::getLink).toArray(String[]::new); | ||
private String toy; | ||
|
||
TOYS(String theToy) { | ||
this.toy = theToy; | ||
} | ||
|
||
public String getLink() { | ||
return toy; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters