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
[jnigen] clarify generation of bindings for built-in Java types (#2641)
This change clarifies that many built-in Java types are now included by default, and provides a clearer example of how to include other classes. It explains that the sources of the Java SDK is no longer required.
Copy file name to clipboardExpand all lines: pkgs/jnigen/README.md
+15-8Lines changed: 15 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,19 +186,26 @@ If the classes are in JAR file, make sure to provide path to JAR file itself, an
186
186
If the errors are similar to `symbol not found`, ensure all dependencies of the source are available. If such dependency is compiled, it can be included in `class_path`.
187
187
188
188
#### Generate bindings for built-in types
189
-
To generate bindings for built-in Java types (like those in `java.*` packages), you need to provide the OpenJDK source code to the generator. Here's how:
189
+
For your convenience, a number of built-in Java types, for example, many of those in `java.lang` and `java.util`, are provided to your build by `jni` by default.
190
190
191
-
1. Locate the `src.zip` file in your Java installation directory
192
-
2. Extract the `java.base` folder from this zip file
193
-
3. Add the path to the extracted `java.base` folder in your `source_path` list in the YAML configuration
191
+
Those don't need to be included in the classes block, and will error if you do so, with the following error:
192
+
`Fatal: Trying to re-import the generated classes`.
194
193
195
-
For example, to generate bindings for `java.lang.Math`, your configuration might look like:
194
+
For any other types that are in core Java, you can add them in your `classes` block and bindings will be generated when you run the generate bindings task.
195
+
196
+
Below is a snippet showing how you might generate bindings for several classes in `java.time.*` and a `java.lang` class that is not included by default.
197
+
198
+
``` yaml
199
+
output:
200
+
dart:
201
+
path: lib/gen/
196
202
197
-
```yaml
198
-
source_path:
199
-
- '/path/to/extracted/java.base'
200
203
classes:
204
+
- 'java.time.Instant'
205
+
- 'java.time.ZoneOffset'
206
+
- 'java.time.ZonedDateTime'
201
207
- 'java.lang.Math'
208
+
# - 'java.lang.Integer' # Will error, already included in binary
0 commit comments