You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference-manual/native-image/guides/build-and-run-native-executable-with-remote-jmx.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,13 +79,13 @@ For other installation options, visit the [Downloads section](https://www.graalv
79
79
}
80
80
```
81
81
82
-
2.Compile the Java file using the GraalVMJDK:
82
+
2.Ccompile the application using the GraalVMJDK:
83
83
```shell
84
84
javac SimpleJmx.java
85
85
```
86
86
This creates _SimpleJmx.class_, _SimpleJmx$Simple.class_, and _SimpleJmx$SimpleMBean.class_ files.
87
87
88
-
3.Add dynamic proxy configuration. JMX uses dynamic proxies, a [dynamic feature](../DynamicFeatures.md) of Java, to access MBeans. To be able to interact with the custom `SimpleMBean` at run time, you need to provide NativeImage with additional [dynamic-proxy metadata](../ReachabilityMetadata.md#reflection) for the MBean interface. Forthis, create or modify a JSON file named _proxy-config.json_ with the following contents:
88
+
3.Add dynamic proxy configuration. JMX uses dynamic proxies, a [dynamic feature](../DynamicFeatures.md) of Java, to access MBeans. To be able to interact with the custom `SimpleMBean` at run time, you need to provide NativeImage with additional [dynamic-proxy metadata](../ReachabilityMetadata.md#reflection) for the MBean interface. Forthis, create or modify a JSON file named _reachability-metadata.json_ with the following contents:
Copy file name to clipboardExpand all lines: docs/reference-manual/native-image/guides/build-with-reflection.md
+41-24Lines changed: 41 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,14 +17,12 @@ The agent generates the configuration for you automatically when you run an appl
17
17
18
18
To learn how to build a native executable with the metadata precomputed in the code, [see the documentation](../ReachabilityMetadata.md).
19
19
20
-
The example application in this guide uses Java reflection.
21
-
The `native-image` tool only partially detects application elements that are accessed using the Java Reflection API.
22
-
So, you need to provide it with details about reflectively accessed classes, methods, and fields.
20
+
The example application in this guide makes use of reflection.
21
+
The `native-image` tool can only partially detect application elements accessed through the Java Reflection API.
22
+
Therefore, you need to explicitly provide details about the classes, methods, and fields accessed reflectively.
23
23
24
24
## Example with No Configuration
25
25
26
-
The following application demonstrates the use of Java reflection.
27
-
28
26
### Prerequisite
29
27
Make sure you have installed a GraalVM JDK.
30
28
The easiest way to get started is with [SDKMAN!](https://sdkman.io/jdks#graal).
@@ -79,9 +77,8 @@ For other installation options, visit the [Downloads section](https://www.graalv
79
77
80
78
3. Create a native executable, as follows:
81
79
```shell
82
-
native-image --no-fallback ReflectionExample
80
+
native-image ReflectionExample
83
81
```
84
-
> **NOTE:** The `--no-fallback` option to `native-image` causes the utility to fail if it can not create an executable file.
85
82
86
83
4. Run the resulting native executable, using the following command:
87
84
```bash
@@ -90,9 +87,9 @@ For other installation options, visit the [Downloads section](https://www.graalv
90
87
You should see an exception, similar to:
91
88
```
92
89
Exception in thread "main" java.lang.ClassNotFoundException: StringReverser
93
-
at java.lang.Class.forName(DynamicHub.java:1338)
94
-
at java.lang.Class.forName(DynamicHub.java:1313)
95
-
at ReflectionExample.main(ReflectionExample.java:25)
90
+
at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:190)
91
+
...
92
+
at ReflectionExample.main(ReflectionExample.java:68)
96
93
```
97
94
This shows that, from its static analysis, the `native-image` tool was unable to determine that class `StringReverser` is used by the application and therefore did not include it in the native executable.
98
95
@@ -112,10 +109,17 @@ The following steps demonstrate how to use the agent, and its output, to create
112
109
This command creates a file named _rechability-metadata.json_ containing the name of the class `StringReverser` and its `reverse()` method.
0 commit comments