You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Christopher Smith (Jira)" <ji...@apache.org> on 2023/01/03 20:20:00 UTC

[jira] [Created] (GROOVY-10894) Duplicate annotations on trait FieldHelper

Christopher Smith created GROOVY-10894:
------------------------------------------

             Summary: Duplicate annotations on trait FieldHelper
                 Key: GROOVY-10894
                 URL: https://issues.apache.org/jira/browse/GROOVY-10894
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 4.0.8
            Reporter: Christopher Smith


The latest nightly (included with GRECLIPSE 4.9.0.v202301012233-e2206) has introduced a regression that appears to be the same bug as GROOVY-10553; JSR-303 annotations applied to a trait property are listed twice in the bytecode on both the field and the {{$get/$set}} methods, resulting in an {{AnnotationFormatError}} at runtime. Compiling with groovyc 4.0.7 produces clean bytecode, and rebuilding in Eclipse reintroduces the duplicate.

Sample:

{code}
trait LocationRelated {
  @NotNull @Valid Location location
}
{code}

In {{FieldHelper}} disassembly:
{code}
  public abstract com.example.Location com_example_LocationRelated__location$set(com.example.Location);
    descriptor: (Lcom/example/Location;)Lcom/example/Location;
    flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT
    RuntimeVisibleTypeAnnotations:
      0: #11(): METHOD_RETURN
        javax.validation.constraints.NotNull
      1: #12(): METHOD_RETURN
        javax.validation.Valid
      2: #11(): METHOD_RETURN
        javax.validation.constraints.NotNull
      3: #12(): METHOD_RETURN
        javax.validation.Valid
      4: #11(): METHOD_FORMAL_PARAMETER, param_index=0
        javax.validation.constraints.NotNull
      5: #12(): METHOD_FORMAL_PARAMETER, param_index=0
        javax.validation.Valid
      6: #11(): METHOD_FORMAL_PARAMETER, param_index=0
        javax.validation.constraints.NotNull
      7: #12(): METHOD_FORMAL_PARAMETER, param_index=0
        javax.validation.Valid
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)