Skip to content

[Bug]: com.github.weisj:jsvg compiles with 1.4.0 but bumped to run with 2.0.0 #6014

Description

@Baaaaaz

Describe the Bug

Was trying to get data:// icons working for custom frames and dialog icons (as a stretch goal for #4018) but found that when trying to use `SVGLoader.load(inputStream)' it was compiling okay, but at runtime raises the error:

[AWT-EventQueue-0] ERROR - java.lang.NoSuchMethodError: 'com.github.weisj.jsvg.SVGDocument com.github.weisj.jsvg.parser.SVGLoader.load(java.io.InputStream)'
java.lang.NoSuchMethodError: 'com.github.weisj.jsvg.SVGDocument com.github.weisj.jsvg.parser.SVGLoader.load(java.io.InputStream)'
        at net.rptools.maptool.client.ui.htmlframe.HTMLFrameFactory.renderSvg(HTMLFrameFactory.java:360)
        at net.rptools.maptool.client.ui.htmlframe.HTMLFrameFactory.getSvgIcon(HTMLFrameFactory.java:374)
        at net.rptools.maptool.client.ui.htmlframe.HTMLFrameFactory.getScaledImageIcon(HTMLFrameFactory.java:393)
        at net.rptools.maptool.client.ui.htmlframe.HTMLFrame.updateFrameIcon(HTMLFrame.java:350)
        at net.rptools.maptool.client.ui.htmlframe.HTMLFrame.setIcon(HTMLFrame.java:334)
...

Doing a bit of digging it seems that it is getting bumped at runtime to version 2.0.0 which has a different method signature (see additional context information below).

There is already the code maintenance PR #5661 to update this dependency , but this ticket highlights a development issue.

To Reproduce

Develop something that uses valid com.github.weisj.jsvg 1.4.0 syntax e.g. SVGLoader.load(inputStream).
See it compiles okay.
Errors when called at runtime.

Expected Behaviour

Can compile and run against the same external dependency versions.

Screenshots

No response

MapTool Info

Develop

Desktop

windows, intellij idea

Additional Context

VERSION AT RUNTIME

Code:

System.out.println(SVGLoader.class.getProtectionDomain()
                .getCodeSource()
                .getLocation());

Runtime Result:

... /.gradle/caches/modules-2/files-2.1/com.github.weisj/jsvg/2.0.0/f65d5c3beed92a2d6cdc666185c3e751b887032f/jsvg-2.0.0.jar

AVAILABLE METHODS AT RUNTIME

Code:

        for (var method : SVGLoader.class.getDeclaredMethods()) {
            System.out.println(method);
        }

Runtime Result:

public com.github.weisj.jsvg.SVGDocument com.github.weisj.jsvg.parser.SVGLoader.load(java.io.InputStream,java.net.URI,com.github.weisj.jsvg.parser.LoaderContext)
public com.github.weisj.jsvg.SVGDocument com.github.weisj.jsvg.parser.SVGLoader.load(com.github.weisj.jsvg.parser.XMLInput,java.net.URI,com.github.weisj.jsvg.parser.LoaderContext)
public com.github.weisj.jsvg.SVGDocument com.github.weisj.jsvg.parser.SVGLoader.load(java.net.URL)
public com.github.weisj.jsvg.SVGDocument com.github.weisj.jsvg.parser.SVGLoader.load(java.net.URL,com.github.weisj.jsvg.parser.LoaderContext)

IDE DEPENDENCY CHECK

Console:

./gradlew dependencyInsight --dependency com.github.weisj:jsvg

IDE Output:

> Task :dependencyInsight
com.github.weisj:jsvg:1.4.0
  Variant compile:
    | Attribute Name                 | Provided | Requested    |
    |--------------------------------|----------|--------------|
    | org.gradle.status              | release  |              |
    | org.gradle.category            | library  | library      |
    | org.gradle.libraryelements     | jar      | classes      |
    | org.gradle.usage               | java-api | java-api     |
    | org.gradle.dependency.bundling |          | external     |
    | org.gradle.jvm.environment     |          | standard-jvm |
    | org.gradle.jvm.version         |          | 21           |

com.github.weisj:jsvg:1.4.0
\--- compileClasspath

IDE RUNTIME DEPENDENCY CHECK

IDE Console:

./gradlew dependencyInsight --configuration runtimeClasspath --dependency com.github.weisj:jsvg

IDE Output:

> Task :dependencyInsight
com.github.weisj:jsvg:2.0.0
  Variant runtime:
    | Attribute Name                 | Provided     | Requested    |
    |--------------------------------|--------------|--------------|
    | org.gradle.status              | release      |              |
    | org.gradle.category            | library      | library      |
    | org.gradle.libraryelements     | jar          | jar          |
    | org.gradle.usage               | java-runtime | java-runtime |
    | org.gradle.dependency.bundling |              | external     |
    | org.gradle.jvm.environment     |              | standard-jvm |
    | org.gradle.jvm.version         |              | 21           |
   Selection reasons:
      - By conflict resolution: between versions 2.0.0 and 1.4.0

com.github.weisj:jsvg:2.0.0
\--- com.formdev:flatlaf-extras:3.6.1
     \--- runtimeClasspath

com.github.weisj:jsvg:1.4.0 -> 2.0.0
+--- runtimeClasspath
\--- project :common
     +--- runtimeClasspath
     \--- project :dicelib
          \--- runtimeClasspath

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions