Skip to content

[jni] Add JType.isA and JType.as to match ffigen's approach#3181

Open
imshubham22apr-gif wants to merge 2 commits intodart-lang:jni_extension_typesfrom
imshubham22apr-gif:fix-jni-is-as
Open

[jni] Add JType.isA and JType.as to match ffigen's approach#3181
imshubham22apr-gif wants to merge 2 commits intodart-lang:jni_extension_typesfrom
imshubham22apr-gif:fix-jni-is-as

Conversation

@imshubham22apr-gif
Copy link

Description

This PR adds isA and as methods to JType to match the approach used in package:objective_c (ffigen). Since JNI classes are now extension types, standard Dart is and as checks are not reliable.

Key changes:

  • Implemented JType.isA and JType.as for safe runtime type checks and casting.
  • Updated JObject.isA and JObject.as to delegate to the new JType methods.
  • Removed the previous hack in findClass (as it was related to this type migration).
  • Added comprehensive documentation in pkgs/jni/doc/runtime_types.md.
  • Updated unit tests to verify the new patterns.

Related Issues

Fixes #3175
Relates to #3174

PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've run dart tool/ci.dart --all locally (Note: Environment setup issue locally, relying on GitHub CI).
  • All existing and new tests are passing.
  • The PR is actually solving the issue.

@liamappelbe
Copy link
Contributor

@imshubham22apr-gif #3093 is a huge refactor to all this infra, so it would be best to wait for that to land before trying to do this.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants