Skip to content

Commit 19d622b

Browse files
committed
Add tests to verify that synthetic method removal is performed
These check that direct and indirect clinit wrappers, as well as stub class synthetic static initialisers, are removed if they are generated but not subsequently called.
1 parent adc9fd4 commit 19d622b

18 files changed

+122
-0
lines changed
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class Test {
2+
3+
// Refers to, but never instantiates or refers to static fields of, Unused.
4+
// Thus a clinit-wrapper for Unused should be created, but subsequently
5+
// discarded.
6+
Unused u;
7+
8+
public static void main() {
9+
10+
}
11+
12+
}
13+
14+
class Unused {
15+
16+
static int x;
17+
18+
static {
19+
x = 1;
20+
}
21+
22+
}
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--show-goto-functions
4+
java::Unused::clinit_wrapper
5+
Unused\.<clinit>\(\)
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
Test.class
3+
--lazy-methods --show-goto-functions
4+
--
5+
java::Unused::clinit_wrapper
6+
Unused\.<clinit>\(\)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CORE
2+
Test.class
3+
--lazy-methods
4+
VERIFICATION SUCCESSFUL
5+
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class Test {
2+
3+
// Refers to, but never instantiates or refers to static fields of, Unused.
4+
// Thus a clinit-wrapper for Unused should be created, but subsequently
5+
// discarded.
6+
Unused1 u;
7+
8+
public static void main() {
9+
10+
}
11+
12+
}
13+
14+
class Unused1 extends Unused2 {
15+
16+
}
17+
18+
class Unused2 {
19+
20+
static int x;
21+
22+
static {
23+
x = 1;
24+
}
25+
26+
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)