Skip to content

Remove the word "experimental" from the MethodHandles flag. #1898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ConstructionProxy<T> create() {
@SuppressWarnings("unchecked") // the injection point is for a constructor of T
final Constructor<T> constructor = (Constructor<T>) injectionPoint.getMember();

if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
MethodHandle target = InternalMethodHandles.unreflectConstructor(constructor);
// If construction fails fall through to the fastclass approach which can
// access more constructors. See comments in ProviderMethod on how to change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void injectMembers() {
// Run injections if we're not in tool stage (ie, PRODUCTION or DEV),
// or if we are in tool stage and the injection point is toolable.
if (!isStageTool || memberInjector.getInjectionPoint().isToolable()) {
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
try {
// In theory, constructing the handle to invoke it exactly once is expensive and
// wasteful, and it is true for
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/google/inject/internal/InternalFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private MethodHandleResult(MethodHandle methodHandle, Cachability cachability) {
*/
static <T> Provider<T> makeDefaultProvider(
InternalFactory<T> factory, InjectorImpl injector, Dependency<?> dependency) {
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
return InternalMethodHandles.makeProvider(factory, injector, dependency);
}
return new DefaultProvider<>(factory, injector, dependency);
Expand Down
8 changes: 4 additions & 4 deletions core/src/com/google/inject/internal/InternalFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public final class InternalFlags {
private static final ColorizeOption COLORIZE_OPTION =
getSystemOption("guice_colorize_error_messages", ColorizeOption.OFF);

private static final UseMethodHandlesOption USE_EXPERIMENTAL_METHOD_HANDLES =
getSystemOption("guice_use_experimental_method_handles", UseMethodHandlesOption.NO);
private static final UseMethodHandlesOption USE_METHOD_HANDLES =
getSystemOption("guice_use_method_handles", UseMethodHandlesOption.NO);

/** The options for using `MethodHandles`. */
public enum UseMethodHandlesOption {
Expand Down Expand Up @@ -170,8 +170,8 @@ public static boolean enableColorizeErrorMessages() {
return COLORIZE_OPTION.enabled();
}

public static boolean getUseExperimentalMethodHandlesOption() {
return USE_EXPERIMENTAL_METHOD_HANDLES
public static boolean getUseMethodHandlesOption() {
return USE_METHOD_HANDLES
== UseMethodHandlesOption.YES
&& isBytecodeGenEnabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static <T> MembersInjectorImpl<T> create(
(InternalFlags.isBytecodeGenEnabled() && !encounter.getAspects().isEmpty())
? encounter.getAspects()
: null;
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
return new MethodHandleMembersInjectorImpl<>(
injector,
typeLiteral,
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/google/inject/internal/ProviderMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static <T> ProviderMethod<T> create(
boolean skipFastClassGeneration,
Annotation annotation) {
int modifiers = method.getModifiers();
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
// `unreflect` fails if the method is not public and there is either a security manager
// blocking access (very rare) or application has set up modules that are not open.
// In that case we fall back to fast class generation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ProviderToInternalFactoryAdapter<T> implements Provider<T> {

static <T> ProviderToInternalFactoryAdapter<T> create(
InjectorImpl injector, InternalFactory<? extends T> internalFactory) {
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
return InternalMethodHandles.makeScopedProvider(internalFactory, injector);
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/com/google/inject/internal/SingleMethodInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Object invoke(Object target, Object... parameters)
}

private MethodInvoker createMethodInvoker(final Method method) {
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
MethodHandle methodHandle = InternalMethodHandles.unreflect(method);
if (methodHandle != null) {
methodHandle = InternalMethodHandles.dropReturn(methodHandle);
Expand Down Expand Up @@ -119,7 +119,7 @@ public MethodHandle getInjectHandle(
if (fastMethod != null) {
// (Object receiver, Object[]) -> void
MethodHandle fastMethodHandle;
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
var handle =
BIFUNCTION_APPLY_HANDLE
.bindTo(fastMethod)
Expand Down
16 changes: 8 additions & 8 deletions core/test/com/google/inject/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ guice_test_suites(
)

[guice_test_suites(
name = "gen_tests_stack_trace_%s_use_experimental_method_handles_%s" % (include_stack_trace_option, use_experimental_method_handles_option),
name = "gen_tests_stack_trace_%s_use_method_handles_%s" % (include_stack_trace_option, use_method_handles_option),
args = [
"--guice_include_stack_traces=%s" % include_stack_trace_option,
"--guice_use_experimental_method_handles=%s" % use_experimental_method_handles_option,
"--guice_use_method_handles=%s" % use_method_handles_option,
],
jvm_flags = [
# those 2 options are required for some tests that checks stack traces
Expand All @@ -149,24 +149,24 @@ guice_test_suites(
"small",
"medium",
],
suffix = "_stack_trace_%s_use_experimental_method_handles_%s" % (include_stack_trace_option, use_experimental_method_handles_option),
suffix = "_stack_trace_%s_use_method_handles_%s" % (include_stack_trace_option, use_method_handles_option),
deps = [
":add_opens_tests",
":tests",
"//core/src/com/google/inject", # bazel requires this b/c of package_info.java
],
) for include_stack_trace_option in [
"OFF",
] for use_experimental_method_handles_option in [
] for use_method_handles_option in [
"NO",
"YES",
]]

[guice_test_suites(
name = "gen_tests_class_loading_%s_method_handles_%s" % (custom_class_loading_option, use_experimental_method_handles_option),
name = "gen_tests_class_loading_%s_method_handles_%s" % (custom_class_loading_option, use_method_handles_option),
args = [
"--guice_custom_class_loading=%s" % custom_class_loading_option,
"--guice_use_experimental_method_handles=%s" % use_experimental_method_handles_option,
"--guice_use_method_handles=%s" % use_method_handles_option,
],
jvm_flags = [
# those 2 options are required for some tests that checks stack traces
Expand All @@ -177,7 +177,7 @@ guice_test_suites(
"small",
"medium",
],
suffix = "_custom_class_loading_%s_method_handles_%s" % (custom_class_loading_option, use_experimental_method_handles_option),
suffix = "_custom_class_loading_%s_method_handles_%s" % (custom_class_loading_option, use_method_handles_option),
deps = [
":add_opens_tests",
":tests",
Expand All @@ -187,7 +187,7 @@ guice_test_suites(
"OFF",
"ANONYMOUS",
"CHILD",
] for use_experimental_method_handles_option in [
] for use_method_handles_option in [
"NO",
"YES",
]]
8 changes: 4 additions & 4 deletions core/test/com/google/inject/errors/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ filegroup(
)

[guice_test_suites(
name = "gen_tests_stack_trace%s_use_experimental_method_handles_%s" % (include_stack_trace_option, use_experimental_method_handles_option),
name = "gen_tests_stack_trace%s_use_method_handles_%s" % (include_stack_trace_option, use_method_handles_option),
args = [
"--guice_include_stack_traces=%s" % include_stack_trace_option,
"--guice_use_experimental_method_handles=%s" % use_experimental_method_handles_option,
"--guice_use_method_handles=%s" % use_method_handles_option,
],
sizes = [
"small",
],
suffix = "_stack_trace_%s_use_experimental_method_handles_%s" % (include_stack_trace_option, use_experimental_method_handles_option),
suffix = "_stack_trace_%s_use_method_handles_%s" % (include_stack_trace_option, use_method_handles_option),
deps = [":tests"],
) for include_stack_trace_option in [
"OFF",
"ONLY_FOR_DECLARING_SOURCE",
] for use_experimental_method_handles_option in [
] for use_method_handles_option in [
"NO",
"YES",
]]
4 changes: 2 additions & 2 deletions core/test/com/google/inject/spi/ProviderMethodsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ Float quux() {

@Test
public void testShareFastClass() {
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
// This test is not relevant for method handles.
return;
}
Expand Down Expand Up @@ -673,7 +673,7 @@ Long bar() {

@Test
public void testShareFastClassWithSuperClass() {
if (InternalFlags.getUseExperimentalMethodHandlesOption()) {
if (InternalFlags.getUseMethodHandlesOption()) {
return;
}
// FastClass is only used when bytecode generation is enabled and this test relies on package
Expand Down
2 changes: 1 addition & 1 deletion core/test/com/googlecode/guice/BytecodeGenTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void testFastClassWithDifferentVersionsOfGuice() throws Throwable {
// Test relies on package access which CHILD loading doesn't have and the methodhandle path
// doesn't use fastclasses
if (InternalFlags.getCustomClassLoadingOption() == CustomClassLoadingOption.CHILD
|| InternalFlags.getUseExperimentalMethodHandlesOption()) {
|| InternalFlags.getUseMethodHandlesOption()) {
return;
}
Injector injector = Guice.createInjector();
Expand Down
Loading