Skip to content
Open
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
6 changes: 5 additions & 1 deletion compiler/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Suppress "module not found" warnings (and unfortunately all other module warnings) for forward
// references of qualified exports (`exports ... to ...`), see https://stackoverflow.com/q/53670052
@SuppressWarnings("module")
module run.endive.compiler {
requires transitive run.endive.runtime;
requires transitive run.endive.wasm;
Expand All @@ -6,6 +9,7 @@
requires org.objectweb.asm.util;

exports run.endive.compiler;
exports run.endive.compiler.internal;
exports run.endive.experimental.aot;
exports run.endive.compiler.internal to
run.endive.build.time.compiler;
}
9 changes: 8 additions & 1 deletion runtime/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// Suppress "module not found" warnings (and unfortunately all other module warnings) for forward
// references of qualified exports (`exports ... to ...`), see https://stackoverflow.com/q/53670052
@SuppressWarnings("module")
module run.endive.runtime {
requires transitive run.endive.wasm;

exports run.endive.runtime;
exports run.endive.runtime.alloc;
exports run.endive.runtime.internal;
exports run.endive.runtime.internal to
run.endive.compiler;

// Code generated by Endive uses internal classes; make them publicly accessible at runtime
opens run.endive.runtime.internal;
Comment on lines +12 to +13

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary, otherwise the tests (and probably also user code) fails with:

IllegalAccessError: class run.endive.$gen.CompiledMachine (in unnamed module @0x72e34f77) cannot access class run.endive.runtime.internal.CompilerInterpreterMachine (in module run.endive.runtime) because module run.endive.runtime does not export run.endive.runtime.internal to unnamed module @0x72e34f77

This cannot be solved using exports ... to because the generated code might be in an arbitrary user-defined module I assume (or even in the unnamed module, as seen here).

So using exports ... to + opens might be the only solution which prevents access at compile-time but allows access at runtime.

Unfortunately opens might give more permissions to reflection at runtime than needed (see JLS, "It also grants reflective access to all types in the package, and all their members, for code in other modules."). But it should be pretty clear to users that they are messing with Endive internals in case they have to rely on reflection.

}
Loading