Skip to content

Commit ba589f3

Browse files
committed
Add a test for custom MethodHandles.lookup
1 parent dfcb222 commit ba589f3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Lincheck
3+
*
4+
* Copyright (C) 2019 - 2025 JetBrains s.r.o.
5+
*
6+
* This Source Code Form is subject to the terms of the
7+
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
8+
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
11+
package org.jetbrains.kotlinx.lincheck_test.trace_debugger;
12+
13+
import org.jetbrains.kotlinx.lincheck.annotations.Operation;
14+
15+
import java.lang.invoke.MethodHandles;
16+
import java.util.Arrays;
17+
import java.util.Collection;
18+
import java.util.List;
19+
import java.util.stream.Collectors;
20+
21+
/**
22+
* This test is intended to check that {@link MethodHandles} is successfully created even on Java 8.
23+
* It is necessary for invokedynamic handling in the trace debugger.
24+
* <p>
25+
* However, due to workaround for <a href="https://github.com/JetBrains/lincheck/issues/500">the issue</a>,
26+
* the tests are actually run on the JDK 17.
27+
* Nevertheless, when the issue is resolved,
28+
* the tests will actually check the correct {@link MethodHandles.Lookup} creation.
29+
*/
30+
public class CollectorsTest extends AbstractDeterministicTest {
31+
@Operation
32+
public Object operation() {
33+
return Arrays.stream(
34+
new List[] {
35+
Arrays.stream(new String[]{"Hello ", "w"}).collect(Collectors.toList()),
36+
Arrays.stream(new String[]{"Hello ", "w"}).collect(Collectors.toList())
37+
}
38+
).flatMap(Collection::stream).collect(Collectors.toList());
39+
}
40+
}

0 commit comments

Comments
 (0)