From 82bd3831b0f1e268ae76b31a803c86094add8e92 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Mon, 26 Jan 2026 20:13:03 +0000 Subject: [PATCH] 8374538: Wrong specification of MethodHandles.constant(...) Reviewed-by: liach, jvernee --- .../share/classes/java/lang/invoke/MethodHandles.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index feb8aaaa1a9..7fde9d1dd89 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -4826,7 +4826,9 @@ assert((int)twice.invokeExact(21) == 42); * Before the method handle is returned, the passed-in value is converted to the requested type. * If the requested type is primitive, widening primitive conversions are attempted, * else reference conversions are attempted. - *

The returned method handle is equivalent to {@code identity(type).bindTo(value)}. + *

The returned method handle is equivalent to {@code identity(type).bindTo(value)}, + * for reference types. For all types it is equivalent to + * {@code insertArguments(identity(type), 0, value)}. * @param type the return type of the desired method handle * @param value the value to return * @return a method handle of the given return type and no arguments, which always returns the given value