plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).

Home Page:http://plasma-umass.github.io/doppio-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yarn install fails with incomplete JVMTypes.d.ts

jason-crawford-xio opened this issue · comments

Running on Windows 10. In Git Bash. Node v16.15.1.

yarn install

eventually chokes with

### Fast Compile >>src/threadpool.ts
### Fast Compile >>src/util.ts
### Fast Compile >>src/VM.ts
Using tsc v2.2.1
includes/JVMTypes.d.ts(30,1): error TS1005: '}' expected.

>> 1 syntax error
>> Error: tsc return code: 2
Warning: Task "ts:dev-cli" failed. Use --force to continue.

Aborted due to warnings.
C:\Users\xio\work\doppio\prepublish.js:13
    throw new Error("Program exited with code " + code);
    ^

Error: Program exited with code 3
    at checkCode (C:\Users\xio\work\doppio\prepublish.js:13:11)
    at ChildProcess.<anonymous> (C:\Users\xio\work\doppio\prepublish.js:27:5)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Looking at includes/JVMTypes.d.ts, it does look incomplete:

// TypeScript declaration file for JVM types. Automatically generated by doppioh.
// http://github.com/plasma-umass/doppio
import * as DoppioJVM from '../src/doppiojvm';
import JVMThread = DoppioJVM.VM.Threading.JVMThread;
import Long = DoppioJVM.VM.Long;
import ClassData = DoppioJVM.VM.ClassFile.ClassData;
import ArrayClassData = DoppioJVM.VM.ClassFile.ArrayClassData;
import ReferenceClassData = DoppioJVM.VM.ClassFile.ReferenceClassData;
import Monitor = DoppioJVM.VM.Monitor;
import ClassLoader = DoppioJVM.VM.ClassFile.ClassLoader;
import Interfaces = DoppioJVM.VM.Interfaces;

declare module JVMTypes {
  export class JVMArray<T> extends java_lang_Object {
    /**
     * NOTE: Our arrays are either JS arrays, or TypedArrays for primitive
     * types.
     */
    public array: T[];
    public getClass(): ArrayClassData<T>;
    /**
     * Create a new JVM array of this type that starts at start, and ends at
     * end. End defaults to the end of the array.
     */
    public slice(start: number, end?: number): JVMArray<T>;
  }
  // Basic, valid JVM types.
  export type BasicType = number | java_lang_Object | Long;
  export type JVMFunction = (thread: JVMThread, args: BasicType[], cb: (e?: JVMTypes.java_lang_Object, rv?: BasicType) => void) => void;

I'm not noticing any earlier warnings+errors after the intentional Cannot find module warnings that would explain the file being partially built. I don't know where the doppioh step that must be failing occurs in these logs:

...
src/natives/sun_reflect.ts(126,89): error TS7006: Parameter 'pType' implicitly has an 'any' type.
src/opcodes.ts(16,27): error TS2307: Cannot find module '../includes/JVMTypes'.
src/threading.ts(14,27): error TS2307: Cannot find module '../includes/JVMTypes'.
src/threading.ts(1002,55): error TS7006: Parameter 'e' implicitly has an 'any' type.
src/util.ts(4,27): error TS2307: Cannot find module '../includes/JVMTypes'.

>> 30 non-emit-preventing type warnings
>> Type errors only.

TypeScript compilation complete: 5.78s for 56 TypeScript files.

Running "check_jdk" task
JDK is up-to-date.

Running "find_native_java" task
Locating JDK8 installation...
>> Using JDK8 installation at C:\Program Files\Java\jdk1.8.0_202
>> Java: C:\Program Files\Java\jdk1.8.0_202\bin\java.exe
>> Javap: C:\Program Files\Java\jdk1.8.0_202\bin\javap.exe
>> Javac: C:\Program Files\Java\jdk1.8.0_202\bin\javac.exe

Running "newer:javac" (newer) task

Running "newer:javac:default" (newer) task

Running "javac:default" (javac) task

Running "newer-postrun:javac:default:1:C:\Users\xio\work\doppio\node_modules\grunt-newer\.cache" (newer-postrun) task

Running "newer:javac:examples" (newer) task

Running "javac:examples" (javac) task

Running "newer-postrun:javac:examples:2:C:\Users\xio\work\doppio\node_modules\grunt-newer\.cache" (newer-postrun) task

Running "generate_doppio_jar" task

Running "compress:doppio" (compress) task
>> Compressed 7 files.

Running "newer:run_java" (newer) task

Running "newer:run_java:default" (newer) task

Running "run_java:default" (run_java) task

Running "newer-postrun:run_java:default:3:C:\Users\xio\work\doppio\node_modules\grunt-newer\.cache" (newer-postrun) task

Running "newer:lineending" (newer) task

Running "newer:lineending:default" (newer) task

Running "lineending:default" (lineending) task
File "classes/test/Annotations.runout" created.
File "classes/test/ArrayCopyTest.runout" created.
File "classes/test/ArrayListOps.runout" created.
... omitting many `classes/test/... created.` messages
File "classes/test/WaitTest.runout" created.
File "classes/test/Wide.runout" created.
File "classes/test/Zip.runout" created.

Running "newer-postrun:lineending:default:4:C:\Users\xio\work\doppio\node_modules\grunt-newer\.cache" (newer-postrun) task

Running "includes:default" (includes) task

Running "enable_type_errors" task

Running "ts:dev-cli" (ts) task
Compiling...
### Fast Compile >>console/doppioh.ts
#

Same problem on my main machine, using the last available version in master 41f41fb.
I'm on Manjaro:

DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=22.0.0
DISTRIB_CODENAME=Sikaris
DISTRIB_DESCRIPTION="Manjaro Linux"

node version is v18.8.0
yarn version is 1.22.19

Pasting my stacktrace too:

...
Running "ts:dev-cli" (ts) task
Compiling...
### Fast Compile >>console/doppioh.ts
### Fast Compile >>console/download_jdk.ts
### Fast Compile >>console/find_invalid_natives.ts
### Fast Compile >>console/generate_thread_transition_graph.ts
### Fast Compile >>console/runner.ts
### Fast Compile >>console/test_runner.ts
### Fast Compile >>src/assert.ts
### Fast Compile >>src/attributes.ts
### Fast Compile >>src/ByteStream.ts
### Fast Compile >>src/ClassData.ts
### Fast Compile >>src/ClassFile.ts
### Fast Compile >>src/ClassLoader.ts
### Fast Compile >>src/ClassLock.ts
### Fast Compile >>src/classpath.ts
### Fast Compile >>src/ConstantPool.ts
### Fast Compile >>src/Debug.ts
### Fast Compile >>src/difflib.ts
### Fast Compile >>src/doppiojvm.ts
### Fast Compile >>src/enums.ts
### Fast Compile >>src/fd_state.ts
### Fast Compile >>src/global_require.ts
### Fast Compile >>src/global.ts
### Fast Compile >>src/gLong.ts
### Fast Compile >>src/heap.ts
### Fast Compile >>src/index.ts
### Fast Compile >>src/interfaces.ts
### Fast Compile >>src/jar.ts
### Fast Compile >>src/java_cli.ts
### Fast Compile >>src/jit.ts
### Fast Compile >>src/jvm.ts
### Fast Compile >>src/logging.ts
### Fast Compile >>src/methods.ts
### Fast Compile >>src/Monitor.ts
### Fast Compile >>src/natives/doppio.ts
### Fast Compile >>src/natives/java_io.ts
### Fast Compile >>src/natives/java_lang.ts
### Fast Compile >>src/natives/java_net.ts
### Fast Compile >>src/natives/java_nio.ts
### Fast Compile >>src/natives/java_security.ts
### Fast Compile >>src/natives/java_util.ts
### Fast Compile >>src/natives/sun_font.ts
### Fast Compile >>src/natives/sun_management.ts
### Fast Compile >>src/natives/sun_misc.ts
### Fast Compile >>src/natives/sun_net.ts
### Fast Compile >>src/natives/sun_nio.ts
### Fast Compile >>src/natives/sun_reflect.ts
### Fast Compile >>src/opcodes.ts
### Fast Compile >>src/option_parser.ts
### Fast Compile >>src/parker.ts
### Fast Compile >>src/SafeMap.ts
### Fast Compile >>src/StringOutputStream.ts
### Fast Compile >>src/testing.ts
### Fast Compile >>src/threading.ts
### Fast Compile >>src/threadpool.ts
### Fast Compile >>src/util.ts
### Fast Compile >>src/VM.ts
Using tsc v2.2.1
includes/JVMTypes.d.ts(30,1): error TS1005: '}' expected.

>> 1 syntax error  
>> Error: tsc return code: 2
Warning: Task "ts:dev-cli" failed. Use --force to continue.

Aborted due to warnings.
/home/angelo/Desktop/doppio/prepublish.js:13
    throw new Error("Program exited with code " + code);
    ^

Error: Program exited with code 3
    at checkCode (/home/angelo/Desktop/doppio/prepublish.js:13:11)
    at ChildProcess.<anonymous> (/home/angelo/Desktop/doppio/prepublish.js:27:5)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5)

Node.js v18.8.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

The resulting includes/JVMTypes.d.ts is the same of OP

commented

I'm having the same issue. I was able to get past it initially but adding the closing bracket to:
https://github.com/plasma-umass/doppio/blob/master/console/doppioh.ts#L544
That allows this JVMTypes.d.ts to be properly parsed but I think it's actually not addressing the issue entirely.
After that, I get a ton of TS errors, mostly about using internal/private variable names.

commented

FYI, I'm doing this on Linux.

I solved this problem using a lower version of node (v12) on linux