Skip to content

Fix getID bug #1029

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

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkgs/jni/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
- **Breaking Change**: `JArray.filled` now uses the generated type class of the
`fill` object and not its Java runtime type.

## 0.7.3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will you release a version 0.7.3? We don't currently have a jnigen-stable branch where you can make this PR on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already did, I made a 0.7.3 branch. I can rename it to jnigen-stable as well: https://github.com/dart-lang/native/tree/jni-0.7.3

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

It's probably fine to just add a tag and delete the branch.

(We need a branch if we need to do multiple fixes on old stable releases.)


- Fixed a bug where `get(Static)MethodID` and `get(Static)FieldID` could access
null and throw.

## 0.7.2

- Fixed a bug where reading non-null terminated strings would overflow.
Expand Down
5 changes: 4 additions & 1 deletion pkgs/jni/src/dartjni.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,28 @@ static inline JniPointerResult _getId(MemberGetter getter,
char* name,
char* sig) {
JniPointerResult result = {NULL, NULL};
attach_thread();
result.value = getter(jniEnv, cls, name, sig);
result.exception = check_exception();
return result;
}

JniPointerResult getMethodID(jclass cls, char* name, char* sig) {
attach_thread();
return _getId((MemberGetter)(*jniEnv)->GetMethodID, cls, name, sig);
}

JniPointerResult getStaticMethodID(jclass cls, char* name, char* sig) {
attach_thread();
return _getId((MemberGetter)(*jniEnv)->GetStaticMethodID, cls, name, sig);
}

JniPointerResult getFieldID(jclass cls, char* name, char* sig) {
attach_thread();
return _getId((MemberGetter)(*jniEnv)->GetFieldID, cls, name, sig);
}

JniPointerResult getStaticFieldID(jclass cls, char* name, char* sig) {
attach_thread();
return _getId((MemberGetter)(*jniEnv)->GetStaticFieldID, cls, name, sig);
}

Expand Down