java-topology/test/langtools/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarHandle_neg.java
russell@unturf.com 0a580b313d undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
2026-03-26 17:11:57 -04:00

22 lines
623 B
Java

/**
* @test /nodynamiccopyright/
* @summary test for VarHandle signature polymorphic methods with wrong return type
* @compile/fail/ref=MethodReferenceTestVarHandle_neg.out -XDrawDiagnostics MethodReferenceTestVarHandle_neg.java
*/
import java.lang.invoke.*;
import java.util.*;
public class MethodReferenceTestVarHandle_neg {
interface Setter {
int apply(int[] arr, int idx, int val);
}
public static void meth() {
VarHandle vh = MethodHandles.arrayElementVarHandle(int[].class);
// Return type of Setter::apply does not match return type of VarHandle::set
Setter f = vh::set;
}
}