pepstock-org / Charba

J2CL and GWT Charts library based on CHART.JS
https://pepstock-org.github.io/Charba-Wiki/docs
Apache License 2.0
62 stars 6 forks source link

GWT compilation error with Charba 5.6-gwt #78

Closed salmonb closed 2 years ago

salmonb commented 2 years ago

hi,

I'm getting the following error when I try to upgrade to charba 5.6-gwt:

[INFO] [ERROR] Unexpected internal compiler error
[INFO] java.lang.ArrayIndexOutOfBoundsException: Index 1149 out of bounds for length 1149
[INFO]  at org.objectweb.asm.ClassReader.readUnsignedShort(ClassReader.java:3596)
[INFO]  at org.objectweb.asm.ClassReader.readUTF8(ClassReader.java:3652)
[INFO]  at org.objectweb.asm.ClassReader.readElementValues(ClassReader.java:2991)
[INFO]  at org.objectweb.asm.ClassReader.accept(ClassReader.java:608)
[INFO]  at org.objectweb.asm.ClassReader.accept(ClassReader.java:424)
[INFO]  at com.google.gwt.dev.javac.BytecodeSignatureMaker.visitCompileDependenciesInBytecode(BytecodeSignatureMaker.java:228)
[INFO]  at com.google.gwt.dev.javac.BytecodeSignatureMaker.getCompileDependencySignature(BytecodeSignatureMaker.java:209)
[INFO]  at com.google.gwt.dev.javac.CompiledClass.getSignatureHash(CompiledClass.java:166)
[INFO]  at com.google.gwt.dev.javac.Dependencies$Ref.<init>(Dependencies.java:41)
[INFO]  at com.google.gwt.dev.javac.Dependencies$Ref.<init>(Dependencies.java:36)
[INFO]  at com.google.gwt.dev.javac.Dependencies.resolve(Dependencies.java:100)
[INFO]  at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:349)
[INFO]  at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:532)
[INFO]  at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:464)
[INFO]  at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:423)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:210)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:190)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:131)
[INFO]  at com.google.gwt.dev.Compiler.compile(Compiler.java:192)
[INFO]  at com.google.gwt.dev.Compiler.compile(Compiler.java:143)
[INFO]  at com.google.gwt.dev.Compiler.compile(Compiler.java:132)
[INFO]  at com.google.gwt.dev.Compiler$1.run(Compiler.java:110)
[INFO]  at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
[INFO]  at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
[INFO]  at com.google.gwt.dev.Compiler.main(Compiler.java:113)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

It's a quite obscure GWT error, but I managed to get a breakpoint in GWT when it occurs, and it appears to happen when reading the JsType annotation of your NativeUIEvent class for any strange reason:

@JsType(isNative = true, name = NativeName.DOM_UI_EVENT, namespace = JsPackage.GLOBAL)
public abstract class NativeUIEvent extends NativeBaseEvent { ... }

Can you please let me know if you manage to reproduce this error?

stockiNail commented 2 years ago

@salmonb this is very weird. I retried right now in my environment, with GWT2.10 and no issue. Which GWT version are u using? and are you including jsinterop annotation lib? if yes, which version? Can you also send me if you are compiling by GWT with some parameters? Needed to try to reproduce the error.

stockiNail commented 2 years ago

@salmonb just for your info. I recompiled right now the charba showcase for GWT using the GWT2.10 and 2.9.0 and this is the result:

GWT 2.10

gwt-compile:
     [java] Compiling module org.pepstock.charba.showcase.Charba_Showcase
     [java]    Compiling 2 permutations
     [java]       Compiling permutation 0...
     [java]       Compiling permutation 1...
     [java]    Compile of permutations succeeded
     [java]    Compilation succeeded -- 134.722s
     [java] Linking into .\git\Charba-Showcase\war\charba_showcase
     [java]    Link succeeded
     [java]    Linking succeeded -- 1.816s

GWT 2.9

gwt-compile:
     [java] Compiling module org.pepstock.charba.showcase.Charba_Showcase
     [java]    Compiling 5 permutations
     [java]       Compiling permutation 0...
     [java]       Compiling permutation 1...
     [java]       Compiling permutation 2...
     [java]       Compiling permutation 3...
     [java]       Compiling permutation 4...
     [java]    Compile of permutations succeeded
     [java]    Compilation succeeded -- 313.895s
     [java] Linking into .\git\Charba-Showcase\war\charba_showcase
     [java]    Link succeeded
     [java]    Linking succeeded -- 2.138s
JVM heap: -Xmx1G
GWT params: -war war -strict -logLevel INFO -style OBFUSCATED org.pepstock.charba.showcase.Charba_Showcase

It's really weird. Let me know because the case is very interesting.

salmonb commented 2 years ago

I'm using GWT 2.10 too, and Elemental2 version 1.1.0.

I'm working on a complex project with many modules and dependencies, but it should be easy to reproduce the problem if you clone it and compile it. Here is the project: https://github.com/modalityone/modality You can clone the main branch and try to compile it using mvn package -P gwt-compile and you should reproduce the error.

You can also directly see the error on our GitHub workflow: https://github.com/modalityone/modality/actions/runs/3003278592/jobs/5030014029

stockiNail commented 2 years ago

We have a look!

stockiNail commented 2 years ago

@salmonb we have cloned the project and run MVN and it failed. But the strange thing is that in the clone we have, it's configuring to use Charba version 5.5 where that class, you mentioned, doesn't exist. We are still investigating

salmonb commented 2 years ago

@stockiNail I found the problem thanks to the point you raised!

The failing module was modality-all-backoffice-application-gwtwhich has a dependency to webfx-extras-visual-charts-peers-gwt-charba which has a dependency to charba 5.6-gwt (this is what I updated this morning).

However Charba 5.5-gwt was still listed in https://github.com/modalityone/modality/blob/main/modality-all/modality-all-backoffice-application-gwt/pom.xml (which explains what you said). After updating this pom to list charba 5.6-gwt as well, the problem is fixed.

So the GWT compilation error was probably caused by the difference of the declared charba version between these 2 modules.

The fault was on our side, sorry! Thank you for helping us to find it!

stockiNail commented 2 years ago

@salmonb very happy to hear you solved! Anyway it has been good exercise for us to have a look to the related stuff to the issue and your project, very good and interesting one ;) !!

salmonb commented 2 years ago

Thanks @stockiNail, it will take at least a year to finish Modality. It's actually a rewrite of a private system already in production, but this time it will be open-source, and I think that yes, it can have some success on GitHub.

I'm also the maintainer of WebFX, a JavaFX transpiler that Modality is based on. You can see some demos on our website. WebFX doesn't cover complex controls yet, such as charts for example. But what I do for now is to provide a simple chart cross-platform API, with a OpenJFX implementation and a GWT implementation. The GWT implementation is using Charba ~ thank you!

stockiNail commented 2 years ago

Sounds interesting... I'm curious to know how it works... I'll have a look. :D

stockiNail commented 2 years ago

@salmonb apologies if I disturb you with a question. Having a look to your project, I don't see any possibilities to use GWT widgets (because you are leveraging on Elemental2) or code splitting. Am I wrong? If I'm right, let me ask you why are you using charba-gwt instead of charba jar?

salmonb commented 2 years ago

Was busy creating our Twitter account and publishing our first tweets...

I hadn't read your documentation correctly and assumed too quickly that charba-gwt version was for GWT and charba for J2CL. You're right, we don't use GWT widgets, just Elemental2. So I switched my dependency to charba jar. Well spotted, thank you!

stockiNail commented 2 years ago

@salmonb ur welcome! Let me know if everything is working well!

salmonb commented 2 years ago

@stockiNail Yes, everything is working well with charba jar, thank you!! :+1:

BTW Amazing how our brand new twitter account just got 97 followers with just 2 tweets. And this brought us 13 additional stars on GitHub in less than 2 days :smile:

stockiNail commented 2 years ago

Great!! Very glad for you! Ì dont have Twitter:) but I think it’s a good approach Congratulations well done