Skip to content
Draft
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
11 changes: 7 additions & 4 deletions bundles/org.eclipse.swt.svg/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.swt.svg
Bundle-Version: 3.132.100.qualifier
Automatic-Module-Name: org.eclipse.swt.svg
Bundle-Name: %fragmentName
Bundle-ActivationPolicy: lazy
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: fragment
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-21
Fragment-Host: org.eclipse.swt
Require-Bundle: org.eclipse.swt
Import-Package: com.github.weisj.jsvg;version="[2.0.0,3.0.0)",
com.github.weisj.jsvg.parser;version="[2.0.0,3.0.0)",
com.github.weisj.jsvg.view;version="[2.0.0,3.0.0)"
Export-Package: org.eclipse.swt.svg;x-internal:=true
Provide-Capability: eclipse.swt;image.format="svg";version:Version="1.0"
Provide-Capability: osgi.serviceloader;osgi.serviceloader="org.eclipse.swt.internal.image.SVGRasterizer",
eclipse.swt;image.format="svg";version:Version="1.0"
Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)"
32 changes: 0 additions & 32 deletions bundles/org.eclipse.swt.svg/META-INF/p2.inf

This file was deleted.

11 changes: 1 addition & 10 deletions bundles/org.eclipse.swt.svg/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ source.. = src/,\
output.. = bin/
bin.includes = META-INF/,\
.,\
fragment.properties,\
plugin.properties,\
about.html
src.includes = about.html

jars.extra.classpath = platform:/plugin/org.eclipse.swt.cocoa.macosx.aarch64,\
platform:/plugin/org.eclipse.swt.cocoa.macosx.x86_64,\
platform:/plugin/org.eclipse.swt.gtk.linux.aarch64,\
platform:/plugin/org.eclipse.swt.gtk.linux.ppc64le,\
platform:/plugin/org.eclipse.swt.gtk.linux.riscv64,\
platform:/plugin/org.eclipse.swt.gtk.linux.x86_64,\
platform:/plugin/org.eclipse.swt.win32.win32.aarch64,\
platform:/plugin/org.eclipse.swt.win32.win32.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
# Contributors:
# Michael Bangas (Vector Informatik GmbH) - initial API and implementation
###############################################################################
fragmentName = SWT SVG Rendering Support
pluginName = SWT SVG Rendering Support
providerName = Eclipse.org
4 changes: 3 additions & 1 deletion bundles/org.eclipse.swt/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Export-Package:
org.eclipse.swt.events,
org.eclipse.swt.graphics,
org.eclipse.swt.internal;x-internal:=true,
org.eclipse.swt.internal.image;x-internal:=true,
org.eclipse.swt.internal.image;x-friends:="org.eclipse.swt.svg",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would need something here to wire SWT+SVG bundles usually like

Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.service loader.processor)(version>=1.0.0)(!(version>=2.0.0)))",
 osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.swt.internal.image.SVGRasterizer)";osgi.serviceloader="org.eclipse.swt.internal.image.SVGRasterizer"

(maybe make it optional if we think SVG rasterizer is really an optional feature)

Then swt.svg would need this in the manifest:

Provide-Capability: osgi.serviceloader;osgi.serviceloader="org.eclipse.swt.internal.image.SVGRasterizer";register:="org.eclipse.swt.internal.image.SVGRasterizer";type=jsvg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thank you. That's something that is required now that the SVG part is not a fragment but a separate bundle such that both use independent class loaders.

What I don't fully get is why there is now a cycle detected:

 Edge between 'Vertex{label='org.eclipse.platform:org.eclipse.swt.svg:3.132.100-SNAPSHOT'}' and 'Vertex{label='org.eclipse.platform:org.eclipse.swt:3.133.100-SNAPSHOT'}' introduces to cycle in the graph org.eclipse.platform:org.eclipse.swt:3.133.100-SNAPSHOT --> org.eclipse.platform:org.eclipse.swt.svg:3.132.100-SNAPSHOT --> org.eclipse.platform:org.eclipse.swt:3.133.100-SNAPSHOT

The SWT bundle has an (optional) requirement for the service provider capability that is provided by the SVG bundle and the SVG bundle of course requires the SWT bundle. Since the former is optional, I would have expected that this is okay. Is that against the specification?
When starting a runtime from the IDE, this all works fine. The SWT bundle starts first, as the SVG bundle depends on it. Then the SVG bundle starts and provides the service. Does that only work by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's the issue that you have reported already. I missed to link that...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the former is optional, I would have expected that this is okay

One can disable optional see https://tycho.eclipseprojects.io/doc/latest/target-platform-configuration/target-platform-configuration-mojo.html#dependency-resolution + https://github.com/eclipse-tycho/tycho/blob/main/target-platform-configuration/src/main/java/org/eclipse/tycho/target/DependencyResolutionConfiguration.java + https://github.com/eclipse-tycho/tycho/blob/main/tycho-api/src/main/java/org/eclipse/tycho/OptionalResolutionAction.java but I'm not 100% sure it is working as this feature is very seldom used

Is that against the specification?

In general the OSGi specification only define runtime behavior never compile / package behavior! Also "optional" has no meaning at compile time because you can't "optionally compile" a class so most often optional is actually mandatory to build the bundle except rare cases (e.g. pur reflection usage or case like this).

When starting a runtime from the IDE, this all works fine.

Yes runtime is easy, because there is only that all wiring must be fulfilled and there is no need for one thing being defined before the other and one can easily have cycles. But for compilation we need a strict cycle free graph of projects. Technically one would be able to compile such setups as one big project, but this conflicts of course with the maven reactor project concept. Of course it won't be a problem at all if swt + swt.svg would be compiled independently ... so it is not always easy.

Does that only work by accident?

No it does work exactly as one would suppose it to work, we have similar problems with p2.inf and some tricks to avoid it but not have such thing (yet) for the generic requirement/capability model of OSGi, what would generally would be superior to the p2.inf approach because p2.inf only works at installation time (thats also why I proposed this in the first place instead of rely on p2.inf or features).

So to summarize: Yes it should work and we have good reasons to make it work and I hope to find some free time to implement something soon (so don't hesitate to ping me if I forget :-)

org.eclipse.swt.layout,
org.eclipse.swt.opengl,
org.eclipse.swt.printing,
Expand All @@ -25,3 +25,5 @@ Export-Package:
Eclipse-ExtensibleAPI: true
Bundle-RequiredExecutionEnvironment: JavaSE-21
Automatic-Module-Name: org.eclipse.swt
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.processor)(version>=1.0.0)(!(version>=2.0.0)))",
osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.swt.internal.image.SVGRasterizer)";resolution:=optional
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
<module>examples/org.eclipse.swt.examples.ole.win32</module>
<module>examples/org.eclipse.swt.examples.views</module>
<module>tests/org.eclipse.swt.tests</module>
<module>tests/org.eclipse.swt.svg.tests</module>
<module>features/org.eclipse.swt.tools.feature</module>
</modules>
</project>
11 changes: 11 additions & 0 deletions tests/org.eclipse.swt.svg.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
41 changes: 41 additions & 0 deletions tests/org.eclipse.swt.svg.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.swt.svg.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<type>1</type>
<locationURI>SHARED_SETTINGS/org.eclipse.jdt.core.prefs</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>SHARED_SETTINGS</name>
<value>$%7BPARENT-2-PROJECT_LOC%7D/examples/.settings_shared</value>
</variable>
</variableList>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
12 changes: 12 additions & 0 deletions tests/org.eclipse.swt.svg.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse SWT Tests SVG
Fragment-Host: org.eclipse.swt.svg
Bundle-SymbolicName: org.eclipse.swt.svg.tests
Bundle-Version: 3.0.0.qualifier
Automatic-Module-Name: org.eclipse.swt.svg.tests
Bundle-RequiredExecutionEnvironment: JavaSE-21
Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"

7 changes: 7 additions & 0 deletions tests/org.eclipse.swt.svg.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

pom.model.packaging = eclipse-test-plugin
pom.model.property.testClass = org.eclipse.swt.svg.AllSVGTests
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2026 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.swt.svg;

import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@Suite
@SelectClasses({ //
JSVGRasterizerTest.class, //
})
public class AllSVGTests {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
* Contributors:
* Yatta Solutions - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.tests.junit;
package org.eclipse.swt.svg;

import static org.eclipse.swt.tests.junit.SwtTestUtil.assertSWTProblem;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand All @@ -23,10 +22,8 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.svg.JSVGRasterizer;
import org.junit.jupiter.api.Test;

@SuppressWarnings("restriction")
class JSVGRasterizerTest {

private final JSVGRasterizer rasterizer = new JSVGRasterizer();
Expand All @@ -51,13 +48,7 @@ void testRasterizeWithZoom() {

@Test
void testRasterizeWithZoomNegative() {
try {
rasterizer.rasterizeSVG(svgStream(svgString), -100);

} catch (IllegalArgumentException e) {
assertSWTProblem("Incorrect exception thrown for negative zoom", SWT.ERROR_INVALID_ARGUMENT, e);
}

assertThrows(IllegalArgumentException.class, () -> rasterizer.rasterizeSVG(svgStream(svgString), -100));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class AllNonBrowserTests {
AllWidgetTests.class, //
// Rest of tests alphabetically
DPIUtilTests.class, //
JSVGRasterizerTest.class, //
Test_org_eclipse_swt_accessibility_Accessible.class, //
Test_org_eclipse_swt_accessibility_AccessibleControlEvent.class, //
Test_org_eclipse_swt_accessibility_AccessibleEvent.class, //
Expand Down
Loading