DevMode launch fails in GWT JSNI project

I am having a strange problem with debugging gwt dev mode.

Below is the JSNI wrapper. I am writing https://github.com/sillysachin/GWTAMChart

This is a fairly small and simple project with a lot of JSNI, JavaScriptObject, and JSON code. It wraps around the popular amcharts graphics library. It works well when debugging in SuperDevMode and Production.

However, I am unable to debug the project in Internet Explorer using Debug Debuging.

java.lang.ClassFormatError: duplicate method name & signature in class file com / google / gwt / core / client / JavaScriptObject $

The main exception is not helping me figure out which part of the code is breaking !!!!!

java.lang.ClassFormatError: Duplicate method name&signature in class file com/google/gwt/core/client/JavaScriptObject$
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
    at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1142)
    at com.google.gwt.dev.shell.CompilingClassLoader.loadClass(CompilingClassLoader.java:1215)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at com.google.gwt.dev.shell.JsValueGlue.set(JsValueGlue.java:220)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:130)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:589)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:315)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:359)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:530)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:368)
    at java.lang.Thread.run(Thread.java:745)

      

+3


source to share


2 answers


The problematic class AmChartJSO

implements the interface IsAmChart

- all methods are declared twice in JavaScriptObject$

. Snippet from bytecode:

public final synthetic com_amcharts_api_IsAmChart_setVersion(Ljava/lang/String;)V
  ALOAD 0
  ALOAD 1
  INVOKESTATIC com/amcharts/jso/AmChartJSO$.setVersion$ (Lcom/amcharts/jso/AmChartJSO;Ljava/lang/String;)V
  RETURN
  MAXSTACK = 2
  MAXLOCALS = 2

// access flags 0x1011
public final synthetic com_amcharts_api_IsAmChart_setVersion(Ljava/lang/String;)V
  ALOAD 0
  ALOAD 1
  INVOKESTATIC com/amcharts/jso/AmChartJSO$.setVersion$ (Lcom/amcharts/jso/AmChartJSO;Ljava/lang/String;)V
  RETURN
  MAXSTACK = 2
  MAXLOCALS = 2

      

You seem to run into a limitation on overlay types - only one JavaScriptObject subtype can implement any given interface :

In practical terms, this means that only one JavaScriptObject type can implement any given interface, but any number of non-JavaScriptObject types can also implement this interface.

Looking at your code, this constraint is violated: AmChartJSO

implements IsAmChart

, but AmCoordinateChartJSO

implements IsAmCoordinateChart

, which extends IsAmChart

- and hence the two JSOs implement the same interface. If I understand this limitation correctly, you cannot even subclass the JSO that implements the interface.

I did a quick test and this code doesn't work either:

public class Test extends JavaScriptObject implements TakesValue<String> {
    protected Test() {
    }

    @Override
    public final void setValue(String value) {
    }

    @Override
    public final String getValue() {
        return null;
    }
}

public class Test2 extends Test {
    protected Test2() {
    }
}

      

With a similarly useless exception:



java.lang.NullPointerException: null
    at com.google.gwt.dev.shell.CompilingClassLoader$MySingleJsoImplData.findOverloadUsingErasure(CompilingClassLoader.java:703)
    at com.google.gwt.dev.shell.CompilingClassLoader$MySingleJsoImplData.<init>(CompilingClassLoader.java:593)
    at com.google.gwt.dev.shell.CompilingClassLoader.<init>(CompilingClassLoader.java:980)
    at com.google.gwt.dev.shell.ShellModuleSpaceHost.onModuleReady(ShellModuleSpaceHost.java:137)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:340)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:745)

      

Please see this thread on the GWT mailing list for workarounds and general discussion of this issue.


To automatically unload generated class files

For future reference, you can dump the generated class

file by setting the system property gwt.dev.classDump

( -Dgwt.dev.classDump=true

). See this wiki page for more information. By default, classes are written to a folder rewritten-classes

(in your case it will be war/rewritten-classes

). Classes are organized in batches, so find JavaScriptObject$

easily: rewritten-classes/com/google/gwt/core/client/JavaScriptObject$.class

.

Now all you have to do is disassemble it - I used the Bytecode Outline plugin for Eclipse and got the bytecode JavaScriptObject$.class

.

To find out which methods were duplicated I could just load the file with class

a classloader and let the JVM figure it out ... But I felt lazy, so I just grep

ed for public final synthetic

in bytecode and run uniq -D

to see only duplicated entries.

+1


source


This happens in dev mode when using JSNI. Since super dev mode is directly debugged in a browser with a pure java script, there are no strict ticks and no errors. Where as in dev mode the java code runs and due to strict type checking you will get a class format exception. It makes no sense. The same problem with tall charts. If it works well in production and super-dev mode, then you shouldn't worry about it. Hope it helps.



0


source







All Articles