fury icon indicating copy to clipboard operation
fury copied to clipboard

feat(java): Add ForyFeature for GraalVM Native Image

Open mengnankkkk opened this issue 2 months ago • 7 comments

Why?

Reflective access to private constructors in the GraalVM Native Image environment is limited. ObjectCreator failures return the wrong type, causing a ClassCastException. Lack of friendly GraalVM error messages.

What does this PR do?

Added GraalVM environment detection and special processing, optimized ObjectCreator implementation, and added unit tests

Related issues

Close #2697

Does this PR introduce any user-facing change?

  • [x] Does this PR introduce any public API change?
  • [x] Does this PR introduce any binary protocol compatibility change?

Benchmark

mengnankkkk avatar Oct 04 '25 15:10 mengnankkkk

ParentNoArgCtrObjectCreator should be able to generate a constructor of parent class to create instance of subclass using jdk.internal.reflect.ReflectionFactory. It's strange why it can't work

chaokunyang avatar Oct 06 '25 16:10 chaokunyang

I was wrong. I should not use unsafe to escape this problem. I should use GraalVM's reachability metadata to solve the problem of ReflectionFactory.

mengnankkkk avatar Oct 07 '25 07:10 mengnankkkk

What should I do? I always encounter a configuration problem. When running in the graalvm environment, there is always a problem of native-image command parsing error. What should I do? I have tried many methods (crying)

mengnankkkk avatar Oct 24 '25 05:10 mengnankkkk

image you can make it use Unsafe for object allocation too when running in graalvm

chaokunyang avatar Oct 24 '25 06:10 chaokunyang

@chaokunyang I'm very sorry. My current coding skills aren't enough to completely fix this bug, and I haven't passed the CI test. Could you please make some changes on my branch to fix this bug? I've tried many methods, but the files are messed up. I'm sorry that after nearly two weeks, I still haven't solved this bug. I'm very sorry. Could you please refactor and upgrade my messy code?

mengnankkkk avatar Oct 25 '25 14:10 mengnankkkk

Hi @mengnankkkk, thanks for your hard work and for letting me know the situation. I understand that you’ve spent quite a bit of time on this bug, and I appreciate the effort you’ve put in.

I’ll take a look at your branch, refactor the code, and work on fixing the bug so we can get the CI tests to pass. Don’t worry about the current state — debugging can be tricky, and each attempt helps us better understand the problem.

Thanks again for your contributions! I’ll update the PR once I’ve made the necessary changes.

chaokunyang avatar Oct 26 '25 10:10 chaokunyang

Hi @mengnankkkk, thanks for your hard work and for letting me know the situation. I understand that you’ve spent quite a bit of time on this bug, and I appreciate the effort you’ve put in.

I’ll take a look at your branch, refactor the code, and work on fixing the bug so we can get the CI tests to pass. Don’t worry about the current state — debugging can be tricky, and each attempt helps us better understand the problem.

Thanks again for your contributions! I’ll update the PR once I’ve made the necessary changes.

I'm very sorry. I pushed AI to find a solution to the problem, but it didn't seem to solve it and made the code look even more shitty. I'm very sorry./(ㄒoㄒ)/~~

mengnankkkk avatar Oct 26 '25 11:10 mengnankkkk