[ 
https://issues.apache.org/jira/browse/GROOVY-11899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18070930#comment-18070930
 ] 

Paul King edited comment on GROOVY-11899 at 4/3/26 10:06 PM:
-------------------------------------------------------------

Claude's analysis:


{quote}The Fix (in Groovy compiler)

  The stub generator (in the Groovy compiler source, likely in 
JavaStubGenerator or similar) needs to either:

  1. Add a dummy body to static methods in trait stubs, e.g.:
  static java.lang.String getMessage() \{ return null; }
  2. Omit static methods from trait stubs entirely, since they live on the 
trait's helper class (TraitWithStaticMethods$Trait$Helper) at runtime, not on 
the
  interface itself.

  Option 2 is arguably more correct — Groovy trait static methods aren't really 
Java interface static methods; they're implemented on a companion helper class.
{quote}
Option 2 also looks correct to me conceptually, but then that might break trait 
usage.


was (Author: paulk):
Claude's analysis:


{quote}The Fix (in Groovy compiler)

  The stub generator (in the Groovy compiler source, likely in 
JavaStubGenerator or similar) needs to either:

  1. Add a dummy body to static methods in trait stubs, e.g.:
  static java.lang.String getMessage() \{ return null; }
  2. Omit static methods from trait stubs entirely, since they live on the 
trait's helper class (TraitWithStaticMethods$Trait$Helper) at runtime, not on 
the
  interface itself.

  Option 2 is arguably more correct — Groovy trait static methods aren't really 
Java interface static methods; they're implemented on a companion helper class.
{quote}
Option 2 also looks correct to me.

> Static methods in Traits do not compile in Java/Groovy joint compiliation
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-11899
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11899
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.0
>            Reporter: Mattias Reichel
>            Priority: Major
>
> Compilation fails in Java/Groovy joint compilation builds where a Java class 
> references a Trait that has static methods.
> Reproducer:
> {code:java}
> git clone https://github.com/matrei/groovy-5-trait-joint-comp-issue.git
> ./gradlew build{code}



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

Reply via email to