Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 14:04:28 +01:00
parent 81b91f4139
commit f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions

View file

@ -0,0 +1,27 @@
Copyright 2023 The Chromium Authors
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,2 @@
agrieve@chromium.org
smaier@chromium.org

View file

@ -0,0 +1,12 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Chromium only applies this check when ENABLE_DCHECK=false.
-checkdiscard @org.jni_zero.CheckDiscard class ** {
*;
}
-checkdiscard class ** {
@org.jni_zero.CheckDiscard *;
}

View file

@ -0,0 +1,255 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/jni_zero/core.h"
#include <sys/prctl.h>
#include "third_party/jni_zero/logging.h"
namespace jni_zero {
namespace {
// Until we fully migrate base's jni_android, we will maintain a copy of this
// global here and will have base set this variable when it sets its own.
JavaVM* g_jvm = nullptr;
jclass (*g_class_resolver)(JNIEnv*, const char*, const char*) = nullptr;
void (*g_exception_handler_callback)(JNIEnv*) = nullptr;
ScopedJavaLocalRef<jclass> GetClassInternal(JNIEnv* env,
const char* class_name,
const char* split_name) {
jclass clazz;
if (g_class_resolver != nullptr) {
clazz = g_class_resolver(env, class_name, split_name);
} else {
clazz = env->FindClass(class_name);
}
if (ClearException(env) || !clazz) {
JNI_ZERO_FLOG("Failed to find class %s", class_name);
}
return ScopedJavaLocalRef<jclass>(env, clazz);
}
} // namespace
JNIEnv* AttachCurrentThread() {
JNI_ZERO_DCHECK(g_jvm);
JNIEnv* env = nullptr;
jint ret = g_jvm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_2);
if (ret == JNI_EDETACHED || !env) {
JavaVMAttachArgs args;
args.version = JNI_VERSION_1_2;
args.group = nullptr;
// 16 is the maximum size for thread names on Android.
char thread_name[16];
int err = prctl(PR_GET_NAME, thread_name);
if (err < 0) {
JNI_ZERO_ELOG("prctl(PR_GET_NAME)");
args.name = nullptr;
} else {
args.name = thread_name;
}
#if defined(JNI_ZERO_IS_ROBOLECTRIC)
ret = g_jvm->AttachCurrentThread(reinterpret_cast<void**>(&env), &args);
#else
ret = g_jvm->AttachCurrentThread(&env, &args);
#endif
JNI_ZERO_CHECK(ret == JNI_OK);
}
return env;
}
JNIEnv* AttachCurrentThreadWithName(const std::string& thread_name) {
JNI_ZERO_DCHECK(g_jvm);
JavaVMAttachArgs args;
args.version = JNI_VERSION_1_2;
args.name = const_cast<char*>(thread_name.c_str());
args.group = nullptr;
JNIEnv* env = nullptr;
#if defined(JNI_ZERO_IS_ROBOLECTRIC)
jint ret = g_jvm->AttachCurrentThread(reinterpret_cast<void**>(&env), &args);
#else
jint ret = g_jvm->AttachCurrentThread(&env, &args);
#endif
JNI_ZERO_CHECK(ret == JNI_OK);
return env;
}
void DetachFromVM() {
// Ignore the return value, if the thread is not attached, DetachCurrentThread
// will fail. But it is ok as the native thread may never be attached.
if (g_jvm) {
g_jvm->DetachCurrentThread();
}
}
void InitVM(JavaVM* vm) {
g_jvm = vm;
}
void DisableJvmForTesting() {
g_jvm = nullptr;
}
bool IsVMInitialized() {
return g_jvm != nullptr;
}
JavaVM* GetVM() {
return g_jvm;
}
bool HasException(JNIEnv* env) {
return env->ExceptionCheck() != JNI_FALSE;
}
bool ClearException(JNIEnv* env) {
if (!HasException(env)) {
return false;
}
env->ExceptionDescribe();
env->ExceptionClear();
return true;
}
void SetExceptionHandler(void (*callback)(JNIEnv*)) {
g_exception_handler_callback = callback;
}
void CheckException(JNIEnv* env) {
if (!HasException(env)) {
return;
}
if (g_exception_handler_callback) {
return g_exception_handler_callback(env);
}
JNI_ZERO_FLOG("jni_zero crashing due to uncaught Java exception");
}
void SetClassResolver(jclass (*resolver)(JNIEnv*, const char*, const char*)) {
g_class_resolver = resolver;
}
ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env,
const char* class_name,
const char* split_name) {
return GetClassInternal(env, class_name, split_name);
}
ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) {
return GetClassInternal(env, class_name, "");
}
// This is duplicated with LazyGetClass below because these are performance
// sensitive.
jclass LazyGetClass(JNIEnv* env,
const char* class_name,
const char* split_name,
std::atomic<jclass>* atomic_class_id) {
const jclass value = atomic_class_id->load(std::memory_order_acquire);
if (value) {
return value;
}
ScopedJavaGlobalRef<jclass> clazz;
clazz.Reset(GetClass(env, class_name, split_name));
jclass cas_result = nullptr;
if (atomic_class_id->compare_exchange_strong(cas_result, clazz.obj(),
std::memory_order_acq_rel)) {
// We intentionally leak the global ref since we are now storing it as a raw
// pointer in |atomic_class_id|.
return clazz.Release();
} else {
return cas_result;
}
}
// This is duplicated with LazyGetClass above because these are performance
// sensitive.
jclass LazyGetClass(JNIEnv* env,
const char* class_name,
std::atomic<jclass>* atomic_class_id) {
const jclass value = atomic_class_id->load(std::memory_order_acquire);
if (value) {
return value;
}
ScopedJavaGlobalRef<jclass> clazz;
clazz.Reset(GetClass(env, class_name));
jclass cas_result = nullptr;
if (atomic_class_id->compare_exchange_strong(cas_result, clazz.obj(),
std::memory_order_acq_rel)) {
// We intentionally leak the global ref since we are now storing it as a raw
// pointer in |atomic_class_id|.
return clazz.Release();
} else {
return cas_result;
}
}
template <MethodID::Type type>
jmethodID MethodID::Get(JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature) {
auto get_method_ptr = type == MethodID::TYPE_STATIC
? &JNIEnv::GetStaticMethodID
: &JNIEnv::GetMethodID;
jmethodID id = (env->*get_method_ptr)(clazz, method_name, jni_signature);
if (ClearException(env) || !id) {
JNI_ZERO_FLOG("Failed to find class %smethod %s %s",
(type == TYPE_STATIC ? "static " : ""), method_name,
jni_signature);
}
return id;
}
// If |atomic_method_id| set, it'll return immediately. Otherwise, it'll call
// into ::Get() above. If there's a race, it's ok since the values are the same
// (and the duplicated effort will happen only once).
template <MethodID::Type type>
jmethodID MethodID::LazyGet(JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature,
std::atomic<jmethodID>* atomic_method_id) {
const jmethodID value = atomic_method_id->load(std::memory_order_acquire);
if (value) {
return value;
}
jmethodID id = MethodID::Get<type>(env, clazz, method_name, jni_signature);
atomic_method_id->store(id, std::memory_order_release);
return id;
}
// Various template instantiations.
template jmethodID MethodID::Get<MethodID::TYPE_STATIC>(
JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature);
template jmethodID MethodID::Get<MethodID::TYPE_INSTANCE>(
JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature);
template jmethodID MethodID::LazyGet<MethodID::TYPE_STATIC>(
JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature,
std::atomic<jmethodID>* atomic_method_id);
template jmethodID MethodID::LazyGet<MethodID::TYPE_INSTANCE>(
JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature,
std::atomic<jmethodID>* atomic_method_id);
} // namespace jni_zero

View file

@ -0,0 +1,125 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef JNI_ZERO_CORE_H_
#define JNI_ZERO_CORE_H_
#include <jni.h>
#include <atomic>
#include <string>
#include "third_party/jni_zero/jni_export.h"
#include "third_party/jni_zero/scoped_java_ref.h"
namespace jni_zero {
// Attaches the current thread to the VM (if necessary) and return the JNIEnv*.
JNI_ZERO_COMPONENT_BUILD_EXPORT JNIEnv* AttachCurrentThread();
// Same to AttachCurrentThread except that thread name will be set to
// |thread_name| if it is the first call. Otherwise, thread_name won't be
// changed. AttachCurrentThread() doesn't regard underlying platform thread
// name, but just resets it to "Thread-???". This function should be called
// right after new thread is created if it is important to keep thread name.
JNI_ZERO_COMPONENT_BUILD_EXPORT JNIEnv* AttachCurrentThreadWithName(
const std::string& thread_name);
// Detaches the current thread from VM if it is attached.
JNI_ZERO_COMPONENT_BUILD_EXPORT void DetachFromVM();
// Initializes the global JVM.
JNI_ZERO_COMPONENT_BUILD_EXPORT void InitVM(JavaVM* vm);
// Returns true if the global JVM has been initialized.
JNI_ZERO_COMPONENT_BUILD_EXPORT bool IsVMInitialized();
// Returns the global JVM, or nullptr if it has not been initialized.
JNI_ZERO_COMPONENT_BUILD_EXPORT JavaVM* GetVM();
// Do not allow any future native->java calls.
// This is necessary in gtest DEATH_TESTS to prevent
// GetJavaStackTraceIfPresent() from accessing a defunct JVM (due to fork()).
// https://crbug.com/1484834
JNI_ZERO_COMPONENT_BUILD_EXPORT void DisableJvmForTesting();
JNI_ZERO_COMPONENT_BUILD_EXPORT void SetExceptionHandler(
void (*callback)(JNIEnv*));
// Returns true if an exception is pending in the provided JNIEnv*.
JNI_ZERO_COMPONENT_BUILD_EXPORT bool HasException(JNIEnv* env);
// If an exception is pending in the provided JNIEnv*, this function clears it
// and returns true.
JNI_ZERO_COMPONENT_BUILD_EXPORT bool ClearException(JNIEnv* env);
// If there's any pending exception, this function will call the set exception
// handler, or if none are set, it will fatally LOG.
JNI_ZERO_COMPONENT_BUILD_EXPORT void CheckException(JNIEnv* env);
// Sets a function to call instead of just using JNIEnv.FindClass. Useful for
// chrome's "splits" which need to be resolved in special ClassLoaders. The
// class name parameter (first string) will be given in package.dot.Format. The
// second parameter is the split name, which will just be an empty string if not
// used.
JNI_ZERO_COMPONENT_BUILD_EXPORT void SetClassResolver(
jclass (*resolver)(JNIEnv*, const char*, const char*));
// Finds the class named |class_name| and returns it.
// Use this method instead of invoking directly the JNI FindClass method (to
// prevent leaking local references).
// This method triggers a fatal assertion if the class could not be found.
// Use HasClass if you need to check whether the class exists.
JNI_ZERO_COMPONENT_BUILD_EXPORT ScopedJavaLocalRef<jclass>
GetClass(JNIEnv* env, const char* class_name, const char* split_name);
JNI_ZERO_COMPONENT_BUILD_EXPORT ScopedJavaLocalRef<jclass> GetClass(
JNIEnv* env,
const char* class_name);
// The method will initialize |atomic_class_id| to contain a global ref to the
// class. And will return that ref on subsequent calls. It's the caller's
// responsibility to release the ref when it is no longer needed.
// The caller is responsible to zero-initialize |atomic_method_id|.
// It's fine to simultaneously call this on multiple threads referencing the
// same |atomic_method_id|.
JNI_ZERO_COMPONENT_BUILD_EXPORT jclass
LazyGetClass(JNIEnv* env,
const char* class_name,
const char* split_name,
std::atomic<jclass>* atomic_class_id);
JNI_ZERO_COMPONENT_BUILD_EXPORT jclass
LazyGetClass(JNIEnv* env,
const char* class_name,
std::atomic<jclass>* atomic_class_id);
// This class is a wrapper for JNIEnv Get(Static)MethodID.
class JNI_ZERO_COMPONENT_BUILD_EXPORT MethodID {
public:
enum Type {
TYPE_STATIC,
TYPE_INSTANCE,
};
// Returns the method ID for the method with the specified name and signature.
// This method triggers a fatal assertion if the method could not be found.
template <Type type>
static jmethodID Get(JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature);
// The caller is responsible to zero-initialize |atomic_method_id|.
// It's fine to simultaneously call this on multiple threads referencing the
// same |atomic_method_id|.
template <Type type>
static jmethodID LazyGet(JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature,
std::atomic<jmethodID>* atomic_method_id);
};
} // namespace jni_zero
#endif // JNI_ZERO_CORE_H_

View file

@ -0,0 +1,49 @@
// This file was generated by
// //third_party/jni_zero/jni_zero.py
// For
// org.jni_zero.JniInit
#ifndef org_jni_1zero_JniInit_JNI
#define org_jni_1zero_JniInit_JNI
#include <jni.h>
#include "third_party/jni_zero/jni_export.h"
#include "../../../../../../../third_party/jni_zero/jni_zero_internal.h"
// Class Accessors
#ifndef org_jni_1zero_JniInit_clazz_defined
#define org_jni_1zero_JniInit_clazz_defined
inline jclass org_jni_1zero_JniInit_clazz(JNIEnv* env) {
static const char kClassName[] = "org/jni_zero/JniInit";
static std::atomic<jclass> cached_class;
return jni_zero::internal::LazyGetClass(env, kClassName, &cached_class);
}
#endif
namespace jni_zero {
// Native to Java functions
static void Java_JniInit_crashIfMultiplexingMisaligned(
JNIEnv* env,
jlong wholeHash,
jlong priorityHash) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = org_jni_1zero_JniInit_clazz(env);
CHECK_CLAZZ(env, clazz, clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"crashIfMultiplexingMisaligned",
"(JJ)V",
&cached_method_id);
env->CallStaticVoidMethod(clazz, call_context.method_id(), wholeHash, priorityHash);
}
} // namespace jni_zero
#endif // org_jni_1zero_JniInit_JNI

View file

@ -0,0 +1,63 @@
// This file was generated by
// //third_party/jni_zero/jni_zero.py
// For
// org.jni_zero.JniUtil
#ifndef org_jni_1zero_JniUtil_JNI
#define org_jni_1zero_JniUtil_JNI
#include <jni.h>
#include "third_party/jni_zero/jni_export.h"
#include "../../../../../../../third_party/jni_zero/jni_zero_internal.h"
// Class Accessors
#ifndef org_jni_1zero_JniUtil_clazz_defined
#define org_jni_1zero_JniUtil_clazz_defined
inline jclass org_jni_1zero_JniUtil_clazz(JNIEnv* env) {
static const char kClassName[] = "org/jni_zero/JniUtil";
static std::atomic<jclass> cached_class;
return jni_zero::internal::LazyGetClass(env, kClassName, &cached_class);
}
#endif
// Native to Java functions
static jni_zero::ScopedJavaLocalRef<jobject> Java_JniUtil_arrayToMap(
JNIEnv* env,
const jni_zero::JavaRef<jobjectArray>& array) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = org_jni_1zero_JniUtil_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"arrayToMap",
"([Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), array.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
static jni_zero::ScopedJavaLocalRef<jobjectArray> Java_JniUtil_mapToArray(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& map) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = org_jni_1zero_JniUtil_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"mapToArray",
"(Ljava/util/Map;)[Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), map.obj());
jobjectArray _ret2 = static_cast<jobjectArray>(_ret);
return jni_zero::ScopedJavaLocalRef<jobjectArray>(env, _ret2);
}
#endif // org_jni_1zero_JniUtil_JNI

View file

@ -0,0 +1,17 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** Applied to fields that are accessed from native via JNI. Causes R8 to not rename them. */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
public @interface AccessedByNative {
public String value() default "";
}

View file

@ -0,0 +1,28 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used by the JNI generator to create the necessary JNI bindings and expose this method to native
* code.
*
* <p>Any uncaught Java exceptions will crash the current process. This is generally the desired
* behavior, since most exceptions indicate an unexpected error. If your java method expects an
* exception, we recommend refactoring to catch exceptions and indicate errors with special return
* values instead. If this is not possible, see {@link CalledByNativeUnchecked} instead.
*/
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface CalledByNative {
/*
* If present, tells which inner class the method belongs to.
*/
public String value() default "";
}

View file

@ -0,0 +1,26 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used by the JNI generator to create the necessary JNI bindings and expose this method to native
* test-only code.
*
* <p>Any method annotated by this will be kept around for tests only. If you wish to call your
* method from non-test code, see {@link CalledByNative} instead.
*/
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface CalledByNativeForTesting {
/*
* If present, tells which inner class the method belongs to.
*/
public String value() default "";
}

View file

@ -0,0 +1,29 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Similar to {@link CalledByNative}, this also exposes JNI bindings to native code. The main
* difference is this <b>will not</b> crash the browser process if the Java method throws an
* exception. However, the C++ caller <b>must</b> handle and clear the exception before calling into
* any other Java code, otherwise the next Java method call will crash (with the previous call's
* exception, which leads to a very confusing debugging experience).
*
* <p>Usage of this annotation should be very rare; due to the complexity of correctly handling
* exceptions in C++, prefer using {@link CalledByNative}.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface CalledByNativeUnchecked {
/*
* If present, tells which inner class the method belongs to.
*/
public String value() default "";
}

View file

@ -0,0 +1,25 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Causes build to assert that annotated classes / methods / fields are optimized away in release
* builds (when using checkdiscard_proguard.flags).
*/
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface CheckDiscard {
/**
* Describes why the element should be discarded.
*
* @return reason for discarding (crbug links are preferred unless reason is trivial).
*/
String value();
}

View file

@ -0,0 +1,20 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @JNINamespace is used by the JNI generator to create the necessary JNI bindings and expose this
* method to native code using the specified namespace.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface JNINamespace {
public String value();
}

View file

@ -0,0 +1,15 @@
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
/**
* Implemented by the TEST_HOOKS field in JNI wrapper classes that are generated
* by the JNI annotation processor. Used in tests for setting the mock
* implementation of a {@link org.chromium.base.annotations.NativeMethods} interface.
* @param <T> The interface annotated with {@link org.chromium.base.annotations.NativeMethods}
*/
public interface JniStaticTestMocker<T> {
void setInstanceForTesting(T instance);
}

View file

@ -0,0 +1,25 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @NativeClassQualifiedName is used by the JNI generator to create the necessary JNI bindings to
* call into the specified native class name.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface NativeClassQualifiedName {
/*
* Tells which native class the method is going to be bound to.
* The first parameter of the annotated method must be an int nativePtr pointing to
* an instance of this class.
*/
public String value();
}

View file

@ -0,0 +1,44 @@
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import org.chromium.build.BuildConfig;
/**
* Exposes native library loading status.
*/
public class NativeLibraryLoadedStatus {
/**
* Interface for querying native method availability.
*/
public interface NativeLibraryLoadedStatusProvider {
boolean areNativeMethodsReady();
}
private static NativeLibraryLoadedStatusProvider sProvider;
public static class NativeNotLoadedException extends RuntimeException {
public NativeNotLoadedException(String s) {
super(s);
}
}
public static void checkLoaded() {
if (sProvider == null) return;
if (!sProvider.areNativeMethodsReady()) {
throw new NativeNotLoadedException(
"Native method called before the native library was ready.");
}
}
public static void setProvider(NativeLibraryLoadedStatusProvider statusProvider) {
sProvider = statusProvider;
}
public static NativeLibraryLoadedStatusProvider getProviderForTesting() {
return sProvider;
}
}

View file

@ -0,0 +1,20 @@
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.jni_zero;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface NativeMethods {
/**
* Tells the build system to call a different GEN_JNI, prefixed by the value we put here. This
* should only be used for feature modules where we need a different GEN_JNI. For example, if
* you did @NativeMethods("dfmname"), this would call into dfmname_GEN_JNI.java.
*/
public String value() default "";
}

View file

@ -0,0 +1,24 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef JNI_ZERO_JNI_EXPORT_H_
#define JNI_ZERO_JNI_EXPORT_H_
#if defined(__i386__)
// Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on
// x86 - use force_align_arg_pointer to realign the stack at the JNI
// boundary. crbug.com/655248
#define JNI_BOUNDARY_EXPORT \
extern "C" __attribute__((visibility("default"), force_align_arg_pointer))
#else
#define JNI_BOUNDARY_EXPORT extern "C" __attribute__((visibility("default")))
#endif
#if defined(COMPONENT_BUILD)
#define JNI_ZERO_COMPONENT_BUILD_EXPORT __attribute__((visibility("default")))
#else
#define JNI_ZERO_COMPONENT_BUILD_EXPORT
#endif
#endif // JNI_ZERO_JNI_EXPORT_H_

View file

@ -0,0 +1,58 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef JNI_ZERO_JNI_INT_WRAPPER_H_
#define JNI_ZERO_JNI_INT_WRAPPER_H_
// Wrapper used to receive int when calling Java from native.
// The wrapper disallows automatic conversion of long to int.
// This is to avoid a common anti-pattern where a Java int is used
// to receive a native pointer. Please use a Java long to receive
// native pointers, so that the code works on both 32-bit and 64-bit
// platforms. Note the wrapper allows other lossy conversions into
// jint that could be consider anti-patterns, such as from size_t.
// Checking is only done in debugging builds.
#ifdef NDEBUG
typedef jint JniIntWrapper;
// This inline is sufficiently trivial that it does not change the
// final code generated by g++.
inline jint as_jint(JniIntWrapper wrapper) {
return wrapper;
}
#else
class JniIntWrapper {
public:
JniIntWrapper() : i_(0) {}
JniIntWrapper(int i) : i_(i) {}
JniIntWrapper(const JniIntWrapper& ji) : i_(ji.i_) {}
template <class T>
JniIntWrapper(const T& t) : i_(t) {}
jint as_jint() const { return i_; }
private:
// If you get an "is private" error at the line below it is because you used
// an implicit conversion to convert a long to an int when calling Java.
// We disallow this, as a common anti-pattern allows converting a native
// pointer (intptr_t) to a Java int. Please use a Java long to represent
// a native pointer. If you want a lossy conversion, please use an
// explicit conversion in your C++ code. Note an error is only seen when
// compiling on a 64-bit platform, as intptr_t is indistinguishable from
// int on 32-bit platforms.
JniIntWrapper(long);
jint i_;
};
inline jint as_jint(const JniIntWrapper& wrapper) {
return wrapper.as_jint();
}
#endif // NDEBUG
#endif // JNI_ZERO_JNI_INT_WRAPPER_H_

View file

@ -0,0 +1,117 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef JNI_ZERO_JNI_ZERO_HELPER_H_
#define JNI_ZERO_JNI_ZERO_HELPER_H_
#include <jni.h>
#include "third_party/jni_zero/core.h"
#include "third_party/jni_zero/jni_export.h"
#include "third_party/jni_zero/jni_int_wrapper.h"
#include "third_party/jni_zero/logging.h"
// Project-specific macros used by the header files generated by
// jni_generator.py. Different projects can then specify their own
// implementation for this file.
#define CHECK_NATIVE_PTR(env, jcaller, native_ptr, method_name, ...) \
JNI_ZERO_DCHECK(native_ptr);
#define CHECK_CLAZZ(env, jcaller, clazz, ...) JNI_ZERO_DCHECK(clazz);
#if defined(__clang__) && __has_attribute(noinline)
#define JNI_ZERO_NOINLINE [[clang::noinline]]
#elif __has_attribute(noinline)
#define JNI_ZERO_NOINLINE __attribute__((noinline))
#endif
#if defined(__clang__) && defined(NDEBUG) && __has_attribute(always_inline)
#define JNI_ZERO_ALWAYS_INLINE [[clang::always_inline]] inline
#elif defined(NDEBUG) && __has_attribute(always_inline)
#define JNI_ZERO_ALWAYS_INLINE inline __attribute__((__always_inline__))
#else
#define JNI_ZERO_ALWAYS_INLINE inline
#endif
namespace jni_zero {
inline void HandleRegistrationError(JNIEnv* env,
jclass clazz,
const char* filename) {
JNI_ZERO_ELOG("RegisterNatives failed in %s", filename);
}
// A 32 bit number could be an address on stack. Random 64 bit marker on the
// stack is much less likely to be present on stack.
constexpr uint64_t kJniStackMarkerValue = 0xbdbdef1bebcade1b;
// Context about the JNI call with exception checked to be stored in stack.
struct JNI_ZERO_COMPONENT_BUILD_EXPORT JniJavaCallContextUnchecked {
JNI_ZERO_ALWAYS_INLINE JniJavaCallContextUnchecked() {
// TODO(ssid): Implement for other architectures.
#if defined(__arm__) || defined(__aarch64__)
// This assumes that this method does not increment the stack pointer.
asm volatile("mov %0, sp" : "=r"(sp));
#else
sp = 0;
#endif
}
// Force no inline to reduce code size.
template <MethodID::Type type>
JNI_ZERO_NOINLINE void Init(JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature,
std::atomic<jmethodID>* atomic_method_id) {
env1 = env;
// Make sure compiler doesn't optimize out the assignment.
memcpy(&marker, &kJniStackMarkerValue, sizeof(kJniStackMarkerValue));
// Gets PC of the calling function.
pc = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
method_id = MethodID::LazyGet<type>(env, clazz, method_name, jni_signature,
atomic_method_id);
}
JNI_ZERO_NOINLINE ~JniJavaCallContextUnchecked() {
// Reset so that spurious marker finds are avoided.
memset(&marker, 0, sizeof(marker));
}
uint64_t marker;
uintptr_t sp;
uintptr_t pc;
JNIEnv* env1;
jmethodID method_id;
};
// Context about the JNI call with exception unchecked to be stored in stack.
struct JNI_ZERO_COMPONENT_BUILD_EXPORT JniJavaCallContextChecked {
// Force no inline to reduce code size.
template <MethodID::Type type>
JNI_ZERO_NOINLINE void Init(JNIEnv* env,
jclass clazz,
const char* method_name,
const char* jni_signature,
std::atomic<jmethodID>* atomic_method_id) {
base.Init<type>(env, clazz, method_name, jni_signature, atomic_method_id);
// Reset |pc| to correct caller.
base.pc = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
}
JNI_ZERO_NOINLINE ~JniJavaCallContextChecked() { CheckException(base.env1); }
JniJavaCallContextUnchecked base;
};
static_assert(sizeof(JniJavaCallContextChecked) ==
sizeof(JniJavaCallContextUnchecked),
"Stack unwinder cannot work with structs of different sizes.");
} // namespace jni_zero
#endif // JNI_ZERO_JNI_ZERO_HELPER_H_

View file

@ -0,0 +1,76 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/jni_zero/logging.h"
#include <stdarg.h>
#include <stdio.h>
#include <atomic>
#include <memory>
#ifndef JNI_ZERO_IS_ROBOLECTRIC
#include <android/log.h>
#endif
namespace jni_zero {
std::atomic<LogMessageCallback> g_log_callback{};
void SetLogMessageCallback(LogMessageCallback callback) {
g_log_callback.store(callback, std::memory_order_relaxed);
}
void LogMessage(LogLev level,
const char* fname,
int line,
const char* fmt,
...) {
char stack_buf[512];
std::unique_ptr<char[]> large_buf;
char* log_msg = &stack_buf[0];
// By default use a stack allocated buffer because most log messages are quite
// short. In rare cases they can be larger (e.g. --help). In those cases we
// pay the cost of allocating the buffer on the heap.
for (size_t max_len = sizeof(stack_buf);;) {
va_list args;
va_start(args, fmt);
int res = vsnprintf(log_msg, max_len, fmt, args);
va_end(args);
// If for any reason the print fails, overwrite the message but still print
// it. The code below will attach the filename and line, which is still
// useful.
if (res < 0) {
snprintf(log_msg, max_len, "%s", "[printf format error]");
break;
}
// if res == max_len, vsnprintf saturated the input buffer. Retry with a
// larger buffer in that case (within reasonable limits).
if (res < static_cast<int>(max_len) || max_len >= 128 * 1024) {
break;
}
max_len *= 4;
large_buf.reset(new char[max_len]);
log_msg = &large_buf[0];
}
LogMessageCallback cb = g_log_callback.load(std::memory_order_relaxed);
if (cb) {
cb({level, line, fname, log_msg});
return;
}
#ifdef JNI_ZERO_IS_ROBOLECTRIC
fprintf(stderr, "%s:%d %s\n", fname, line, log_msg);
#else
__android_log_print(int{ANDROID_LOG_DEBUG} + level, "jni_zero", "%s:%d %s",
fname, line, log_msg);
#endif
if (level >= kLogFatal) {
JNI_ZERO_IMMEDIATE_CRASH();
}
}
} // namespace jni_zero

View file

@ -0,0 +1,90 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef JNI_ZERO_LOGGING_H_
#define JNI_ZERO_LOGGING_H_
#include "third_party/jni_zero/jni_export.h"
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
#define JNI_ZERO_DCHECK_IS_ON() false
#else
#define JNI_ZERO_DCHECK_IS_ON() true
#endif
// Simplified version of Google's logging. Adapted from perfetto's
// implementation.
namespace jni_zero {
// Constexpr functions to extract basename(__FILE__), e.g.: ../foo/f.c -> f.c .
constexpr const char* StrEnd(const char* s) {
return *s ? StrEnd(s + 1) : s;
}
constexpr const char* BasenameRecursive(const char* s,
const char* begin,
const char* end) {
return (*s == '/' && s < end)
? (s + 1)
: ((s > begin) ? BasenameRecursive(s - 1, begin, end) : s);
}
constexpr const char* Basename(const char* str) {
return BasenameRecursive(StrEnd(str), str, StrEnd(str));
}
enum LogLev { kLogInfo = 0, kLogError, kLogFatal };
struct LogMessageCallbackArgs {
LogLev level;
int line;
const char* filename;
const char* message;
};
using LogMessageCallback = void (*)(LogMessageCallbackArgs);
// This is not thread safe and must be called before using tracing from other
// threads.
JNI_ZERO_COMPONENT_BUILD_EXPORT void SetLogMessageCallback(
LogMessageCallback callback);
JNI_ZERO_COMPONENT_BUILD_EXPORT void LogMessage(LogLev,
const char* fname,
int line,
const char* fmt,
...)
__attribute__((__format__(__printf__, 4, 5)));
#define JNI_ZERO_IMMEDIATE_CRASH() \
do { \
__builtin_trap(); \
__builtin_unreachable(); \
} while (0)
#define JNI_ZERO_XLOG(level, fmt, ...) \
::jni_zero::LogMessage(level, ::jni_zero::Basename(__FILE__), __LINE__, fmt, \
##__VA_ARGS__)
#define JNI_ZERO_ILOG(fmt, ...) \
JNI_ZERO_XLOG(::jni_zero::kLogInfo, fmt, ##__VA_ARGS__)
#define JNI_ZERO_ELOG(fmt, ...) \
JNI_ZERO_XLOG(::jni_zero::kLogError, fmt, ##__VA_ARGS__)
#define JNI_ZERO_FLOG(fmt, ...) \
JNI_ZERO_XLOG(::jni_zero::kLogFatal, fmt, ##__VA_ARGS__)
#define JNI_ZERO_CHECK(x) \
do { \
if (__builtin_expect(!(x), 0)) { \
JNI_ZERO_FLOG("%s", "JNI_ZERO_CHECK(" #x ")"); \
} \
} while (0)
#if JNI_ZERO_DCHECK_IS_ON()
#define JNI_ZERO_DCHECK(x) JNI_ZERO_CHECK(x)
#else
#define JNI_ZERO_DCHECK(x) \
do { \
} while (false && (x))
#endif
} // namespace jni_zero
#endif // JNI_ZERO_LOGGING_H_

View file

@ -0,0 +1,14 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Keeps for method level annotations.
-keepclasseswithmembers,allowaccessmodification class ** {
@org.jni_zero.AccessedByNative <fields>;
}
-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** {
@org.jni_zero.CalledByNative <methods>;
}
-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** {
@org.jni_zero.CalledByNativeUnchecked <methods>;
}

View file

@ -0,0 +1,7 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** {
@org.jni_zero.CalledByNativeForTesting <methods>;
}

View file

@ -0,0 +1,93 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/jni_zero/scoped_java_ref.h"
#include "third_party/jni_zero/core.h"
namespace jni_zero {
namespace {
const int kDefaultLocalFrameCapacity = 16;
} // namespace
ScopedJavaLocalFrame::ScopedJavaLocalFrame(JNIEnv* env) : env_(env) {
int failed = env_->PushLocalFrame(kDefaultLocalFrameCapacity);
JNI_ZERO_DCHECK(!failed);
}
ScopedJavaLocalFrame::ScopedJavaLocalFrame(JNIEnv* env, int capacity)
: env_(env) {
int failed = env_->PushLocalFrame(capacity);
JNI_ZERO_DCHECK(!failed);
}
ScopedJavaLocalFrame::~ScopedJavaLocalFrame() {
env_->PopLocalFrame(nullptr);
}
#if JNI_ZERO_DCHECK_IS_ON()
// This constructor is inlined when DCHECKs are disabled; don't add anything
// else here.
JavaRef<jobject>::JavaRef(JNIEnv* env, jobject obj) : obj_(obj) {
if (obj) {
JNI_ZERO_DCHECK(env && env->GetObjectRefType(obj) == JNILocalRefType);
}
}
#endif
JNIEnv* JavaRef<jobject>::SetNewLocalRef(JNIEnv* env, jobject obj) {
if (!env) {
env = AttachCurrentThread();
} else {
JNI_ZERO_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
}
if (obj) {
obj = env->NewLocalRef(obj);
}
if (obj_) {
env->DeleteLocalRef(obj_);
}
obj_ = obj;
return env;
}
void JavaRef<jobject>::SetNewGlobalRef(JNIEnv* env, jobject obj) {
if (!env) {
env = AttachCurrentThread();
} else {
JNI_ZERO_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
}
if (obj) {
obj = env->NewGlobalRef(obj);
}
if (obj_) {
env->DeleteGlobalRef(obj_);
}
obj_ = obj;
}
void JavaRef<jobject>::ResetLocalRef(JNIEnv* env) {
if (obj_) {
JNI_ZERO_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
env->DeleteLocalRef(obj_);
obj_ = nullptr;
}
}
void JavaRef<jobject>::ResetGlobalRef() {
if (obj_) {
AttachCurrentThread()->DeleteGlobalRef(obj_);
obj_ = nullptr;
}
}
jobject JavaRef<jobject>::ReleaseInternal() {
jobject obj = obj_;
obj_ = nullptr;
return obj;
}
} // namespace jni_zero

View file

@ -0,0 +1,534 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef JNI_ZERO_SCOPED_JAVA_REF_H_
#define JNI_ZERO_SCOPED_JAVA_REF_H_
#include <jni.h>
#include <stddef.h>
#include <type_traits>
#include <utility>
#include "third_party/jni_zero/jni_export.h"
#include "third_party/jni_zero/logging.h"
namespace jni_zero {
// Creates a new local reference frame, in which at least a given number of
// local references can be created. Note that local references already created
// in previous local frames are still valid in the current local frame.
class JNI_ZERO_COMPONENT_BUILD_EXPORT ScopedJavaLocalFrame {
public:
explicit ScopedJavaLocalFrame(JNIEnv* env);
ScopedJavaLocalFrame(JNIEnv* env, int capacity);
ScopedJavaLocalFrame(const ScopedJavaLocalFrame&) = delete;
ScopedJavaLocalFrame& operator=(const ScopedJavaLocalFrame&) = delete;
~ScopedJavaLocalFrame();
private:
// This class is only good for use on the thread it was created on so
// it's safe to cache the non-threadsafe JNIEnv* inside this object.
JNIEnv* env_;
};
// Forward declare the generic java reference template class.
template <typename T>
class JavaRef;
// Template specialization of JavaRef, which acts as the base class for all
// other JavaRef<> template types. This allows you to e.g. pass
// ScopedJavaLocalRef<jstring> into a function taking const JavaRef<jobject>&
template <>
class JNI_ZERO_COMPONENT_BUILD_EXPORT JavaRef<jobject> {
public:
// Initializes a null reference.
constexpr JavaRef() {}
// Allow nullptr to be converted to JavaRef. This avoids having to declare an
// empty JavaRef just to pass null to a function, and makes C++ "nullptr" and
// Java "null" equivalent.
constexpr JavaRef(std::nullptr_t) {}
JavaRef(const JavaRef&) = delete;
JavaRef& operator=(const JavaRef&) = delete;
// Public to allow destruction of null JavaRef objects.
~JavaRef() {}
// TODO(torne): maybe rename this to get() for consistency with unique_ptr
// once there's fewer unnecessary uses of it in the codebase.
jobject obj() const { return obj_; }
explicit operator bool() const { return obj_ != nullptr; }
// Deprecated. Just use bool conversion.
// TODO(torne): replace usage and remove this.
bool is_null() const { return obj_ == nullptr; }
protected:
// Takes ownership of the |obj| reference passed; requires it to be a local
// reference type.
#if JNI_ZERO_DCHECK_IS_ON()
// Implementation contains a DCHECK; implement out-of-line when DCHECK_IS_ON.
JavaRef(JNIEnv* env, jobject obj);
#else
JavaRef(JNIEnv* env, jobject obj) : obj_(obj) {}
#endif
// Used for move semantics. obj_ must have been released first if non-null.
void steal(JavaRef&& other) {
obj_ = other.obj_;
other.obj_ = nullptr;
}
// The following are implementation detail convenience methods, for
// use by the sub-classes.
JNIEnv* SetNewLocalRef(JNIEnv* env, jobject obj);
void SetNewGlobalRef(JNIEnv* env, jobject obj);
void ResetLocalRef(JNIEnv* env);
void ResetGlobalRef();
jobject ReleaseInternal();
private:
jobject obj_ = nullptr;
};
// Forward declare the object array reader for the convenience function.
template <typename T>
class JavaObjectArrayReader;
// Generic base class for ScopedJavaLocalRef and ScopedJavaGlobalRef. Useful
// for allowing functions to accept a reference without having to mandate
// whether it is a local or global type.
template <typename T>
class JavaRef : public JavaRef<jobject> {
public:
constexpr JavaRef() {}
constexpr JavaRef(std::nullptr_t) {}
JavaRef(const JavaRef&) = delete;
JavaRef& operator=(const JavaRef&) = delete;
~JavaRef() {}
T obj() const { return static_cast<T>(JavaRef<jobject>::obj()); }
// Get a JavaObjectArrayReader for the array pointed to by this reference.
// Only defined for JavaRef<jobjectArray>.
// You must pass the type of the array elements (usually jobject) as the
// template parameter.
template <typename ElementType,
typename T_ = T,
typename = std::enable_if_t<std::is_same_v<T_, jobjectArray>>>
JavaObjectArrayReader<ElementType> ReadElements() const {
return JavaObjectArrayReader<ElementType>(*this);
}
protected:
JavaRef(JNIEnv* env, T obj) : JavaRef<jobject>(env, obj) {}
};
// Holds a local reference to a JNI method parameter.
// Method parameters should not be deleted, and so this class exists purely to
// wrap them as a JavaRef<T> in the JNI binding generator. Do not create
// instances manually.
template <typename T>
class JavaParamRef : public JavaRef<T> {
public:
// Assumes that |obj| is a parameter passed to a JNI method from Java.
// Does not assume ownership as parameters should not be deleted.
JavaParamRef(JNIEnv* env, T obj) : JavaRef<T>(env, obj) {}
// Allow nullptr to be converted to JavaParamRef. Some unit tests call JNI
// methods directly from C++ and pass null for objects which are not actually
// used by the implementation (e.g. the caller object); allow this to keep
// working.
JavaParamRef(std::nullptr_t) {}
JavaParamRef(const JavaParamRef&) = delete;
JavaParamRef& operator=(const JavaParamRef&) = delete;
~JavaParamRef() {}
// TODO(torne): remove this cast once we're using JavaRef consistently.
// http://crbug.com/506850
operator T() const { return JavaRef<T>::obj(); }
};
// Holds a local reference to a Java object. The local reference is scoped
// to the lifetime of this object.
// Instances of this class may hold onto any JNIEnv passed into it until
// destroyed. Therefore, since a JNIEnv is only suitable for use on a single
// thread, objects of this class must be created, used, and destroyed, on a
// single thread.
// Therefore, this class should only be used as a stack-based object and from a
// single thread. If you wish to have the reference outlive the current
// callstack (e.g. as a class member) or you wish to pass it across threads,
// use a ScopedJavaGlobalRef instead.
template <typename T>
class ScopedJavaLocalRef : public JavaRef<T> {
public:
// Take ownership of a bare jobject. This does not create a new reference.
// This should only be used by JNI helper functions, or in cases where code
// must call JNIEnv methods directly.
static ScopedJavaLocalRef Adopt(JNIEnv* env, T obj) {
return ScopedJavaLocalRef(env, obj);
}
constexpr ScopedJavaLocalRef() {}
constexpr ScopedJavaLocalRef(std::nullptr_t) {}
// Copy constructor. This is required in addition to the copy conversion
// constructor below.
ScopedJavaLocalRef(const ScopedJavaLocalRef& other) : env_(other.env_) {
JavaRef<T>::SetNewLocalRef(env_, other.obj());
}
// Copy conversion constructor.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaLocalRef(const ScopedJavaLocalRef<U>& other) : env_(other.env_) {
JavaRef<T>::SetNewLocalRef(env_, other.obj());
}
// Move constructor. This is required in addition to the move conversion
// constructor below.
ScopedJavaLocalRef(ScopedJavaLocalRef&& other) : env_(other.env_) {
JavaRef<T>::steal(std::move(other));
}
// Move conversion constructor.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaLocalRef(ScopedJavaLocalRef<U>&& other) : env_(other.env_) {
JavaRef<T>::steal(std::move(other));
}
// Constructor for other JavaRef types.
explicit ScopedJavaLocalRef(const JavaRef<T>& other) { Reset(other); }
// Assumes that |obj| is a local reference to a Java object and takes
// ownership of this local reference.
// TODO(torne): make legitimate uses call Adopt() instead, and make this
// private.
ScopedJavaLocalRef(JNIEnv* env, T obj) : JavaRef<T>(env, obj), env_(env) {}
~ScopedJavaLocalRef() { Reset(); }
// Null assignment, for disambiguation.
ScopedJavaLocalRef& operator=(std::nullptr_t) {
Reset();
return *this;
}
// Copy assignment.
ScopedJavaLocalRef& operator=(const ScopedJavaLocalRef& other) {
Reset(other);
return *this;
}
// Copy conversion assignment.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaLocalRef& operator=(const ScopedJavaLocalRef<U>& other) {
Reset(other);
return *this;
}
// Move assignment.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaLocalRef& operator=(ScopedJavaLocalRef<U>&& other) {
env_ = other.env_;
Reset();
JavaRef<T>::steal(std::move(other));
return *this;
}
// Assignment for other JavaRef types.
ScopedJavaLocalRef& operator=(const JavaRef<T>& other) {
Reset(other);
return *this;
}
void Reset() { JavaRef<T>::ResetLocalRef(env_); }
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
void Reset(const ScopedJavaLocalRef<U>& other) {
// We can copy over env_ here as |other| instance must be from the same
// thread as |this| local ref. (See class comment for multi-threading
// limitations, and alternatives).
env_ = JavaRef<T>::SetNewLocalRef(other.env_, other.obj());
}
void Reset(const JavaRef<T>& other) {
// If |env_| was not yet set (is still null) it will be attached to the
// current thread in SetNewLocalRef().
env_ = JavaRef<T>::SetNewLocalRef(env_, other.obj());
}
// Releases the local reference to the caller. The caller *must* delete the
// local reference when it is done with it. Note that calling a Java method
// is *not* a transfer of ownership and Release() should not be used.
T Release() { return static_cast<T>(JavaRef<T>::ReleaseInternal()); }
private:
// This class is only good for use on the thread it was created on so
// it's safe to cache the non-threadsafe JNIEnv* inside this object.
JNIEnv* env_ = nullptr;
// Prevent ScopedJavaLocalRef(JNIEnv*, T obj) from being used to take
// ownership of a JavaParamRef's underlying object - parameters are not
// allowed to be deleted and so should not be owned by ScopedJavaLocalRef.
// TODO(torne): this can be removed once JavaParamRef no longer has an
// implicit conversion back to T.
ScopedJavaLocalRef(JNIEnv* env, const JavaParamRef<T>& other);
// Friend required to get env_ from conversions.
template <typename U>
friend class ScopedJavaLocalRef;
// Avoids JavaObjectArrayReader having to accept and store its own env.
template <typename U>
friend class JavaObjectArrayReader;
};
// Holds a global reference to a Java object. The global reference is scoped
// to the lifetime of this object. This class does not hold onto any JNIEnv*
// passed to it, hence it is safe to use across threads (within the constraints
// imposed by the underlying Java object that it references).
template <typename T>
class ScopedJavaGlobalRef : public JavaRef<T> {
public:
constexpr ScopedJavaGlobalRef() {}
constexpr ScopedJavaGlobalRef(std::nullptr_t) {}
// Copy constructor. This is required in addition to the copy conversion
// constructor below.
ScopedJavaGlobalRef(const ScopedJavaGlobalRef& other) { Reset(other); }
// Copy conversion constructor.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaGlobalRef(const ScopedJavaGlobalRef<U>& other) {
Reset(other);
}
// Move constructor. This is required in addition to the move conversion
// constructor below.
ScopedJavaGlobalRef(ScopedJavaGlobalRef&& other) {
JavaRef<T>::steal(std::move(other));
}
// Move conversion constructor.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaGlobalRef(ScopedJavaGlobalRef<U>&& other) {
JavaRef<T>::steal(std::move(other));
}
// Conversion constructor for other JavaRef types.
explicit ScopedJavaGlobalRef(const JavaRef<T>& other) { Reset(other); }
// Create a new global reference to the object.
// Deprecated. Don't use bare jobjects; use a JavaRef as the input.
ScopedJavaGlobalRef(JNIEnv* env, T obj) { Reset(env, obj); }
~ScopedJavaGlobalRef() { Reset(); }
// Null assignment, for disambiguation.
ScopedJavaGlobalRef& operator=(std::nullptr_t) {
Reset();
return *this;
}
// Copy assignment.
ScopedJavaGlobalRef& operator=(const ScopedJavaGlobalRef& other) {
Reset(other);
return *this;
}
// Copy conversion assignment.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaGlobalRef& operator=(const ScopedJavaGlobalRef<U>& other) {
Reset(other);
return *this;
}
// Move assignment.
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
ScopedJavaGlobalRef& operator=(ScopedJavaGlobalRef<U>&& other) {
Reset();
JavaRef<T>::steal(std::move(other));
return *this;
}
// Assignment for other JavaRef types.
ScopedJavaGlobalRef& operator=(const JavaRef<T>& other) {
Reset(other);
return *this;
}
void Reset() { JavaRef<T>::ResetGlobalRef(); }
template <typename U,
typename = std::enable_if_t<std::is_convertible_v<U, T>>>
void Reset(const ScopedJavaGlobalRef<U>& other) {
Reset(nullptr, other.obj());
}
void Reset(const JavaRef<T>& other) { Reset(nullptr, other.obj()); }
// Deprecated. You can just use Reset(const JavaRef&).
void Reset(JNIEnv* env, const JavaParamRef<T>& other) {
Reset(env, other.obj());
}
// Deprecated. Don't use bare jobjects; use a JavaRef as the input.
void Reset(JNIEnv* env, T obj) { JavaRef<T>::SetNewGlobalRef(env, obj); }
// Releases the global reference to the caller. The caller *must* delete the
// global reference when it is done with it. Note that calling a Java method
// is *not* a transfer of ownership and Release() should not be used.
T Release() { return static_cast<T>(JavaRef<T>::ReleaseInternal()); }
};
// Wrapper for a jobjectArray which supports input iteration, allowing Java
// arrays to be iterated over with a range-based for loop, or used with
// <algorithm> functions that accept input iterators.
//
// The iterator returns each object in the array in turn, wrapped in a
// ScopedJavaLocalRef<T>. T will usually be jobject, but if you know that the
// array contains a more specific type (such as jstring) you can use that
// instead. This does not check the type at runtime!
//
// The wrapper holds a local reference to the array and only queries the size of
// the array once, so must only be used as a stack-based object from the current
// thread.
//
// Note that this does *not* update the contents of the array if you mutate the
// returned ScopedJavaLocalRef.
template <typename T>
class JavaObjectArrayReader {
public:
class iterator {
public:
// We can only be an input iterator, as all richer iterator types must
// implement the multipass guarantee (always returning the same object for
// the same iterator position), which is not practical when returning
// temporary objects.
using iterator_category = std::input_iterator_tag;
using difference_type = ptrdiff_t;
using value_type = ScopedJavaLocalRef<T>;
// It doesn't make sense to return a reference type as the iterator creates
// temporary wrapper objects when dereferenced. Fortunately, it's not
// required that input iterators actually use references, and defining it
// as value_type is valid.
using reference = value_type;
// This exists to make operator-> work as expected: its return value must
// resolve to an actual pointer (otherwise the compiler just keeps calling
// operator-> on the return value until it does), so we need an extra level
// of indirection. This is sometimes called an "arrow proxy" or similar, and
// this version is adapted from base/value_iterators.h.
class pointer {
public:
explicit pointer(const reference& ref) : ref_(ref) {}
pointer(const pointer& ptr) = default;
pointer& operator=(const pointer& ptr) = delete;
reference* operator->() { return &ref_; }
private:
reference ref_;
};
iterator(const iterator&) = default;
~iterator() = default;
iterator& operator=(const iterator&) = default;
bool operator==(const iterator& other) const {
JNI_ZERO_DCHECK(reader_ == other.reader_);
return i_ == other.i_;
}
bool operator!=(const iterator& other) const {
JNI_ZERO_DCHECK(reader_ == other.reader_);
return i_ != other.i_;
}
reference operator*() const {
JNI_ZERO_DCHECK(i_ < reader_->size_);
// JNIEnv functions return unowned local references; take ownership with
// Adopt so that ~ScopedJavaLocalRef will release it automatically later.
return value_type::Adopt(
reader_->array_.env_,
static_cast<T>(reader_->array_.env_->GetObjectArrayElement(
reader_->array_.obj(), i_)));
}
pointer operator->() const { return pointer(operator*()); }
iterator& operator++() {
JNI_ZERO_DCHECK(i_ < reader_->size_);
++i_;
return *this;
}
iterator operator++(int) {
iterator old = *this;
++*this;
return old;
}
private:
iterator(const JavaObjectArrayReader* reader, jsize i)
: reader_(reader), i_(i) {}
const JavaObjectArrayReader<T>* reader_;
jsize i_;
friend JavaObjectArrayReader;
};
JavaObjectArrayReader(const JavaRef<jobjectArray>& array) : array_(array) {
size_ = array_.env_->GetArrayLength(array_.obj());
}
// Copy constructor to allow returning it from JavaRef::ReadElements().
JavaObjectArrayReader(const JavaObjectArrayReader& other) = default;
// Assignment operator for consistency with copy constructor.
JavaObjectArrayReader& operator=(const JavaObjectArrayReader& other) =
default;
// Allow move constructor and assignment since this owns a local ref.
JavaObjectArrayReader(JavaObjectArrayReader&& other) = default;
JavaObjectArrayReader& operator=(JavaObjectArrayReader&& other) = default;
bool empty() const { return size_ == 0; }
jsize size() const { return size_; }
iterator begin() const { return iterator(this, 0); }
iterator end() const { return iterator(this, size_); }
private:
ScopedJavaLocalRef<jobjectArray> array_;
jsize size_;
friend iterator;
};
} // namespace jni_zero
#endif // JNI_ZERO_SCOPED_JAVA_REF_H_

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,385 @@
// This file was generated by
// //third_party/jni_zero/jni_zero.py
// For
// java.util.Collection
#ifndef java_util_Collection_JNI
#define java_util_Collection_JNI
#include <jni.h>
#include "third_party/jni_zero/jni_export.h"
#include "../../../../../../../third_party/jni_zero/jni_zero_internal.h"
// Class Accessors
#ifndef java_util_Collection_clazz_defined
#define java_util_Collection_clazz_defined
inline jclass java_util_Collection_clazz(JNIEnv* env) {
static const char kClassName[] = "java/util/Collection";
static std::atomic<jclass> cached_class;
return jni_zero::internal::LazyGetClass(env, kClassName, &cached_class);
}
#endif
namespace JNI_Collection {
// Native to Java functions
[[maybe_unused]] static jboolean Java_Collection_add(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"add",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_addAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"addAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static void Java_Collection_clear(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"clear",
"()V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id());
}
[[maybe_unused]] static jboolean Java_Collection_contains(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"contains",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_containsAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"containsAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_equals(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"equals",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jint Java_Collection_hashCode(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"hashCode",
"()I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_isEmpty(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"isEmpty",
"()Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Collection_iterator(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"iterator",
"()Ljava/util/Iterator;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Collection_parallelStream(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"parallelStream",
"()Ljava/util/stream/Stream;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_Collection_remove(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"remove",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_removeAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"removeAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_removeIf(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"removeIf",
"(Ljava/util/function/Predicate;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Collection_retainAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"retainAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jint Java_Collection_size(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"size",
"()I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Collection_spliterator(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"spliterator",
"()Ljava/util/Spliterator;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Collection_stream(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"stream",
"()Ljava/util/stream/Stream;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobjectArray> Java_Collection_toArray(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"toArray",
"()[Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
jobjectArray _ret2 = static_cast<jobjectArray>(_ret);
return jni_zero::ScopedJavaLocalRef<jobjectArray>(env, _ret2);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobjectArray> Java_Collection_toArray__java_util_function_IntFunction(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"toArray",
"(Ljava/util/function/IntFunction;)[Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj());
jobjectArray _ret2 = static_cast<jobjectArray>(_ret);
return jni_zero::ScopedJavaLocalRef<jobjectArray>(env, _ret2);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobjectArray> Java_Collection_toArray__ObjectArray(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobjectArray>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Collection_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"toArray",
"([Ljava/lang/Object;)[Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj());
jobjectArray _ret2 = static_cast<jobjectArray>(_ret);
return jni_zero::ScopedJavaLocalRef<jobjectArray>(env, _ret2);
}
} // namespace JNI_Collection
#endif // java_util_Collection_JNI

View file

@ -0,0 +1,994 @@
// This file was generated by
// //third_party/jni_zero/jni_zero.py
// For
// java.util.List
#ifndef java_util_List_JNI
#define java_util_List_JNI
#include <jni.h>
#include "third_party/jni_zero/jni_export.h"
#include "../../../../../../../third_party/jni_zero/jni_zero_internal.h"
// Class Accessors
#ifndef java_util_List_clazz_defined
#define java_util_List_clazz_defined
inline jclass java_util_List_clazz(JNIEnv* env) {
static const char kClassName[] = "java/util/List";
static std::atomic<jclass> cached_class;
return jni_zero::internal::LazyGetClass(env, kClassName, &cached_class);
}
#endif
namespace JNI_List {
// Native to Java functions
[[maybe_unused]] static jboolean Java_List_add(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"add",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static void Java_List_add(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"add",
"(ILjava/lang/Object;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), as_jint(p0), p1.obj());
}
[[maybe_unused]] static jboolean Java_List_addAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"addAll",
"(ILjava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), as_jint(p0), p1.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_List_addAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"addAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static void Java_List_addFirst(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"addFirst",
"(Ljava/lang/Object;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static void Java_List_addLast(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"addLast",
"(Ljava/lang/Object;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static void Java_List_clear(JNIEnv* env, const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"clear",
"()V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id());
}
[[maybe_unused]] static jboolean Java_List_contains(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"contains",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_List_containsAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"containsAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_copyOf(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"copyOf",
"(Ljava/util/Collection;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_List_equals(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"equals",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_get(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"get",
"(I)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), as_jint(p0));
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_getFirst(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"getFirst",
"()Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_getLast(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"getLast",
"()Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jint Java_List_hashCode(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"hashCode",
"()I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jint Java_List_indexOf(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"indexOf",
"(Ljava/lang/Object;)I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_List_isEmpty(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"isEmpty",
"()Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_iterator(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"iterator",
"()Ljava/util/Iterator;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jint Java_List_lastIndexOf(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"lastIndexOf",
"(Ljava/lang/Object;)I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_listIterator(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"listIterator",
"()Ljava/util/ListIterator;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_listIterator(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"listIterator",
"(I)Ljava/util/ListIterator;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), as_jint(p0));
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(JNIEnv* env) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"()Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of__Object(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_of__ObjectArray(
JNIEnv* env,
const jni_zero::JavaRef<jobjectArray>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"([Ljava/lang/Object;)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_List_remove__Object(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"remove",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_remove__int(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"remove",
"(I)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), as_jint(p0));
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_List_removeAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"removeAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_removeFirst(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"removeFirst",
"()Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_removeLast(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"removeLast",
"()Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static void Java_List_replaceAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"replaceAll",
"(Ljava/util/function/UnaryOperator;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static jboolean Java_List_retainAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"retainAll",
"(Ljava/util/Collection;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_reversed(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"reversed",
"()Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_reversed1(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"reversed",
"()Ljava/util/SequencedCollection;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_set(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"set",
"(ILjava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), as_jint(p0), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jint Java_List_size(JNIEnv* env, const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"size",
"()I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static void Java_List_sort(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"sort",
"(Ljava/util/Comparator;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_spliterator(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"spliterator",
"()Ljava/util/Spliterator;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_List_subList(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
JniIntWrapper p0,
JniIntWrapper p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"subList",
"(II)Ljava/util/List;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), as_jint(p0), as_jint(p1));
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobjectArray> Java_List_toArray(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"toArray",
"()[Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
jobjectArray _ret2 = static_cast<jobjectArray>(_ret);
return jni_zero::ScopedJavaLocalRef<jobjectArray>(env, _ret2);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobjectArray> Java_List_toArray(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobjectArray>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_List_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"toArray",
"([Ljava/lang/Object;)[Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj());
jobjectArray _ret2 = static_cast<jobjectArray>(_ret);
return jni_zero::ScopedJavaLocalRef<jobjectArray>(env, _ret2);
}
} // namespace JNI_List
#endif // java_util_List_JNI

View file

@ -0,0 +1,950 @@
// This file was generated by
// //third_party/jni_zero/jni_zero.py
// For
// java.util.Map
#ifndef java_util_Map_JNI
#define java_util_Map_JNI
#include <jni.h>
#include "third_party/jni_zero/jni_export.h"
#include "../../../../../../../third_party/jni_zero/jni_zero_internal.h"
// Class Accessors
#ifndef java_util_Map_clazz_defined
#define java_util_Map_clazz_defined
inline jclass java_util_Map_clazz(JNIEnv* env) {
static const char kClassName[] = "java/util/Map";
static std::atomic<jclass> cached_class;
return jni_zero::internal::LazyGetClass(env, kClassName, &cached_class);
}
#endif
namespace JNI_Map {
// Native to Java functions
[[maybe_unused]] static void Java_Map_clear(JNIEnv* env, const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"clear",
"()V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id());
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_compute(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"compute",
"(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_computeIfAbsent(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"computeIfAbsent",
"(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_computeIfPresent(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"computeIfPresent",
"(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_Map_containsKey(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"containsKey",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jboolean Java_Map_containsValue(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"containsValue",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_copyOf(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"copyOf",
"(Ljava/util/Map;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_entry(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"entry",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map$Entry;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_entrySet(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"entrySet",
"()Ljava/util/Set;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_Map_equals(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"equals",
"(Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj());
return _ret;
}
[[maybe_unused]] static void Java_Map_forEach(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"forEach",
"(Ljava/util/function/BiConsumer;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_get(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"get",
"(Ljava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_getOrDefault(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"getOrDefault",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jint Java_Map_hashCode(JNIEnv* env, const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"hashCode",
"()I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jboolean Java_Map_isEmpty(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"isEmpty",
"()Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_keySet(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"keySet",
"()Ljava/util/Set;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_merge(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"merge",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(
obj.obj(),
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(JNIEnv* env) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"()Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9,
const jni_zero::JavaRef<jobject>& p10,
const jni_zero::JavaRef<jobject>& p11) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj(),
p10.obj(),
p11.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9,
const jni_zero::JavaRef<jobject>& p10,
const jni_zero::JavaRef<jobject>& p11,
const jni_zero::JavaRef<jobject>& p12,
const jni_zero::JavaRef<jobject>& p13) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj(),
p10.obj(),
p11.obj(),
p12.obj(),
p13.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9,
const jni_zero::JavaRef<jobject>& p10,
const jni_zero::JavaRef<jobject>& p11,
const jni_zero::JavaRef<jobject>& p12,
const jni_zero::JavaRef<jobject>& p13,
const jni_zero::JavaRef<jobject>& p14,
const jni_zero::JavaRef<jobject>& p15) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj(),
p10.obj(),
p11.obj(),
p12.obj(),
p13.obj(),
p14.obj(),
p15.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9,
const jni_zero::JavaRef<jobject>& p10,
const jni_zero::JavaRef<jobject>& p11,
const jni_zero::JavaRef<jobject>& p12,
const jni_zero::JavaRef<jobject>& p13,
const jni_zero::JavaRef<jobject>& p14,
const jni_zero::JavaRef<jobject>& p15,
const jni_zero::JavaRef<jobject>& p16,
const jni_zero::JavaRef<jobject>& p17) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj(),
p10.obj(),
p11.obj(),
p12.obj(),
p13.obj(),
p14.obj(),
p15.obj(),
p16.obj(),
p17.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_of(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2,
const jni_zero::JavaRef<jobject>& p3,
const jni_zero::JavaRef<jobject>& p4,
const jni_zero::JavaRef<jobject>& p5,
const jni_zero::JavaRef<jobject>& p6,
const jni_zero::JavaRef<jobject>& p7,
const jni_zero::JavaRef<jobject>& p8,
const jni_zero::JavaRef<jobject>& p9,
const jni_zero::JavaRef<jobject>& p10,
const jni_zero::JavaRef<jobject>& p11,
const jni_zero::JavaRef<jobject>& p12,
const jni_zero::JavaRef<jobject>& p13,
const jni_zero::JavaRef<jobject>& p14,
const jni_zero::JavaRef<jobject>& p15,
const jni_zero::JavaRef<jobject>& p16,
const jni_zero::JavaRef<jobject>& p17,
const jni_zero::JavaRef<jobject>& p18,
const jni_zero::JavaRef<jobject>& p19) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"of",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(
clazz,
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj(),
p3.obj(),
p4.obj(),
p5.obj(),
p6.obj(),
p7.obj(),
p8.obj(),
p9.obj(),
p10.obj(),
p11.obj(),
p12.obj(),
p13.obj(),
p14.obj(),
p15.obj(),
p16.obj(),
p17.obj(),
p18.obj(),
p19.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_ofEntries(
JNIEnv* env,
const jni_zero::JavaRef<jobjectArray>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, clazz, clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_STATIC>(
env,
clazz,
"ofEntries",
"([Ljava/util/Map$Entry;)Ljava/util/Map;",
&cached_method_id);
auto _ret = env->CallStaticObjectMethod(clazz, call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_put(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static void Java_Map_putAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"putAll",
"(Ljava/util/Map;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_putIfAbsent(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"putIfAbsent",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_Map_remove(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"remove",
"(Ljava/lang/Object;Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_remove(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"remove",
"(Ljava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static jboolean Java_Map_replace(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1,
const jni_zero::JavaRef<jobject>& p2) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, false);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"replace",
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z",
&cached_method_id);
auto _ret = env->CallBooleanMethod(
obj.obj(),
call_context.method_id(),
p0.obj(),
p1.obj(),
p2.obj());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_replace(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0,
const jni_zero::JavaRef<jobject>& p1) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"replace",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id(), p0.obj(), p1.obj());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
[[maybe_unused]] static void Java_Map_replaceAll(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj,
const jni_zero::JavaRef<jobject>& p0) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"replaceAll",
"(Ljava/util/function/BiFunction;)V",
&cached_method_id);
env->CallVoidMethod(obj.obj(), call_context.method_id(), p0.obj());
}
[[maybe_unused]] static jint Java_Map_size(JNIEnv* env, const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, 0);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"size",
"()I",
&cached_method_id);
auto _ret = env->CallIntMethod(obj.obj(), call_context.method_id());
return _ret;
}
[[maybe_unused]] static jni_zero::ScopedJavaLocalRef<jobject> Java_Map_values(
JNIEnv* env,
const jni_zero::JavaRef<jobject>& obj) {
static std::atomic<jmethodID> cached_method_id(nullptr);
jclass clazz = java_util_Map_clazz(env);
CHECK_CLAZZ(env, obj.obj(), clazz, nullptr);
jni_zero::internal::JniJavaCallContext<true> call_context;
call_context.Init<jni_zero::MethodID::TYPE_INSTANCE>(
env,
clazz,
"values",
"()Ljava/util/Collection;",
&cached_method_id);
auto _ret = env->CallObjectMethod(obj.obj(), call_context.method_id());
return jni_zero::ScopedJavaLocalRef<jobject>(env, _ret);
}
} // namespace JNI_Map
#endif // java_util_Map_JNI