Skip to content

Commit c918b8f

Browse files
committed
Add tests for java 25 method references
1 parent 0fc2542 commit c918b8f

File tree

7 files changed

+322
-0
lines changed

7 files changed

+322
-0
lines changed

test/org/jetbrains/java/decompiler/SingleClassesTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ private void registerDefault() {
793793
register(JAVA_8, "TestTryLoopSimpleFinally");
794794
register(JAVA_8, "TestTryLoopReturnFinally");
795795
register(JASM, "TestNumberCompareToBoolean");
796+
797+
register(JAVA_21, "TestMethodReferenceJ21", "ext/RefsExt");
798+
register(JAVA_25, "TestMethodReferenceJ25", "ext/RefsExt");
796799
}
797800

798801
private void registerEntireClassPath() {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package pkg;
2+
3+
import ext.RefsExt;
4+
import java.util.function.Consumer;
5+
6+
public class TestMethodReferenceJ21 extends RefsExt {
7+
private void test() {
8+
this.consume(x$0 -> this.accept(x$0));// 9
9+
}// 10
10+
11+
private void test2() {
12+
this.consume(this::accept2);// 13
13+
}// 14
14+
15+
private void test3(TestMethodReferenceJ21 ref) {
16+
this.consume(x$0 -> ref.accept(x$0));// 17
17+
}// 18
18+
19+
private void test4(TestMethodReferenceJ21 ref) {
20+
this.consume(ref::accept2);// 21
21+
}// 22
22+
23+
private void test5(RefsExt ref) {
24+
this.consume(ref::accept2);// 25
25+
}// 26
26+
27+
protected void consume(Consumer<String> c) {
28+
}// 30
29+
}
30+
31+
class 'pkg/TestMethodReferenceJ21' {
32+
method 'test ()V' {
33+
0 7
34+
7 7
35+
8 7
36+
9 7
37+
a 8
38+
}
39+
40+
method 'lambda$test$0 (Lpkg/TestMethodReferenceJ21;Ljava/lang/String;)V' {
41+
0 7
42+
1 7
43+
2 7
44+
3 7
45+
4 7
46+
5 7
47+
}
48+
49+
method 'test2 ()V' {
50+
0 11
51+
1 11
52+
7 11
53+
8 11
54+
9 11
55+
a 12
56+
}
57+
58+
method 'test3 (Lpkg/TestMethodReferenceJ21;)V' {
59+
0 15
60+
c 15
61+
d 15
62+
e 15
63+
f 16
64+
}
65+
66+
method 'lambda$test3$1 (Lpkg/TestMethodReferenceJ21;Ljava/lang/String;)V' {
67+
0 15
68+
1 15
69+
2 15
70+
3 15
71+
4 15
72+
5 15
73+
}
74+
75+
method 'test4 (Lpkg/TestMethodReferenceJ21;)V' {
76+
0 19
77+
1 19
78+
c 19
79+
d 19
80+
e 19
81+
f 20
82+
}
83+
84+
method 'test5 (Lext/RefsExt;)V' {
85+
0 23
86+
1 23
87+
c 23
88+
d 23
89+
e 23
90+
f 24
91+
}
92+
93+
method 'consume (Ljava/util/function/Consumer;)V' {
94+
0 27
95+
}
96+
}
97+
98+
Lines mapping:
99+
9 <-> 8
100+
10 <-> 9
101+
13 <-> 12
102+
14 <-> 13
103+
17 <-> 16
104+
18 <-> 17
105+
21 <-> 20
106+
22 <-> 21
107+
25 <-> 24
108+
26 <-> 25
109+
30 <-> 28
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package pkg;
2+
3+
import ext.RefsExt;
4+
import java.util.Objects;
5+
import java.util.function.Consumer;
6+
7+
public class TestMethodReferenceJ25 extends RefsExt {
8+
private void test() {
9+
TestMethodReferenceJ25 var1 = this;
10+
this.consume(x$0 -> var1.accept(x$0));// 9
11+
}// 10
12+
13+
private void test2() {
14+
this.consume(this::accept2);// 13
15+
}// 14
16+
17+
private void test3(TestMethodReferenceJ25 ref) {
18+
Objects.requireNonNull(ref);
19+
TestMethodReferenceJ25 var2 = ref;
20+
this.consume(x$0 -> var2.accept(x$0));// 17
21+
}// 18
22+
23+
private void test4(TestMethodReferenceJ25 ref) {
24+
this.consume(ref::accept2);// 21
25+
}// 22
26+
27+
private void test5(RefsExt ref) {
28+
this.consume(ref::accept2);// 25
29+
}// 26
30+
31+
protected void consume(Consumer<String> c) {
32+
}// 30
33+
}
34+
35+
class 'pkg/TestMethodReferenceJ25' {
36+
method 'test ()V' {
37+
0 9
38+
1 8
39+
2 8
40+
9 9
41+
a 9
42+
b 9
43+
c 10
44+
}
45+
46+
method 'lambda$test$0 (Lpkg/TestMethodReferenceJ25;Ljava/lang/String;)V' {
47+
0 9
48+
1 9
49+
2 9
50+
3 9
51+
4 9
52+
5 9
53+
}
54+
55+
method 'test2 ()V' {
56+
0 13
57+
1 13
58+
7 13
59+
8 13
60+
9 13
61+
a 14
62+
}
63+
64+
method 'test3 (Lpkg/TestMethodReferenceJ25;)V' {
65+
0 19
66+
1 17
67+
3 17
68+
4 17
69+
5 17
70+
7 18
71+
e 19
72+
f 19
73+
10 19
74+
11 20
75+
}
76+
77+
method 'lambda$test3$0 (Lpkg/TestMethodReferenceJ25;Ljava/lang/String;)V' {
78+
0 19
79+
1 19
80+
2 19
81+
3 19
82+
4 19
83+
5 19
84+
}
85+
86+
method 'test4 (Lpkg/TestMethodReferenceJ25;)V' {
87+
0 23
88+
1 23
89+
c 23
90+
d 23
91+
e 23
92+
f 24
93+
}
94+
95+
method 'test5 (Lext/RefsExt;)V' {
96+
0 27
97+
1 27
98+
c 27
99+
d 27
100+
e 27
101+
f 28
102+
}
103+
104+
method 'consume (Ljava/util/function/Consumer;)V' {
105+
0 31
106+
}
107+
}
108+
109+
Lines mapping:
110+
9 <-> 10
111+
10 <-> 11
112+
13 <-> 14
113+
14 <-> 15
114+
17 <-> 20
115+
18 <-> 21
116+
21 <-> 24
117+
22 <-> 25
118+
25 <-> 28
119+
26 <-> 29
120+
30 <-> 32
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ext;
2+
3+
public class RefsExt {
4+
5+
6+
protected void accept(String s) {
7+
8+
}
9+
10+
public void accept2(String s) {
11+
12+
}
13+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package pkg;
2+
3+
import ext.RefsExt;
4+
5+
import java.util.function.Consumer;
6+
7+
public class TestMethodReferenceJ21 extends RefsExt {
8+
private void test() {
9+
consume(this::accept);
10+
}
11+
12+
private void test2() {
13+
consume(this::accept2);
14+
}
15+
16+
private void test3(TestMethodReferenceJ21 ref) {
17+
consume(ref::accept);
18+
}
19+
20+
private void test4(TestMethodReferenceJ21 ref) {
21+
consume(ref::accept2);
22+
}
23+
24+
private void test5(RefsExt ref) {
25+
consume(ref::accept2);
26+
}
27+
28+
protected void consume(Consumer<String> c) {
29+
30+
}
31+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ext;
2+
3+
import java.util.function.Consumer;
4+
5+
public class RefsExt {
6+
7+
8+
protected void accept(String s) {
9+
10+
}
11+
12+
public void accept2(String s) {
13+
14+
}
15+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package pkg;
2+
3+
import ext.RefsExt;
4+
5+
import java.util.function.Consumer;
6+
7+
public class TestMethodReferenceJ25 extends RefsExt {
8+
private void test() {
9+
consume(this::accept);
10+
}
11+
12+
private void test2() {
13+
consume(this::accept2);
14+
}
15+
16+
private void test3(TestMethodReferenceJ25 ref) {
17+
consume(ref::accept);
18+
}
19+
20+
private void test4(TestMethodReferenceJ25 ref) {
21+
consume(ref::accept2);
22+
}
23+
24+
private void test5(RefsExt ref) {
25+
consume(ref::accept2);
26+
}
27+
28+
protected void consume(Consumer<String> c) {
29+
30+
}
31+
}

0 commit comments

Comments
 (0)