Skip to content

Merge jnigen #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 141 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
2a39260
[jnigen] Initial commit
dcharkes May 31, 2022
3742faa
[jnigen] Add build badge (https://github.com/dart-lang/jnigen/issues/1)
dcharkes Jun 7, 2022
982a267
[jnigen] Delete CONTRIBUTING.md (https://github.com/dart-lang/jnigen/…
devoncarew Jul 1, 2022
837ceb4
[jnigen] Move stub package to its own folder (https://github.com/dart…
mahesh-hegde Jul 1, 2022
6353457
[jnigen] Top level project information files (https://github.com/dart…
mahesh-hegde Jul 4, 2022
3dee1d8
[jnigen] Create FFI plugin (https://github.com/dart-lang/jnigen/issue…
mahesh-hegde Jul 6, 2022
a06690e
[jnigen] Initial JNI support (https://github.com/dart-lang/jnigen/iss…
mahesh-hegde Jul 23, 2022
b516049
[jnigen] Initial code generator support (https://github.com/dart-lang…
mahesh-hegde Aug 25, 2022
0f7ced7
[jnigen] Add basic YAML config support (https://github.com/dart-lang/…
mahesh-hegde Aug 29, 2022
91a41f6
[jnigen] Rename java package of simple_test to com.github.dart_lang..…
mahesh-hegde Aug 29, 2022
ef4a9f8
[jnigen] Jni_gen Examples (https://github.com/dart-lang/jnigen/issues…
mahesh-hegde Sep 2, 2022
41e7871
[jnigen] Android plugin example (https://github.com/dart-lang/jnigen/…
mahesh-hegde Sep 5, 2022
a1bd070
[jnigen] Rename to jnigen (https://github.com/dart-lang/jnigen/issues…
mahesh-hegde Sep 5, 2022
cd369f0
[jnigen] logging (https://github.com/dart-lang/jnigen/issues/48)
mahesh-hegde Sep 5, 2022
e53465b
[jnigen] Jni refactor (https://github.com/dart-lang/jnigen/issues/53)
mahesh-hegde Sep 12, 2022
ac9f26a
[jnigen] Update pubspec.yaml (https://github.com/dart-lang/jnigen/iss…
devoncarew Sep 15, 2022
33105e7
[jnigen] Update pubspec.yaml (https://github.com/dart-lang/jnigen/iss…
devoncarew Sep 15, 2022
550b27e
[jnigen] Windows support (https://github.com/dart-lang/jnigen/issues/59)
mahesh-hegde Sep 21, 2022
a719f3b
[jnigen] LICENSE trailer for generated code (https://github.com/dart-…
dcharkes Sep 27, 2022
abb3c7b
[jnigen] General cleanup (https://github.com/dart-lang/jnigen/issues/80)
mahesh-hegde Oct 4, 2022
d6fed49
[jnigen] tools: generate_ide_files.dart and pre_commit_checks.dart (h…
mahesh-hegde Oct 4, 2022
81bda33
[jnigen] Few improvements in generated C code including exception sup…
mahesh-hegde Oct 7, 2022
3e801f9
[jnigen] Move output related configuration to single place (https://g…
mahesh-hegde Oct 13, 2022
9cb65f6
[jnigen] bump jackson-databind to 2.14.0-rc2 (https://github.com/dart…
mahesh-hegde Oct 14, 2022
644e75f
[jnigen] Make jni:setup build all native libraries (https://github.co…
mahesh-hegde Oct 15, 2022
226e60f
[jnigen] File-per-class and single file bindings (https://github.com/…
mahesh-hegde Oct 17, 2022
5cb0060
[jnigen] Reduce concatenation in binding generator code (https://gith…
mahesh-hegde Oct 19, 2022
a9446e7
[jnigen] Array signatures fix (https://github.com/dart-lang/jnigen/is…
HosseinYousefi Oct 25, 2022
f5b33be
[jnigen] colorized warning in logger (https://github.com/dart-lang/jn…
mahesh-hegde Oct 25, 2022
27ca310
[jnigen] Add regenerate script (https://github.com/dart-lang/jnigen/i…
mahesh-hegde Oct 25, 2022
88dcfc9
[jnigen] fix: pr_checks now works on macOS (https://github.com/dart-l…
HosseinYousefi Oct 26, 2022
35f1ba8
[jnigen] Pure dart bindings (https://github.com/dart-lang/jnigen/issu…
mahesh-hegde Oct 27, 2022
cbe3344
[jnigen] Some summarizer improvements (https://github.com/dart-lang/j…
mahesh-hegde Oct 28, 2022
5e87326
[jnigen] Summarizer fix (https://github.com/dart-lang/jnigen/issues/116)
mahesh-hegde Oct 28, 2022
068d88f
[jnigen] Array support (https://github.com/dart-lang/jnigen/issues/118)
HosseinYousefi Nov 8, 2022
a80a378
[jnigen] `JniX` to `JX` rename (https://github.com/dart-lang/jnigen/i…
HosseinYousefi Nov 9, 2022
1d36198
[jnigen] added .filled ctor to JArray (https://github.com/dart-lang/j…
HosseinYousefi Nov 9, 2022
a9e526b
[jnigen] Improve coverage (https://github.com/dart-lang/jnigen/issues…
mahesh-hegde Nov 14, 2022
d057af5
[jnigen] Add some documentation (https://github.com/dart-lang/jnigen/…
mahesh-hegde Nov 15, 2022
da1647c
[jnigen] Generic support (https://github.com/dart-lang/jnigen/issues/…
HosseinYousefi Nov 21, 2022
51f71d8
[jnigen] Updated docs to reflect renames (https://github.com/dart-lan…
HosseinYousefi Nov 23, 2022
8460b26
[jnigen] fixed the problem with annotations containing enums + reg te…
HosseinYousefi Nov 24, 2022
c470670
[jnigen] blast_repo fixes (https://github.com/dart-lang/jnigen/issues…
devoncarew Dec 2, 2022
c195412
[jnigen] Bump coverallsapp/github-action from 1.1.2 to 1.1.3 (https:/…
dependabot[bot] Dec 2, 2022
611c964
[jnigen] Use .jar metadata to generate generic types (https://github.…
HosseinYousefi Dec 13, 2022
659e626
[jnigen] Exclude methods and fields of excluded classes (https://git…
HosseinYousefi Dec 21, 2022
540922a
[jnigen] Bump actions/setup-java (https://github.com/dart-lang/jnigen…
dependabot[bot] Jan 5, 2023
87bba4e
[jnigen] Bump actions/checkout from 3.1.0 to 3.3.0 (https://github.co…
dependabot[bot] Jan 5, 2023
7bf0a71
[jnigen] 0.2.0 (https://github.com/dart-lang/jnigen/issues/174)
HosseinYousefi Jan 25, 2023
6c6b5f5
[jnigen] 0.2.1 (https://github.com/dart-lang/jnigen/issues/175)
HosseinYousefi Jan 26, 2023
e22150d
[jnigen] fix link (https://github.com/dart-lang/jnigen/issues/177)
HosseinYousefi Jan 27, 2023
800a110
[jnigen] Bump egor-tensin/setup-clang from 1.3 to 1.4 (https://github…
dependabot[bot] Feb 1, 2023
466ed3f
[jnigen] Bump actions/setup-java (https://github.com/dart-lang/jnigen…
dependabot[bot] Feb 1, 2023
4f770ad
[jnigen] Convert Kotlin's `suspend fun` to Dart's async methods (http…
HosseinYousefi Feb 16, 2023
2267ff4
[jnigen] 0.3.0 (https://github.com/dart-lang/jnigen/issues/189)
HosseinYousefi Feb 16, 2023
ce9e59e
[jnigen] Bump SDK constraint to 4.0.0 (https://github.com/dart-lang/j…
dcharkes Feb 16, 2023
b54e1cb
[jnigen] Bump actions/setup-java (https://github.com/dart-lang/jnigen…
dependabot[bot] Mar 2, 2023
64fec92
[jnigen] Bump coverallsapp/github-action from 1.1.3 to 1.2.4 (https:/…
dependabot[bot] Mar 2, 2023
1566826
[jnigen] Refactor into Visitor pattern (https://github.com/dart-lang/…
HosseinYousefi Mar 16, 2023
4562edc
[jnigen] Add Coverage badge (https://github.com/dart-lang/jnigen/issu…
dcharkes Mar 23, 2023
a16ad44
[jnigen] Generate JValue wrapper classes in pure Dart bindings (https…
HosseinYousefi Mar 29, 2023
5883326
[jnigen] Remove array extensions from the generated code (https://git…
HosseinYousefi Mar 30, 2023
f16de6d
[jnigen] 1.5x the timeout for the kotlin test (https://github.com/dar…
HosseinYousefi Mar 31, 2023
ea63bdf
[jnigen] Bump actions/checkout from 3.3.0 to 3.5.0 (https://github.co…
dependabot[bot] Apr 3, 2023
9250933
[jnigen] Bump actions/setup-java (https://github.com/dart-lang/jnigen…
dependabot[bot] Apr 3, 2023
eea221d
[jnigen] Bump subosito/flutter-action from 2.8.0 to 2.10.0 (https://g…
dependabot[bot] Apr 3, 2023
732f363
[jnigen] Bump coverallsapp/github-action from 1.2.4 to 2.0.0 (https:/…
dependabot[bot] Apr 3, 2023
0dd2f0d
[jnigen] Use `package:cli_config` (https://github.com/dart-lang/jnige…
dcharkes Apr 4, 2023
c9c73a0
[jnigen] 1.5x the timeout for the other kotlin test (https://github.c…
HosseinYousefi Apr 4, 2023
e998636
[jnigen] JAR handling improvements (https://github.com/dart-lang/jnig…
mahesh-hegde Apr 4, 2023
4d24823
[jnigen] Add ability to use source dependencies from Gradle (https://…
mahesh-hegde Apr 6, 2023
b7db0fa
[jnigen] Rethrow exception in gradle stub (https://github.com/dart-la…
mahesh-hegde Apr 10, 2023
af0ee4f
[jnigen] Type inference for generics (https://github.com/dart-lang/jn…
HosseinYousefi Apr 12, 2023
d21b672
[jnigen] (An attempt to) Improve CI workflows (https://github.com/dar…
mahesh-hegde Apr 12, 2023
e279dd5
[jnigen] Make README more approachable. (https://github.com/dart-lang…
mahesh-hegde Apr 12, 2023
215832a
[jnigen] Remove FFI patch and use mutex around method/field lookups (…
mahesh-hegde Apr 18, 2023
24f449b
[jnigen] Fix summary generation tests (https://github.com/dart-lang/j…
mahesh-hegde Apr 18, 2023
80808da
[jnigen] Further FFI improvements (https://github.com/dart-lang/jnige…
mahesh-hegde Apr 20, 2023
1753fed
[jnigen] Bunch of small testsuite improvements (https://github.com/da…
mahesh-hegde Apr 21, 2023
f129cdf
[jnigen] Add FAQ entry about references (https://github.com/dart-lang…
mahesh-hegde Apr 25, 2023
e9f16e6
[jnigen] Support Maven version 4 (https://github.com/dart-lang/jnigen…
alex-james-dev Apr 27, 2023
16f2d4e
[jnigen] Bump actions/checkout from 3.5.0 to 3.5.2 (https://github.co…
dependabot[bot] May 2, 2023
cf3db19
[jnigen] Bump coverallsapp/github-action from 2.0.0 to 2.1.2 (https:/…
dependabot[bot] May 2, 2023
fa265a8
[jnigen] Stress tests and a few runtime fixes (https://github.com/dar…
mahesh-hegde May 2, 2023
995c530
[jnigen] 0.4.0 (https://github.com/dart-lang/jnigen/issues/270)
HosseinYousefi May 2, 2023
06afdf1
[jnigen] Boxed types + Map + Set + List (https://github.com/dart-lang…
HosseinYousefi May 4, 2023
6822f90
[jnigen] improve coverage (https://github.com/dart-lang/jnigen/issues…
HosseinYousefi May 9, 2023
d6a0594
[jnigen] Summarizer fix class listing (https://github.com/dart-lang/j…
mahesh-hegde May 11, 2023
58a1e63
[jnigen] CI fix (https://github.com/dart-lang/jnigen/issues/277)
HosseinYousefi May 12, 2023
7452aae
[jnigen] closes https://github.com/dart-lang/jnigen/issues/280 (https…
HosseinYousefi May 15, 2023
31eb7b8
[jnigen] Fix encoding bug (https://github.com/dart-lang/jnigen/issues…
mahesh-hegde May 16, 2023
1ecd702
[jnigen] Refactor C bindings generation (https://github.com/dart-lang…
HosseinYousefi May 16, 2023
32d057e
[jnigen] blast_repo fixes (https://github.com/dart-lang/jnigen/issues…
devoncarew May 19, 2023
19ff0d2
[jnigen] Using a yaml symbols file instead of hard coding package:jni…
HosseinYousefi May 31, 2023
756cd11
[jnigen] Generating List/Map/... from classes in `package:jni` (https…
HosseinYousefi May 31, 2023
4827fc3
[jnigen] remove simpleName and packageName (https://github.com/dart-l…
HosseinYousefi Jun 2, 2023
72e7019
[jnigen] Add proguard-rules for kotlin_plugin (https://github.com/dar…
HosseinYousefi Jun 2, 2023
9ef4d1f
[jnigen] Non static nested class construction (https://github.com/dar…
HosseinYousefi Jun 13, 2023
cda6564
[jnigen] Added the namespace property in build.gradle if the field is…
marcoedomingos Jun 26, 2023
fc6688d
[jnigen] Parse Kotlin's metadata + Remove `suspend_fun_to_async` flag…
HosseinYousefi Jun 26, 2023
fc8bd8e
[jnigen] Bump coverallsapp/github-action from 2.1.2 to 2.2.0 (https:/…
dependabot[bot] Jul 3, 2023
e6bdddb
[jnigen] Bump actions/checkout from 3.5.2 to 3.5.3 (https://github.co…
dependabot[bot] Jul 3, 2023
7960c76
[jnigen] Fix summarizer nested class bug (https://github.com/dart-lan…
mahesh-hegde Jul 5, 2023
0673049
[jnigen] Interface implementation (https://github.com/dart-lang/jnige…
HosseinYousefi Jul 25, 2023
7e690dd
[jnigen] Fix CI (https://github.com/dart-lang/jnigen/issues/330)
HosseinYousefi Jul 25, 2023
ef33349
[jnigen] Fix windows specifics and global reference ownership in inte…
HosseinYousefi Jul 31, 2023
bb1c49f
[jnigen] Closes https://github.com/dart-lang/jnigen/issues/325 (https…
HosseinYousefi Jul 31, 2023
db9185a
[jnigen] Override JObject's toString with appropriate Java's toString…
HosseinYousefi Jul 31, 2023
2527e47
[jnigen] Bump coverallsapp/github-action from 2.2.0 to 2.2.1 (https:/…
dependabot[bot] Aug 1, 2023
9492c19
[jnigen] Bump actions/setup-java from 3.11.0 to 3.12.0 (https://githu…
dependabot[bot] Aug 8, 2023
17d48f8
[jnigen] Clean up interface implementation using auxiliary generated …
HosseinYousefi Aug 16, 2023
651320e
[jnigen] Update Dart API headers (https://github.com/dart-lang/jnigen…
HosseinYousefi Aug 16, 2023
7c9cca9
[jnigen] Use isolate_id instead of thread_id (https://github.com/dart…
HosseinYousefi Aug 17, 2023
fa5ff14
[jnigen] Check for free in reference getter (https://github.com/dart-…
HosseinYousefi Aug 17, 2023
204d869
[jnigen] Rename ctor to new (https://github.com/dart-lang/jnigen/issu…
HosseinYousefi Aug 18, 2023
4f85ced
[jnigen] Add tests on summary content (https://github.com/dart-lang/j…
mahesh-hegde Aug 18, 2023
95c8375
[jnigen] Finalize interfaces in Java (https://github.com/dart-lang/jn…
HosseinYousefi Aug 24, 2023
b7cc048
[jnigen] Run Java GC using jcmd in tests (https://github.com/dart-lan…
HosseinYousefi Aug 24, 2023
244596e
[jnigen] Throw DartExceptions in Java (https://github.com/dart-lang/j…
HosseinYousefi Aug 29, 2023
bd8aae4
[jnigen] Rename `delete` to `release` (https://github.com/dart-lang/j…
HosseinYousefi Aug 30, 2023
7684bdb
[jnigen] Configure autopublishing (https://github.com/dart-lang/jnige…
HosseinYousefi Sep 1, 2023
35d7522
[jnigen] Bump actions/checkout from 3.5.3 to 3.6.0 (https://github.co…
dependabot[bot] Sep 1, 2023
6606892
[jnigen] jni-0.6.1 fix number of topics (https://github.com/dart-lang…
HosseinYousefi Sep 1, 2023
1d46985
[jnigen] Specify JDK min and max version in README (https://github.co…
HosseinYousefi Sep 4, 2023
619b502
[jnigen] Add correct cast to interface method invocation (https://git…
brianquinlan Sep 10, 2023
eb49cba
[jnigen] Add `ignore_for_file: lines_longer_than_80_chars` to generat…
brianquinlan Sep 11, 2023
e8e0a98
[jnigen] Add `JBuffer`, `JByteBuffer` to enable fast copying to and f…
HosseinYousefi Sep 13, 2023
9fafeac
[jnigen] Convert incorrect exceptions into errors (https://github.com…
HosseinYousefi Sep 19, 2023
266ab71
[jnigen] Use Dart 3 class modifiers in `package:jni` (https://github.…
HosseinYousefi Sep 20, 2023
8456a7c
[jnigen] Add `JLazyReference` and `JFinalString` (https://github.com/…
HosseinYousefi Sep 26, 2023
917ed4d
[jnigen] Bump actions/setup-java from 3.12.0 to 3.13.0 (https://githu…
dependabot[bot] Oct 1, 2023
abcebe0
[jnigen] Bump coverallsapp/github-action from 2.2.1 to 2.2.3 (https:/…
dependabot[bot] Oct 1, 2023
f2a82d8
[jnigen] Bump actions/checkout from 3.6.0 to 4.1.0 (https://github.co…
dependabot[bot] Oct 14, 2023
039040e
[jnigen] Bump subosito/flutter-action from 2.10.0 to 2.12.0 (https://…
dependabot[bot] Nov 1, 2023
8974cb0
[jnigen] Bump actions/checkout from 4.1.0 to 4.1.1 (https://github.co…
dependabot[bot] Nov 2, 2023
b4a59e2
[jnigen] Remove macos plugin from package:jni (https://github.com/dar…
HosseinYousefi Nov 2, 2023
69c3e21
[jnigen] Fix buffer overflow issue when converting strings from JNI t…
slightfoot Nov 3, 2023
3f34c6c
[jnigen] Reformat with the latest version of dart format (https://git…
HosseinYousefi Nov 16, 2023
05994dd
[jnigen] Fix beta CI and print the analyzer failures (https://github.…
HosseinYousefi Nov 16, 2023
37789d6
[jnigen] Add paths to github workflow
HosseinYousefi Nov 16, 2023
9d35138
Merge package:jni and package:jnigen into shared native repository
HosseinYousefi Nov 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
428 changes: 428 additions & 0 deletions .github/workflows/jnigen.yaml

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions pkgs/jni/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

.vscode/
39 changes: 39 additions & 0 deletions pkgs/jni/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: 676cefaaff197f27424942307668886253e1ec35
channel: stable

project_type: plugin_ffi

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 676cefaaff197f27424942307668886253e1ec35
base_revision: 676cefaaff197f27424942307668886253e1ec35
- platform: android
create_revision: 676cefaaff197f27424942307668886253e1ec35
base_revision: 676cefaaff197f27424942307668886253e1ec35
- platform: linux
create_revision: 676cefaaff197f27424942307668886253e1ec35
base_revision: 676cefaaff197f27424942307668886253e1ec35
- platform: macos
create_revision: 676cefaaff197f27424942307668886253e1ec35
base_revision: 676cefaaff197f27424942307668886253e1ec35
- platform: windows
create_revision: 676cefaaff197f27424942307668886253e1ec35
base_revision: 676cefaaff197f27424942307668886253e1ec35

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
84 changes: 84 additions & 0 deletions pkgs/jni/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## 0.8.0-wip

- **Breaking Change** ([#394](https://github.com/dart-lang/jnigen/issues/394)):
Converted various `Exception`s into `Error`s:
- `UseAfterReleaseException` -> `UseAfterReleaseError`
- `DoubleReleaseException` -> `DoubleReleaseError`
- `SpawnException` -> `JniError` (It's now a `sealed class`)
- `JNullException` -> `JNullError`
- `InvalidCallTypeException` -> `InvalidCallTypeError`
- `HelperNotFoundException` -> `HelperNotFoundError`
- `JvmExistsException` -> `JniVmExistsError`
- `NoJvmInstanceException` -> `NoJvmInstanceError`
- **Breaking Change**: Removed `InvalidJStringException`.
- **Breaking Change**: The default return `callType` of type parameter `int` for
methods such as `JObject.callMethodByName<int>` is now Java's `long` instead
of `int` to be consistent with the way arguments work.
- **Breaking Change**: `JType` is now `sealed`.
- **Breaking Change**: Primitive types and their type classes are now `final`.
- **Breaking Change**: `JArray.filled` now uses the generated type class of the
`fill` object and not its Java runtime type.

## 0.7.2
- Fixed a bug where reading non-null terminated strings would overflow.

## 0.7.1
- Removed macOS Flutter plugin until package:jni supports it ([#41](https://github.com/dart-lang/jnigen/issues/41)).

## 0.7.0

- **Breaking Change** ([#387](https://github.com/dart-lang/jnigen/issues/387)):
Added `JBuffer` and `JByteBuffer` classes as default classes for
`java.nio.Buffer` and `java.nio.ByteBuffer` respectively.
- **Breaking Change**: Made the type classes `final`.
- Fixed a bug where `addAll`, `removeAll` and `retainAll` in `JSet` would run
their respective operation twice.
- Fixed a bug where `JList.insertAll` would not throw the potentially thrown
Java exception.

## 0.6.1

- Depend on the stable version of Dart 3.1.

## 0.6.0

- **Breaking Change** ([#131](https://github.com/dart-lang/jnigen/issues/131)):
Renamed `delete*` to `release*`.
- Added `PortProxy` and related methods used for interface implementation.
- Added the missing binding for `java.lang.Character`.

## 0.5.0

- **Breaking Change** ([#137](https://github.com/dart-lang/jnigen/issues/137)):
Java primitive types are now all lowercase like `jint`, `jshort`, ...
- The bindings for `java.util.Set`, `java.util.Map`, `java.util.List` and the
numeric types like `java.lang.Integer`, `java.lang.Boolean`, ... are now
included in `package:jni`.

## 0.4.0

- Type classes now have `superCount` and `superType` getters used for type
inference.

## 0.3.0

- Added `PortContinuation` used for `suspend fun` in Kotlin.
- `dartjni` now depends on `dart_api_dl.h`.

## 0.2.1

- Added `.clang-format` to pub.

## 0.2.0

- Added array support
- Added generic support
- `JniX` turned into `JX` for a more terse code.

## 0.1.1

- Windows support for running tests and examples on development machines.

## 0.1.0

- Initial version: Android and Linux support, JObject API
27 changes: 27 additions & 0 deletions pkgs/jni/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2022, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18 changes: 18 additions & 0 deletions pkgs/jni/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# jni

This is a support library to access JNI from Dart / Flutter code. This provides the common infrastructure to bindings generated by [jnigen](https://pub.dev/packages/jnigen), as well as some utility methods.

This library contains:

* Functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. JNIEnv is exposed via `GlobalJniEnv` type which provides a thin abstraction over JNIEnv, so that it can be used from multiple threads.
* Functions to spawn a JVM on desktop platforms (`Jni.spawn`).
* Some Android-specific helpers (get application context and current activity references).
* `JObject` class, which provides base class for classes generated by jnigen.
* Commonly used Java classes like `JList`, `JMap`, `JInteger`, ...

Apart from being the base library for code generated by `jnigen` this can also be used for one-off uses of the JNI and debugging. __To generate type-safe bindings from Java libraries, use `jnigen`.__

## Documentation
The test/ directory contains files with comments explaining the basics of this module, and the example/ directory contains a flutter example which also touches some Android-specifics.

Using this library assumes some familiarity with JNI - it's threading model and object references, among other things.
13 changes: 13 additions & 0 deletions pkgs/jni/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include: package:flutter_lints/flutter.yaml

analyzer:
exclude: [build/**, third_party/**]
language:
strict-raw-types: true

linter:
rules:
- prefer_final_locals
- prefer_const_declarations
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
9 changes: 9 additions & 0 deletions pkgs/jni/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx
1 change: 1 addition & 0 deletions pkgs/jni/android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains the [Android plugin class](src/main/java/com/github/dart_lang/jni/JniPlugin.java) which takes care of initializing JNI on Android.
89 changes: 89 additions & 0 deletions pkgs/jni/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// The Android Gradle Plugin builds the native code with the Android NDK.

group 'com.github.dart_lang.jni'
version '1.0'

buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: 'com.android.library'

android {
// Keeping the classes from being removed by proguard.
defaultConfig {
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
}
}

// Condition for namespace compatibility in AGP 8
if (project.android.hasProperty("namespace")) {
namespace 'com.github.dart_lang.jni'
}

// Adding [PortContinuation] and [PortProxy] classes shared between Flutter and
// Dart-standalone versions of package:jni.
sourceSets {
main {
java {
srcDirs '../java/src/main/java'
}
}
}

// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion 31

// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
// Note(MaheshH) - Flutter seems to download minimum NDK of flutter when
// below line is commented out.
// How about leaving it?
// ndkVersion "21.1.6352462"

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 16
}
}
1 change: 1 addition & 0 deletions pkgs/jni/android/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class com.github.dart_lang.jni.** { *; }
1 change: 1 addition & 0 deletions pkgs/jni/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'jni'
3 changes: 3 additions & 0 deletions pkgs/jni/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.dart_lang.jni">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

package com.github.dart_lang.jni;

import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.PluginRegistry.Registrar;

public class JniPlugin implements FlutterPlugin, ActivityAware {

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
setup(binding.getApplicationContext());
}

public static void registerWith(Registrar registrar) {
JniPlugin plugin = new JniPlugin();
plugin.setup(registrar.activeContext());
}

private void setup(Context context) {
initializeJni(context, getClass().getClassLoader());
}

@Override
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {}

// Activity handling methods
@Override
public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
Activity activity = binding.getActivity();
setJniActivity(activity, activity.getApplicationContext());
}

@Override
public void onDetachedFromActivityForConfigChanges() {}

@Override
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
Activity activity = binding.getActivity();
setJniActivity(activity, activity.getApplicationContext());
}

@Override
public void onDetachedFromActivity() {}

native void initializeJni(Context context, ClassLoader classLoader);

native void setJniActivity(Activity activity, Context context);

static {
System.loadLibrary("dartjni");
}
}
Loading