mokapot/jvm/module.rs
1//! Modules in the JPMS.
2use bitflags::bitflags;
3
4use crate::macros::see_jvm_spec;
5
6use super::references::{ClassRef, ModuleRef, PackageRef};
7
8/// A service provided by a module.
9#[doc = see_jvm_spec!(4, 7, 25)]
10#[derive(Debug, Clone)]
11pub struct Provide {
12 /// The reference to a class which is provided as a service.
13 pub service: ClassRef,
14 /// The list of the classes which implement the service.
15 pub with: Vec<ClassRef>,
16}
17
18/// A module opening.
19#[doc = see_jvm_spec!(4, 7, 25)]
20#[derive(Debug, Clone)]
21pub struct Open {
22 /// The reference to the package which is opened.
23 pub package: PackageRef,
24 /// The flags of the opening.
25 pub flags: OpenFlags,
26 /// The list of the modules which can access the package.
27 pub to: Vec<ModuleRef>,
28}
29
30/// A module export.
31#[doc = see_jvm_spec!(4, 7, 25)]
32#[derive(Debug, Clone)]
33pub struct Export {
34 /// The reference to the package which is exported.
35 pub package: PackageRef,
36 /// The flags of the export.
37 pub flags: ExportFlags,
38 /// The list of the modules which can access the package.
39 pub to: Vec<ModuleRef>,
40}
41
42/// A module require.
43#[doc = see_jvm_spec!(4, 7, 25)]
44#[derive(Debug, Clone)]
45pub struct Require {
46 /// The reference to the module which is required.
47 pub module: ModuleRef,
48 /// The flags of the require.
49 pub flags: RequireFlags,
50 /// The version of the required module.
51 pub version: Option<String>,
52}
53
54bitflags! {
55 /// The flags of a module.
56 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
57 pub struct Flags: u16 {
58 /// Indicates that this module is open.
59 const OPEN = 0x0020;
60 /// Indicates that this module was not explicitly or implicitly declared.
61 const SYNTHETIC = 0x1000;
62 /// Indicates that this module is implicitly declared.
63 const MANDATED = 0x8000;
64 }
65}
66
67bitflags! {
68 /// The flags of a module require.
69 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
70 pub struct RequireFlags: u16 {
71 /// Indicates that any module which depends on the current module, implicitly declares a dependence on the module indicated by this entry.
72 const TRANSITIVE = 0x0020;
73 /// Indicates that the module indicated by this entry can be read by the current module at compile time, despite not being observable at run time.
74 const STATIC_PHASE = 0x0040;
75 /// Indicates that the dependence indicated by this entry is mandatory at run time.
76 const SYNTHETIC = 0x1000;
77 /// Indicates that the dependence indicated by this entry was implicitly declared in source code, such as by an import statement.
78 const MANDATED = 0x8000;
79 }
80}
81
82bitflags! {
83 /// The flags of a module export.
84 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
85 pub struct ExportFlags: u16 {
86 /// Indicates that this opening was not explicitly or implicitly declared in the source of the module declaration.
87 const SYNTHETIC = 0x1000;
88 /// Indicates that this opening was implicitly declared in the source of the module declaration.
89 const MANDATED = 0x8000;
90 }
91}
92
93bitflags! {
94 /// The flags of a module open.
95 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
96 pub struct OpenFlags: u16 {
97 /// Indicates that this opening was not explicitly or implicitly declared in the source of the module declaration.
98 const SYNTHETIC = 0x1000;
99 /// Indicates that this opening was implicitly declared in the source of the module declaration.
100 const MANDATED = 0x8000;
101 }
102}