Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 18 additions & 11 deletions .github/workflows/aot-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,52 @@ jobs:
run: sbt GraalVMNativeImage/packageBin

- name: Test the binary
shell: bash
run: |
set -eux
set -euo pipefail

# See if it runs at all
target/graalvm-native-image/jelly-cli version
target/graalvm-native-image/jelly-cli version || exit 1

# Make sure reflection is supported
target/graalvm-native-image/jelly-cli version | grep "JVM reflection: supported"
target/graalvm-native-image/jelly-cli version | grep "JVM reflection: supported" \
|| exit 1

# Make sure large RDF/XML file parsing is supported
target/graalvm-native-image/jelly-cli version | grep "Large RDF/XML file parsing: supported"
target/graalvm-native-image/jelly-cli version | grep "Large RDF/XML file parsing: supported" \
|| exit 1

# Test RDF conversions
echo '_:b <http://t.org/> _:b .' > in.nt
target/graalvm-native-image/jelly-cli \
rdf to-jelly --in-format=nt in.nt > out.jelly && \
[ -s out.jelly ]
[ -s out.jelly ] || exit 1
target/graalvm-native-image/jelly-cli \
rdf from-jelly --out-format=jelly-text out.jelly > out.txt && \
[ -s out.txt ]
[ -s out.txt ] || exit 1
# From jelly-text
target/graalvm-native-image/jelly-cli \
rdf to-jelly --in-format=jelly-text out.txt > out2.jelly && \
[ -s out2.jelly ] || exit 1
target/graalvm-native-image/jelly-cli \
rdf from-jelly --out-format=jsonld out.jelly > out.json && \
[ -s out.json ]
[ -s out.json ] || exit 1
echo '{"@graph":[{"@id":"http://e.org/r","http://e.org/p":{"@value":"v"}}]}' | \
target/graalvm-native-image/jelly-cli rdf to-jelly --in-format "jsonld" > jsonld.jelly && \
[ -s jsonld.jelly ]
[ -s jsonld.jelly ] || exit 1
echo '<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Seq rdf:about="http://example.org/favourite-fruit"></rdf:Seq></rdf:RDF>' | \
target/graalvm-native-image/jelly-cli rdf to-jelly --in-format "rdfxml" > rdfxml.jelly && \
[ -s rdfxml.jelly ]
[ -s rdfxml.jelly ] || exit 1

# Invalid RDF/XMl input test
# Regression test for: https://github.com/Jelly-RDF/cli/issues/217
echo 'invalidxml' | \
( ! target/graalvm-native-image/jelly-cli rdf to-jelly --in-format "rdfxml" &> error.txt ) && \
grep 'Content is not allowed in prolog' error.txt
grep 'Content is not allowed in prolog' error.txt || exit 1

# Test rdf validate
target/graalvm-native-image/jelly-cli \
rdf validate out.jelly --compare-to-rdf-file in.nt
rdf validate out.jelly --compare-to-rdf-file in.nt || exit 1

- name: Upload binary
uses: actions/upload-artifact@v4
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/eu/neverblink/jelly/cli/graal/GraalSubstitutes.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.apicatalog.jsonld.JsonLdError;
import com.apicatalog.jsonld.http.HttpClient;
import com.apicatalog.jsonld.http.HttpResponse;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.google.protobuf.Descriptors;
import com.google.protobuf.TextFormat;
import com.oracle.svm.core.annotate.*;

import java.net.URI;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -93,3 +93,22 @@ final class UnicodeDetectingInputStreamSubstitute {
@Delete
private static Charset UTF_32LE;
}

/**
* Alias for TextFormat.TextGenerator to be used in substitutions (TextGenerator is private).
*/
@TargetClass(className = "com.google.protobuf.TextFormat", innerClass = "TextGenerator")
final class TextFormatTextGeneratorAlias {
}

/**
* Disable redaction support in protobuf TextFormat printer, which we don't need.
* This a lot of reflection-heavy code that we can do without.
*/
@TargetClass(className = "com.google.protobuf.TextFormat", innerClass = "Printer")
final class TextFormatPrinterSubstitute {
@Substitute
private boolean shouldRedact(final Descriptors.FieldDescriptor field, TextFormatTextGeneratorAlias generator) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class ProtobufFeature extends Feature:

override def beforeAnalysis(access: BeforeAnalysisAccess): Unit =
val reflections = Reflections("eu.neverblink.jelly.core.proto.google.v1", Scanners.SubTypes)
val classes = reflections.getSubTypesOf(
val classesForSubtyping: Seq[Class[?]] = Seq(
classOf[com.google.protobuf.GeneratedMessage],
).asScala ++
reflections.getSubTypesOf(classOf[com.google.protobuf.GeneratedMessage.Builder[?]]).asScala ++
reflections.getSubTypesOf(classOf[com.google.protobuf.ProtocolMessageEnum]).asScala
classOf[com.google.protobuf.GeneratedMessage.Builder[?]],
classOf[com.google.protobuf.ProtocolMessageEnum],
)
val classes: Seq[Class[?]] =
classesForSubtyping.flatMap(reflections.getSubTypesOf(_).asScala.toSeq)
classes.foreach(clazz => {
RuntimeReflection.register(clazz)
RuntimeReflection.register(clazz.getDeclaredMethods*)
Expand Down