home.social

#jni — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #jni, aggregated by home.social.

fetched live
  1. Создаем Java обертку для C++ класса в Android приложении, а также реализуем обратные вызовы из нэйтива

    Кратко расскажу о себе и о том, зачем возникла необходимость в подобном. Я более десяти лет пишу приложения под Android, около 5 лет под IOS, и сейчас переношу свои наработки под десктопы. Приложения мои предназначены для сисадминов, это SSH клиент, сетевые сканеры и тд. В общем, самое сложное - не сам интерфейс, а то, что под капотом. Когда я лишь начинал, я думал, что остановлюсь на платформе Android и стал пилить все на Java. Но затем осознал свою ошибку и исправил ее. На данный момент все мои приложения состоят из двух частей: общего для всех систем ядра на С++ и платформозависимого интерфейса, написанного на Java/Swift/C++ в зависимости от системы. Оговорюсь сразу, эта статья будет лишь своего рода вступлением. Я покажу, как работать с объектно-ориентированным кодом на C++ в Java оболочке (в JNI нам доступен экспорт С функций). Инициализировать объект, делать из него вызовы, удалять, при этом имея аналогичный класс в оболочке, будто бы наш код был написан на Java. Задача эта не слишком сложная, но прежде чем опытные прогеры закрыли эту статью, я оговорюсь, что в следующей части мы уже будем работать с каллбэками - вызовами Java листенеров из нашего С++ кода, а вот это уже задача совсем нетривиальная, требующая понимания работы JNI и Dalvik. Но обо всем по порядку. Итак, у нас есть некий CPP класс и Java оболочка. Через JNI мы можем вызывать только С-функции, то есть не объектный код. Так как же нам работать с ООП? Главная проблема - не столько вызовы, сколько хранение адреса объекта нативного класса. Лично для себя я нашел решение - хранить его в Java классе, как long. То есть, у нас получается приблизительно такой код:

    habr.com/ru/articles/1017486/

    #Java #C++ #ООП #Dalvik #JNI #android

  2. Previously I shared a blog post comparing Java JNI and FFM examples, the follow up is compiling these back to native images using GraalVM lofthouse.dev/2026/02/20/java-

  3. Previously I shared a blog post comparing Java JNI and FFM examples, the follow up is compiling these back to native images using GraalVM lofthouse.dev/2026/02/20/java- #JNI #FFM #Native #Java #GraalVM

  4. “Is it worth to run #Java on #ARM?” If your stack depends on old #JNI libraries, the answer may be complicated. @ArturSkowronski outlines the main migration blockers & possible workarounds. Want the decision framework?

    Read here: javapro.io/2025/12/05/is-it-wo

    @awscloud #performance

  5. “Is it worth to run #Java on #ARM?” If your stack depends on old #JNI libraries, the answer may be complicated. @ArturSkowronski outlines the main migration blockers & possible workarounds. Want the decision framework?

    Read here: javapro.io/2025/12/05/is-it-wo

    @awscloud #performance

  6. Jextract : "jextract is a tool which mechanically generates Java bindings from native library headers. This tools leverages the clang C API in order to parse the headers associated with a given native library, and the generated Java bindings build upon the Foreign Function & Memory API."

    github.com/openjdk/jextract

    #java #jni #C

  7. Jextract : "jextract is a tool which mechanically generates Java bindings from native library headers. This tools leverages the clang C API in order to parse the headers associated with a given native library, and the generated Java bindings build upon the Foreign Function & Memory API."

    github.com/openjdk/jextract

    #java #jni #C

  8. Getting GPS coordinates from Android through Go wasn't easy, but it's done. It's straightforward when you get the JNI weirdness, but it's a lot of boilerplate and hard to debug.

    I'll try to integrate directly it into Fyne with a nice API in the future.

    #fyne #golang #jni #android

  9. Getting GPS coordinates from Android through Go wasn't easy, but it's done. It's straightforward when you get the JNI weirdness, but it's a lot of boilerplate and hard to debug.

    I'll try to integrate directly it into Fyne with a nice API in the future.

    #fyne #golang #jni #android

  10. Погружение в JNI: проблемы и решения при взаимодействии между JVM и нативным кодом

    Привет! Меня зовут Геннадий Денисов, я руковожу одной из команд разработки мобильного Яндекс Браузера для Android. Недавно в рамках одного проекта мы интегрировали С++‑код в мобильное приложение Браузера. В этой статье я поделюсь основными нюансами работы с Java Native Interface (JNI), инструментами для упрощения разработки и подробностями нашего подхода.

    habr.com/ru/companies/yandex/a

    #яндекс #с++ #jni #java

  11. 🚀🔧 Ah yes, the classic "let's duct-tape #Rust onto Java" strategy—you know, because nothing says "I'm a serious developer" like turning a memory-safe language into a DIY memory management nightmare. 🤦‍♂️ Ever wonder where your weekends went? They're now spent deciphering #JNI error messages! 😂
    medium.com/@greptime/how-to-su #Java #DuctTape #MemoryManagement #DeveloperHumor #HackerNews #ngated

  12. 🚀🔧 Ah yes, the classic "let's duct-tape #Rust onto Java" strategy—you know, because nothing says "I'm a serious developer" like turning a memory-safe language into a DIY memory management nightmare. 🤦‍♂️ Ever wonder where your weekends went? They're now spent deciphering #JNI error messages! 😂
    medium.com/@greptime/how-to-su #Java #DuctTape #MemoryManagement #DeveloperHumor #HackerNews #ngated

  13. For most of my career I have stayed in the Java space and not strayed into native code, recently I have been experimenting with those two worlds coming together include with the new Foreign Function APIs.

    This is just a record of my experimentation so far but in case someone finds it useful I have published as a blog post lofthouse.dev/2025/03/29/begin

  14. #Android friends, how do you unit test your #JNI / #KNI code? Do you write extra KNI glue just so you can trigger internal native methods that call back out into #Kotlin?

    Do you restrict yourself to only integration tests and black-box tests and just *not* unit-test this stuff?

    All solutions we’ve tried/considered so far kinda feel bad.

    (I'm mostly dealing with C/C++ and Kotlin)

  15. #Android friends, how do you unit test your #JNI / #KNI code? Do you write extra KNI glue just so you can trigger internal native methods that call back out into #Kotlin?

    Do you restrict yourself to only integration tests and black-box tests and just *not* unit-test this stuff?

    All solutions we’ve tried/considered so far kinda feel bad.

    (I'm mostly dealing with C/C++ and Kotlin)

  16. [Перевод] Кофе и крабы. Вызов Rust-кода из Java

    Java — один из наиболее часто используемых языков программирования, который мы еще не обсуждали в нашем Rust Interop Guide . В этой статье мы рассмотрим три различных метода вызова кода Rust из Java : JNI , JNR-FFI и Project Panama . Мы покажем различия между этими методами и проведем базовый бенчмаркинг для сравнения их производительности. Эти методы работают не только для Java , но и для других языков JVM, таких как Kotlin . Здесь мы в основном сосредоточимся на Java , но примеры Kotlin доступны в ветке Kotlin нашего репозитория GitHub . Эта статья является частью нашего Rust Interop Guide .

    habr.com/ru/articles/884150/

    #rust #java #interop #ffi #project_panama #jni #jnr

  17. It has been [0] days since I passed a Java ByteArray object into a C function instead of the GetArrayElements() pointer inside it. #jni

  18. It has been [0] days since I passed a Java ByteArray object into a C function instead of the GetArrayElements() pointer inside it. #jni

  19. [Перевод] Java становится надежнее: “Целостность по умолчанию” в действии

    Команда Spring АйО перевела статью про ужесточение контроля за динамической загрузкой агентов, ограничения доступа к опасным методам работы с памятью и JNI в новых версиях JDK.

    habr.com/ru/companies/spring_a

    #java #spring #java_platform #integrity_in_java #jni

  20. Want to know something odd... ? In the screencast attached you see a single OpenGL-context... the bottom-left part is rendered via Java/lwjgl and the top-right part is rendered via native C++/OpenGL (JNI). Why? Because I can ;) No, there are actually reasons for this :) #C++ #Java #OpenGL #jni

  21. @fglock @profoundlynerdy We’ve been here before, as far back as 1998 when Larry Wall himself developed the JPL “#Java #Perl Lingo” for @OReillyMedia: github.com/Perl/perl5/blob/per

    It was basically a Java code preprocessor that let you inline Perl code in Java methods that could themselves call back to Java via #JNI.

    The eventual goal was a Perl-to-Java compiler but it never got there despite distribution with Perl 5.6 through 5.8 as a separate installer.

  22. @fglock @profoundlynerdy We’ve been here before, as far back as 1998 when Larry Wall himself developed the JPL “#Java #Perl Lingo” for @OReillyMedia: github.com/Perl/perl5/blob/per

    It was basically a Java code preprocessor that let you inline Perl code in Java methods that could themselves call back to Java via #JNI.

    The eventual goal was a Perl-to-Java compiler but it never got there despite distribution with Perl 5.6 through 5.8 as a separate installer.

  23. #JDK22 contains the final version of the Foreign Function & Memory API (#JEP454). Being a modern successor to #JNI, it allows cool stuff like building Java wrappers arounds C libraries.

    We did just that and are proud to announce the first production-ready version of #jFUSE, allowing you to develop #FUSE filesystems in #Java. It is module-ready, multi-platform, thoroughly tested by @cryptomator and thanks to the FFM API requires no further dependencies.

    github.com/cryptomator/jfuse

  24. #JDK22 contains the final version of the Foreign Function & Memory API (#JEP454). Being a modern successor to #JNI, it allows cool stuff like building Java wrappers arounds C libraries.

    We did just that and are proud to announce the first production-ready version of #jFUSE, allowing you to develop #FUSE filesystems in #Java. It is module-ready, multi-platform, thoroughly tested by @cryptomator and thanks to the FFM API requires no further dependencies.

    github.com/cryptomator/jfuse

  25. I'm trying to compile #RStat as a static library with the -fPIC flag (so I can use it within #java #jni), but I cannot find the right flags to compile it this way. I tested various flags but I cannot find the correct syntax.

    ```
    configure.ac:278: error: possibly undefined macro: AM_CONDITIONAL
    If this token and others are legitimate, please use m4_pattern_allow.
    See the Autoconf documentation.
    ```

    gist.github.com/lindenb/e8659d

  26. I'm trying to compile #RStat as a static library with the -fPIC flag (so I can use it within #java #jni), but I cannot find the right flags to compile it this way. I tested various flags but I cannot find the correct syntax.

    ```
    configure.ac:278: error: possibly undefined macro: AM_CONDITIONAL
    If this token and others are legitimate, please use m4_pattern_allow.
    See the Autoconf documentation.
    ```

    gist.github.com/lindenb/e8659d

  27. Who do I know who can write JNI code in Rust? Brendan needs to call a threading function because omg and I have enough Redmi phones already.

    #jni #rust

  28. Who do I know who can write JNI code in Rust? Brendan needs to call a threading function because omg and I have enough Redmi phones already.

    #jni #rust

  29. Tool of the day: github.com/dg76/signpackage
    If you want to notarize your Java app with native libraries for Mac OS.
    #notarize #java #jni #macos

  30. Tool of the day: github.com/dg76/signpackage
    If you want to notarize your Java app with native libraries for Mac OS.
    #notarize #java #jni #macos

  31. is a nice language. Having interop between Swift and ++ would be neat, but with Socket Runtime we would lose out on a lot of code reuse, Windows and Linux are mostly C/C++ code bases, and our Android is mostly C++ via the , as a result there’s actually very very little ++ in the project. I’m pretty much +0 on the idea of interop.

  32. #Swift is a nice language. Having interop between Swift and #C++ would be neat, but with Socket Runtime we would lose out on a lot of code reuse, Windows and Linux are mostly C/C++ code bases, and our Android is mostly C++ via the #JNI, as a result there’s actually very very little #ObjC++ in the project. I’m pretty much +0 on the idea of interop.

  33. I have been consulting the ancient texts

    #java #jni

  34. Reading a 25 year old engineering book on #Java #JNI that is still the most up-to-date book on the subject. Native development is wild.