Both Worker and Main JS runtime instances use the same Java environment hence the native objects can be shared between the two.
Main:
const nativeObject = new java.lang.String("string");
const worker = new Worker(...);
worker.postMessage({
myNativeString: globalThis.createNativeHandle(nativeObject)
});
Worker:
globalThis.onmessage = (message) => {
const nativeObject = globalThis.resolveNativeHandle(message.myNativeString);
}