Skip to content
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

refactor: Remove method get_global_jclass #580

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

eejbyfeldt
Copy link
Contributor

@eejbyfeldt eejbyfeldt commented Jun 17, 2024

The method uses unsafe code to cast a value to a static lifetime using std::mem::transmute. But none of users of the method actually seems to depend on this lifetime extention. So to me it seems better to just call the underlying find_class method and delete the unsafe code.

Which issue does this PR close?

We needed to change this code in #570 when upgrading to rust 1.79 and that highlights that usage of transmute is fishy.

Rationale for this change

Less code and less unsafe which makes it easier to check and understand that the code is correct.

What changes are included in this PR?

Removed the method get_global_jclass. All users could be changed to use the underlying method find_class without further changes.

How are these changes tested?

Existing tests.

@eejbyfeldt eejbyfeldt marked this pull request as ready for review June 17, 2024 12:24
@andygrove
Copy link
Member

LGTM, and the tests pass, so this seems like a safe change, but I don't know the original motivation for the unsafe code, so I think we will need @viirya or @sunchao to review.

@andygrove andygrove requested review from viirya and sunchao June 20, 2024 13:29
eejbyfeldt and others added 2 commits June 20, 2024 22:07
The method uses unsafe code to cast a value to a static lifetime using
std::mem::transmute. But none of users of the method actually seems to
depend on this lifetime extention. So to me it seems better to just call
the underlying `find_class` method and delete the unsafe code.
Remove no longer needed comments.

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
Copy link
Member

@sunchao sunchao left a comment

Choose a reason for hiding this comment

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

LGTM too

@viirya viirya merged commit 9f44a74 into apache:main Jun 21, 2024
66 checks passed
@viirya
Copy link
Member

viirya commented Jun 21, 2024

Merged. Thanks @eejbyfeldt @andygrove @sunchao

@eejbyfeldt eejbyfeldt deleted the remove-get-global-jclass branch June 29, 2024 17:23
himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
* refactor: Remove method get_global_jclass

The method uses unsafe code to cast a value to a static lifetime using
std::mem::transmute. But none of users of the method actually seems to
depend on this lifetime extention. So to me it seems better to just call
the underlying `find_class` method and delete the unsafe code.

* Apply suggestions from code review

Remove no longer needed comments.

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>

---------

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants