2

I want to instrument native method in java 13+ (preferably using javassist). Say I want to add logging for particular method and then call real native method. It was possible before via native method prefix (issue https://bugs.openjdk.org/browse/JDK-6263317 and my answer with possible solution with javassist Editing a native method class with javassist?) but since J13 it's not possible to add new method without explicit option (issue https://bugs.openjdk.java.net/browse/JDK-8221528) which is deprecated from start and can be removed at any time.

There are a lot of questions for this topic like:

But none of them covers topic how to wrap native method without -XX:+AllowRedefinitionToAddDeleteMethods option in J13+ using javassist. I can replace method body but cannot see next good move. It's quite hard or impossible to implement every interesting native method in pure java and does not scale well so I cannot just replace method. May be I did something wrong in my previous attempt with javassist. Or may be my only option is to use JNA somehow to invoke arbitrary function from jdk libs.

ainlolcat
  • 544
  • 4
  • 15

0 Answers0