Skip to content

Commit 17bb56e

Browse files
committed
Use UsingLookup.of(lookup) for Dialog loading #1360
This replaces the use `Default.INJECTION` class-loading stragey with one based on lookups. The inject-based strategy is using reflection via the Unsafe method, which due to stronger encapsulation no longer works properly with Java 25 and onwards. Closes #1360
1 parent fe1844f commit 17bb56e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/widgets

org.eclipse.wb.rcp/src/org/eclipse/wb/internal/rcp/model/widgets/DialogInfo.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2025 Google, Inc. and others.
2+
* Copyright (c) 2011, 2026 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -28,6 +28,7 @@
2828
import org.eclipse.wb.internal.core.utils.ast.AstEditor;
2929
import org.eclipse.wb.internal.core.utils.ast.AstNodeUtils;
3030
import org.eclipse.wb.internal.core.utils.check.Assert;
31+
import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils;
3132
import org.eclipse.wb.internal.core.utils.execution.RunnableEx;
3233
import org.eclipse.wb.internal.rcp.IExceptionConstants;
3334
import org.eclipse.wb.internal.swt.model.widgets.ControlInfo;
@@ -43,6 +44,7 @@
4344
import net.bytebuddy.ByteBuddy;
4445
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
4546

47+
import java.lang.invoke.MethodHandles;
4648
import java.util.List;
4749
import java.util.Objects;
4850

@@ -196,11 +198,14 @@ public static Class<?> getNotAbstractDialog(ClassLoader classLoader)
196198
try {
197199
return classLoader.loadClass("org.eclipse.swt.widgets.Dialog_");
198200
} catch (ClassNotFoundException e) {
201+
Class<?> clazz = classLoader.loadClass("org.eclipse.swt.widgets.Dialog");
202+
MethodHandles.Lookup lookup = ExecutionUtils
203+
.runObject(() -> MethodHandles.privateLookupIn(clazz, MethodHandles.lookup()));
199204
return new ByteBuddy()
200205
.subclass(classLoader.loadClass("org.eclipse.swt.widgets.Dialog")) //
201206
.name("org.eclipse.swt.widgets.Dialog_") //
202207
.make() // We have to use injection to load the class in the CreationSupport
203-
.load(classLoader, ClassLoadingStrategy.Default.INJECTION) //
208+
.load(classLoader, ClassLoadingStrategy.UsingLookup.of(lookup)) //
204209
.getLoaded();
205210
}
206211
}

0 commit comments

Comments
 (0)