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

Constructors

Accessors

  • get asyncJavaExceptionObjects(): null | boolean
  • Get whether to return Java exceptions as objects in async methods.

    Returns null | boolean

    Since

    2.6.0

  • set asyncJavaExceptionObjects(value): void
  • 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.

    Parameters

    • value: undefined | null | boolean

    Returns void

    Since

    2.6.0

  • get asyncSuffix(): null | string
  • Get the suffix for asynchronous methods.

    Returns null | string

    Since

    2.4.0

  • set asyncSuffix(value): void
  • 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.

    Parameters

    • value: undefined | null | string

      the suffix to use for asynchronous methods

    Returns void

    See

    syncSuffix

    Since

    2.4.0

  • get config(): Config
  • Get the current config.

    Returns Config

    Since

    2.4.0

  • set config(value): void
  • Override the whole config. If you want to change only a single field, use the static setters instead.

    Parameters

    • value: Config

      the config to use

    Returns void

    Since

    2.4.0

  • get customInspect(): boolean
  • Get whether to add custom inspect methods to java objects.

    Returns boolean

    whether to add custom inspect methods to java objects

    Since

    2.4.0

  • set customInspect(value): void
  • 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.

    Parameters

    • value: boolean

      whether to add custom inspect methods to java objects

    Returns void

    Since

    2.4.0

  • get runEventLoopWhenInterfaceProxyIsActive(): boolean
  • Experimental

    Experimental Feature

    Get whether to run the event loop when an interface proxy is active.

    Returns boolean

    Since

    2.2.3

  • set runEventLoopWhenInterfaceProxyIsActive(value): void
  • 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.

    Parameters

    • value: boolean

      whether to run the event loop when an interface proxy is active

    Returns void

    Since

    2.2.3

  • get syncSuffix(): null | string
  • Get the suffix for synchronous methods.

    Returns null | string

    Since

    2.4.0

  • set syncSuffix(value): void
  • 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.

    Example

    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!');

    Parameters

    • value: undefined | null | string

      the suffix to use for synchronous methods

    Returns void

    See

    asyncSuffix

    Since

    2.4.0

Methods

  • Reset the config to the default values.

    Returns void

    Since

    2.4.0

Generated using TypeDoc