Bug 562408 - Various problems when native->java callback throws RuntimeException

The problem occurred with a single native API called multiple Java
callbacks, and one of such callbacks thrown a Java exception. In such
case, all subsequent callbacks were skipped until the native API
returned. Sometimes a caller does not expect that callback will be
skipped (or does not expect the default return value from callback)
and will do weird things or downright crash JVM.

A simple way to understand how a single native API could call multiple
callbacks is a Table with multiple items. A single "paint()" native API
will invoke Measure/Paint/etc callbacks per every item and will not
return until everything is done.

This patch fixes the problem: now even if one of the callbacks throws,
the others will still execute as normal.

One potential side effect is that some unexpected callbacks will now
be called. For example, consider a theoretical native API that invokes
3 callbacks: "init", "doWork" and "cleanup". Previously, if "init"
thrown, "doWork" and "cleanup" would be skipped, but this is no longer
the case.

I understand that this side effect is reasonable, because throwing
RuntimeException's is not a proper way to cancel something. If something
does indeed need to be canceled on exception, this shall be done with an
explicit cancel. Alternatively, SWT can be taught to explicitly skip
specific subsequent callbacks if the previous one thrown.

This patch also removes 'JNI_VERSION' which is not used since 569853.

Change-Id: Ic428e081dc19eeb65e40a690388538b87601977e
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/182120
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
4 files changed
tree: 7c5962dc198960dc90a3e769cb6eb33230bf3bdf
  1. bundles/
  2. container/
  3. examples/
  4. features/
  5. local-build/
  6. tests/
  7. .gitignore
  8. CONTRIBUTING
  9. LICENSE
  10. NOTICE
  11. pom.xml
  12. README.md
README.md

Contributing to SWT

Thanks for your interest in this project.

Developer resources:

See the following description for how to contribute a feature or a bug fix to SWT.

Information regarding source code management, builds, coding standards, and more and be found under the following link.

Contributor License Agreement:

Before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Foundation Contributor License Agreement (CLA).

Contact:

Contact the project developers via the project's “dev” list.

Search for bugs:

This project uses Bugzilla to track ongoing development and issues.

Create a new bug:

Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!