WPILibC++ 2023.4.3-108-ge5452e3
jni_util.h File Reference
#include <jni.h>
#include <concepts>
#include <queue>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "wpi/ConvertUTF.h"
#include "wpi/SafeThread.h"
#include "wpi/SmallString.h"
#include "wpi/SmallVector.h"
#include "wpi/StringExtras.h"
#include "wpi/mutex.h"
#include "wpi/raw_ostream.h"

Go to the source code of this file.

Classes

class  wpi::java::JClass
 Finds a class and keeps it as a global reference. More...
 
struct  wpi::java::JClassInit
 
class  wpi::java::JGlobal< T >
 
class  wpi::java::JLocal< T >
 Container class for cleaning up Java local references. More...
 
class  wpi::java::JStringRef
 Java string (jstring) reference. More...
 
class  wpi::java::detail::JArrayRefInner< C, T >
 
class  wpi::java::detail::JArrayRefInner< C, jbyte >
 Specialization of JArrayRefBase to provide std::string_view conversion and span<const uint8_t> conversion. More...
 
class  wpi::java::detail::JArrayRefInner< C, jlong >
 Specialization of JArrayRefBase to handle both "long long" and "long" on 64-bit systems. More...
 
class  wpi::java::detail::JArrayRefBase< T >
 Base class for J*ArrayRef and CriticalJ*ArrayRef. More...
 
struct  wpi::java::detail::ConvertIntArray< T >
 
class  wpi::java::JCallbackThread< T >
 Generic callback thread implementation. More...
 
class  wpi::java::JCallbackManager< T >
 
class  wpi::java::JSingletonCallbackManager< T >
 
class  wpi::java::JException
 Finds an exception class and keep it as a global reference. More...
 
struct  wpi::java::JExceptionInit
 

Namespaces

namespace  wpi
 
namespace  wpi::java
 Java Native Interface (JNI) utility functions.
 
namespace  wpi::java::detail
 

Macros

#define WPI_JNI_JARRAYREF(T, F)
 
#define WPI_JNI_MAKEJARRAY(T, F)
 

Functions

std::string wpi::java::GetJavaStackTrace (JNIEnv *env, std::string *func=nullptr, std::string_view excludeFuncPrefix={})
 Gets a Java stack trace. More...
 
jstring wpi::java::MakeJString (JNIEnv *env, std::string_view str)
 Convert a UTF8 string into a jstring. More...
 
template<typename T >
jintArray wpi::java::MakeJIntArray (JNIEnv *env, std::span< const T > arr)
 Convert a span to a jintArray. More...
 
template<typename T >
jintArray wpi::java::MakeJIntArray (JNIEnv *env, const SmallVectorImpl< T > &arr)
 Convert a SmallVector to a jintArray. More...
 
template<typename T >
jintArray wpi::java::MakeJIntArray (JNIEnv *env, const std::vector< T > &arr)
 Convert a std::vector to a jintArray. More...
 
jbyteArray wpi::java::MakeJByteArray (JNIEnv *env, std::span< const uint8_t > str)
 Convert a span into a jbyteArray. More...
 
jbooleanArray wpi::java::MakeJBooleanArray (JNIEnv *env, std::span< const int > arr)
 Convert an array of integers into a jbooleanArray. More...
 
jbooleanArray wpi::java::MakeJBooleanArray (JNIEnv *env, std::span< const bool > arr)
 Convert an array of booleans into a jbooleanArray. More...
 
template<class T >
requires (sizeof(typename T::value_type) == sizeof(jlong) && std::integral<typename T::value_type>)
jlongArray wpi::java::MakeJLongArray (JNIEnv *env, const T &arr)
 
jobjectArray wpi::java::MakeJStringArray (JNIEnv *env, std::span< const std::string > arr)
 Convert an array of std::string into a jarray of jstring. More...
 
jobjectArray wpi::java::MakeJStringArray (JNIEnv *env, std::span< std::string_view > arr)
 Convert an array of std::string into a jarray of jstring. More...
 
std::string wpi::java::GetJavaStackTrace (JNIEnv *env, std::string_view skipPrefix)
 

Macro Definition Documentation

◆ WPI_JNI_JARRAYREF

#define WPI_JNI_JARRAYREF (   T,
 
)

◆ WPI_JNI_MAKEJARRAY

#define WPI_JNI_MAKEJARRAY (   T,
 
)
Value:
inline T##Array MakeJ##F##Array(JNIEnv* env, std::span<const T> arr) { \
T##Array jarr = env->New##F##Array(arr.size()); \
if (!jarr) { \
return nullptr; \
} \
env->Set##F##ArrayRegion(jarr, 0, arr.size(), arr.data()); \
return jarr; \
}
static constexpr const unit_t< compound_unit< charge::coulomb, inverse< substance::mol > > > F(N_A *e)
Faraday constant.