groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Smith (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7514) static final fields on trait aren't final
Date Tue, 21 Jul 2015 18:15:05 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-7514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Christopher Smith updated GROOVY-7514:
--------------------------------------
    Description: 
In order to work around the fact that {{@Slf4j}} doesn't work on traits, I declared an slf4j
logger the traditional way:

{code}
private static final Logger slf4j = LoggerFactory.getLogger(Auditing)
{code}

However, the {{final}} keyword is ignored when the trait is applied to a class. From {{javap}}:

{code}
  private static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j;
  public static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j$get();
  public static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j$set(org.slf4j.Logger);
{code}

  was:
In order to work around the fact that {{@Slf4j} doesn't work on traits, I declared an slf4j
logger the traditional way:

{code}
private static final Logger slf4j = LoggerFactory.getLogger(Auditing)
{code}

However, the {{final}} keyword is ignored when the trait is applied to a class. From {{javap}}:

{code}
  private static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j;
  public static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j$get();
  public static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j$set(org.slf4j.Logger);
{code}


> static final fields on trait aren't final
> -----------------------------------------
>
>                 Key: GROOVY-7514
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7514
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.4
>            Reporter: Christopher Smith
>            Priority: Minor
>
> In order to work around the fact that {{@Slf4j}} doesn't work on traits, I declared an
slf4j logger the traditional way:
> {code}
> private static final Logger slf4j = LoggerFactory.getLogger(Auditing)
> {code}
> However, the {{final}} keyword is ignored when the trait is applied to a class. From
{{javap}}:
> {code}
>   private static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j;
>   public static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j$get();
>   public static org.slf4j.Logger com_artsquare_studio_audit_api_Auditing__slf4j$set(org.slf4j.Logger);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message