Skip to content

[jnigen] Dart API 2026-08-28 feedback #3596

Open

Description

@dcharkes

I've only found a single JniGenerator( with visitors:. I have low data on what real life use cases migrated to the visitor API look like.

  • Migrate all existing yaml files in the repo.
  • Migrate some existing use cases. (Cronet HTTP?) For visualization purposes.

I have little feedback on the visitor API as a result of this.

Example code style

(Our examples are public docs, what we intend our users to do, so I care about nits.)
pkgs/jnigen/example/in_app_java/tool/jnigen.dart
pkgs/jnigen/example/maven_libs/tool/generate_bindings.dart
pkgs/jnigen/example/maven_libs_groovy/tool/generate_bindings.dart
pkgs/jnigen/README.md

  • avoid splitting an await and async method call across multiple lines
await JniGenerator(
  ...
).generate();

->

final generator =  JniGenerator(
  ...
);
await generator.generate();

Internal implementation nits

pkgs/jni/tool/generate_jni_bindings.dart

base class Renamer extends Visitor {
  • Should this be final or private class? And/or should be be renamed _JniRenamer? e.g. for clarity that this renamer is and should not be imported anywhere. I know it's in tool/ but...

pkgs/jnigen/test/jackson_core_test/generate.dart

JniGenerator getConfig({
  String? root,
  bool generateFullVersion = false,
  bool useAsm = false,
  SummarizerBackend? backend,
}) {
  • aren't useAsm and backend redundant?

pkgs/jnigen/test/test_util/summary_util.dart

const removalPackageForSummaryTests = 'com.github.dart_lang.jnigen.pkg2';

/// List of FQNs passed to summarizer for simple_package_test.
final summarizerClassesSpec = [
  ...javaClasses.where((e) => !e.startsWith('$removalPackageForSummaryTests.')),
  removalPackageForSummaryTests,
];
  • inline in getSummaryGenerationConfig to avoid making it public?

Activity

  1. liamappelbe commented on Sep 2, 2026

    @liamappelbe
    Contributor
    • Migrate some existing use cases. (Cronet HTTP?) For visualization purposes.

    Created dart-lang/http#1980. Can't land it until jnigen publishes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions