Skip to content

Commit

Permalink
constify JNINativeMethod tables
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Jun 1, 2020
1 parent 33b99af commit e1b6653
Show file tree
Hide file tree
Showing 31 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions benchmark/micro-native/micro_native.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
static void NativeMethods_emptyJniStaticSynchronizedMethod0(JNIEnv*, jclass) { }
static void NativeMethods_emptyJniSynchronizedMethod0(JNIEnv*, jclass) { }

static JNINativeMethod gMethods_NormalOnly[] = {
static const JNINativeMethod gMethods_NormalOnly[] = {
NATIVE_METHOD(NativeMethods, emptyJniStaticSynchronizedMethod0, "()V"),
NATIVE_METHOD(NativeMethods, emptyJniSynchronizedMethod0, "()V"),
};
Expand All @@ -53,7 +53,7 @@ static void NativeMethods_emptyJniStaticMethod6L(JNIEnv*, jclass, jobject, jarra
static void NativeMethods_emptyJniStaticMethod0(JNIEnv*, jclass) { }
static void NativeMethods_emptyJniStaticMethod6(JNIEnv*, jclass, int, int, int, int, int, int) { }

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(NativeMethods, emptyJniMethod0, "()V"),
NATIVE_METHOD(NativeMethods, emptyJniMethod6, "(IIIIII)V"),
NATIVE_METHOD(NativeMethods, emptyJniMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
Expand All @@ -72,7 +72,7 @@ static void NativeMethods_emptyJniStaticMethod6L_Fast(JNIEnv*, jclass, jobject,
static void NativeMethods_emptyJniStaticMethod0_Fast(JNIEnv*, jclass) { }
static void NativeMethods_emptyJniStaticMethod6_Fast(JNIEnv*, jclass, int, int, int, int, int, int) { }

static JNINativeMethod gMethods_Fast[] = {
static const JNINativeMethod gMethods_Fast[] = {
NATIVE_METHOD(NativeMethods, emptyJniMethod0_Fast, "()V"),
NATIVE_METHOD(NativeMethods, emptyJniMethod6_Fast, "(IIIIII)V"),
NATIVE_METHOD(NativeMethods, emptyJniMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
Expand All @@ -88,7 +88,7 @@ DEFINE_CRITICAL_JNI_METHOD(void, emptyJniStaticMethod0_1Critical)() { }
DEFINE_NORMAL_JNI_METHOD(void, emptyJniStaticMethod6_1Critical)(JNIEnv*, jclass, int, int, int, int, int, int) { }
DEFINE_CRITICAL_JNI_METHOD(void, emptyJniStaticMethod6_1Critical)(int, int, int, int, int, int) { }

static JNINativeMethod gMethods_Critical[] = {
static const JNINativeMethod gMethods_Critical[] = {
// Don't use NATIVE_METHOD because the name is mangled differently.
{ "emptyJniStaticMethod0_Critical", "()V",
reinterpret_cast<void*>(NAME_CRITICAL_JNI_METHOD(emptyJniStaticMethod0_1Critical)) },
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/dalvik_system_DexFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ static void DexFile_setTrusted(JNIEnv* env, jclass, jobject j_cookie) {
}
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(DexFile, closeDexFile, "(Ljava/lang/Object;)Z"),
NATIVE_METHOD(DexFile,
defineClassNative,
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/dalvik_system_VMDebug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ static void VMDebug_setAllocTrackerStackDepth(JNIEnv* env, jclass, jint stack_de
}
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMDebug, countInstancesOfClass, "(Ljava/lang/Class;Z)J"),
NATIVE_METHOD(VMDebug, countInstancesOfClasses, "([Ljava/lang/Class;Z)[J"),
NATIVE_METHOD(VMDebug, crash, "()V"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/dalvik_system_VMRuntime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static jboolean VMRuntime_hasBootImageSpaces(JNIEnv* env ATTRIBUTE_UNUSED,
return Runtime::Current()->GetHeap()->HasBootImageSpace() ? JNI_TRUE : JNI_FALSE;
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(VMRuntime, addressOf, "(Ljava/lang/Object;)J"),
NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"),
NATIVE_METHOD(VMRuntime, clampGrowthLimit, "()V"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/dalvik_system_VMStack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static jobjectArray VMStack_getAnnotatedThreadStackTrace(JNIEnv* env, jclass, jo
return GetThreadStack(soa, javaThread, fn);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(VMStack, fillStackTraceElements, "(Ljava/lang/Thread;[Ljava/lang/StackTraceElement;)I"),
FAST_NATIVE_METHOD(VMStack, getCallingClassLoader, "()Ljava/lang/ClassLoader;"),
FAST_NATIVE_METHOD(VMStack, getClosestUserClassLoader, "()Ljava/lang/ClassLoader;"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/dalvik_system_ZygoteHooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void ZygoteHooks_stopZygoteNoThreadCreation(JNIEnv* env ATTRIBUTE_UNUSED,
Runtime::Current()->SetZygoteNoThreadSection(false);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(ZygoteHooks, nativePreFork, "()J"),
NATIVE_METHOD(ZygoteHooks, nativePostZygoteFork, "()V"),
NATIVE_METHOD(ZygoteHooks, nativePostForkSystemServer, "()V"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_Class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ static jobject Class_newInstance(JNIEnv* env, jobject javaThis) {
return soa.AddLocalReference<jobject>(receiver.Get());
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Class, classForName,
"(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"),
FAST_NATIVE_METHOD(Class, getDeclaredAnnotation,
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_Object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static jint Object_identityHashCodeNative(JNIEnv* env, jclass, jobject javaObjec
return static_cast<jint>(o->IdentityHashCode());
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Object, internalClone, "()Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Object, notify, "()V"),
FAST_NATIVE_METHOD(Object, notifyAll, "()V"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_String.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static jcharArray String_toCharArray(JNIEnv* env, jobject java_this) {
return soa.AddLocalReference<jcharArray>(s->ToCharArray(soa.Self()));
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(String, charAt, "(I)C"),
FAST_NATIVE_METHOD(String, compareTo, "(Ljava/lang/String;)I"),
FAST_NATIVE_METHOD(String, concat, "(Ljava/lang/String;)Ljava/lang/String;"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_StringFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static jstring StringFactory_newStringFromString(JNIEnv* env, jclass, jstring to
return soa.AddLocalReference<jstring>(result);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(StringFactory, newStringFromBytes, "([BIII)Ljava/lang/String;"),
FAST_NATIVE_METHOD(StringFactory, newStringFromChars, "(II[C)Ljava/lang/String;"),
FAST_NATIVE_METHOD(StringFactory, newStringFromString, "(Ljava/lang/String;)Ljava/lang/String;"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_System.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void System_arraycopyBooleanUnchecked(JNIEnv* env,
javaDst, dstPos, count);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(System, arraycopy, "(Ljava/lang/Object;ILjava/lang/Object;II)V"),
FAST_NATIVE_METHOD(System, arraycopyCharUnchecked, "([CI[CII)V"),
FAST_NATIVE_METHOD(System, arraycopyByteUnchecked, "([BI[BII)V"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_Thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static void Thread_yield(JNIEnv*, jobject) {
sched_yield();
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Thread, currentThread, "()Ljava/lang/Thread;"),
FAST_NATIVE_METHOD(Thread, interrupted, "()Z"),
FAST_NATIVE_METHOD(Thread, isInterrupted, "()Z"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_Throwable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static jobjectArray Throwable_nativeGetStackTrace(JNIEnv* env, jclass, jobject j
return Thread::InternalStackTraceToStackTraceElementArray(soa, javaStackState);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Throwable, nativeFillInStackTrace, "()Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Throwable, nativeGetStackTrace, "(Ljava/lang/Object;)[Ljava/lang/StackTraceElement;"),
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_VMClassLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static jobjectArray VMClassLoader_getBootClassPathEntries(JNIEnv* env, jclass) {
return array;
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(VMClassLoader, findLoadedClass, "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;"),
NATIVE_METHOD(VMClassLoader, getBootClassPathEntries, "()[Ljava/lang/String;"),
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_invoke_MethodHandleImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static jobject MethodHandleImpl_getMemberInternal(JNIEnv* env, jobject thiz) {
return soa.AddLocalReference<jobject>(h_object.Get());
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(MethodHandleImpl, getMemberInternal, "()Ljava/lang/reflect/Member;"),
};

Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_ref_FinalizerReference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static jobject FinalizerReference_getReferent(JNIEnv* env, jobject javaThis) {
return soa.AddLocalReference<jobject>(referent);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(FinalizerReference, makeCircularListIfUnenqueued, "()Z"),
FAST_NATIVE_METHOD(FinalizerReference, getReferent, "()Ljava/lang/Object;"),
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_ref_Reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void Reference_clearReferent(JNIEnv* env, jobject javaThis) {
Runtime::Current()->GetHeap()->GetReferenceProcessor()->ClearReferent(ref);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Reference, getReferent, "()Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Reference, clearReferent, "()V"),
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static jobject Array_createObjectArray(JNIEnv* env, jclass, jclass javaElementCl
return soa.AddLocalReference<jobject>(new_array);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Array, createMultiArray, "(Ljava/lang/Class;[I)Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Array, createObjectArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"),
};
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Constructor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static jobject Constructor_newInstanceFromSerialization(JNIEnv* env, jclass unus
return env->NewObject(allocClass, ctor);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Constructor, getExceptionTypes, "()[Ljava/lang/Class;"),
FAST_NATIVE_METHOD(Constructor, newInstance0, "([Ljava/lang/Object;)Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Constructor, newInstanceFromSerialization, "(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Executable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static jint Executable_getParameterCountInternal(JNIEnv* env, jobject javaMethod
}


static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Executable, compareMethodParametersInternal,
"(Ljava/lang/reflect/Method;)I"),
FAST_NATIVE_METHOD(Executable, getAnnotationNative,
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static jboolean Field_isAnnotationPresentNative(JNIEnv* env,
return annotations::IsFieldAnnotationPresent(field, klass);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Field, get, "(Ljava/lang/Object;)Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Field, getBoolean, "(Ljava/lang/Object;)Z"),
FAST_NATIVE_METHOD(Field, getByte, "(Ljava/lang/Object;)B"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static jobject Method_invoke(JNIEnv* env, jobject javaMethod, jobject javaReceiv
return InvokeMethod(soa, javaMethod, javaReceiver, javaArgs);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Method, getDefaultValue, "()Ljava/lang/Object;"),
FAST_NATIVE_METHOD(Method, getExceptionTypes, "()[Ljava/lang/Class;"),
FAST_NATIVE_METHOD(Method, invoke, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Parameter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static jobject Parameter_getAnnotationNative(JNIEnv* env,
annotations::GetAnnotationForMethodParameter(method, parameterIndex, klass));
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(
Parameter,
getAnnotationNative,
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_lang_reflect_Proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring name, jobjectArra
soa, name, interfaces, loader, methods, throws));
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"),
};

Expand Down
2 changes: 1 addition & 1 deletion runtime/native/java_util_concurrent_atomic_AtomicLong.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static jboolean AtomicLong_VMSupportsCS8(JNIEnv*, jclass) {
return QuasiAtomic::LongAtomicsUseMutexes(kRuntimeISA) ? JNI_FALSE : JNI_TRUE;
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(AtomicLong, VMSupportsCS8, "()Z"),
};

Expand Down
2 changes: 1 addition & 1 deletion runtime/native/libcore_util_CharsetUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static jbyteArray CharsetUtils_toUtf8Bytes(JNIEnv* env, jclass, jstring java_str
return out.toByteArray();
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(CharsetUtils, asciiBytesToChars, "([BII[C)V"),
FAST_NATIVE_METHOD(CharsetUtils, isoLatin1BytesToChars, "([BII[C)V"),
FAST_NATIVE_METHOD(CharsetUtils, toAsciiBytes, "(Ljava/lang/String;II)[B"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/org_apache_harmony_dalvik_ddmc_DdmServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void DdmServer_nativeSendChunk(JNIEnv* env, jclass, jint type,
Runtime::Current()->GetRuntimeCallbacks()->DdmPublishChunk(static_cast<uint32_t>(type), chunk);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(DdmServer, nativeSendChunk, "(I[BII)V"),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static void DdmVmInternal_threadNotify(JNIEnv*, jclass, jboolean enable) {
Dbg::DdmSetThreadNotification(enable);
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(DdmVmInternal, enableRecentAllocations, "(Z)V"),
FAST_NATIVE_METHOD(DdmVmInternal, getRecentAllocations, "()[B"),
FAST_NATIVE_METHOD(DdmVmInternal, getRecentAllocationStatus, "()Z"),
Expand Down
2 changes: 1 addition & 1 deletion runtime/native/sun_misc_Unsafe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ static void Unsafe_unpark(JNIEnv* env, jobject, jobject jthread) {
}
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Unsafe, compareAndSwapInt, "(Ljava/lang/Object;JII)Z"),
FAST_NATIVE_METHOD(Unsafe, compareAndSwapLong, "(Ljava/lang/Object;JJJ)Z"),
FAST_NATIVE_METHOD(Unsafe, compareAndSwapObject, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z"),
Expand Down
2 changes: 1 addition & 1 deletion test/004-JniTest/jni_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static JavaVM* jvm = nullptr;
static jint Java_Main_intFastNativeMethod(JNIEnv*, jclass, jint a, jint b, jint c);
static jint Java_Main_intCriticalNativeMethod(jint a, jint b, jint c);

static JNINativeMethod sMainMethods[] = {
static const JNINativeMethod sMainMethods[] = {
{"intFastNativeMethod", "(III)I", reinterpret_cast<void*>(Java_Main_intFastNativeMethod) },
{"intCriticalNativeMethod", "(III)I", reinterpret_cast<void*>(Java_Main_intCriticalNativeMethod) },
};
Expand Down
2 changes: 1 addition & 1 deletion test/139-register-natives/regnative.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace art {
static void foo(JNIEnv*, jclass) {
}

static JNINativeMethod gMethods[] = {
static const JNINativeMethod gMethods[] = {
{ "foo", "()V", reinterpret_cast<void*>(foo) }
};

Expand Down

0 comments on commit e1b6653

Please sign in to comment.