Skip to content

AUI_JNI_CLASS#

Defines getClassName and other useful methods required for Java class definition.

Header:#include <AUI/JNI/AJni.h>
CMake:aui_link(my_target PUBLIC aui::core)

Definition#

#define AUI_JNI_CLASS(path, name) \
class name ## _info: public ::aui::jni::GlobalRef { \
public:                           \
    static constexpr auto JAVA_CLASS_NAME = #path ## _asl;                        \
    [[nodiscard]] static constexpr auto getClassName() noexcept { return #path; } \
    [[nodiscard]] static auto getClass() noexcept { static ::aui::jni::GlobalRef t = ::aui::jni::env()->FindClass(getClassName()); AUI_ASSERTX(t.asClass() != nullptr, "no such class: " #path); return t.asClass(); } \
                                      \
};                                \
struct name: public name ## _info

Detailed Description#

Usage:

namespace com::github::aui::android {
    AUI_JNI_CLASS(com/github/aui/android/Platform, AUI) {
    public:
        // class definition
        AUI_JNI_STATIC_METHOD(void, callStaticMethod, ())
        AUI_JNI_METHOD(void, CallNonStaticMethod, ())
    };
}
..
com::github::aui::android::Platform::getClassName() -> "com/github/aui/android/Platform"