mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8297727: Forcing LF interpretation lead to StackOverflowError in reflection code
Reviewed-by: jvernee
This commit is contained in:
parent
24bc714d5e
commit
e36756b264
@ -214,7 +214,6 @@ sealed class DirectMethodHandle extends MethodHandle {
|
||||
which = LF_INVSPECIAL_IFC;
|
||||
}
|
||||
LambdaForm lform = preparedLambdaForm(mtype, which);
|
||||
maybeCompile(lform, m);
|
||||
assert(lform.methodType().dropParameterTypes(0, 1)
|
||||
.equals(m.getInvocationType().basicType()))
|
||||
: Arrays.asList(m, m.getInvocationType().basicType(), lform, lform.methodType());
|
||||
@ -320,12 +319,6 @@ sealed class DirectMethodHandle extends MethodHandle {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void maybeCompile(LambdaForm lform, MemberName m) {
|
||||
if (lform.vmentry == null && VerifyAccess.isSamePackage(m.getDeclaringClass(), MethodHandle.class))
|
||||
// Help along bootstrapping...
|
||||
lform.compileToBytecode();
|
||||
}
|
||||
|
||||
/** Static wrapper for DirectMethodHandle.internalMemberName. */
|
||||
@ForceInline
|
||||
/*non-public*/
|
||||
@ -666,7 +659,6 @@ sealed class DirectMethodHandle extends MethodHandle {
|
||||
formOp += (AF_GETSTATIC_INIT - AF_GETSTATIC);
|
||||
}
|
||||
LambdaForm lform = preparedFieldLambdaForm(formOp, isVolatile, ftype);
|
||||
maybeCompile(lform, m);
|
||||
assert(lform.methodType().dropParameterTypes(0, 1)
|
||||
.equals(m.getInvocationType().basicType()))
|
||||
: Arrays.asList(m, m.getInvocationType().basicType(), lform, lform.methodType());
|
||||
@ -843,6 +835,9 @@ sealed class DirectMethodHandle extends MethodHandle {
|
||||
}
|
||||
LambdaForm.associateWithDebugName(form, nameBuilder.toString());
|
||||
}
|
||||
|
||||
// NF_UNSAFE uses field form, avoid circular dependency in interpreter
|
||||
form.compileToBytecode();
|
||||
return form;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2025, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8297727
|
||||
* @summary MethodHandle field access fails with bytecode compilation disabled
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+ShowHiddenFrames
|
||||
* -Djava.lang.invoke.MethodHandle.COMPILE_THRESHOLD=-1
|
||||
* ReflectionInInterpretTest
|
||||
*/
|
||||
public class ReflectionInInterpretTest {
|
||||
private static Integer f; // non-Object type is required to find a non-compiled form
|
||||
|
||||
public static void main(String... args) throws Throwable {
|
||||
MethodHandle mh = MethodHandles.lookup().findStaticGetter(ReflectionInInterpretTest.class, "f", Integer.class);
|
||||
var _ = (Integer) mh.invokeExact();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user