From 97c08bbecf4e3674674f373edcb25dcb9fd2be10 Mon Sep 17 00:00:00 2001 From: Hossein Yousefi Date: Thu, 4 Apr 2024 10:13:55 +0200 Subject: [PATCH] 0.8.0 - Exclude clinit (#1069) --- pkgs/jni/CHANGELOG.md | 2 +- pkgs/jni/pubspec.yaml | 2 +- pkgs/jnigen/CHANGELOG.md | 4 +++- pkgs/jnigen/README.md | 2 +- pkgs/jnigen/lib/src/bindings/excluder.dart | 1 + pkgs/jnigen/pubspec.yaml | 2 +- .../com/github/dart_lang/jnigen/simple_package/Example.java | 5 +++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index effdd657b..757642d74 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.8.0-wip +## 0.8.0 - **Breaking Change** ([#981](https://github.com/dart-lang/native/issues/981)): diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 014aa9f95..4347e06bb 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -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: diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index d58f03830..d87840173 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -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 @@ -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 `` (class initialization method) which is not + necessary to be exposed was generated. ## 0.7.0 diff --git a/pkgs/jnigen/README.md b/pkgs/jnigen/README.md index bcdd67155..ca921f191 100644 --- a/pkgs/jnigen/README.md +++ b/pkgs/jnigen/README.md @@ -58,7 +58,7 @@ final ffi.Pointer Function(String sym) jniLookup = /// from: com.example.in_app_java.AndroidUtils class AndroidUtils extends jni.JObject { - AndroidUtils.fromRef(ffi.Pointer ref) : super.fromRef(ref); + AndroidUtils.fromReference(JReference reference) : super.fromReference(reference); static final _showToast = jniLookup< ffi.NativeFunction< diff --git a/pkgs/jnigen/lib/src/bindings/excluder.dart b/pkgs/jnigen/lib/src/bindings/excluder.dart index 1568bd3ec..6f5e9765b 100644 --- a/pkgs/jnigen/lib/src/bindings/excluder.dart +++ b/pkgs/jnigen/lib/src/bindings/excluder.dart @@ -42,6 +42,7 @@ class _ClassExcluder extends Visitor { node.methods = node.methods.where((method) { final included = !_isPrivate(method) && !method.name.startsWith('_') && + method.name != '' && (config.exclude?.methods?.included(node, method) ?? true); if (!included) { log.fine('Excluded method ${node.binaryName}#${method.name}'); diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 58c5c83c5..cb369d130 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -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: diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java index b96156eba..5e1c19000 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Example.java @@ -7,6 +7,11 @@ import java.util.*; public class Example { + static { + // This turns into a 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;