Skip to content
Snippets Groups Projects
Commit 5dfe5553 authored by Junyu Lai's avatar Junyu Lai
Browse files

Use NewOject to invoke constructor of NetworkStats.Entry

AllocObject doesn't invoke the constructor, and when working on
Java code we wouldn't expect that stuff initialized in the
constructor wouldn't actually be initialized on instances
created from JNI.

Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Fix: 322456911
Change-Id: Ibc87ab5ebaf02a7bcaa88307511bd3aaea8698ed
parent 9a6f8ccf
No related branches found
No related tags found
No related merge requests found
......@@ -45,8 +45,14 @@ static jobject statsValueToEntry(JNIEnv* env, StatsValue* stats) {
return nullptr;
}
// Find the constructor.
jmethodID constructorID = env->GetMethodID(gEntryClass, "<init>", "()V");
if (constructorID == nullptr) {
return nullptr;
}
// Create a new instance of the Java class
jobject result = env->AllocObject(gEntryClass);
jobject result = env->NewObject(gEntryClass, constructorID);
if (result == nullptr) {
return nullptr;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment