Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reference to internal class #393

Merged
merged 5 commits into from
Jun 30, 2024

Conversation

fourlastor
Copy link
Contributor

This PR removes references to the class com.apple.eio.FileManager as it's part of an internal API, and creates problems when trying to package an application via jlink. We notice this being a problem in the libgdx discord server a couple times, with the following error:

Error: Module JDK removed internal API/com.apple.eio not found
java.lang.module.FindException: Module JDK removed internal API/com.apple.eio not found
        at java.base/java.lang.module.Resolver.findFail(Resolver.java:893)
        at java.base/java.lang.module.Resolver.resolve(Resolver.java:129)
        at java.base/java.lang.module.Configuration.resolve(Configuration.java:421)
        at java.base/java.lang.module.Configuration.resolve(Configuration.java:255)
        at jdk.jlink/jdk.tools.jlink.internal.Jlink$JlinkConfiguration.resolve(Jlink.java:217)
        at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImageProvider(JlinkTask.java:536)
        at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImage(JlinkTask.java:424)
        at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:276)
        at jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:55)
        at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:33)

I also noticed a typo in the readme and fixed it

Note: I don't have an Apple computer so I couldn't try these changes there, the way I tested it was by adding a new module to the project, with the following changes:

// settings.gradle
rootProject.name = 'vis-ui'
rootProject.buildFileName = 'build.gradle'
include 'ui', 'usl'
include 'example'
// example/build.gradle
plugins {
    id("java")
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.badlogicgames.gdx:gdx:1.12.1")
    implementation("com.badlogicgames.gdx:gdx-platform:1.12.1:natives-desktop")
    implementation("com.badlogicgames.gdx:gdx-backend-lwjgl3:1.12.1")
    implementation(project(":ui"))
}
// example/src/main/java/org/example/DesktopLauncher.java
package org.example;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.HdpiMode;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.ScreenUtils;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.file.FileChooser;
import org.lwjgl.glfw.GLFW;

public class DesktopLauncher {

    public static void main(String[] arg) {
        Lwjgl3ApplicationConfiguration.getDisplayMode();
        long monitor = GLFW.glfwGetMonitors().get(0);
        float[] scaleX = new float[1];
        float[] scaleY = new float[1];
        GLFW.glfwGetMonitorContentScale(monitor, scaleX, scaleY);
        Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
        config.setForegroundFPS(60);
        config.setTitle("Game");
        config.setHdpiMode(HdpiMode.Pixels);
        setWindowedMode(config, scaleX[0], scaleY[0]);
        new Lwjgl3Application(new GdxGame(), config);
    }

    private static void setWindowedMode(Lwjgl3ApplicationConfiguration config, float scaleX, float scaleY) {
        int width = (int) (720 * scaleX);
        int height = (int) (450 * scaleY);
        config.setWindowedMode(width, height);
    }

    public static class GdxGame extends Game {

        private Stage stage;

        @Override
        public void create() {
            VisUI.load(VisUI.SkinScale.X2);
            stage = new Stage();
            Gdx.input.setInputProcessor(stage);
            stage.addActor(new FileChooser(FileChooser.Mode.OPEN));
        }

        @Override
        public void render() {
            super.render();
            ScreenUtils.clear(Color.BLACK);
            stage.act();
            stage.draw();
        }
    }
}

Then right clicking one of the files in the list, and picking "Show in explorer"

@fourlastor fourlastor changed the title Remove deprecated dependency Remove reference to internal class Jun 29, 2024
@kotcrab
Copy link
Owner

kotcrab commented Jun 29, 2024

It's not the same behavior but should be fine, please fix the code formatting though (to match rest of the file).
revealInFinder behaves like Desktop.getDesktop().browseFileDirectory() (added in JDK 9). We should probably use browseFileDirectory if available (since that's the actual desired behavior of this feature) and otherwise fallback to open if running on older JDK.

@fourlastor
Copy link
Contributor Author

please fix the code formatting though (to match rest of the file)

is there a gradle task for this? I don't know which parts should be changed and how, and I couldn't find it

I tried reformatting with intellij after setting the code style to the project one but it changes a lot of the file, not only the changed lines

@fourlastor
Copy link
Contributor Author

browseFileDirectory doesn't seem to work on Linux (JDK 17):

Caused by: java.lang.UnsupportedOperationException: The BROWSE_FILE_DIR action is not supported on the current platform!

@kotcrab
Copy link
Owner

kotcrab commented Jun 29, 2024

See https://github.com/kotcrab/vis-ui/blob/master/CONTRIBUTING.md#code-formatter
The primary issue is your changes are using spaces while this project uses tabs.

I tried reformatting with intellij after setting the code style to the project one

Do you mean you used the file mentioned in the above doc? It's old so I guess it's possible it's no longer compatible.

browseFileDirectory doesn't seem to work on Linux (JDK 17):

Caused by: java.lang.UnsupportedOperationException: The BROWSE_FILE_DIR action is not supported on the current platform!

That's unfortunate, should be fine to fallback to open in case of every exception then.

@kotcrab
Copy link
Owner

kotcrab commented Jun 29, 2024

It's also not supported on Windows which is pretty surprising.

@czyzby czyzby self-requested a review June 29, 2024 13:02
Copy link
Owner

@kotcrab kotcrab left a comment

Choose a reason for hiding this comment

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

Thanks

@kotcrab kotcrab merged commit 08d70d3 into kotcrab:master Jun 30, 2024
1 check passed
kotcrab added a commit that referenced this pull request Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants