What about the case for a DualSimple (e.g. an interface that has both java and jso implementations). In this case, my fix doesn't allow the jso to be assigned to an array of DualSimple[]. Is that expected (I'm guessing not).
Jason On Tue, Jun 28, 2011 at 2:05 PM, <cromwell...@google.com> wrote: > > http://gwt-code-reviews.appspot.com/1470801/diff/1/user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java > File user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java > (right): > > http://gwt-code-reviews.appspot.com/1470801/diff/1/user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java#newcode531 > user/test/com/google/gwt/dev/jjs/test/SingleJsoImplTest.java:531: Simple > simpleTwo = (Simple) JavaScriptObject.createObject(); > I don't think that's the expected behavior. IIRC, ArrayStoreException is > thrown when the element being stored is not castable to the element type > of the array right? > > e.g. > String[] x = new String[...]; > Object[] y = x; > y[0] = new Foo(); // array store exception > > Putting a SimpleJava into a Simple[] should succeed without ASE. > > When you have > > simple[0] = (Simple) JSO; > > GWT semantics allow the cast to succeed, even though JSO doesn't > implement Simple. (In regular Java it would be a runtime CCE without > classloader magic) > > Basically, the setCheck() method should be checking if the type being > stored is either a JSO or a castable to Simple, if the actual array type > is a singleJSO. > > it should only be an ArrayStoreException if the array were declared as > "JsoSimple[] simples" > > I see the following cases: > > JsoSimple[] simples; // JSO allowed, ASE thrown if Java instance > JavaSimple[] simples; // Java types allow, ASE thrown if JSO > Simple[] simples; // JSO and Java types allowed > > On 2011/06/28 14:52:26, jbrosenberg wrote: >> >> The problem with that, is as soon as I create a non-JSO Simple object, > > Simple is >> >> no longer has a SingleJsoImpl, and so it causes an > > ArrayStoreException....which >> >> I think is the expected behavior (so maybe I should make a test to > > confirm >> >> that!). > > http://gwt-code-reviews.appspot.com/1470801/ > -- http://groups.google.com/group/Google-Web-Toolkit-Contributors