Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Scripting engine missing modules when using native image #1858

Closed
Sculas opened this issue May 7, 2023 · 5 comments
Closed

[core] Scripting engine missing modules when using native image #1858

Sculas opened this issue May 7, 2023 · 5 comments
Labels
bug Core Issues in jadx-core module

Comments

@Sculas
Copy link

Sculas commented May 7, 2023

When trying to run the deobf script, I get this error:

WARN : Script execution issue: Using new faster version of JAR FS: it should make your build faster, but the new implementation is experimental
ERROR: Script execution error: Module kotlin.stdlib cannot be found in the module graph
ERROR: Script execution error: Module kotlin.script.runtime cannot be found in the module graph
ERROR: Script execution error: Module kotlin.reflect cannot be found in the module graph
ERROR: Script execution failed: deobf

If I then click on the script in the GUI and click Run, things get even worse:

Log
ERROR: Cannot access script base class 'jadx.plugins.script.runtime.JadxScriptTemplate'. Check your module classpath for missing or conflicting dependencies (deobf.jadx.kts:1:1)
ERROR: Unresolved reference: getJadxInstance (deobf.jadx.kts:3:12)
ERROR: Variable expected (deobf.jadx.kts:4:11)
ERROR: Variable expected (deobf.jadx.kts:5:11)
ERROR: Unresolved reference: emptySet (deobf.jadx.kts:5:25)
ERROR: Unresolved reference: toRegex (deobf.jadx.kts:7:26)
ERROR: Cannot infer a type for this parameter. Please specify it explicitly. (deobf.jadx.kts:9:19)
ERROR: Cannot infer a type for this parameter. Please specify it explicitly. (deobf.jadx.kts:9:25)
ERROR: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:10:2)
ERROR: Cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:12:39)
ERROR: Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:12:39)
ERROR: Cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:12:40)
ERROR: Unresolved reference: println (deobf.jadx.kts:13:4)
ERROR: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:13:54)
ERROR: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:14:4)
ERROR: Unresolved reference: println (deobf.jadx.kts:20:2)
ERROR: Cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:20:27)
ERROR: Cannot access script base class 'jadx.plugins.script.runtime.JadxScriptTemplate'. Check your module classpath for missing or conflicting dependencies (deobf.jadx.kts:1:1)
ERROR: Unresolved reference: getJadxInstance (deobf.jadx.kts:3:12)
ERROR: Variable expected (deobf.jadx.kts:4:11)
ERROR: Variable expected (deobf.jadx.kts:5:11)
ERROR: Unresolved reference: emptySet (deobf.jadx.kts:5:25)
ERROR: Unresolved reference: toRegex (deobf.jadx.kts:7:26)
ERROR: Cannot infer a type for this parameter. Please specify it explicitly. (deobf.jadx.kts:9:19)
ERROR: Cannot infer a type for this parameter. Please specify it explicitly. (deobf.jadx.kts:9:25)
ERROR: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:10:2)
ERROR: Cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:12:39)
ERROR: Cannot access built-in declaration 'kotlin.Unit'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:12:39)
ERROR: Cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:12:40)
ERROR: Unresolved reference: println (deobf.jadx.kts:13:4)
ERROR: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:13:54)
ERROR: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:14:4)
ERROR: Unresolved reference: println (deobf.jadx.kts:20:2)
ERROR: Cannot access built-in declaration 'kotlin.Int'. Ensure that you have a dependency on the Kotlin standard library (deobf.jadx.kts:20:27)

Weirdly enough, I'm able to run scripts fine when running JADX in the IDE, but not when running it standalone. I'm having this issue with my own JADX scripts as well, but this applies to any script as far as I'm aware.

@Sculas Sculas added bug Core Issues in jadx-core module labels May 7, 2023
@skylot
Copy link
Owner

skylot commented May 7, 2023

but not when running it standalone

How do you build this version?
Because I can't reproduce your issue using unstable build nor with version built by ./gradlew dist.

@Sculas
Copy link
Author

Sculas commented May 7, 2023

I just downloaded this build: https://nightly.link/skylot/jadx/workflows/build-artifacts/master/jadx-gui-1.4.7.146-5aaceee9-no-jre-win.exe
.. downloaded the deobf.jadx.kts script from GitHub and was able to reproduce it immediately.

@Sculas
Copy link
Author

Sculas commented May 7, 2023

I just realized that in all my testing, everytime I ran it standalone, it was using the native image. In the IDE, it just ran the main function. It could also very well be that scripting just doesn't work in the native image. If still needed, I'll test that in 30 mins.

@skylot
Copy link
Owner

skylot commented May 7, 2023

Oh, thanks! Looks like issue in building fat jar for that artifact, I will investigate this.
As workaround, for now, you can try using zip bundle like this.

@Sculas Sculas changed the title [core] Scripting missing modules and not working at all [core] Scripting engine missing modules when using native image May 7, 2023
@skylot
Copy link
Owner

skylot commented May 7, 2023

Issue caused by ShadowJar removing module-info.class files (check GradleUp/shadow#710) so Kotlin script compiler was unable to find modules while building new execution classpath. Also I am not sure if it is even possible to have several modules in one jar file.
As a workaround, I set Kotlin compiler to JDK release 8, so it will not use modules anymore 🤣

@skylot skylot closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants