mike-lischke / jree

A port of the Java Runtime Environment to Typescript
MIT License
3 stars 0 forks source link

Failing to run in browser - undefined (reading 'charCodeAt') #2

Open ApKatos opened 1 year ago

ApKatos commented 1 year ago

I am working on a Vue3 application bundled with Rollup Vite. I have a working module which runs correctly using ts-node, however, when I try to run it in the browser it fails. I tried to debug it, but even this minimal example resolves in:

TypeError: Cannot read properties of undefined (reading 'charCodeAt')
    at node_modules/jree/lib/java/io/File.js (File.ts:29:57)
    at __require (chunk-GQAZXEAK.js?v=35bfa32c:10:50)
    at node_modules/jree/lib/java/io/PrintStream.js (PrintStream.ts:21:1)
    at __require (chunk-GQAZXEAK.js?v=35bfa32c:10:50)
    at node_modules/jree/lib/java/lang/System.js (System.ts:13:1)
    at __require (chunk-GQAZXEAK.js?v=35bfa32c:10:50)
    at node_modules/jree/lib/java/lang/Boolean.js (Boolean.ts:10:1)
    at __require (chunk-GQAZXEAK.js?v=35bfa32c:10:50)
    at node_modules/jree/lib/java/lang/index.js (index.ts:8:1)
    at __require (chunk-GQAZXEAK.js?v=35bfa32c:10:50)
import { java } from "jree";

export function testBrowserString() {
  let str = new java.lang.String("TEST_STRING");
}

I am importing this code example in my Vue component and trying to call this testBrowserString on mounted. I tried to call other methods eg. java.lang.Integer and java.lang.StringBuilder, etc. and it also fails. Is this a jree issue or is it a problem on my side? The documentation claims it should be compatible with browsers (except stated file modules, which I am not planning to use anyway).

mike-lischke commented 1 year ago

I have not really worked out all details for running in a browser. In this case the code uses the path node module, which is obviously not available there.