bytecode-viewer icon indicating copy to clipboard operation
bytecode-viewer copied to clipboard

Javap disassembler requires tools.jar which is not available in Java 9+

Open BomBardyGamer opened this issue 3 years ago • 6 comments

The tools.jar, along with this entire structure of the JDK, was removed in Java 9, in favour of using modules instead, meaning using tools.jar is no longer an option for these newer Java versions. I don't know what the solution is at the moment, but if I find one before you do, I will update this issue with what I found.

BomBardyGamer avatar Feb 02 '22 10:02 BomBardyGamer

Basically a duplicate of #356. I already tried fixing this issue, but at the moment, I also don't see a solution.

ThexXTURBOXx avatar Feb 04 '22 08:02 ThexXTURBOXx

Ah okay. Yeah, looks like it's now part of the jdk.jdeps module, but that isn't exported since it's internal. That's a shame.

BomBardyGamer avatar Feb 04 '22 08:02 BomBardyGamer

Yes, that's true. Also, it should give you a warning if Javap is not available because of this: https://github.com/Konloch/bytecode-viewer/commit/c8af835fb51050c1cf252a883542e7e4836d9373 Is there any error message for you?

ThexXTURBOXx avatar Feb 04 '22 08:02 ThexXTURBOXx

Well, the way I was trying to use javap was by trying to select it as one of the view panes, in which it would prompt me to select the tools JAR, and not let me out of the menu until I selected something, and if I selected something other than what it wanted, it would give me an error, likely saying it wasn't a JAR.

TL; DR I never got a warning about using javap on Java 16+

BomBardyGamer avatar Feb 04 '22 08:02 BomBardyGamer

On newer Java versions supporting modules, you need to use the file ${JAVA_HOME}/jmods/jdk.deps.jmod file instead of the tools.jar. In that case, this should definetly made more clear and I'm gonna note that as a TODO. Maybe, we should just detect the major JDK version being used and if it is 8 or less, you should be prompted to select the tools.jar file, otherwise the jdk.deps.jmod file. When using the above approach, you should get this warning instead when using Java 16 and beyond (using the jdk.deps.jmod file, you should be able to use Javap at least until Java 15): grafik

ThexXTURBOXx avatar Feb 04 '22 09:02 ThexXTURBOXx

Alright. I will try that, though I doubt it'll help me much, since I'm working with Java 17 and beyond. It is unfortunate that tools like this are no longer accessible in these newer Java versions. I hope that the built-in bytecode reader will do me good enough though. I was only interested in using javap through this program because I'm writing a Java virtual machine, and I need a lower level representation of the bytecode. Anyway, thanks for your help.

BomBardyGamer avatar Feb 04 '22 09:02 BomBardyGamer