From fd5408d11f08ad8277c8d0ba68f55379c7d5b95b Mon Sep 17 00:00:00 2001 From: squid233 <60126026+squid233@users.noreply.github.com> Date: Wed, 8 Jan 2025 08:46:48 +0800 Subject: [PATCH] fix: fix OverrunGL::actualVersion --- buildSrc/src/main/kotlin/module.conventions.gradle.kts | 3 ++- .../overrungl.core/src/main/java/overrungl/OverrunGL.java | 2 +- .../src/main/java/overrungl/internal/RuntimeHelper.java | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/module.conventions.gradle.kts b/buildSrc/src/main/kotlin/module.conventions.gradle.kts index f69486b9..2bc9ff52 100644 --- a/buildSrc/src/main/kotlin/module.conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/module.conventions.gradle.kts @@ -69,10 +69,11 @@ extensions.configure("java") { } tasks.named("jar") { + val split = projVersion.split('.', limit = 3) manifest.attributes( "Specification-Title" to projName, "Specification-Vendor" to "Overrun Organization", - "Specification-Version" to projVersion.split('.', limit = 2)[0], + "Specification-Version" to "${split[0]}.${split[1]}", "Implementation-Title" to projName, "Implementation-Vendor" to "Overrun Organization", "Implementation-Version" to projVersion diff --git a/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java b/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java index f553135c..a8474ad8 100644 --- a/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java +++ b/modules/overrungl.core/src/main/java/overrungl/OverrunGL.java @@ -62,7 +62,7 @@ private OverrunGL() { */ public static String actualVersion() { try { - final URL url = ((URLClassLoader) OverrunGL.class.getClassLoader()).findResource("META-INF/MANIFEST.MF"); + final URL url = OverrunGL.class.getResource("/META-INF/MANIFEST.MF"); if (url == null) { return VERSION; } diff --git a/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java b/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java index ef16dfd7..3949b970 100644 --- a/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java +++ b/modules/overrungl.core/src/main/java/overrungl/internal/RuntimeHelper.java @@ -37,7 +37,6 @@ public final class RuntimeHelper { private static final Path tmpdir = Path.of(System.getProperty("java.io.tmpdir")) .resolve("overrungl" + System.getProperty("user.name")); - private static final StackWalker STACK_WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); private static final Linker LINKER = Linker.nativeLinker(); /** @@ -72,7 +71,7 @@ public static String unknownToken(String description, int token) { /** * Loads a library from classpath or local. * - * @param module the module name. e.x. {@code glfw} + * @param module the module name. e.g. {@code glfw} * @param basename the basename of the library (without file extensions) * @param version the version suffix * @return the {@link SymbolLookup} @@ -107,7 +106,7 @@ public static SymbolLookup load(String module, String basename, String version) if (!Files.exists(libFile)) { // Extract final String fromPath = module + "/" + os.familyName() + "-" + Architecture.current() + "/" + path; - try (var is = STACK_WALKER.getCallerClass().getClassLoader().getResourceAsStream(fromPath)) { + try (var is = ClassLoader.getSystemResourceAsStream(fromPath)) { Files.copy(Objects.requireNonNull(is, "File not found in classpath: " + fromPath), libFile); } catch (Exception e) { throw new IllegalStateException("Couldn't load file: " + libFile.toAbsolutePath().normalize() + " or " + localFile.toAbsolutePath().normalize() + "; try setting -Doverrungl.natives to a valid path", e);