gwtproject / gwt-typedarrays

Apache License 2.0
6 stars 10 forks source link

Compilation fails on Uint8Array creation #6

Closed foal closed 4 years ago

foal commented 4 years ago

Have the exception:

Caused by: java.lang.AssertionError: Native methods can not be devirtualized
    at com.google.gwt.dev.jjs.impl.MakeCallsStatic$CreateStaticImplsVisitor.visit(MakeCallsStatic.java:150)
    at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:777)
    at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:127)
    ... 34 more
      [ERROR] at Uint8ClampedArray.java(54): org.gwtproject.typedarrays.shared.Uint8ClampedArray.subarray(II)Lorg/gwtproject/typedarrays/shared/Uint8Array;
         com.google.gwt.dev.jjs.ast.JMethod

for the following sniplet

ArrayBuffer buffer = xhr.getResponseArrayBuffer();
Uint8Array array = TypedArrays.createUint8Array(buffer);
niloc132 commented 4 years ago

It looks like the jsinterop code of this repo is valid (that is, it is valid according to j2cl, and generates valid JS even in GWT2 if you disabled assertions in the compiler as it runs.

This likely means that this is a bug in the assertion in GWT2, or the assertion is correct and J2CL is permitting code that isn't correct. I think that the either the assertion itself is confused and needs to be loosened, or the method that is being passed in was malformed - the instance of the subarray(int, int) method is somehow marked as being default (it isnt a default method), isSynthetic is true, and the implementation is just a call to ... subarray(int,int) (so appears to cause infinite recursion).

I'm going to close this shortly after I file a bug against gwt itself to see what is happening here.