[gwt-contrib] Change in gwt[master]: Fixes UiHandler method matching in generic classes
Goktug Gokdogan has submitted this change and it was merged. Change subject: Fixes UiHandler method matching in generic classes .. Fixes UiHandler method matching in generic classes Method matching in UiHandler is completely broken for generic ui fields as FieldWriterOfExistingType is using the raw type of the ui field. Raw type of a generic field erases all generics from the method signature. This was causing type parameter information to be not used while matching methods. This is a huge problem with some common events like SelectEvent and ValueChangeEvent. We were not hitting the problem in some cases because JRawType is broken and doesn't correctly delete the generics from the signature of parent methods. However that was causing another problem: UiBinder uses the type information for ui.xml so it doesn't really know the type parameters so it can't match generics methods from the parent class (Issue 6091). This fix changes the UiBinder generator so that - it will enhance the type information if there is a @uifield declaration - it will not use raw type in FieldWriterOfExistingType - it will fallback to erase type if it can't find any method match Bugs: Issue 6091 Change-Id: I3121542b6eb4f06f36b88b02006b155422c45726 Review-Link: https://gwt-review.googlesource.com/#/c/3250/ --- M user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java M user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java M user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java A user/test/com/google/gwt/uibinder/test/client/ExtendsValueChangeWidget.java M user/test/com/google/gwt/uibinder/test/client/UiHandlerTest.java A user/test/com/google/gwt/uibinder/test/client/ValueChangeWidget.java M user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java M user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml D user/test/com/google/gwt/uibinder/test/client/WildcardValueChangeWidget.java 9 files changed, 238 insertions(+), 153 deletions(-) Approvals: Roberto Lublinerman: Looks good to me, approved Leeroy Jenkins: Verified diff --git a/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java b/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java index c6d8a35..46e5b73 100644 --- a/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java +++ b/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java @@ -16,7 +16,6 @@ package com.google.gwt.uibinder.rebind; import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JGenericType; /** * Implementation of FieldWriter for fields whose type already exists (that is, @@ -33,12 +32,6 @@ if (type == null) { throw new IllegalArgumentException("type cannot be null"); } - -JGenericType genericType = type.isGenericType(); -if (genericType != null) { - type = genericType.getRawType(); -} - this.type = type; } diff --git a/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java b/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java index cc7bc2c..a2fd077 100644 --- a/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java +++ b/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java @@ -25,6 +25,7 @@ import com.google.gwt.event.shared.EventHandler; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.uibinder.rebind.model.OwnerClass; +import com.google.gwt.uibinder.rebind.model.OwnerField; import com.google.web.bindery.event.shared.HandlerRegistration; /** @@ -153,10 +154,13 @@ ("Method '%s' can not be bound. You probably missed ui:field='%s' " + "in the template."), boundMethod, objectName); } +JClassType objectType = fieldWriter.getInstantiableType(); +if (objectType.isGenericType() != null) { + objectType = tryEnhancingTypeInfo(objectName, objectType); +} // Retrieves the "add handler" method in the object. -JMethod addHandlerMethodType = getAddHandlerMethodForObject( -fieldWriter.getInstantiableType(), handlerType); +JMethod addHandlerMethodType = getAddHandlerMethodForObject(objectType, handlerType); if (addHandlerMethodType == null) { logger.die("Field '%s' does not have an 'add%s' method associated.", objectName, handlerType.getName()); @@ -167,6 +171,23 @@ addHandlerMethodType.getName(), objectName); } } + } + + private JClassType tryEnhancingTypeInfo(String objectName, JClassType objectType) { +OwnerField uiField = ownerClass.getUiField(objectName); +if (uiField != null) { + JParameterizedType pType = uiField.getRawType().isParameterized(); + if (pType != null) { +// Even field is parameterized, it might be a super class. In that
[gwt-contrib] Change in gwt[master]: Fixes UiHandler method matching in generic classes
Roberto Lublinerman has posted comments on this change. Change subject: Fixes UiHandler method matching in generic classes .. Patch Set 2: Code-Review+2 -- To view, visit https://gwt-review.googlesource.com/3250 To unsubscribe, visit https://gwt-review.googlesource.com/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3121542b6eb4f06f36b88b02006b155422c45726 Gerrit-PatchSet: 2 Gerrit-Project: gwt Gerrit-Branch: master Gerrit-Owner: Goktug Gokdogan Gerrit-Reviewer: Leeroy Jenkins Gerrit-Reviewer: Roberto Lublinerman Gerrit-HasComments: No -- http://groups.google.com/group/Google-Web-Toolkit-Contributors --- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[gwt-contrib] Change in gwt[master]: Fixes UiHandler method matching in generic classes
Hello Leeroy Jenkins, I'd like you to reexamine a change. Please visit https://gwt-review.googlesource.com/3250 to look at the new patch set (#2). Change subject: Fixes UiHandler method matching in generic classes .. Fixes UiHandler method matching in generic classes Method matching in UiHandler is completely broken for generic ui fields as FieldWriterOfExistingType is using the raw type of the ui field. Raw type of a generic field erases all generics from the method signature. This was causing type parameter information to be not used while matching methods. This is a huge problem with some common events like SelectEvent and ValueChangeEvent. We were not hitting the problem in some cases because JRawType is broken and doesn't correctly delete the generics from the signature of parent methods. However that was causing another problem: UiBinder uses the type information for ui.xml so it doesn't really know the type parameters so it can't match generics methods from the parent class (Issue 6091). This fix changes the UiBinder generator so that - it will enhance the type information if there is a @uifield declaration - it will not use raw type in FieldWriterOfExistingType - it will fallback to erase type if it can't find any method match Bugs: Issue 6091 Change-Id: I3121542b6eb4f06f36b88b02006b155422c45726 Review-Link: https://gwt-review.googlesource.com/#/c/3250/ --- M user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java M user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java M user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java A user/test/com/google/gwt/uibinder/test/client/ExtendsValueChangeWidget.java M user/test/com/google/gwt/uibinder/test/client/UiHandlerTest.java A user/test/com/google/gwt/uibinder/test/client/ValueChangeWidget.java M user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java M user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml D user/test/com/google/gwt/uibinder/test/client/WildcardValueChangeWidget.java 9 files changed, 238 insertions(+), 153 deletions(-) -- To view, visit https://gwt-review.googlesource.com/3250 To unsubscribe, visit https://gwt-review.googlesource.com/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I3121542b6eb4f06f36b88b02006b155422c45726 Gerrit-PatchSet: 2 Gerrit-Project: gwt Gerrit-Branch: master Gerrit-Owner: Goktug Gokdogan Gerrit-Reviewer: Leeroy Jenkins -- http://groups.google.com/group/Google-Web-Toolkit-Contributors --- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[gwt-contrib] Change in gwt[master]: Fixes UiHandler method matching in generic classes
Goktug Gokdogan has uploaded a new change for review. https://gwt-review.googlesource.com/3250 Change subject: Fixes UiHandler method matching in generic classes .. Fixes UiHandler method matching in generic classes Method matching in UiHandler is completely broken for generic ui fields as FieldWriterOfExistingType is using the raw type of the ui field. Raw type of a generic field erases all generics from the method signature. This was causing type parameter information to be not used while matching methods. This is a huge problem with some common events like SelectEvent and ValueChangeEvent. We were not hitting the problem in some cases because JRawType is broken and doesn't correctly delete the generics from the signature of parent methods. However that was causing another problem: UiBinder uses the type information for ui.xml so it doesn't really know the type parameters so it can't match generics methods from the parent class (Issue 6091). This fix changes the UiBinder generator so that - it will enhance the type information if there is a @uifield declaration - it will not use raw type in FieldWriterOfExistingType - it will fallback to erase type if it can't find any method match Bugs: Issue 6091 Change-Id: I3121542b6eb4f06f36b88b02006b155422c45726 --- M user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java M user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java M user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java A user/test/com/google/gwt/uibinder/test/client/ExtendsValueChangeWidget.java M user/test/com/google/gwt/uibinder/test/client/UiHandlerTest.java A user/test/com/google/gwt/uibinder/test/client/ValueChangeWidget.java M user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java M user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml D user/test/com/google/gwt/uibinder/test/client/WildcardValueChangeWidget.java 9 files changed, 239 insertions(+), 153 deletions(-) diff --git a/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java b/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java index c6d8a35..46e5b73 100644 --- a/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java +++ b/user/src/com/google/gwt/uibinder/rebind/FieldWriterOfExistingType.java @@ -16,7 +16,6 @@ package com.google.gwt.uibinder.rebind; import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JGenericType; /** * Implementation of FieldWriter for fields whose type already exists (that is, @@ -33,12 +32,6 @@ if (type == null) { throw new IllegalArgumentException("type cannot be null"); } - -JGenericType genericType = type.isGenericType(); -if (genericType != null) { - type = genericType.getRawType(); -} - this.type = type; } diff --git a/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java b/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java index cc7bc2c..cae7dc4 100644 --- a/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java +++ b/user/src/com/google/gwt/uibinder/rebind/HandlerEvaluator.java @@ -23,8 +23,10 @@ import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.uibinder.rebind.model.OwnerClass; +import com.google.gwt.uibinder.rebind.model.OwnerField; import com.google.web.bindery.event.shared.HandlerRegistration; /** @@ -153,10 +155,13 @@ ("Method '%s' can not be bound. You probably missed ui:field='%s' " + "in the template."), boundMethod, objectName); } +JClassType objectType = fieldWriter.getInstantiableType(); +if (objectType.isGenericType() != null) { + objectType = tryEnhancingTypeInfo(objectName, objectType); +} // Retrieves the "add handler" method in the object. -JMethod addHandlerMethodType = getAddHandlerMethodForObject( -fieldWriter.getInstantiableType(), handlerType); +JMethod addHandlerMethodType = getAddHandlerMethodForObject(objectType, handlerType); if (addHandlerMethodType == null) { logger.die("Field '%s' does not have an 'add%s' method associated.", objectName, handlerType.getName()); @@ -167,6 +172,23 @@ addHandlerMethodType.getName(), objectName); } } + } + + private JClassType tryEnhancingTypeInfo(String objectName, JClassType objectType) { +OwnerField uiField = ownerClass.getUiField(objectName); +if (uiField != null) { + JParameterizedType pType = uiField.getRawType().isParameterized(); + if (pType != null) { +// Even field is para