-
Couldn't load subscription status.
- Fork 317
feat(java): Add ForyFeature for GraalVM Native Image #2701
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
base: main
Are you sure you want to change the base?
Conversation
|
|
|
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. |
da5cdf1 to
ed60ff4
Compare
...re/src/main/resources/META-INF/native-image/org.apache.fory/fory-core/reflection-config.json
Outdated
Show resolved
Hide resolved
b79af66 to
ed60ff4
Compare
b39dfc4 to
8d10234
Compare
integration_tests/graalvm_tests/src/main/java/org/apache/fory/graalvm/FeatureTestExample.java
Outdated
Show resolved
Hide resolved
integration_tests/graalvm_tests/src/main/java/org/apache/fory/graalvm/FeatureTestExample.java
Outdated
Show resolved
Hide resolved
java/fory-core/src/main/java/org/apache/fory/reflect/ObjectCreators.java
Outdated
Show resolved
Hide resolved
...ry-graalvm-feature/src/test/java/org/apache/fory/graalvm/feature/ForyGraalVMFeatureTest.java
Show resolved
Hide resolved
integration_tests/graalvm_tests/src/main/java/org/apache/fory/graalvm/FeatureTestExample.java
Show resolved
Hide resolved
java/fory-core/src/main/java/org/apache/fory/util/GraalvmSupport.java
Outdated
Show resolved
Hide resolved
java/fory-core/src/test/java/org/apache/fory/resolver/ClassResolverTest.java
Outdated
Show resolved
Hide resolved
2fae1ae to
332c960
Compare
...gration_tests/graalvm_tests/src/test/java/org/apache/fory/util/GraalvmSupportRecordTest.java
Show resolved
Hide resolved
java/fory-graalvm-feature/src/main/java/org/apache/fory/graalvm/feature/ForyGraalVMFeature.java
Outdated
Show resolved
Hide resolved
44f7bd3 to
e787e3f
Compare
|
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) |
| * null, allowing the serializer to use alternative approaches like Unsafe.allocateInstance. | ||
| */ | ||
| private static ObjectStreamClass safeObjectStreamClassLookup(Class<?> type) { | ||
| if (GraalvmSupport.isGraalRuntime()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use GraalvmSupport.IS_GRAALVM_NATIVE_IMAGE
…nstead of concrete class in ObjectStreamSerializer
|
@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? |
|
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ㄒ)/~~ |

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?
Benchmark