@@ -37,7 +37,7 @@ This property holds regardless of whether any packages are exported.
37
37
` Hibernate ` inject values into nonpublic fields of classes.
38
38
39
39
## project content
40
- ### ** moduleA**
40
+ ### moduleA
41
41
```
42
42
module moduleA {
43
43
exports moduleA.export;
@@ -54,8 +54,7 @@ to it. For example if you uncomment the line in `moduleB.TestB`:
54
54
// InternalA internalA; // no access
55
55
```
56
56
project will not compile.
57
-
58
- ### ** moduleB**
57
+ ### moduleB
59
58
```
60
59
module moduleB {
61
60
requires transitive moduleA;
@@ -78,7 +77,7 @@ Note that we have to put `moduleA` also in `pom.xml` (without `pom.xml`
78
77
we should add ` moduleA ` to ` module-path ` of ` moduleB ` otherwise project
79
78
will not compile).
80
79
81
- ### ** moduleC**
80
+ ### moduleC
82
81
```
83
82
module moduleC {
84
83
requires moduleB;
@@ -112,3 +111,42 @@ exported only to `moduleB` (`moduleB.TestB`)
112
111
```
113
112
ExportA.export();
114
113
```
114
+ ____
115
+ ### reflection
116
+ Module with only one simple class ` Invoker ` to invoker static methods:
117
+ ```
118
+ public static void invokeStatic(Object obj, String methodName) throws IllegalAccessException {
119
+ try {
120
+ obj.getClass().getMethod(methodName).invoke(null);
121
+ } catch (InvocationTargetException | NoSuchMethodException e) {
122
+ throw new RuntimeException(e);
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### openModule
128
+ ```
129
+ open module openModule {
130
+ requires reflection;
131
+ }
132
+ ```
133
+ Running ` openModule.Test ` class will cause printing to console: "Hello
134
+ from openModule!" - because of that the modul is marked as ` open ` in the
135
+ ` module-info.java ` file.
136
+
137
+ ### ordinaryModule
138
+ ```
139
+ module ordinaryModule {
140
+ requires reflection;
141
+ }
142
+ ```
143
+ Running ` ordinaryModule.Test ` class will cause printing to console:
144
+ ```
145
+ java.lang.IllegalAccessException: class Invoker (in module reflection) cannot access class
146
+ Test (in module ordinaryModule) because module ordinaryModule does not export ordinaryModule
147
+ to module reflection
148
+ ```
149
+
150
+ ## remarks
151
+ * If we are using ` maven ` the file ` module-info.java ` should be added to
152
+ * asd
0 commit comments