Looks like a GWT compiler and/or GIN error.

52 views
Skip to first unread message

seas

unread,
Nov 30, 2012, 3:14:03 AM11/30/12
to google-we...@googlegroups.com
I've got a class, TestPlace, that derives from Place that takes two parameters, both Strings.

I use GIN so I have a PlaceFactory to create instances of my places.  It has a method for creating TestPlace that has two String parameters.

It all looks pretty straight forward, except that inside the TestPlace constructor, both strings end up being the first parameter in the call to the factory method!

Here's the TestPlace constructor:
<pre>
@Inject
public TestPlace (@Assisted String testId, @Assisted String authType) {
logger.fine("testId: " + testId+ "; authType: " + authType);
this.testId= testId;
this.authType = authType;
}
</pre>
It has the @Inject and @Assisted annotations, as you would expect.

The method signature in the PlaceFactory interface looks like this:
<pre>
TestPlace createTestPlace(String testId, String authType);
</pre>
Everything looks pretty normal so far.  However, the log shows that the createTestPlace caller is calling with two different strings, but inside the TestPlace constructor, the strings are identical.

When createTestPlace is compiled to JavaScript, it looks like this:
<pre>
function $createTestPlace(p0){
  var result;
  result = new TestPlace_0(p0, p0);
  return result;
}
</pre>
Notice how it has just one parameter, which it uses twice when calling the TestPlace constructor.

Similarly, the JavaScript call to createTestPlace only has the first parameter.  The second parameter, which is clearly there in the Java, is missing the JavaScript.

Anyone have any ideas what's going on here?

Started seeing this in GWT 2.4. Tonight I upgraded to 2.5 but the problem is still there.  Also using gin-1.5-post-gwt-2.2.jar.

Thomas Broyer

unread,
Nov 30, 2012, 6:20:24 AM11/30/12
to google-we...@googlegroups.com


On Friday, November 30, 2012 9:14:03 AM UTC+1, seas wrote:
I've got a class, TestPlace, that derives from Place that takes two parameters, both Strings.

I use GIN so I have a PlaceFactory to create instances of my places.

Places are value-objects, so it's not clear to me why you need a factory (and how it's related to using GIN).
 
 It has a method for creating TestPlace that has two String parameters.

It all looks pretty straight forward, except that inside the TestPlace constructor, both strings end up being the first parameter in the call to the factory method!

Here's the TestPlace constructor:
<pre>
@Inject
public TestPlace (@Assisted String testId, @Assisted String authType) {

 

seas

unread,
Nov 30, 2012, 1:00:47 PM11/30/12
to google-we...@googlegroups.com
Thanks Thomas.  That's exactly what I needed.

Also, thanks for the constructive criticism.  I wasn't aware the factories are not normally used for value objects, and it did seem to be muddying the waters a bit.
Reply all
Reply to author
Forward
0 new messages