diff --git a/eclipse-distribution/org.springframework.boot.ide.branding/META-INF/MANIFEST.MF b/eclipse-distribution/org.springframework.boot.ide.branding/META-INF/MANIFEST.MF index a92e0182d8..dac4198fb2 100644 --- a/eclipse-distribution/org.springframework.boot.ide.branding/META-INF/MANIFEST.MF +++ b/eclipse-distribution/org.springframework.boot.ide.branding/META-INF/MANIFEST.MF @@ -8,11 +8,16 @@ Require-Bundle: org.eclipse.ui, org.eclipse.equinox.p2.ui, org.eclipse.equinox.p2.ui.sdk, org.springsource.ide.eclipse.commons.core, - org.eclipse.equinox.p2.engine + org.eclipse.equinox.p2.engine, + org.eclipse.equinox.app, + org.eclipse.ui.ide.application, + org.objectweb.asm Bundle-RequiredExecutionEnvironment: JavaSE-21 Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Import-Package: org.eclipse.core.runtime, org.eclipse.osgi.service.datalocation, - org.osgi.framework + org.osgi.framework, + org.osgi.framework.hooks.weaving Eclipse-BundleShape: dir +Export-Package: org.springframework.boot.ide.branding diff --git a/eclipse-distribution/org.springframework.boot.ide.branding/build.properties b/eclipse-distribution/org.springframework.boot.ide.branding/build.properties index 17dd7fd450..c7585f9b53 100644 --- a/eclipse-distribution/org.springframework.boot.ide.branding/build.properties +++ b/eclipse-distribution/org.springframework.boot.ide.branding/build.properties @@ -1,5 +1,7 @@ output.. = bin/ +source.. = src/ bin.includes = META-INF/,\ + .,\ about.ini,\ about.properties,\ plugin.properties,\ @@ -15,5 +17,3 @@ bin.includes = META-INF/,\ about.html,\ sts4-16.png,\ trusted-keys/ -output.library.jar = bin/ -source.. = src/ diff --git a/eclipse-distribution/org.springframework.boot.ide.branding/plugin.xml b/eclipse-distribution/org.springframework.boot.ide.branding/plugin.xml index 1c7d235186..bf76fa6f8e 100644 --- a/eclipse-distribution/org.springframework.boot.ide.branding/plugin.xml +++ b/eclipse-distribution/org.springframework.boot.ide.branding/plugin.xml @@ -2,8 +2,18 @@ + + + + + + + - + diff --git a/eclipse-distribution/org.springframework.boot.ide.branding/src/org/springframework/boot/ide/branding/MacOs26Dot1TextSelectionWorkaround.java b/eclipse-distribution/org.springframework.boot.ide.branding/src/org/springframework/boot/ide/branding/MacOs26Dot1TextSelectionWorkaround.java new file mode 100644 index 0000000000..06529741a1 --- /dev/null +++ b/eclipse-distribution/org.springframework.boot.ide.branding/src/org/springframework/boot/ide/branding/MacOs26Dot1TextSelectionWorkaround.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2025 Broadcom, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Broadcom, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.boot.ide.branding; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.SWT; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.Version; +import org.osgi.framework.hooks.weaving.WeavingHook; +import org.osgi.framework.hooks.weaving.WovenClass; + +/** + * Workaround for + * https://github.com/eclipse-platform/eclipse.platform.swt/pull/2694 + * + * contributed by Sebastian Ratz + */ +@SuppressWarnings({ "nls" }) +class MacOs26Dot1TextSelectionWorkaround implements WeavingHook { + + @Override + public void weave(WovenClass wovenClass) { + + if (!"org.eclipse.swt.graphics.TextLayout".equals(wovenClass.getClassName())) { + return; + } + + try { + ClassReader cr = new ClassReader(wovenClass.getBytes()); + ClassWriter cw = new ClassWriter(cr, 0); + ClassVisitor cv = new ClassVisitor(Opcodes.ASM9, cw) { + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + if ("draw".equals(name) + && "(Lorg/eclipse/swt/graphics/GC;IIIILorg/eclipse/swt/graphics/Color;Lorg/eclipse/swt/graphics/Color;I)V" + .equals(desc)) { + return new MethodVisitor(Opcodes.ASM9, mv) { + @Override + public void visitLdcInsn(Object value) { + if (value instanceof Double d && d.doubleValue() == 2.147483647E9d) { // 0x7fffffff + super.visitLdcInsn(0.5e7d); // OS.MAX_TEXT_CONTAINER_SIZE + } else { + super.visitLdcInsn(value); + } + } + }; + } + return mv; + } + }; + cr.accept(cv, 0); + wovenClass.setBytes(cw.toByteArray()); + } catch (Throwable t) { + // Ignore for the moment + } + } + + public static void installIfNecessary() { + if (!Platform.OS_MACOSX.equals(Platform.getOS())) { + return; + } + if (FrameworkUtil.getBundle(SWT.class).getVersion().compareTo(Version.parseVersion("3.132.0")) >= 0) { + return; + } + FrameworkUtil.getBundle(MacOs26Dot1TextSelectionWorkaround.class).getBundleContext().registerService(WeavingHook.class.getName(), + new MacOs26Dot1TextSelectionWorkaround(), null); + } + +} + diff --git a/eclipse-distribution/org.springframework.boot.ide.branding/src/org/springframework/boot/ide/branding/SpringToolsApplication.java b/eclipse-distribution/org.springframework.boot.ide.branding/src/org/springframework/boot/ide/branding/SpringToolsApplication.java new file mode 100644 index 0000000000..533cfc69ad --- /dev/null +++ b/eclipse-distribution/org.springframework.boot.ide.branding/src/org/springframework/boot/ide/branding/SpringToolsApplication.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2025 Broadcom, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Broadcom, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.boot.ide.branding; + +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.ui.internal.ide.application.IDEApplication; + +@SuppressWarnings("restriction") +public class SpringToolsApplication extends IDEApplication { + + @Override + public Object start(IApplicationContext appContext) throws Exception { + MacOs26Dot1TextSelectionWorkaround.installIfNecessary(); + return super.start(appContext); + } + +} diff --git a/eclipse-distribution/org.springframework.boot.ide.product.e437/org.springframework.boot.ide.product b/eclipse-distribution/org.springframework.boot.ide.product.e437/org.springframework.boot.ide.product index e3a47e0daa..a220c77825 100644 --- a/eclipse-distribution/org.springframework.boot.ide.product.e437/org.springframework.boot.ide.product +++ b/eclipse-distribution/org.springframework.boot.ide.product.e437/org.springframework.boot.ide.product @@ -1,6 +1,6 @@ - +