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

[Native Image] ClassNotFoundException #9930

Open
2 tasks done
Ferrarisrex opened this issue Oct 21, 2024 · 8 comments
Open
2 tasks done

[Native Image] ClassNotFoundException #9930

Ferrarisrex opened this issue Oct 21, 2024 · 8 comments
Assignees

Comments

@Ferrarisrex
Copy link

Ferrarisrex commented Oct 21, 2024

Describe the Issue

I package and compile the jar using the maven native image plugin, and the output works fine on the computer that compiled it, even if i change the executables directory, however, if i put it on a different computer, I get
java.lang.ClassNotFoundException: com.sun.prism.shader.Mask_TextureSuper_Loader
i did bring all the DLL files with it, and the target computer has java 1.8

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

java version "21.0.4" 2024-07-16 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41, mixed mode, sharing)

Operating System and Version

Windows 10 22h2

Diagnostic Flag Confirmation

  • I tried the -H:ThrowMissingRegistrationErrors= flag.

Run Command

image.exe

Expected Behavior

to finish running

Actual Behavior

opens a menu, and then has the above error constantly reoutputted to the command prompt and does not continue

Steps to Reproduce

  1. Run the file

Additional Context

No response

Run-Time Log Output and Error Messages

No response

@Karm
Copy link
Contributor

Karm commented Oct 21, 2024

@Ferrarisrex Help us help you with a small reproducer, an application you can share that demonstrates this behavior. You most definitely need libraries from the GraalVM distro, not anything pulled from Java 1.8.

@Ferrarisrex
Copy link
Author

I can not reproduce the error without the code I already made, so I do not know
the app works fine on computers that compile it, but if I open up a VM of the same OS on that pc, I get that error. is there any way to make sure that the class is included in reflection? it doesn't seem to work with the automatic reflection generator

@Ferrarisrex
Copy link
Author

I tried fixing it by just copying the format of the other shaders in reflect-config.json, but that results in a InvocationTargetExcaption

@Ferrarisrex
Copy link
Author

I tried it differently, doing:
name: com.sun.prism.shader.Mask_TextureSuper_Loader
allDeclaredClasses: true
allPublicClasses: true
but it says method not found com.sun.prism.shader.Mask_TextureSuper_Loader.loadShader()

@Ferrarisrex
Copy link
Author

if I do -H:IncludeResources=".*" it works, but the file size is huge, but if i do -H:IncludeResources="com.sun.prism.shader.Mask_TextureSuper_Loader.class" it does not work

@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Oct 23, 2024
@oubidar-Abderrahim
Copy link
Member

oubidar-Abderrahim commented Oct 23, 2024

Did you try building your native-image from a jar-with-dependencies?

@Ferrarisrex
Copy link
Author

i did do that

@Ferrarisrex
Copy link
Author

Ferrarisrex commented Oct 24, 2024

i did find a workaround, you must do the following:
in your reflect-config.json you must add:
{
"name":"com.sun.prism.shader.Mask_TextureSuper_Loader",
"allDeclaredClasses":true,
"allPublicClasses":true,
"methods":[{"name":"loadShader","parameterTypes":["com.sun.prism.ps.ShaderFactory","java.io.InputStream"] }]
},

and in your pom.xml you must add:
<buildArg>-H:IncludeResources=".*/prism/.*"</buildArg>
<buildArg>-H:IncludeResources=".*/sun/scenario/effect/.*"</buildArg>

this does seem to work for other missing classes of the same flavor, such as com.sun.prism.shader.Solid_Color_Loader, just change the name in reflect-config.json
i put this together without really knowing what i was doing or how things work, so there is probably a better way to do this, please do tell if you know, but this does work well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants