Skip to content

Commit c943bbb

Browse files
workaround for macOS 26.1 incompatibility when Eclipse base platform is from 2025-09 or prior to that (#1711)
Signed-off-by: BoykoAlex <[email protected]> Co-authored-by: Martin Lippert <[email protected]>
1 parent 13ad183 commit c943bbb

File tree

6 files changed

+130
-6
lines changed

6 files changed

+130
-6
lines changed

eclipse-distribution/org.springframework.boot.ide.branding/META-INF/MANIFEST.MF

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ Require-Bundle: org.eclipse.ui,
88
org.eclipse.equinox.p2.ui,
99
org.eclipse.equinox.p2.ui.sdk,
1010
org.springsource.ide.eclipse.commons.core,
11-
org.eclipse.equinox.p2.engine
11+
org.eclipse.equinox.p2.engine,
12+
org.eclipse.equinox.app,
13+
org.eclipse.ui.ide.application,
14+
org.objectweb.asm
1215
Bundle-RequiredExecutionEnvironment: JavaSE-21
1316
Bundle-Localization: plugin
1417
Bundle-ActivationPolicy: lazy
1518
Import-Package: org.eclipse.core.runtime,
1619
org.eclipse.osgi.service.datalocation,
17-
org.osgi.framework
20+
org.osgi.framework,
21+
org.osgi.framework.hooks.weaving
1822
Eclipse-BundleShape: dir
23+
Export-Package: org.springframework.boot.ide.branding

eclipse-distribution/org.springframework.boot.ide.branding/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
output.. = bin/
2+
source.. = src/
23
bin.includes = META-INF/,\
4+
.,\
35
about.ini,\
46
about.properties,\
57
plugin.properties,\
@@ -15,5 +17,3 @@ bin.includes = META-INF/,\
1517
about.html,\
1618
sts4-16.png,\
1719
trusted-keys/
18-
output.library.jar = bin/
19-
source.. = src/

eclipse-distribution/org.springframework.boot.ide.branding/plugin.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
<?eclipse version="3.2"?>
33
<plugin>
44

5+
<extension
6+
id="spring-tools-application"
7+
point="org.eclipse.core.runtime.applications">
8+
<application>
9+
<run
10+
class="org.springframework.boot.ide.branding.SpringToolsApplication">
11+
</run>
12+
</application>
13+
</extension>
14+
515
<extension id="sts4" point="org.eclipse.core.runtime.products">
6-
<product name="%productName" application="org.eclipse.ui.ide.workbench" description="%productBlurb">
16+
<product name="%productName" application="org.springframework.boot.ide.branding.spring-tools-application" description="%productBlurb">
717
<property name="windowImages" value="sts4-16.png,sts4-32.png,sts4-48.png"/>
818
<property name="aboutImage" value="sts_lg.gif"/>
919
<property name="aboutText" value="%productBlurb"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Broadcom, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Broadcom, Inc. - initial API and implementation
10+
*******************************************************************************/
11+
package org.springframework.boot.ide.branding;
12+
13+
import org.eclipse.core.runtime.Platform;
14+
import org.eclipse.swt.SWT;
15+
import org.objectweb.asm.ClassReader;
16+
import org.objectweb.asm.ClassVisitor;
17+
import org.objectweb.asm.ClassWriter;
18+
import org.objectweb.asm.MethodVisitor;
19+
import org.objectweb.asm.Opcodes;
20+
import org.osgi.framework.FrameworkUtil;
21+
import org.osgi.framework.Version;
22+
import org.osgi.framework.hooks.weaving.WeavingHook;
23+
import org.osgi.framework.hooks.weaving.WovenClass;
24+
25+
/**
26+
* Workaround for
27+
* https://github.com/eclipse-platform/eclipse.platform.swt/pull/2694
28+
*
29+
* contributed by Sebastian Ratz
30+
*/
31+
@SuppressWarnings({ "nls" })
32+
class MacOs26Dot1TextSelectionWorkaround implements WeavingHook {
33+
34+
@Override
35+
public void weave(WovenClass wovenClass) {
36+
37+
if (!"org.eclipse.swt.graphics.TextLayout".equals(wovenClass.getClassName())) {
38+
return;
39+
}
40+
41+
try {
42+
ClassReader cr = new ClassReader(wovenClass.getBytes());
43+
ClassWriter cw = new ClassWriter(cr, 0);
44+
ClassVisitor cv = new ClassVisitor(Opcodes.ASM9, cw) {
45+
@Override
46+
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
47+
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
48+
if ("draw".equals(name)
49+
&& "(Lorg/eclipse/swt/graphics/GC;IIIILorg/eclipse/swt/graphics/Color;Lorg/eclipse/swt/graphics/Color;I)V"
50+
.equals(desc)) {
51+
return new MethodVisitor(Opcodes.ASM9, mv) {
52+
@Override
53+
public void visitLdcInsn(Object value) {
54+
if (value instanceof Double d && d.doubleValue() == 2.147483647E9d) { // 0x7fffffff
55+
super.visitLdcInsn(0.5e7d); // OS.MAX_TEXT_CONTAINER_SIZE
56+
} else {
57+
super.visitLdcInsn(value);
58+
}
59+
}
60+
};
61+
}
62+
return mv;
63+
}
64+
};
65+
cr.accept(cv, 0);
66+
wovenClass.setBytes(cw.toByteArray());
67+
} catch (Throwable t) {
68+
// Ignore for the moment
69+
}
70+
}
71+
72+
public static void installIfNecessary() {
73+
if (!Platform.OS_MACOSX.equals(Platform.getOS())) {
74+
return;
75+
}
76+
if (FrameworkUtil.getBundle(SWT.class).getVersion().compareTo(Version.parseVersion("3.132.0")) >= 0) {
77+
return;
78+
}
79+
FrameworkUtil.getBundle(MacOs26Dot1TextSelectionWorkaround.class).getBundleContext().registerService(WeavingHook.class.getName(),
80+
new MacOs26Dot1TextSelectionWorkaround(), null);
81+
}
82+
83+
}
84+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Broadcom, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Broadcom, Inc. - initial API and implementation
10+
*******************************************************************************/
11+
package org.springframework.boot.ide.branding;
12+
13+
import org.eclipse.equinox.app.IApplicationContext;
14+
import org.eclipse.ui.internal.ide.application.IDEApplication;
15+
16+
@SuppressWarnings("restriction")
17+
public class SpringToolsApplication extends IDEApplication {
18+
19+
@Override
20+
public Object start(IApplicationContext appContext) throws Exception {
21+
MacOs26Dot1TextSelectionWorkaround.installIfNecessary();
22+
return super.start(appContext);
23+
}
24+
25+
}

eclipse-distribution/org.springframework.boot.ide.product.e437/org.springframework.boot.ide.product

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<?pde version="3.5"?>
3-
<product name="Spring Tools for Eclipse" id="org.springframework.boot.ide.branding.sts4" uid="org.springframework.boot.ide.branding.sts4" application="org.eclipse.ui.ide.workbench" version="4.32.2.qualifier" useFeatures="true" includeLaunchers="true">
3+
<product name="Spring Tools for Eclipse" id="org.springframework.boot.ide.branding.sts4" uid="org.springframework.boot.ide.branding.sts4" application="org.springframework.boot.ide.branding.spring-tools-application" version="4.32.2.qualifier" useFeatures="true" includeLaunchers="true">
44

55
<configIni use="default">
66
</configIni>

0 commit comments

Comments
 (0)