Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve JNI exception handling and logging #691

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

CedNaru
Copy link
Member

@CedNaru CedNaru commented Sep 16, 2024

  • Added Typed MethodID and made the JObject's method calls use them for type safety. Updated all JvmWrapper jni methods.
  • Logging methods have been rewamped to allow formatting without vformat().
  • Crash methods are gone, the only thing left that can explicitly crash the module are the DEV_ASSERT statements. As we progress toward a stable release, we already removed most of the crashes. I simply finished the last remaining ones. The new DEV_ASSERT statements are mostly related to JNI errors, which is not the type users should have to care about.
  • LOG_ERROR_WITH_ALERT is also gone. Since Godot 4.3, errors are automatically displayed in the editor as small popups. It's not necessary to spawn our own alert window anymore.
  • A new way to handle exceptions. The Env's methods are now much simpler, without difference in behavior between DEBUG and release. You can now set a custom "exception handler" that will be called instead of exceptionDescribe() when set. This handler is now set to be the method of a new singleton wrapper that takes a Throwable instance and print its stacktrace directly.

This is what it looks like when a JVM exception is handled from the C++ side with the new handler:
image

@CedNaru CedNaru force-pushed the improvement/exception_handling branch 2 times, most recently from 57715a6 to e54dc51 Compare September 16, 2024 20:54
@CedNaru CedNaru force-pushed the improvement/exception_handling branch 4 times, most recently from beaf58a to cf4bdd9 Compare September 17, 2024 00:57
@CedNaru CedNaru force-pushed the improvement/exception_handling branch from cf4bdd9 to 91c5fda Compare September 17, 2024 01:07
@CedNaru CedNaru marked this pull request as ready for review September 17, 2024 18:56
@CedNaru CedNaru requested review from chippmann and piiertho and removed request for chippmann September 17, 2024 18:56
@CedNaru CedNaru force-pushed the improvement/exception_handling branch from 95ba9f2 to 4e11878 Compare September 17, 2024 19:00
src/logging.h Outdated Show resolved Hide resolved
src/logging.h Outdated Show resolved Hide resolved
src/logging.h Outdated Show resolved Hide resolved
@CedNaru CedNaru force-pushed the improvement/exception_handling branch from 8bfb736 to a11df23 Compare September 18, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants