Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
92341ba
fix(ci): Exit with subprocess return code in run_ci.py
esafak Sep 1, 2025
f676a53
Ensure subprocess is called with correct working directory
esafak Sep 2, 2025
0046a37
Fix formatting, install pyfory in openj9 and Java tests for xlang
esafak Sep 2, 2025
7638af3
Fix formatting
esafak Sep 2, 2025
c7a1a99
Attempt to fix type_id=None bug, remove Java 8 since fory-format requ…
esafak Sep 2, 2025
7e50559
fix java8 ut
chaokunyang Sep 2, 2025
1b9e7c5
fix graavlm build
chaokunyang Sep 2, 2025
57c278b
skip fory format install for integration tests
chaokunyang Sep 2, 2025
d6f2d6a
lint java code
chaokunyang Sep 2, 2025
4528647
add java8 back
chaokunyang Sep 2, 2025
9654208
fix skip fory-format on java8
chaokunyang Sep 2, 2025
9296ca4
fix skip fory-testsuite
chaokunyang Sep 2, 2025
b84f496
fix native-image.properties
chaokunyang Sep 2, 2025
6fdb74d
fix javadoc
chaokunyang Sep 2, 2025
c86c545
use jdk 11 for integration tests
chaokunyang Sep 2, 2025
c53a4c6
attempt to fix python CI bazel error
esafak Sep 2, 2025
f421ce0
run bazel sync --configure first
esafak Sep 2, 2025
95d55fd
run bazel sync --configure first
esafak Sep 2, 2025
ca76174
run bazel fetch
esafak Sep 2, 2025
a1298bb
restrict bazel fetch scope
esafak Sep 2, 2025
1ec9d2e
Use FunctionSerializer for functions
esafak Sep 2, 2025
ff42f2d
Restore install_bazel_windows
esafak Sep 2, 2025
e5713c3
E721: Use isinstance for type check
esafak Sep 2, 2025
a623110
fix formatting, integration test pom.xml
esafak Sep 2, 2025
dc44a39
reformat two files
esafak Sep 2, 2025
fc4e557
reformat one file
esafak Sep 2, 2025
6af6b23
fix graalvm init error
chaokunyang Sep 2, 2025
d805324
fix ObjectStreamSerializer$1
chaokunyang Sep 2, 2025
c9fcb50
fix lambda init
chaokunyang Sep 2, 2025
b79b206
use serializable func
chaokunyang Sep 2, 2025
9cb0a29
fix lmabda lazy init
chaokunyang Sep 2, 2025
fb2da8f
register lamdba
chaokunyang Sep 2, 2025
dd1afa6
ensureSerializersCompiled for proxy
chaokunyang Sep 2, 2025
7e452c2
refine exception msg for lambda serialzier
chaokunyang Sep 2, 2025
5bb7521
init proxy serializer
chaokunyang Sep 2, 2025
cc7c924
move proxy at static
chaokunyang Sep 2, 2025
f3f2759
add TestInvocationHandler for build time init
chaokunyang Sep 2, 2025
610ca01
fix proxy
chaokunyang Sep 2, 2025
ea85b81
fix proxy serializer init
chaokunyang Sep 2, 2025
1cfbb47
add serialization-config.json
chaokunyang Sep 2, 2025
ae937d9
fix config
chaokunyang Sep 2, 2025
07b37de
move proxy-config.json
chaokunyang Sep 2, 2025
32ac097
add proxy-config.json
chaokunyang Sep 2, 2025
62d1ff0
fix proxy as lambda
chaokunyang Sep 2, 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
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Contribution Checklist

- Fory has a strong focus on performance. If the PR you submit will have an impact on performance, please benchmark it first and provide the benchmark result here.
-->

## Why?

<!-- Describe the purpose of this PR. -->
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install python dependencies
run: pip install pyarrow==15.0.0 Cython wheel pytest setuptools -U
- name: Install pyfory for xlang tests
run: pip install -e python/
- name: Run CI with Maven
run: python ./ci/run_ci.py java --version ${{ matrix.java-version }}
- name: Upload Test Report
Expand Down Expand Up @@ -93,6 +95,8 @@ jobs:
python-version: 3.8
- name: Install bazel
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install pyfory for xlang tests
run: pip install -e python/
- name: Install python dependencies
run: pip install pyarrow==15.0.0 Cython wheel pytest setuptools -U
- name: Run CI with Maven
Expand Down Expand Up @@ -190,10 +194,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up JDK8
- name: Set up JDK11
uses: actions/setup-java@v4
with:
java-version: 8
java-version: 11
distribution: "temurin"
- name: Set up Python 3.8
uses: actions/setup-python@v5
Expand Down Expand Up @@ -274,9 +278,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install bazel
- name: Install bazel (Unix)
if: runner.os != 'Windows'
shell: bash
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install bazel (Windows)
if: runner.os == 'Windows'
shell: bash
run: ./ci/run_ci.sh install_bazel_windows
- name: Run Python CI
shell: bash
run: python ./ci/run_ci.py python
Expand All @@ -303,7 +312,7 @@ jobs:
run: python ./ci/run_ci.py cpp --install-deps-only
- name: Install python dependencies
run: pip install pyarrow==15.0.0 cython wheel pytest setuptools -U
- name: Install pyfory
- name: Install pyfory for xlang tests
run: pip install -e python/
- name: Run Golang CI
run: python ./ci/run_ci.py go
Expand Down
7 changes: 3 additions & 4 deletions ci/run_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def run_shell_script(command, *args):
cmd = [bash_path, script_path, command]
cmd.extend(args)
logging.info(f"Falling back to shell script with bash: {' '.join(cmd)}")
return subprocess.call(cmd)
sys.exit(subprocess.call(cmd))
else:
logging.error(
"Bash is not available on this Windows system. Cannot run shell script."
Expand All @@ -101,7 +101,7 @@ def run_shell_script(command, *args):
cmd = [script_path, command]
cmd.extend(args)
logging.info(f"Falling back to shell script: {' '.join(cmd)}")
return subprocess.call(cmd)
sys.exit(subprocess.call(cmd))


def parse_args():
Expand Down Expand Up @@ -237,14 +237,13 @@ def parse_args():
if USE_PYTHON_JAVA:
func(**arg_dict)
else:

if not arg_dict.get("version"):
func(**arg_dict)
return
# Map Python version argument to shell script command
version = arg_dict.get("version", "17")
release = arg_dict.get("release", False)

if release:
logging.info("Release mode requested - using Python implementation")
func(**arg_dict)
Expand Down
4 changes: 2 additions & 2 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ install_jdks() {

graalvm_test() {
cd "$ROOT"/java
mvn -T10 -B --no-transfer-progress clean install -DskipTests
mvn -T10 -B --no-transfer-progress clean install -DskipTests -pl '!:fory-format,!:fory-testsuite'
echo "Start to build graalvm native image"
cd "$ROOT"/integration_tests/graalvm_tests
mvn -DskipTests=true --no-transfer-progress -Pnative package
Expand Down Expand Up @@ -231,7 +231,7 @@ case $1 in
echo "Executing fory java tests"
cd "$ROOT/java"
set +e
mvn -T16 --batch-mode --no-transfer-progress test
mvn -T16 --batch-mode --no-transfer-progress test -pl '!:fory-format,!:fory-testsuite'
testcode=$?
if [[ $testcode -ne 0 ]]; then
exit $testcode
Expand Down
61 changes: 35 additions & 26 deletions ci/tasks/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import logging
import os
import sys
import subprocess
import re
from . import common
Expand All @@ -26,7 +25,7 @@
def get_jdk_major_version():
try:
# Run the 'java -version' command
result = subprocess.run(['java', '-version'], capture_output=True, text=True)
result = subprocess.run(["java", "-version"], capture_output=True, text=True)
output = result.stderr # java -version outputs to stderr

# Use regex to find the version string
Expand All @@ -37,8 +36,8 @@ def get_jdk_major_version():
version_string = match.group(1)

# Parse the version string
version_parts = version_string.split('.')
if version_parts[0] == '1':
version_parts = version_string.split(".")
if version_parts[0] == "1":
# Java 8 or earlier
return int(version_parts[1])
else:
Expand Down Expand Up @@ -81,54 +80,56 @@ def create_toolchains_xml(jdk_mappings):
import os
import xml.etree.ElementTree as ET
from xml.dom import minidom

# Create ~/.m2 directory if it doesn't exist
m2_dir = os.path.expanduser("~/.m2")
os.makedirs(m2_dir, exist_ok=True)

# Create the root element
toolchains = ET.Element("toolchains")

for version, jdk_name in jdk_mappings.items():
toolchain = ET.SubElement(toolchains, "toolchain")

# Set type
type_elem = ET.SubElement(toolchain, "type")
type_elem.text = "jdk"

# Set provides
provides = ET.SubElement(toolchain, "provides")
version_elem = ET.SubElement(provides, "version")
version_elem.text = version
vendor_elem = ET.SubElement(provides, "vendor")
vendor_elem.text = "azul"

# Set configuration
configuration = ET.SubElement(toolchain, "configuration")
jdk_home = ET.SubElement(configuration, "jdkHome")
jdk_home.text = os.path.abspath(os.path.join(common.PROJECT_ROOT_DIR, jdk_name))

# Create pretty XML string
rough_string = ET.tostring(toolchains, 'unicode')
rough_string = ET.tostring(toolchains, "unicode")
reparsed = minidom.parseString(rough_string)
pretty_xml = reparsed.toprettyxml(indent=" ")

# Add proper XML header with encoding
xml_header = '<?xml version="1.0" encoding="UTF8"?>\n'
pretty_xml = xml_header + pretty_xml.split('\n', 1)[1] # Remove the default header and add our custom one

pretty_xml = (
xml_header + pretty_xml.split("\n", 1)[1]
) # Remove the default header and add our custom one

# Write to ~/.m2/toolchains.xml
toolchains_path = os.path.join(m2_dir, "toolchains.xml")
with open(toolchains_path, 'w', encoding='utf-8') as f:
with open(toolchains_path, "w", encoding="utf-8") as f:
f.write(pretty_xml)

logging.info(f"Created toolchains.xml at {toolchains_path}")
logging.info("Toolchains configuration:")
for version, jdk_name in jdk_mappings.items():
jdk_path = os.path.join(common.PROJECT_ROOT_DIR, jdk_name)
logging.info(f" JDK {version}: {jdk_path}")
# print toolchains.xml
with open(toolchains_path, 'r', encoding='utf-8') as f:
with open(toolchains_path, "r", encoding="utf-8") as f:
logging.info(f.read())


Expand All @@ -149,7 +150,9 @@ def run_java8():
logging.info("Executing fory java tests with Java 8")
install_jdks()
common.cd_project_subdir("java")
common.exec_cmd("mvn -T16 --batch-mode --no-transfer-progress test -pl '!fory-format'")
common.exec_cmd(
"mvn -T16 --batch-mode --no-transfer-progress test -pl '!:fory-format,!:fory-testsuite'"
)
logging.info("Executing fory java tests succeeds")


Expand Down Expand Up @@ -208,7 +211,9 @@ def run_integration_tests():
logging.info("Executing fory integration tests")

common.cd_project_subdir("java")
common.exec_cmd("mvn -T10 -B --no-transfer-progress clean install -DskipTests")
common.exec_cmd(
"mvn -T10 -B --no-transfer-progress clean install -DskipTests -pl '!:fory-format,!:fory-testsuite'"
)

logging.info("benchmark tests")
common.cd_project_subdir("java/benchmark")
Expand Down Expand Up @@ -270,7 +275,9 @@ def run_graalvm_test():
logging.info("Start GraalVM tests")

common.cd_project_subdir("java")
common.exec_cmd("mvn -T10 -B --no-transfer-progress clean install -DskipTests")
common.exec_cmd(
"mvn -T10 -B --no-transfer-progress clean install -DskipTests -pl '!:fory-format,!:fory-testsuite'"
)

logging.info("Start to build graalvm native image")
common.cd_project_subdir("integration_tests/graalvm_tests")
Expand All @@ -285,17 +292,19 @@ def run_graalvm_test():

def run_release():
"""Release to Maven Central."""
logging.info(f"Starting release to Maven Central with Java")
logging.info("Starting release to Maven Central with Java")
common.cd_project_subdir("java")

# Clean and install without tests first
logging.info("Cleaning and installing dependencies")
common.exec_cmd("mvn -T10 -B --no-transfer-progress clean install -DskipTests")

# Deploy to Maven Central
logging.info("Deploying to Maven Central")
common.exec_cmd("mvn -T10 -B --no-transfer-progress clean deploy -Dgpg.skip -DskipTests -Papache-release")

common.exec_cmd(
"mvn -T10 -B --no-transfer-progress clean deploy -Dgpg.skip -DskipTests -Papache-release"
)

logging.info("Release to Maven Central completed successfully")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@
* under the License.
*/

package org.apache.fory.graalvm;

import org.apache.fory.Fory;
package org.apache.fory.graalvm;

import java.util.AbstractMap;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.fory.Fory;

public class ObjectStreamExample extends AbstractMap<Integer, Integer> {
private static final Fory FORY = Fory.builder()
.withName(ObjectStreamExample.class.getName())
.registerGuavaTypes(false)
.build();
private static final Fory FORY =
Fory.builder()
.withName(ObjectStreamExample.class.getName())
.registerGuavaTypes(false)
.build();

static {
FORY.register(ObjectStreamExample.class, true);
FORY.ensureSerializersCompiled();
FORY.register(ObjectStreamExample.class, true);
FORY.ensureSerializersCompiled();
}

final int[] ints = new int[10];

public static void main(String[] args) {
FORY.reset();
byte[] bytes = FORY.serialize(new ObjectStreamExample());
FORY.reset();
ObjectStreamExample o = (ObjectStreamExample) FORY.deserialize(bytes);
System.out.println(Arrays.toString(o.ints));
FORY.reset();
byte[] bytes = FORY.serialize(new ObjectStreamExample());
FORY.reset();
ObjectStreamExample o = (ObjectStreamExample) FORY.deserialize(bytes);
System.out.println(Arrays.toString(o.ints));
}

@Override
public Set<Entry<Integer, Integer>> entrySet() {
HashSet<Entry<Integer, Integer>> set = new HashSet<>();
for (int i = 0; i < ints.length; i++) {
set.add(new AbstractMap.SimpleEntry<>(i, ints[i]));
}
return set;
HashSet<Entry<Integer, Integer>> set = new HashSet<>();
for (int i = 0; i < ints.length; i++) {
set.add(new AbstractMap.SimpleEntry<>(i, ints[i]));
}
return set;
}
}
}
15 changes: 15 additions & 0 deletions integration_tests/jdk_compatibility_tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,26 @@
</properties>

<dependencies>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-format</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>benchmark</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ private Expression getRecordFieldValue(Expression inputBeanExpr, Descriptor desc
if (ref == null) {
Class<?> funcInterface = methodInfo.f0;
TypeRef<?> getterType = TypeRef.of(funcInterface);
if (GraalvmSupport.isGraalBuildtime()) {
// generate getter ahead at native image build time.
Functions.makeGetterFunction(beanClass, fieldName);
}
Expression getter =
new StaticInvoke(
Functions.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,8 @@ public ExprCode doGenCode(CodegenContext ctx) {
action.apply(
new Reference(i),
new Reference(leftElemValue, leftElemType, true),
// elemValue nullability check uses isNullAt inside action, so elemValueRef's nullable is false.
// elemValue nullability check uses isNullAt inside action, so elemValueRef's nullable
// is false.
new Reference(rightElemValue, rightElemType, false));
ExprCode elementExprCode = elemExpr.genCode(ctx);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void addListener(ClassResolver classResolver) {
lock.writeLock().lock();
listeners.put(classResolver, true);
} finally {
lock.writeLock().unlock();
lock.writeLock().unlock();
}
}

Expand Down
Loading
Loading