judovana / java-runtime-decompiler

GNU General Public License v3.0
68 stars 14 forks source link

compile parameters are not passed to cli and fsvm shodl not throw with system classes on #230

Closed mkoncek closed 2 years ago

mkoncek commented 2 years ago

Compile tool according to instructions does not work (because of bytecode extraction inside CPLC)

./start.sh -compile ...
mkoncek commented 2 years ago

After fixing it, the readme should also be updated to refer to existing namespace.

mkoncek commented 2 years ago

Reproducer:

$ ./start.sh -decompile ~/.m2/repository/io/github/mkoncek/classpathless-compiler/2.1/classpathless-compiler-2.1.jar Cfr  '.*'  -saveas /tmp/cplc -savelike dir

...

$ ./start.sh -compile -cp ~/.m2/repository/io/github/mkoncek/classpathless-compiler/2.1/classpathless-compiler-2.1.jar /tmp/cplc/io/github/mkoncek/classpathless/impl/LoggingSwitch.java -savelike fqn -saveas .
java.lang.RuntimeException: Agent returned error response 'java.lang.RuntimeException: java.io.IOException: java.util.stream.Stream not found on CP' for request 'BYTES\njava.util.stream.Stream'.
        at org.jrd.backend.core.DecompilerRequestReceiver.getResponse(DecompilerRequestReceiver.java:152)
        at org.jrd.backend.core.DecompilerRequestReceiver.getByteCodeAction(DecompilerRequestReceiver.java:199)
        at org.jrd.backend.core.DecompilerRequestReceiver.processRequest(DecompilerRequestReceiver.java:78)
        at org.jrd.frontend.frame.main.DecompilationController.submitRequest(DecompilationController.java:550)
        at org.jrd.backend.data.Cli.obtainClass(Cli.java:808)
        at org.jrd.backend.communication.RuntimeCompilerConnector$JrdClassesProvider.getClass(RuntimeCompilerConnector.java:44)
        at io.github.mkoncek.classpathless.util.BytecodeExtractor.extractDependenciesImpl(BytecodeExtractor.java:340)
        at io.github.mkoncek.classpathless.util.BytecodeExtractorAccessor.extractDependenciesImpl(BytecodeExtractorAccessor.java:28)
        at io.github.mkoncek.classpathless.impl.CompilerJavac.compileClass(CompilerJavac.java:87)
        at org.jrd.backend.data.Cli.compile(Cli.java:407)
        at org.jrd.backend.data.Cli.consumeCli(Cli.java:211)
        at org.jrd.backend.data.Main.main(Main.java:20)
Initialization of class 'java.util.stream.Stream' successful.
java.lang.RuntimeException: Agent returned error response 'java.lang.RuntimeException: java.io.IOException: java.util.stream.Stream not found on CP' for request 'BYTES\njava.util.stream.Stream'.
        at org.jrd.backend.core.DecompilerRequestReceiver.getResponse(DecompilerRequestReceiver.java:152)
        at org.jrd.backend.core.DecompilerRequestReceiver.getByteCodeAction(DecompilerRequestReceiver.java:199)
        at org.jrd.backend.core.DecompilerRequestReceiver.processRequest(DecompilerRequestReceiver.java:78)
        at org.jrd.frontend.frame.main.DecompilationController.submitRequest(DecompilationController.java:550)
        at org.jrd.backend.data.Cli.obtainClass(Cli.java:808)
        at org.jrd.backend.communication.RuntimeCompilerConnector$JrdClassesProvider.getClass(RuntimeCompilerConnector.java:54)
        at io.github.mkoncek.classpathless.util.BytecodeExtractor.extractDependenciesImpl(BytecodeExtractor.java:340)
        at io.github.mkoncek.classpathless.util.BytecodeExtractorAccessor.extractDependenciesImpl(BytecodeExtractorAccessor.java:28)
        at io.github.mkoncek.classpathless.impl.CompilerJavac.compileClass(CompilerJavac.java:87)
        at org.jrd.backend.data.Cli.compile(Cli.java:407)
        at org.jrd.backend.data.Cli.consumeCli(Cli.java:211)
        at org.jrd.backend.data.Main.main(Main.java:20)
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Classes couldn't be loaded.Do you have agent configured?On JDK 9 and higher, did you run the target process with '-Djdk.attach.allowAttachSelf=true'?
        at io.github.mkoncek.classpathless.impl.CompilerJavac.compileClass(CompilerJavac.java:142)
        at org.jrd.backend.data.Cli.compile(Cli.java:407)
        at org.jrd.backend.data.Cli.consumeCli(Cli.java:211)
        at org.jrd.backend.data.Main.main(Main.java:20)
Caused by: java.lang.RuntimeException: Classes couldn't be loaded.Do you have agent configured?On JDK 9 and higher, did you run the target process with '-Djdk.attach.allowAttachSelf=true'?
        at org.jrd.backend.data.Cli.obtainClass(Cli.java:813)
        at org.jrd.backend.communication.RuntimeCompilerConnector$JrdClassesProvider.getClass(RuntimeCompilerConnector.java:54)
        at io.github.mkoncek.classpathless.util.BytecodeExtractor.extractDependenciesImpl(BytecodeExtractor.java:340)
        at io.github.mkoncek.classpathless.util.BytecodeExtractorAccessor.extractDependenciesImpl(BytecodeExtractorAccessor.java:28)
        at io.github.mkoncek.classpathless.impl.CompilerJavac.compileClass(CompilerJavac.java:87)
        ... 3 more
judovana commented 2 years ago
 sh images/target/runtime-decompiler-6.0-0.pre.1-with-decompilers/start.sh  -compile -cp  ~/.m2/repository/io/github/mkoncek/classpathless-compiler/2.1/classpathless-compiler-2.1.jar:/usr/lib/jvm/java-1.8.0/jre/lib/rt.jar:/home/jvanek/.m2/repository/io/github/mkoncek/classpathless-compiler-api/2.1/classpathless-compiler-api-2.1.jar  ~/io.github.mkoncek.classpathless.impl.LoggingSwitch.java  -savelike fqn -saveas .
Saved: ./io.github.mkoncek.classpathless.impl.LoggingSwitch$Null.class
Saved: ./io.github.mkoncek.classpathless.impl.LoggingSwitch.class

In case of FS, yo are responsibel for your classpath. Youtr exmaple works agaisnt runtime live cp.

judovana commented 2 years ago

Hower...

 sh images/target/runtime-decompiler-6.0-0.pre.1-with-decompilers/start.sh  -compile -cp  ~/.m2/repository/io/github/mkoncek/classpathless-compiler/2.1/classpathless-compiler-2.1.jar:/home/jvanek/.m2/repository/io/github/mkoncek/classpathless-compiler-api/2.1/classpathless-compiler-api-2.1.jar  ~/io.github.mkoncek.classpathless.impl.LoggingSwitch.java  -savelike fqn -saveas .
java.lang.RuntimeException: Agent returned error response 'java.lang.RuntimeException: java.io.IOException: java.util.stream.Stream not found on CP' for request 'BYTES\njava.util.stream.Stream'.
    at org.jrd.backend.core.DecompilerRequestReceiver.getResponse(DecompilerRequestReceiver.java:152)
    at org.jrd.backend.core.DecompilerRequestReceiver.getByteCodeAction(DecompilerRequestReceiver.java:199)

shold be fixable by use hsot classes - so either jrd is not reading that withc, or cpcl is using it wrong.

judovana commented 2 years ago

confirmed. CLI do not read the config.

judovana commented 2 years ago

even after passing proper hostClasses to cplc, the host system classes are nto used in case of fs-vm. => bug in cplc

judovana commented 2 years ago

https://github.com/pmikova/java-runtime-decompiler/commit/a79f0b4d71c1e8c4c8ccf864f18e6627fd7e18fe https://github.com/pmikova/java-runtime-decompiler/commit/4d9ab4d12d21f38391d745c063b6de234c0a592f