Skip to content

Commit a9586da

Browse files
committed
Fix: don't test JIT26CreateRegionLegacy more than once, add build and code assertions
1 parent dd10f21 commit a9586da

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

JavaApp/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ TARGETS := $(TARGETS:$(SOURCEDIR)/%=$(OUTPUTDIR)/%.jar)
1212
JCFLAGS := -cp "$(subst $() $(),:,$(wildcard $(SOURCEDIR)/*/):$(wildcard libs/*/*.jar))" -XDignore.symbol.file
1313

1414
all: $(TARGETS)
15+
16+
# Sometimes the CI produces empty class file resulting in broken jar, so we check and abort here
17+
check_empty_classes:
18+
@set -e
19+
@echo "Checking for empty class files"
20+
$(eval EMPTY_CLASSES := $(shell find $(OUTPUTDIR) -name '*.class' -size 0))
21+
@if [ -n "$(EMPTY_CLASSES)" ]; then \
22+
echo "Error: found empty class files in $@: $(EMPTY_CLASSES)"; \
23+
exit 1; \
24+
fi
1525

1626
# Rules for building java class
1727
$(CLASSES): $(OUTPUTDIR)/%.class: $(SOURCEDIR)/%.java
@@ -23,12 +33,12 @@ $(CLASSES): $(OUTPUTDIR)/%.class: $(SOURCEDIR)/%.java
2333
@$(BOOTJDK)/javac $(JCFLAGS) -d $(OUTPUTDIR)/classes $<
2434
@cp $(@:$(OUTPUTDIR)/$(TARGET)/%.class=$(OUTPUTDIR)/classes/%*.class) $(dir $@)/
2535

26-
$(OUTPUTDIR)/launcher.jar: $(CLASSES)
36+
$(OUTPUTDIR)/launcher.jar: $(CLASSES) check_empty_classes
2737
@set -e
2838
@echo "Creating $@"
2939
@$(BOOTJDK)/jar -cf $@ -C $(basename $@) .
3040

31-
$(OUTPUTDIR)/lwjgl.jar: $(CLASSES)
41+
$(OUTPUTDIR)/lwjgl.jar: $(CLASSES) check_empty_classes
3242
@set -e
3343
@echo "Creating $@"
3444
@mkdir -p $(OUTPUTDIR)/lwjgl_lib

Natives/JavaLauncher.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
104104
BOOL requiresTXMWorkaround = DeviceRequiresTXMWorkaround();
105105
BOOL jit26AlwaysAttached = getPrefBool(@"debug.debug_always_attached_jit");
106106
if (requiresTXMWorkaround) {
107-
void *result = JIT26CreateRegionLegacy(getpagesize());
107+
static void *result;
108+
if(!result) result = JIT26CreateRegionLegacy(getpagesize());
108109
if ((uint32_t)result != 0x690000E0) {
109110
munmap(result, getpagesize());
110111
// we can't continue since legacy script only allows calling breakpoint once
@@ -121,7 +122,7 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
121122
}
122123
}
123124
[NSFileManager.defaultManager copyItemAtPath:inBundleScriptPath toPath:[NSString stringWithFormat:@"%s/UniversalJIT26.js", getenv("POJAV_HOME")] error:nil];
124-
showDialog(localize(@"Error", nil), @"Support for legacy script has been removed. Please switch to Universal JIT script. To import it, long-press on Amethyst when enabling JIT in StikDebug and tap \"Assign Script\", then go to Amethyst's Documents directory and pick it.");
125+
showDialog(localize(@"Error", nil), @"Support for legacy script has been removed. Please switch to Universal JIT script. To import it, long-press on Amethyst when enabling JIT in StikDebug and tap \"Assign Script\", then go to Amethyst's Documents directory and pick it. (on sideloaded StikDebug, the builtin script is named Amethyst-MeloNX.js)");
125126
[PLLogOutputView handleExitCode:1];
126127
return 1;
127128
}
@@ -142,6 +143,7 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
142143
BOOL launchJar = NO;
143144
NSString *gameDir;
144145
NSString *defaultJRETag;
146+
NSCAssert(launchTarget, @"Unexpected nil launchTarget");
145147
if ([launchTarget isKindOfClass:NSDictionary.class]) {
146148
// Get preferred Java version from current profile
147149
int preferredJavaVersion = [PLProfiles resolveKeyForCurrentProfile:@"javaVersion"].intValue;

Natives/LauncherNavigationController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
373373

374374
self.progressViewMain.observedProgress = nil;
375375
if (self.task.metadata) {
376+
__block NSDictionary *metadata = self.task.metadata;
376377
[self invokeAfterJITEnabled:^{
377-
UIKit_launchMinecraftSurfaceVC(self.view.window, self.task.metadata);
378+
UIKit_launchMinecraftSurfaceVC(self.view.window, metadata);
378379
}];
379380
} else {
380381
[self reloadProfileList];

0 commit comments

Comments
 (0)