Skip to content

Commit

Permalink
Fix runtime crash on Intel Mac's when LWJGL has been updated. Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 authored Oct 15, 2023
1 parent f73f596 commit bc3c51b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public ApplicationResult getApplicationResult() {
return ApplicationResult.MUST_APPLY;
}

if (platform.getOperatingSystem().isMacOS() && context.isJava19OrLater() && !context.supportsJava19OrLater()) {
// Apply when LWJGL has been updated on MacOS to support Java 19
return ApplicationResult.MUST_APPLY;
}

// A developer can opt into this
return ApplicationResult.CAN_APPLY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class LWJGL3UpgradeLibraryProcessorTest extends LibraryProcessorTest {
"1.12.2" || LibraryProcessor.ApplicationResult.DONT_APPLY // Not LWJGL 3
}

// TODO once Minecraft updates to LWJGL 3.3.2 add a new test for this that uses that mc version
def "Apply when using Java 19 or later"() {
when:
def (_, context) = getLibs("1.19.4", PlatformTestUtils.WINDOWS_X64, version)
Expand All @@ -66,6 +65,21 @@ class LWJGL3UpgradeLibraryProcessorTest extends LibraryProcessorTest {
JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY
}

def "Dont apply when using Java 19 or later on supported LWJGL version"() {
when:
def (_, context) = getLibs("1.20.2", PlatformTestUtils.WINDOWS_X64, version)
def processor = new LWJGL3UpgradeLibraryProcessor(PlatformTestUtils.WINDOWS_X64, context)
then:
processor.applicationResult == result

where:
version || result
JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY
}

def "Apply when adding macOS ARM64 support"() {
when:
def (_, context) = getLibs(id, PlatformTestUtils.MAC_OS_ARM64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package net.fabricmc.loom.test.unit.library.processors

import org.gradle.api.JavaVersion

import net.fabricmc.loom.configuration.providers.minecraft.library.Library
import net.fabricmc.loom.configuration.providers.minecraft.library.LibraryProcessor
import net.fabricmc.loom.configuration.providers.minecraft.library.processors.LoomNativeSupportLibraryProcessor
Expand All @@ -48,6 +50,51 @@ class LoomNativeSupportLibraryProcessorTest extends LibraryProcessorTest {
"1.12.2" || LibraryProcessor.ApplicationResult.DONT_APPLY // Not LWJGL 3
}

def "Apply when using Java 19 or later on macOS"() {
when:
def (_, context) = getLibs("1.19.4", PlatformTestUtils.MAC_OS_X64, version)
def processor = new LoomNativeSupportLibraryProcessor(PlatformTestUtils.MAC_OS_X64, context)
then:
processor.applicationResult == result

where:
version || result
JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.MUST_APPLY
JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.MUST_APPLY
JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY
}

def "Dont apply when using Java 19 or later on macOS with supported version"() {
when:
def (_, context) = getLibs("1.20.2", PlatformTestUtils.MAC_OS_X64, version)
def processor = new LoomNativeSupportLibraryProcessor(PlatformTestUtils.MAC_OS_X64, context)
then:
processor.applicationResult == result

where:
version || result
JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY
}

def "Can apply when using Java 19 or later on other platforms"() {
when:
def (_, context) = getLibs("1.19.4", PlatformTestUtils.WINDOWS_ARM64, version)
def processor = new LoomNativeSupportLibraryProcessor(PlatformTestUtils.WINDOWS_ARM64, context)
then:
processor.applicationResult == result

where:
version || result
JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY
JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY
}

def "Can apply on other platforms"() {
when:
def (_, context) = getLibs(id, platform)
Expand Down

0 comments on commit bc3c51b

Please sign in to comment.