Skip to content

Commit

Permalink
Revert "Android Java SDK: test that we can use @CriticalNative."
Browse files Browse the repository at this point in the history
This reverts commit 0665c31.

Reason for revert: AOSP build failure

Change-Id: Ibd19375ce605df27e84eede166fe6d7e281ca737
  • Loading branch information
KirillTim authored and Gerrit Code Review committed Feb 27, 2025
1 parent 0665c31 commit 7fb4fcc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

#include "src/java_sdk/main/cpp/example.h"

static jint Java_com_google_perfetto_sdk_PerfettoExampleWrapper_runPerfettoMain(
JNIEXPORT jint JNICALL
Java_com_google_perfetto_sdk_PerfettoExampleWrapper_runPerfettoMain(
JNIEnv* env,
jobject /*thiz*/,
jstring outputFilePath) {
Expand All @@ -31,38 +32,3 @@ static jint Java_com_google_perfetto_sdk_PerfettoExampleWrapper_runPerfettoMain(
env->ReleaseStringUTFChars(outputFilePath, cstr);
return run_main(file_path);
}

static jint
Java_com_google_perfetto_sdk_PerfettoExampleWrapper_incrementIntCritical(
jint value) {
return value + 1;
}

static const JNINativeMethod myMethods[] = {
{"runPerfettoMain", "(Ljava/lang/String;)I",
reinterpret_cast<void*>(
Java_com_google_perfetto_sdk_PerfettoExampleWrapper_runPerfettoMain)},
{"incrementIntCritical", "(I)I",
reinterpret_cast<void*>(
Java_com_google_perfetto_sdk_PerfettoExampleWrapper_incrementIntCritical)}};

JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
return JNI_ERR;
}

jclass myCls =
env->FindClass("com/google/perfetto/sdk/PerfettoExampleWrapper");
if (myCls == nullptr) {
return JNI_ERR;
}

int rc = env->RegisterNatives(myCls, myMethods,
sizeof(myMethods) / sizeof(JNINativeMethod));
if (rc != JNI_OK) {
return JNI_ERR;
}

return JNI_VERSION_1_6;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@
* limitations under the License.
*/

#ifndef SRC_JAVA_SDK_MAIN_CPP_COM_GOOGLE_PERFETTO_SDK_PERFETTOEXAMPLEWRAPPER_H_
#define SRC_JAVA_SDK_MAIN_CPP_COM_GOOGLE_PERFETTO_SDK_PERFETTOEXAMPLEWRAPPER_H_

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_android_bazel_PerfettoExampleWrapper */

#ifndef SRC_JAVA_SDK_MAIN_CPP_COM_GOOGLE_PERFETTO_SDK_PERFETTOEXAMPLEWRAPPER_H_
#define SRC_JAVA_SDK_MAIN_CPP_COM_GOOGLE_PERFETTO_SDK_PERFETTOEXAMPLEWRAPPER_H_
#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*);
/*
* Class: com_google_perfetto_sdk_PerfettoExampleWrapper
* Method: runPerfettoMain
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_com_google_perfetto_sdk_PerfettoExampleWrapper_runPerfettoMain(JNIEnv*,
jobject,
jstring);

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.google.perfetto.sdk;

import dalvik.annotation.optimization.CriticalNative;

public class PerfettoExampleWrapper {

static {
Expand All @@ -29,7 +27,4 @@ public static int doRunPerfettoMain(String outputFilePath) {
}

private native int runPerfettoMain(String outputFilePath);

@CriticalNative
public static native int incrementIntCritical(int value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,5 @@ public void testDoRunPerfettoMain() {
Assert.assertEquals(0, perfettoResult);
Assert.assertTrue(perfettoOutput.exists());
Assert.assertTrue(perfettoOutput.length() > 0);

int criticalValuePlusOne = PerfettoExampleWrapper.incrementIntCritical(10);
Log.i(TAG, "criticalValuePlusOne: " + criticalValuePlusOne);
Assert.assertEquals(11, criticalValuePlusOne);
}
}

0 comments on commit 7fb4fcc

Please sign in to comment.