-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jni] Add the ability to check if a JObject
is a subclass of a Java class.
#1943
base: main
Are you sure you want to change the base?
Conversation
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs.
API leaks
|
Package | Leaked API symbols |
---|---|
jni | _ReferenceType _opaque_pthread_mutex_t _opaque_pthread_cond_t _Dart_FinalizableHandle |
This check can be disabled by tagging the PR with skip-leaking-check
.
License Headers ✔️
// Copyright (c) 2025, 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.
Files |
---|
no missing headers |
All source files should start with a license header.
Unrelated files missing license headers
Files |
---|
pkgs/jni/lib/src/third_party/generated_bindings.dart |
pkgs/objective_c/lib/src/ns_input_stream.dart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes! Thanks Brian! I added a few small comments.
T as<T extends JObject?>( | ||
JObjType<T> type, { | ||
bool releaseOriginal = false, | ||
}) { | ||
assert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I had used assert here was not to do the type check in release mode.
Fetching the jclass and calling instanceof might be expensive if we perform a lot of castings.
Maybe we can have an unsafe flag which is false by default and if true will not do the checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should be safe by default.
I'd suggest that we do not offer an unsafe option unless we find a need for it. Put I'd be fine having a unsafeCast
option, if you'd like me to add one.
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.