Skip to content

Commit

Permalink
[jnigen] Add a helper for sending jobjects through method channels (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HosseinYousefi authored Oct 11, 2024
1 parent 9836208 commit 1a832b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkgs/jni/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.12.1-wip

- Add `JniUtils.fromReferenceAddress` which helps with sending `JObject`s
through method channels. You can send the address of the pointer as `long` and
reconstruct the class using the helper method.

## 0.12.0

- **Breaking Change**: Renamed `castTo` to `as`.
Expand Down
13 changes: 13 additions & 0 deletions pkgs/jni/java/src/main/java/com/github/dart_lang/jni/JniUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2024, 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;

public class JniUtils {
static {
System.loadLibrary("dartjni");
}

public static native Object fromReferenceAddress(long address);
}
2 changes: 1 addition & 1 deletion pkgs/jni/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: jni
description: A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen.
version: 0.12.0
version: 0.12.1-wip
repository: https://github.com/dart-lang/native/tree/main/pkgs/jni

topics:
Expand Down

0 comments on commit 1a832b7

Please sign in to comment.