hex007 / freej2me

A free J2ME emulator with libretro, awt and sdl2 frontends.
Other
500 stars 78 forks source link

Crash due to unable to find startApp method #6

Closed uuksu closed 7 years ago

uuksu commented 7 years ago

Game is Fantasy Warrior 2 - Evil (fantasy_warrior_2.evil.jar).

Steps to reproduce:

  1. Launch FreeJ2ME (freej2me.jar)
  2. Select fantasy_warrior_2.evil.jar
  3. Game crashes and FreeJ2ME exits

I debugged this briefly and it seems that when loading jar it could not find startApp method. I investigated Fantasy Warrior jar with jadx and it seems that main class (FantasyWarrior2_Evil) inherits GameMIDlet class that should have startApp method. Method has following signature:

protected final void startApp()

I can share game privately but it should be also easy to find it using Google.

hex007 commented 7 years ago

Try other emulators and see if any of them work. Doesnt work on microemu btw.

Might be an implementation bug or dependency issue.

uuksu commented 7 years ago

KEmulator seems to run to run it fine.

hex007 commented 7 years ago

Great. will check it out soon.

Please post a screenshot so I know I am working with the same game file

uuksu commented 7 years ago

java_2017-09-25_11-22-15

If this was what you meant, here we go. If it was something else please tell and I'll provide!

Florin9doi commented 7 years ago

https://pastebin.com/9UwzxmCi

diff --git a/src/org/recompile/mobile/MIDletLoader.java b/src/org/recompile/mobile/MIDletLoader.java
index 65c93a6..74d8e9a 100644
--- a/src/org/recompile/mobile/MIDletLoader.java
+++ b/src/org/recompile/mobile/MIDletLoader.java
@@ -130,8 +130,21 @@ public class MIDletLoader extends URLClassLoader
                {
                        System.out.println("Can't Find startApp Method");
                        e.printStackTrace();
-                       System.exit(0);
-                       return;
+
+
+                       try
+                       {
+                               mainClass = loadClass(mainClass.getSuperclass().getName(), true);
+                               start = mainClass.getDeclaredMethod("startApp");
+                               start.setAccessible(true);
+                       }
+                       catch (Exception f)
+                       {
+                               System.out.println("Can't Find startApp Method");
+                               f.printStackTrace();
+                               System.exit(0);
+                               return;
+                       }
                }

                try
hex007 commented 7 years ago

@recompileorg any suggestions?

recompileorg commented 7 years ago

I'll decompile it later and have a look. From what was described, it's most likely a problem with the midlet loader.

hex007 commented 7 years ago

@recompileorg @Florin9doi 's patch works. Is there a better way to incorporate it?

recompileorg commented 7 years ago

Ed: Bah, didn't pay enough attention.

It looks good. It only checks the super class if the startApp method can't be found on the class named in the manifest. It's a nice, simple, fix.

hex007 commented 7 years ago

@uuksu It runs well on testing. Can you make a video of like a 5 min gameplay with kemulator. I dont have windows and cannot test the game.

screenshot from 2017-09-25 10-34-21

uuksu commented 7 years ago

I actually didn't play very far earlier, I just tested that it starts. It seems that with KEmulator I can get to about same where you are in your screenshot but when entering battle by touching the bug game gets stuck.

https://youtu.be/jN9zyJt6Cio

hex007 commented 7 years ago

Yes same here. I cannot move past the battle sequence.

Although I would say that this bug has been handled. The game is just buggy

uuksu commented 7 years ago

I agree. Main concern was that it was not loaded at all and now as it works I think this can be closed.