Do not instantiate this class. Use the default.config instance instead.
Get whether to return Java exceptions as objects in async methods.
2.6.0
If true, any Java exception will be returned in the cause
field of the thrown JavaError
even in async methods.
Enabling this will cause the stack trace of the
JavaScript error to be lost.
If not specified, the value from the global configuration will be used.
2.6.0
Get the suffix for asynchronous methods.
2.4.0
Set the suffix for asynchronous methods.
This is Async
by default.
Pass null
or an empty string to disable the suffix.
This must not be the same as the syncSuffix.
This option does not affect standard methods of java classes
like toString
, toStringSync
, toStringAsync
and newInstanceAsync
.
the suffix to use for asynchronous methods
syncSuffix
2.4.0
Get whether to add custom inspect methods to java objects.
whether to add custom inspect methods to java objects
2.4.0
Whether to add custom inspect methods to java objects.
This is disabled by default.
This allows console.log to print java objects in a more readable way
using the toString
method of the java object.
whether to add custom inspect methods to java objects
2.4.0
Experimental
Experimental Feature
Get whether to run the event loop when an interface proxy is active.
2.2.3
Experimental
Experimental Feature
Set whether to run the event loop when an interface proxy is active. This is disabled by default. Enabling this will cause the bridge to run the event loop when an interface proxy either as direct proxy or as daemon proxy is active. This is only required if the proxied method calls back into the javascript process in the same thread. If the proxy is used either in an async method or in a different thread, this is not required.
Note: Enabling this may cause the application to crash. Use with caution.
whether to run the event loop when an interface proxy is active
2.2.3
Get the suffix for synchronous methods.
2.4.0
Set the suffix for synchronous methods.
This is Sync
by default.
Pass null
or an empty string to disable the suffix.
This must not be the same as the asyncSuffix.
This option does not affect standard methods of java classes
like toString
, toStringSync
, toStringAsync
and newInstanceAsync
.
import { config, clearClassProxies } from 'java-bridge';
// Set the async suffix in order to prevent errors
config.asyncSuffix = 'Async';
// Set the sync suffix to an empty string
config.syncSuffix = '';
// This would do the same
config.syncSuffix = null;
// Clear the class proxy cache
clearClassProxies();
// Import the class
const ArrayList = importClass('java.util.ArrayList');
// Create a new instance
const list = new ArrayList();
// Call the method
list.add('Hello World!');
// Async methods now have the 'Async' suffix
await list.addAsync('Hello World!');
the suffix to use for synchronous methods
asyncSuffix
2.4.0
Generated using TypeDoc
Configuration options for the java bridge.
As of version 2.4.0, the options are cached inside the class proxy cache. This means that changing the options will not affect any class proxies that have already been created by importing a class using importClass or importClassAsync. You must clear the class proxy cache using the clearClassProxies method in order to apply the new options to all classes imported at a later date. This does not affect already instantiated or imported classes.
Do not instantiate this class. Use the default.config instance instead.
Since
2.2.3