Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ce38d2a
feat: add fory-graalvm-feature
mengnankkkk Oct 9, 2025
c8be5a3
fix: ci bug
mengnankkkk Oct 9, 2025
8d10234
fix: ci bugs
mengnankkkk Oct 9, 2025
9caacb7
fix: checkstyle
mengnankkkk Oct 9, 2025
2e78cdf
Update pom.xml
mengnankkkk Oct 9, 2025
de00781
fix: ci bugs
mengnankkkk Oct 9, 2025
ed2b97a
fix: ci bug
mengnankkkk Oct 9, 2025
6960c25
Merge branch 'main' into fix-mengnankk
mengnankkkk Oct 9, 2025
191d2a8
Merge branch 'main' into fix-mengnankk
mengnankkkk Oct 9, 2025
3a261fc
fix: ci bugs
mengnankkkk Oct 9, 2025
0c5e82b
feat: fix Timing issue in GraalVM Feature
mengnankkkk Oct 10, 2025
1592b3a
feat: remove static fields
mengnankkkk Oct 11, 2025
ab25f6d
fix: chectstyle
mengnankkkk Oct 11, 2025
e9f8ef4
fix: Api bug
mengnankkkk Oct 13, 2025
21d7de8
fix: adapt jdk17
mengnankkkk Oct 13, 2025
56e00e7
fix: adapt jdk17
mengnankkkk Oct 13, 2025
95abbde
Merge branch 'main' into fix-mengnankk
mengnankkkk Oct 13, 2025
021b1c5
fix:APi moved to GraalvmSupport
mengnankkkk Oct 13, 2025
25d3203
Update java/fory-core/src/main/java/org/apache/fory/util/GraalvmSuppo…
mengnankkkk Oct 14, 2025
f896fef
fix: replace name
mengnankkkk Oct 14, 2025
e4a9852
fix: checkstyle
mengnankkkk Oct 14, 2025
39ad1b7
fix: move registerClassForGraalvm
mengnankkkk Oct 15, 2025
d5c62e5
fix: ci test bug
mengnankkkk Oct 15, 2025
fa7c904
Update integration_tests/graalvm_tests/src/main/java/org/apache/fory/…
mengnankkkk Oct 16, 2025
9db3ce4
fix: move something to GraalvmSupport
mengnankkkk Oct 21, 2025
4ef6f86
Merge branch 'main' into fix-mengnankk
mengnankkkk Oct 21, 2025
e39fff8
fix: only init in Graalvm
mengnankkkk Oct 21, 2025
cf7f88d
fix: test up
mengnankkkk Oct 21, 2025
761dc74
fix: modules bug
mengnankkkk Oct 21, 2025
f079030
fix: pom test
mengnankkkk Oct 22, 2025
9984a8f
fix: pom bug
mengnankkkk Oct 22, 2025
5992a1c
Update pom.xml
mengnankkkk Oct 22, 2025
545bb13
fix: pom.xml
mengnankkkk Oct 22, 2025
d3d0e2b
fix: test bugs
mengnankkkk Oct 22, 2025
11e4d95
Update native-image.properties
mengnankkkk Oct 22, 2025
cb789a5
fix: move someting
mengnankkkk Oct 23, 2025
69f3a25
Update pom.xml
mengnankkkk Oct 23, 2025
d276915
feat: replace junit
mengnankkkk Oct 23, 2025
23c81c9
fix: something error
mengnankkkk Oct 23, 2025
332c960
fix: test in graalvm
mengnankkkk Oct 24, 2025
e787e3f
fix: test
mengnankkkk Oct 24, 2025
287df20
fix: use unsafe to solve
mengnankkkk Oct 24, 2025
b1cb3c8
fix: add ObjectCreator and ObjectCreators imports and use interface i…
mengnankkkk Oct 24, 2025
7bb71eb
style: apply code formatting with spotless
mengnankkkk Oct 24, 2025
21cd616
docs: add missing Javadoc comments for inner classes
mengnankkkk Oct 24, 2025
fe8aaa7
fix: configure javadoc plugin to handle incubating modules in GraalVM
mengnankkkk Oct 24, 2025
7643cec
fix: ci bug
mengnankkkk Oct 25, 2025
bb3c396
fix: ci bug from pom
mengnankkkk Oct 25, 2025
4114145
fix: ci bug use unsafe
mengnankkkk Oct 25, 2025
7bc5d40
fix: ci bug?
mengnankkkk Oct 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions integration_tests/graalvm_tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.fory</groupId>
<artifactId>fory-parent</artifactId>
<version>0.13.0</version>
<version>0.13.0-SNAPSHOT</version>
<relativePath>../../java</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -35,7 +35,6 @@
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.9.28</native.maven.plugin.version>
<junit.jupiter.version>5.8.1</junit.jupiter.version>
<mainClass>org.apache.fory.graalvm.Main</mainClass>
<imageName>main</imageName>
</properties>
Expand All @@ -59,6 +58,16 @@
<artifactId>fory-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-graalvm-feature</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -149,20 +158,14 @@
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<!-- Build native image (no fork) to align with CI behavior -->
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<fallback>false</fallback>
Expand All @@ -184,17 +187,13 @@
<execution>
<id>java-agent</id>
<goals>
<goal>exec</goal>
<goal>java</goal>
</goals>
<phase>test</phase>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${mainClass}</argument>
</arguments>
<mainClass>${mainClass}</mainClass>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.fory.graalvm;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.apache.fory.Fory;
import org.apache.fory.builder.Generated;
import org.apache.fory.config.Language;
import org.apache.fory.util.GraalvmSupport;

public class FeatureTestExample {

public static class PrivateConstructorClass {
private String value;

private PrivateConstructorClass() {
// Private constructor
}

public PrivateConstructorClass(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}

// Test interface for proxy
public interface TestInterface {
String getValue();

void setValue(String value);
}

// Simple invocation handler
public static class TestInvocationHandler implements InvocationHandler {
private String value;

public TestInvocationHandler(String value) {
this.value = value;
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("getValue".equals(method.getName())) {
return value;
} else if ("setValue".equals(method.getName())) {
value = (String) args[0];
return null;
}
return null;
}
}

public static void main(String[] args) {
System.out.println("Testing Fory GraalVM Feature...");

Fory fory =
Fory.builder().withLanguage(Language.JAVA).withRefTracking(true).withCodegen(true).build();

fory.register(PrivateConstructorClass.class);
fory.register(TestInvocationHandler.class);

// Register proxy interface
GraalvmSupport.registerProxySupport(TestInterface.class);

try {
// Test 1: Serialize/deserialize class with private constructor
PrivateConstructorClass original = new PrivateConstructorClass("test-value");
byte[] serialized = fory.serialize(original);
PrivateConstructorClass deserialized = (PrivateConstructorClass) fory.deserialize(serialized);

// Assert that the serializer is generated
if (!(fory.getClassResolver().getSerializer(PrivateConstructorClass.class)
instanceof Generated)) {
throw new RuntimeException(
"Expected Generated serializer for PrivateConstructorClass but got: "
+ fory.getClassResolver().getSerializer(PrivateConstructorClass.class).getClass());
}

if (!"test-value".equals(deserialized.getValue())) {
throw new RuntimeException("Private constructor class test failed");
}
System.out.println("Private constructor class serialization test passed");

// Test 2: Serialize/deserialize proxy object
TestInterface proxy =
(TestInterface)
Proxy.newProxyInstance(
TestInterface.class.getClassLoader(),
new Class[] {TestInterface.class},
new TestInvocationHandler("proxy-value"));

byte[] proxySerialised = fory.serialize(proxy);
TestInterface deserializedProxy = (TestInterface) fory.deserialize(proxySerialised);

if (!"proxy-value".equals(deserializedProxy.getValue())) {
throw new RuntimeException("Proxy test failed");
}
System.out.println("Proxy serialization test passed");

System.out.println("All GraalVM Feature tests passed!");

} catch (Exception e) {
System.err.println("GraalVM Feature test failed: " + e.getMessage());
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ public static void main(String[] args) throws Throwable {
Benchmark.main(args);
CollectionExample.main(args);
ArrayExample.main(args);
FeatureTestExample.main(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ Args=-H:+ReportExceptionStackTraces \
org.apache.fory.graalvm.EnsureSerializerExample$CustomSerializer,\
org.apache.fory.graalvm.CollectionExample,\
org.apache.fory.graalvm.ArrayExample,\
org.apache.fory.graalvm.Benchmark,\
org.apache.fory.graalvm.Main
org.apache.fory.graalvm.Benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.fory.graalvm;

import org.apache.fory.Fory;
import org.apache.fory.config.Language;
import org.apache.fory.util.GraalvmSupport;
import org.testng.Assert;
import org.testng.annotations.Test;

public class GraalvmRegistrationTest {

static class GraalvmRegistrationBean {
int value;
}

@Test
public void testEnsureSerializersCompiledRegistersClassesForGraalvm() {
Fory fory = Fory.builder().withLanguage(Language.JAVA).requireClassRegistration(true).build();
GraalvmSupport.clearRegistrations();
Assert.assertFalse(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));

fory.register(GraalvmRegistrationBean.class);

if (GraalvmSupport.IN_GRAALVM_NATIVE_IMAGE) {
Assert.assertTrue(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));

GraalvmSupport.clearRegistrations();
Assert.assertFalse(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));

fory.ensureSerializersCompiled();

Assert.assertTrue(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));
} else {
Assert.assertFalse(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));

GraalvmSupport.clearRegistrations();
Assert.assertFalse(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));

fory.ensureSerializersCompiled();

Assert.assertFalse(
GraalvmSupport.getRegisteredClasses().contains(GraalvmRegistrationBean.class));
}
}
}
Loading
Loading