Skip to content

Commit

Permalink
0.8.0 - Exclude clinit
Browse files Browse the repository at this point in the history
  • Loading branch information
HosseinYousefi committed Apr 3, 2024
1 parent 179a177 commit be7fc59
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkgs/jni/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.8.0-wip
## 0.8.0

- **Breaking Change** ([#981](https://github.com/dart-lang/native/issues/981)):

Expand Down
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.8.0-wip
version: 0.8.0
repository: https://github.com/dart-lang/native/tree/main/pkgs/jni

topics:
Expand Down
4 changes: 3 additions & 1 deletion pkgs/jnigen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.8.0-wip
## 0.8.0

- **Breaking Change** ([#981](https://github.com/dart-lang/native/issues/981)):
- `fromRef` is now `fromReference`, and it gets a `JReference` instead of a
Expand All @@ -12,6 +12,8 @@
`static const String` fields in Dart.
- Fixed a bug where a package would either be searched from sources or classes
but not both.
- Fixed a bug where `<clinit>` (class initialization method) which is not
necessary to be exposed was generated.

## 0.7.0

Expand Down
2 changes: 1 addition & 1 deletion pkgs/jnigen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final ffi.Pointer<T> Function<T extends ffi.NativeType>(String sym) jniLookup =
/// from: com.example.in_app_java.AndroidUtils
class AndroidUtils extends jni.JObject {
AndroidUtils.fromRef(ffi.Pointer<ffi.Void> ref) : super.fromRef(ref);
AndroidUtils.fromReference(JReference reference) : super.fromReference(reference);
static final _showToast = jniLookup<
ffi.NativeFunction<
Expand Down
1 change: 1 addition & 0 deletions pkgs/jnigen/lib/src/bindings/excluder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class _ClassExcluder extends Visitor<ClassDecl, void> {
node.methods = node.methods.where((method) {
final included = !_isPrivate(method) &&
!method.name.startsWith('_') &&
method.name != '<clinit>' &&
(config.exclude?.methods?.included(node, method) ?? true);
if (!included) {
log.fine('Excluded method ${node.binaryName}#${method.name}');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/jnigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: jnigen
description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine.
version: 0.8.0-wip
version: 0.8.0
repository: https://github.com/dart-lang/native/tree/main/pkgs/jnigen

environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import java.util.*;

public class Example {
static {
// This turns into a <clinit> method in the bytecode. Making sure jnigen
// does not generate it.
}

// static fields - primitive & string
public static final int ON = 1;
public static final int OFF = 0;
Expand Down

0 comments on commit be7fc59

Please sign in to comment.