Tennessene / jDOSBox

Java x86 emulator based on DOSBox
9 stars 1 forks source link

Diagnose exception in Java 17 #5

Closed pietrygamat closed 1 year ago

pietrygamat commented 1 year ago

When starting emulator on java 17, there is an exception I do not see when running on java 8.

java -jar launcher/target/launcher-0.74.31-SNAPSHOT-jar-with-dependencies.jar

mount c ~/Games/gog/theme-hospital
c:
c:\Hospital.exe
int eaa;int ss = CPU_Regs.reg_ssPhys.dword;CPU.CPU_Cycles-=19;/*256*/CPU.CPU_Push32(CPU_Regs.reg_esi.dword);
CPU_Regs.reg_eip+=2;
  /*255*/CPU.CPU_Push32(CPU_Regs.reg_ebp.dword);
CPU_Regs.reg_eip+=2;
  /*1e*/CPU.CPU_Push16(CPU_Regs.reg_dsVal.dword);
CPU_Regs.reg_eip+=1;
  /*29c*//* Uses Flags */if (CPU.CPU_PUSHF(true)){return RUNEXCEPTION();}
/*be*/CPU_Regs.reg_esi.word(152);
CPU_Regs.reg_eip+=5;
  /*8e*/if (CPU.CPU_SetSegGeneralDS(CPU_Regs.reg_esi.word())) {return RUNEXCEPTION();}
int ds = CPU_Regs.reg_dsPhys.dword;/*3b7*/CPU_Regs.reg_ebp.dword=CPU_Regs.reg_esp.word();
/*28d*/CPU_Regs.reg_ebp.dword=CPU_Regs.reg_ebp.dword+14;
CPU_Regs.reg_eip+=11;
  /*3b7*/CPU_Regs.reg_esi.dword=Memory.mem_readw(ss+((CPU_Regs.reg_ebp.word()+8) & 0xFFFF));
CPU_Regs.reg_eip+=5;
  /*8c*/Memory.mem_writew(ds+((CPU_Regs.reg_esi.word()+6) & 0xFFFF), CPU_Regs.reg_esVal.dword);
CPU_Regs.reg_eip+=3;
  /*8c*/Memory.mem_writew(ds+((CPU_Regs.reg_esi.word()+8) & 0xFFFF), CPU_Regs.reg_fsVal.dword);
CPU_Regs.reg_eip+=3;
  /*8c*/Memory.mem_writew(ds+((CPU_Regs.reg_esi.word()+10) & 0xFFFF), CPU_Regs.reg_gsVal.dword);
CPU_Regs.reg_eip+=3;
  /*289*/Memory.mem_writed(ds+((CPU_Regs.reg_esi.word()+28) & 0xFFFF), CPU_Regs.reg_ebx.dword);
CPU_Regs.reg_eip+=4;
  /*289*/Memory.mem_writed(ds+((CPU_Regs.reg_esi.word()+36) & 0xFFFF), CPU_Regs.reg_ecx.dword);
CPU_Regs.reg_eip+=4;
  /*289*/Memory.mem_writed(ds+((CPU_Regs.reg_esi.word()+32) & 0xFFFF), CPU_Regs.reg_edx.dword);
CPU_Regs.reg_eip+=4;
  /*289*/Memory.mem_writed(ds+((CPU_Regs.reg_esi.word()+12) & 0xFFFF), CPU_Regs.reg_edi.dword);
CPU_Regs.reg_eip+=4;
  /*287*/eaa = ds+((CPU_Regs.reg_esi.word()+40) & 0xFFFF);int val = Memory.mem_readd(eaa);Memory.mem_writed(eaa, CPU_Regs.reg_eax.dword);CPU_Regs.reg_eax.dword=val;
/*80*/Instructions.CMPB(9,CPU_Regs.reg_eax.high());
CPU_Regs.reg_eip+=7;
  /*185*//* Uses Flags */if ((Flags.lf_resb()!=0)) {CPU_Regs.reg_ip(CPU_Regs.reg_ip()+42);return Constants.BR_Link1;}CPU_Regs.reg_ip(CPU_Regs.reg_ip()+4);return Constants.BR_Link2;}
java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
        at jdos.cpu.core_dynamic.Compiler.compileMethod(Compiler.java:7452)
        at jdos.cpu.core_dynamic.Compiler.do_compile(Compiler.java:487)
        at jdos.cpu.core_dynamic.Compiler$1.run(Compiler.java:56)
        at java.base/java.lang.Thread.run(Thread.java:833)
java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (Red_Hat-17.0.8.0.7-1.fc38) (build 17.0.8+7)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.8.0.7-1.fc38) (build 17.0.8+7, mixed mode, sharing)
Tennessene commented 1 year ago

Yeah, I forgot to tell you that. That's one of the reasons JDK 17 doesn't work. Another reason is the networking was all built around Java 6 32-bit. We'll have to do a little work to fix this. I'll try to see what I can do with the networking and I'm not sure about this

Tennessene commented 1 year ago

Yeah I tried to go through the stacktrace and do exactly what you did, but I don't know as much about reflection, so something must have been still incorrect

Tennessene commented 1 year ago

I'm also not sure what to do about the networking as the version that James sent to me in an email once doesn't work and the modern version of jnetpcap requires JDK 19. What if we made our own networking system somehow? Would we just have to try to send and recieve packets?

EDIT: Whatever version is bundled now seems to work