Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GwtSpecificValidatorCreator generates wrong code for annotations with long value #9288

Closed
butchyyyy opened this issue Feb 22, 2016 · 2 comments
Milestone

Comments

@butchyyyy
Copy link
Contributor

Found in GWT 2.7.0.

When using long value in validation annotation, the generated code is wrong.

For example using Max annotation on validation model with long value:

@Override
@Max(value = 9999999999L, message = "OPID_CODE_INVALID_FORMAT")
public Long getOpId() {
    return super.getOpId();
}

Will generate validator implementation with:

.setAnnotation( 
              new javax.validation.constraints.Max(){
                  public Class<? extends Annotation> annotationType() {  return javax.validation.constraints.Max.class; }
                  public java.lang.Class[] groups() { return new java.lang.Class[] {};}
                  public long value() { return 1410065407L;}
                  public java.lang.String message() { return "OPID_CODE_INVALID_FORMAT";}
                  public java.lang.Class[] payload() { return new java.lang.Class[] {};}
              }
              )
          .setAttributes(attributeBuilder()
            .put("message", "OPID_CODE_INVALID_FORMAT")
            .put("value", 1410065407L)
            .put("payload", new java.lang.Class[] {})
            .put("groups", new java.lang.Class[] {javax.validation.groups.Default.class})
            .build())

Problem is in GwtSpecificValidatorCreator.asLiteral method:

Current code:

} else if (value instanceof Long) {
      return JLongLiteral.get(((Long) value).intValue()).toSource();

Should be:

} else if (value instanceof Long) {
      return JLongLiteral.get(((Long) value).longValue()).toSource();
@freddyboucher
Copy link
Contributor

Can you submit a fix in Gerrit?
http://www.gwtproject.org/makinggwtbetter.html
Thanks

@tbroyer
Copy link
Member

tbroyer commented Feb 29, 2016

@tbroyer tbroyer added this to the 2.8 milestone Feb 29, 2016
@tbroyer tbroyer closed this as completed Feb 29, 2016
bauna pushed a commit to bauna/gwt that referenced this issue Mar 1, 2016
… long value

Bug-Link: gwtproject#9288
Change-Id: Ib1c9956f51c4e4fdc601db7abb825b73c5b62ef9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants