All Projects → dukeify → Fake Jni

dukeify / Fake Jni

Licence: gpl-3.0
An implementation of the JNI and JVMTI with support for direct interaction between natively registered classes and JVM objects.

Programming Languages

java
68154 projects - #9 most used programming language
cpp17
186 projects

Projects that are alternatives of or similar to Fake Jni

imgui-java
JNI based binding for Dear ImGui
Stars: ✭ 270 (+1250%)
Mutual labels:  native, jvm, jni
Android
Swift library for Android
Stars: ✭ 48 (+140%)
Mutual labels:  jvm, jni
Kotlinnativesample
Kotlin Native app working on Android & iPhone
Stars: ✭ 119 (+495%)
Mutual labels:  jvm, native
SquirrelJME
SquirrelJME is a Java ME 8 Virtual Machine for embedded and Internet of Things devices. It has the ultimate goal of being 99.9% compatible with the Java ME standard.
Stars: ✭ 148 (+640%)
Mutual labels:  native, jvm
Easyincrementalupdate
Android差分补丁库,通过native层合并APK,实现增量更新升级,让你更新的APK更小。
Stars: ✭ 233 (+1065%)
Mutual labels:  jni, native
Stackparam
JVM agent to add method parameters to Java stack traces
Stars: ✭ 90 (+350%)
Mutual labels:  jvm, jni
Inline Java
Haskell/Java interop via inline Java code in Haskell modules.
Stars: ✭ 197 (+885%)
Mutual labels:  jvm, jni
sbt-jni
SBT Plugin to ease working with JNI
Stars: ✭ 110 (+450%)
Mutual labels:  jvm, jni
jni-bindgen
Generate Rust JVM FFI wrappers around APIs defined by .jar or .class files, because maintaining your own hand-written bindings is an exercise in boredom, soundness bugs, and pain.
Stars: ✭ 55 (+175%)
Mutual labels:  jvm, jni
jvm-dump-proxy
A proxy DLL for Windows to dump JVM classes at JNI level
Stars: ✭ 53 (+165%)
Mutual labels:  jvm, jni
Xcrash
🔥 xCrash provides the Android app with the ability to capture java crash, native crash and ANR. No root permission or any system permissions are required.
Stars: ✭ 2,689 (+13345%)
Mutual labels:  jni, native
Dart native
Write iOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
Stars: ✭ 564 (+2720%)
Mutual labels:  jni, native
Jpegkit Android
Efficient JPEG operations for Android without the risk of an OutOfMemoryException.
Stars: ✭ 154 (+670%)
Mutual labels:  jni, native
Jni By Examples
🎇Fun Java JNI By Examples - with CMake and C++ (or C, of course!) ‼️ Accepting PRs
Stars: ✭ 99 (+395%)
Mutual labels:  jvm, jni
Androidsecurity
Android安全实践
Stars: ✭ 150 (+650%)
Mutual labels:  jni, native
Xcrash
🔥 xCrash provides the Android app with the ability to capture java crash, native crash and ANR. No root permission or any system permissions are required.
Stars: ✭ 148 (+640%)
Mutual labels:  jni, native
Android Luajit Launcher
Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
Stars: ✭ 87 (+335%)
Mutual labels:  jni, native
jni-bind
JNI Bind is a set of advanced syntactic sugar for writing efficient correct JNI Code in C++17 (and up).
Stars: ✭ 42 (+110%)
Mutual labels:  jvm, jni
Mvikotlin
Extendable MVI framework for Kotlin Multiplatform with powerful debugging tools (logging and time travel)
Stars: ✭ 483 (+2315%)
Mutual labels:  jvm, native
Klock
Multiplatform Date and time library for Kotlin
Stars: ✭ 569 (+2745%)
Mutual labels:  jvm, native

fake-jni

DEPRECATION WARNING

This fork was the original prototype and is currently unmaintained. Any issues or PRs posted for this version will be closed without question. There is a production-ready version coming soon, stay posted for a new upstream with full unit and integration test coverage and cross-platform + cross-architecture support.

Cloning

git clone --depth 1 --recursive https://github.com/meme/fake-jni.git

Requirements

fake-jni has no runtime dependencies :)

Build Requirements

  • CMake >= 3.8
  • libdl
  • make or ninja

Usage

To include fake-jni in your CMake project, clone it into your project's root directory and add the following lines to your CMakeLists.txt:

project(my_project)

#define any desired fake-jni build variables BEFORE including fake-jni
add_subdirectory(fake-jni)

target_link_libraries(my_project fake-jni)

Building

Build Flags

Flag Usage Default Description
BUILD_FAKE_JNI_TESTS =[ON OFF] ON Builds and runs the test suite
BUILD_FAKE_JNI_EXAMPLES =[ON OFF] ON Builds and runs the examples
BUILD_FAKE_JNI_DEBUG =[ON OFF] OFF Builds a debug release
BUILD_FAKE_JNI_ASAN =[ON OFF] OFF Builds with ASAN
FFI_CC ={DESIRED_C_COMPILER} ${CMAKE_C_COMPILER} Set the C compiler for libffi
FFI_CXX ={DESIRED_CXX_COMPILER} ${CMAKE_CXX_COMPILER} Set the C++ compiler for libffi
FFI_CONFIGURE_FLAGS ={CONFIGURE_FLAGS} `` Set the configure flags for libffi
UNWIND_CC ={DESIRED_C_COMPILER} ${CMAKE_C_COMPILER} Set the C compiler for libunwind
UNWIND_CXX ={DESIRED_CXX_COMPILER} ${CMAKE_CXX_COMPILER} Set the C++ compiler for libunwind
UNWIND_CONFIGURE_FLAGS ={CONFIGURE_FLAGS} `` Set the configure flags for libunwind

Simply build as usual:

mkdir build
cd build
env CC=clang CXX=clang++ cmake ..
make -j

or optionally build with ninja:

mkdir build
cd build
env CC=clang CXX=clang++ cmake -GNinja ..
ninja -j0

Cross Compiling

To compile for another host you must set the following environment variables:

  • CMAKE_CXX_COMPILER_TARGET - The target architecture
  • CC - The C cross-compiler
  • CXX - The C++ cross-compiler

Optionally, you may also set the following variables:

  • FFI_CC
  • FFI_CXX
  • UNWIND_CC
  • UNWIND_CXX

Note: When compiling for Android you must set both FFI_CC and FFI_CXX to their respective toolchains, otherwise libffi will fail to compile. The compilers will be located inside of your distribution's NDK installation, under $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin.

For example, to compile fake-jni for Android API level 21 and the AArch64 architecture, your CMakeLists.txt would look like the following:

project(my_project)

#these build variables must be set BEFORE including fake-jni
set(FFI_CC aarch64-linux-android21-clang)
set(FFI_CXX aarch64-linux-android21-clang++)

add_subdirectory(fake-jni)

target_link_libraries(my_project fake-jni)

Then to build, run the following:

export PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
mkdir build
cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-21 ..
ninja -j0

Goals

  • Binary compatability with JNI 1.8
  • Drop-in replacement for an actual JVM, allowing users to compile against fake-jni while retaining full functionality
  • The definition and linking of C++ classes through fake-jni to act as proxies for Java classes, that would otherwise be running on an actual JVM
  • Portability to other platforms and architectures

Licensing

The JNI headers are licensed under the GPL, with the "classpath" exception, meaning that we are free to use and implement the JNI headers in fake-jni, however, any changes made to include/jni.h or include/jni_md.h will be made under the GPL, in complete compliance with the licensing. The rest of fake-jni, including implementations of other GPL licensed headers, are licensed under the GPLv3 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].