I figured I'd ask here before I open a bug report.  I don't know if
it's unwanted to open bugs against trunk, but I'm running into this
problem, and thought it'd be good to bring up.

For some brackground, I've got a large amount of JavaScript code, and
I'm refactoring some components to GWT and integrating it with the
existing data model.  I am using JavaScriptObjects (Generated from
server side code) to match the data model our existing JavaScript
uses, and that works fine.  The integration itself went fine, but
while trying to abstract the DTO objects from the DataModel so we
could use pure java unit tests I ran into an issue.

I compiled the trunk code and used an interface to hide the JSO
implementation, so I could then used a generated JAVA DTO to test
outside of the Gwt container.  During the final stages,  I run into an
AbstractMethodError, only in Hosted mode.  The code compiles fine and
deploys to the hybrid JS/Gwt application.  Here's what I have.

/*
 * IList - Interface
 */
package com.zs.type;

public interface IList<T> {

        T get(int index);

        int length();

        void set(int idx, T val);
}

/*
 * JavaScriptObject implementation.
 */
package com.zs.type.jsImpl;

import com.google.gwt.core.client.JavaScriptObject;
import com.zs.type.IList;

class JsArray<T> extends JavaScriptObject implements IList<T> {

        protected JsArray() { }

        private native final T doGet(int index)/*-{
                return this[index];
        }-*/;

        private native final int getLength() /*-{
                return this.length;
        }-*/;

        private native final void doSet(int idx, Object val) /*-{
                this[idx] = val;
        }-*/;

        final public T get(int index) {
                return (T)doGet(index);
        }

        final public int length() {
                return getLength();
        }

        final public void set(int idx, T val) {
                doSet(idx, val);
        }
}

/*
 * Unit test
 */

package com.zs.type.jsImpl;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.junit.client.GWTTestCase;
import com.zs.type.IList;

public class JsArrayGwtTest extends GWTTestCase {

        /**
         * Passes - So Far so good
         */
        public void testSet() {
                JsArray<Integer> l = JavaScriptObject.createArray().cast();
                l.set(3, 5);
        }

        /**
         * Barfs See Stack Trace below.
         */
        public void testIListSet() {
                JsArray<Integer> jsList = JavaScriptObject.createArray().cast();
                IList<Integer> l = jsList;
                l.set(3, 4);
        }

        @Override
        public String getModuleName() {
                return "com.zs.Type";
        }
}

/* Type.gwt.xml  - for completeness */
<module>

    <!-- Inherit the core Web Toolkit stuff.                  -->
    <inherits name='com.google.gwt.user.User'/>

    <source path="type" includes="**/*.java"/>
</module>

I'm running this using the codehaus maven plugin, and a gwtHome
pointed at the build/staging/gwt-linux-0.0.0 dir which I updated to
rev 5989.  When I run this I get the following stack trace

[INFO] [jar:jar]
[INFO] Building jar: /home/robert/workspace/gwt/baseLibs/target/
baseLibs-1.0-SNAPSHOT.jar
[INFO] [gwt:test {execution: default}]
[INFO] using GWT jars from local installation /home/robert/workspace/
gwt-trunk/build/staging/gwt-linux-0.0.0
[INFO] establishing classpath list (scope = test)
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.zs.type.jsImpl.JsArrayGwtTest
[INFO] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
23.837 sec <<< FAILURE!
[INFO] testListSet(com.zs.type.jsImpl.JsArrayGwtTest)  Time elapsed:
0.074 sec  <<< ERROR!
[INFO] java.lang.AbstractMethodError:
com.google.gwt.core.client.JavaScriptObject$.com_zs_type_IList_set
(ILjava/lang/Object;)V
[INFO]  at com.zs.type.jsImpl.JsArrayGwtTest.testIListSet
(JsArrayGwtTest.java:18)
[INFO]  at com.zs.type.jsImpl.__JsArrayGwtTest_unitTestImpl.doRunTest
(transient source for com.zs.type.jsImpl.__JsArrayGwtTest_unitTestImpl:
10)
[INFO]  at junit.framework.TestCase.runTest(TestCase.java:62)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.runBare
(GWTTestCase.java:206)
[INFO]  at com.google.gwt.junit.client.GWTTestCase.__doRunTest
(GWTTestCase.java:137)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.runTest
(GWTRunner.java:233)
[INFO]  at com.google.gwt.junit.client.impl.GWTRunner.doRunTest
(GWTRunner.java:195)

I also have a JAVA implementation which runs during the standard
surefire java tests, and does the same tests.  This works perfectly
fine in surefire, but blows up when it runs in a GwtTestCase.  From
the little I found on the exception, it seems it may be an eclipse
javac bug?  I don't know details about eclipses relation to javac/
reimplementation, or if GWT uses that internally, but I thought I'd
post before opening a bug in case someone knew of something better to
help.

I also don't know if there's another way to hide the JSO
implementation of our DTO objects without an interface.  I think my
only other solution would be to drop the generics and use just object,
but I was hoping to enjoy the type safety.

Any Comments, Suggestions, Help, or Questions?

Thanks,
    Robert L Zaleski
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to