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

[Java] Fix out-dated signatures of JNI methods #2756

Merged
merged 11 commits into from
Aug 30, 2018

Conversation

jovany-wang
Copy link
Contributor

@jovany-wang jovany-wang commented Aug 28, 2018

What do these changes do?

When Java code invoke native code by JNI, it will find the function by the function name which is declared in native code(org_ray_spi_impl_DefaultLocalSchedulerClient.cc). If there are some overloading functions, the JNI will find the most matching one by the signature in the comment, like this:

/*
 * Class:     org_ray_spi_impl_DefaultLocalSchedulerClient
 * Method:    _reconstructObjects
 * Signature: (J[BZ)V   /******This is the Signature declaration.******/
 */

Many signatures are not correct yet.
But because there are no overloading, this issue is not triggered.

In this PR, I do these things:

  1. Renamed the native JNI methods and some parameters of JNI methods.
  2. Fixed native JNI methods' signatures by javah tool.
  3. Removed some useless native methods.

Related issue number

N/A

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7822/
Test FAILed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7823/
Test PASSed.

Copy link
Contributor

@raulchen raulchen left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me.

Most of the function parameters in org_ray_spi_impl_DefaultLocalSchedulerClient.cc don't have meaningful names. Could you also improve that with this PR? thanks.

Copy link
Collaborator

@robertnishihara robertnishihara left a comment

Choose a reason for hiding this comment

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

Looks good to me, though we should still get rid of the autogenerated files at some point.

@jovany-wang
Copy link
Contributor Author

I have updated some code.

In conclusion, it contains 3 changes:

  1. Renamed the native JNI methods and some parameters of JNI methods.
  2. Fixed native JNI methods' signatures by javah tool.
  3. Removed some useless native methods.

@robertnishihara @raulchen Could u plz review this again?

@jovany-wang
Copy link
Contributor Author

@eric-jj cc

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7852/
Test PASSed.

Copy link
Contributor

@raulchen raulchen left a comment

Choose a reason for hiding this comment

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

There's lint error in org_ray_spi_impl_DefaultLocalSchedulerClient.cc. Otherwise looks good.

@raulchen raulchen changed the title [Java] Fix methods' signatures for JNI. [Java] Fix out-dated signatures of JNI methods Aug 29, 2018
@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7855/
Test PASSed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7856/
Test FAILed.

@jovany-wang
Copy link
Contributor Author

I didn't change any py file, and just changed org_ray_spi_impl_DefaultLocalSchedulerClient.h and org_ray_spi_impl_DefaultLocalSchedulerClient.cc which are used for Java.
But in many times, the CI job #1 and #2 can't pass.

=============== 1 failed, 47 passed, 8 skipped in 218.85 seconds ===============
The command "python -m pytest -v test/actor_test.py" exited with 1.

@robertnishihara Do u guys have any idea about it?

@@ -153,7 +153,8 @@ Java_org_ray_spi_impl_DefaultLocalSchedulerClient_nativeReconstructObjects(
std::vector<ObjectID> object_ids;
auto len = env->GetArrayLength(objectIds);
for (int i = 0; i < len; i++) {
jbyteArray object_id_bytes = (jbyteArray) env->GetObjectArrayElement(objectIds, i);
jbyteArray object_id_bytes =
(jbyteArray) env->GetObjectArrayElement(objectIds, i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not use C style casts here

@@ -209,7 +211,8 @@ Java_org_ray_spi_impl_DefaultLocalSchedulerClient_nativeWaitObject(
std::vector<ObjectID> object_ids;
auto len = env->GetArrayLength(objectIds);
for (int i = 0; i < len; i++) {
jbyteArray object_id_bytes = (jbyteArray) env->GetObjectArrayElement(objectIds, i);
jbyteArray object_id_bytes =
(jbyteArray) env->GetObjectArrayElement(objectIds, i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

C style cast

@robertnishihara
Copy link
Collaborator

@jovan-wong I think those test failures are unrelated. Can you remove the C-style casts? Then I think we can merge it.

@raulchen
Copy link
Contributor

@jovan-wong It's weird the first 2 jobs failed consistently for a few times. It should be unrelated. But let's at least make sure that the same test case doesn't fail again. Then I'll merge it.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7879/
Test FAILed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7883/
Test PASSed.

@raulchen raulchen merged commit 5146334 into ray-project:master Aug 30, 2018
@jovany-wang jovany-wang deleted the fix_jni branch August 31, 2018 09:10
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