[jira] [Comment Edited] (GROOVY-10757) Regression from 2.5.16+: ClassCastException at runtime

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-10757 at 9/14/22 10:25 PM:


Can you say where {{BarPurchaseDao}} fits into the picture?

You could try making the call to {{retrieveAvailableProducts}} from a 
static-compile method, like this:
{code:groovy}
@CompileStatic
abstract class GenericServicePurchaseBean ... {
  protected abstract List retrieveAvailableProducts()
  private List retrieveProducts() {
retrieveAvailableProducts()
  }
  @CompileDynamic
  void resetState() {
// ...
def products = retrieveProducts()
// ...
  }
}
{code}

Not ideal, but changes the call semantics for that one call.  I've done this 
before when a method makes multiple super.something() references so there is 
only one _super$n$something_ MOP method.

Update: Another thing to try is casting "dao" in FooPurchaseBean:
{code:groovy}
  ((FooPurchaseDao)dao).loadAllAvailableProductsForNewPurchase(customer)
{code}

Not sure if Spring is getting tripped up by the covariant setDao methods or 
what.  When you start up, what bean(s) get sent into the dao setter(s)?


was (Author: emilles):
Can you say where {{BarPurchaseDao}} fits into the picture?

You could try making the call to {{retrieveAvailableProducts}} from a 
static-compile method, like this:
{code:groovy}
@CompileStatic
abstract class GenericServicePurchaseBean ... {
  protected abstract List retrieveAvailableProducts()
  private List retrieveProducts() {
retrieveAvailableProducts()
  }
  @CompileDynamic
  void resetState() {
// ...
def products = retrieveProducts()
// ...
  }
}
{code}

Not ideal, but changes the call semantics for that one call.  I've done this 
before when a method makes multiple super.something() references so there is 
only one _super$n$something_ MOP method.

> Regression from 2.5.16+: ClassCastException at runtime
> --
>
> Key: GROOVY-10757
> URL: https://issues.apache.org/jira/browse/GROOVY-10757
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 2.5.16, 2.5.17, 2.5.18
>Reporter: Mauro Molinari
>Assignee: Eric Milles
>Priority: Major
>
> I've found a very nasty bug in Groovy 2.5.16+.
> It's really hard to extract a simple test case, so I'll try to explain what 
> is going on as much as possible.
> I have a {{@CompileStatic}} Groovy class hierarchy. Compilation succeeds, but 
> a {{ClassCastException}} happens at runtime. The hierarchy is like this:
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> abstract class GenericServicePurchaseBean GenericServicePurchaseDao> implements Serializable {
> T dao
>     void setDao(final T dao) {
>         this.dao = dao
>     }
> protected abstract List retrieveAvailableProducts()
>   @CompileDynamic // see note below
>   void resetState() {
>   // ...
> retrieveAvailableProducts()
> // ...
> }
> }
> {code}
>  
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> class FooPurchaseBean extends GenericServicePurchaseBean {
>   @Inject
>   @Named('fooPurchaseDao')
>   @Override
>   void setDao(final FooPurchaseDao dao) {
>   super.setDao(dao)
>   }
>   @Override
>   protected List retrieveAvailableProducts() {
>   dao.loadAllAvailableProductsForNewPurchase(customer)
>   }
>   @Override
>   void resetState() {
>   super.resetState();
> // ...
> }
> }
> {code}
> The error I get at runtime is this:
> {noformat}
> Caused by: java.lang.ClassCastException: class 
> it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  cannot be cast to class it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao 
> (it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  and it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao are in unnamed 
> module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5a075a)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.retrieveAvailableProducts(FooPurchaseBean.groovy:217)
> at 
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at 
> it.dcssrl.shop.web.purchase.view.GenericServicePurchaseBean.resetState(GenericServicePurchaseBean.groovy:682)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.resetState(FooPurchaseBean.groovy:148)
>  [...]
> {noformat}
> If I remove the Groovy compiler optimization to enable Indy compilation, the 
> error happens all the same, but the stack trace does not have the line about 
> {{org.codehaus

[jira] [Commented] (GROOVY-10757) Regression from 2.5.16+: ClassCastException at runtime

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-10757:
--

There is a 2.5.19 snapshot available with many fixes.  Can you give it a quick 
try and say if this issue is still present?  If I can get a recreation 
scenario, I might be able to get a fix into 2.5.19 which is coming very soon.

> Regression from 2.5.16+: ClassCastException at runtime
> --
>
> Key: GROOVY-10757
> URL: https://issues.apache.org/jira/browse/GROOVY-10757
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 2.5.16, 2.5.17, 2.5.18
>Reporter: Mauro Molinari
>Assignee: Eric Milles
>Priority: Major
>
> I've found a very nasty bug in Groovy 2.5.16+.
> It's really hard to extract a simple test case, so I'll try to explain what 
> is going on as much as possible.
> I have a {{@CompileStatic}} Groovy class hierarchy. Compilation succeeds, but 
> a {{ClassCastException}} happens at runtime. The hierarchy is like this:
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> abstract class GenericServicePurchaseBean GenericServicePurchaseDao> implements Serializable {
> T dao
>     void setDao(final T dao) {
>         this.dao = dao
>     }
> protected abstract List retrieveAvailableProducts()
>   @CompileDynamic // see note below
>   void resetState() {
>   // ...
> retrieveAvailableProducts()
> // ...
> }
> }
> {code}
>  
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> class FooPurchaseBean extends GenericServicePurchaseBean {
>   @Inject
>   @Named('fooPurchaseDao')
>   @Override
>   void setDao(final FooPurchaseDao dao) {
>   super.setDao(dao)
>   }
>   @Override
>   protected List retrieveAvailableProducts() {
>   dao.loadAllAvailableProductsForNewPurchase(customer)
>   }
>   @Override
>   void resetState() {
>   super.resetState();
> // ...
> }
> }
> {code}
> The error I get at runtime is this:
> {noformat}
> Caused by: java.lang.ClassCastException: class 
> it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  cannot be cast to class it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao 
> (it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  and it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao are in unnamed 
> module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5a075a)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.retrieveAvailableProducts(FooPurchaseBean.groovy:217)
> at 
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at 
> it.dcssrl.shop.web.purchase.view.GenericServicePurchaseBean.resetState(GenericServicePurchaseBean.groovy:682)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.resetState(FooPurchaseBean.groovy:148)
>  [...]
> {noformat}
> If I remove the Groovy compiler optimization to enable Indy compilation, the 
> error happens all the same, but the stack trace does not have the line about 
> {{org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)}}.
> Please note that:
> - this problem does not happen with Groovy 2.5.15
> - it happens with Groovy 2.5.16, 2.5.17 and 2.5.18
> - it DOES NOT happen if compiling/running the application within Eclipse/WTP 
> and Groovy Eclipse plugin
> - the {{resetState()}} method above in the base class is marked with 
> {{@CompileDynamic}} because of another nasty problem I was not able to 
> isolate, which otherwise produces another {{ClassCastException}} at runtime, 
> although completely different from this one; this has been happening from 
> 2.5.13 at least (it was not occurring with 2.5.9)
> Any idea of what is going on? And of a possible not-too-dirty workaround 
> (apart from downgrading to Groovy 2.5.15)?



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


[jira] [Comment Edited] (GROOVY-10757) Regression from 2.5.16+: ClassCastException at runtime

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-10757 at 9/14/22 10:18 PM:


Can you say where {{BarPurchaseDao}} fits into the picture?

You could try making the call to {{retrieveAvailableProducts}} from a 
static-compile method, like this:
{code:groovy}
@CompileStatic
abstract class GenericServicePurchaseBean ... {
  protected abstract List retrieveAvailableProducts()
  private List retrieveProducts() {
retrieveAvailableProducts()
  }
  @CompileDynamic
  void resetState() {
// ...
def products = retrieveProducts()
// ...
  }
}
{code}

Not ideal, but changes the call semantics for that one call.  I've done this 
before when a method makes multiple super.something() references so there is 
only one _super$n$something_ MOP method.


was (Author: emilles):
Can you say where {{BarPurchaseDao}} fits into the picture?

You could try making the call to {{retrieveAvailableProducts}} from a 
static-compile method, like this:
{code:groovy}
@CompileStatic
abstract class GenericServicePurchaseBean ... {
  protected abstract List retrieveAvailableProducts()
  private void resetProducts() {
retrieveAvailableProducts()
  }
  @CompileDynamic
  void resetState() {
// ...
resetProducts()
// ...
  }
}
{code}

Not ideal, but changes the call semantics for that one call.  I've done this 
before when a method makes multiple super.something() references so there is 
only one _super$n$something_ MOP method.

> Regression from 2.5.16+: ClassCastException at runtime
> --
>
> Key: GROOVY-10757
> URL: https://issues.apache.org/jira/browse/GROOVY-10757
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 2.5.16, 2.5.17, 2.5.18
>Reporter: Mauro Molinari
>Assignee: Eric Milles
>Priority: Major
>
> I've found a very nasty bug in Groovy 2.5.16+.
> It's really hard to extract a simple test case, so I'll try to explain what 
> is going on as much as possible.
> I have a {{@CompileStatic}} Groovy class hierarchy. Compilation succeeds, but 
> a {{ClassCastException}} happens at runtime. The hierarchy is like this:
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> abstract class GenericServicePurchaseBean GenericServicePurchaseDao> implements Serializable {
> T dao
>     void setDao(final T dao) {
>         this.dao = dao
>     }
> protected abstract List retrieveAvailableProducts()
>   @CompileDynamic // see note below
>   void resetState() {
>   // ...
> retrieveAvailableProducts()
> // ...
> }
> }
> {code}
>  
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> class FooPurchaseBean extends GenericServicePurchaseBean {
>   @Inject
>   @Named('fooPurchaseDao')
>   @Override
>   void setDao(final FooPurchaseDao dao) {
>   super.setDao(dao)
>   }
>   @Override
>   protected List retrieveAvailableProducts() {
>   dao.loadAllAvailableProductsForNewPurchase(customer)
>   }
>   @Override
>   void resetState() {
>   super.resetState();
> // ...
> }
> }
> {code}
> The error I get at runtime is this:
> {noformat}
> Caused by: java.lang.ClassCastException: class 
> it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  cannot be cast to class it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao 
> (it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  and it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao are in unnamed 
> module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5a075a)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.retrieveAvailableProducts(FooPurchaseBean.groovy:217)
> at 
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at 
> it.dcssrl.shop.web.purchase.view.GenericServicePurchaseBean.resetState(GenericServicePurchaseBean.groovy:682)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.resetState(FooPurchaseBean.groovy:148)
>  [...]
> {noformat}
> If I remove the Groovy compiler optimization to enable Indy compilation, the 
> error happens all the same, but the stack trace does not have the line about 
> {{org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)}}.
> Please note that:
> - this problem does not happen with Groovy 2.5.15
> - it happens with Groovy 2.5.16, 2.5.17 and 2.5.18
> - it DOES NOT happen if compiling/running the application within Eclipse/WTP 
> and Groovy Eclipse plugin
> - the {{resetState()}} 

[jira] [Commented] (GROOVY-10757) Regression from 2.5.16+: ClassCastException at runtime

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-10757:
--

Can you say where {{BarPurchaseDao}} fits into the picture?

You could try making the call to {{retrieveAvailableProducts}} from a 
static-compile method, like this:
{code:groovy}
@CompileStatic
abstract class GenericServicePurchaseBean ... {
  protected abstract List retrieveAvailableProducts()
  private void resetProducts() {
retrieveAvailableProducts()
  }
  @CompileDynamic
  void resetState() {
// ...
resetProducts()
// ...
  }
}
{code}

Not ideal, but changes the call semantics for that one call.  I've done this 
before when a method makes multiple super.something() references so there is 
only one _super$n$something_ MOP method.

> Regression from 2.5.16+: ClassCastException at runtime
> --
>
> Key: GROOVY-10757
> URL: https://issues.apache.org/jira/browse/GROOVY-10757
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 2.5.16, 2.5.17, 2.5.18
>Reporter: Mauro Molinari
>Assignee: Eric Milles
>Priority: Major
>
> I've found a very nasty bug in Groovy 2.5.16+.
> It's really hard to extract a simple test case, so I'll try to explain what 
> is going on as much as possible.
> I have a {{@CompileStatic}} Groovy class hierarchy. Compilation succeeds, but 
> a {{ClassCastException}} happens at runtime. The hierarchy is like this:
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> abstract class GenericServicePurchaseBean GenericServicePurchaseDao> implements Serializable {
> T dao
>     void setDao(final T dao) {
>         this.dao = dao
>     }
> protected abstract List retrieveAvailableProducts()
>   @CompileDynamic // see note below
>   void resetState() {
>   // ...
> retrieveAvailableProducts()
> // ...
> }
> }
> {code}
>  
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> class FooPurchaseBean extends GenericServicePurchaseBean {
>   @Inject
>   @Named('fooPurchaseDao')
>   @Override
>   void setDao(final FooPurchaseDao dao) {
>   super.setDao(dao)
>   }
>   @Override
>   protected List retrieveAvailableProducts() {
>   dao.loadAllAvailableProductsForNewPurchase(customer)
>   }
>   @Override
>   void resetState() {
>   super.resetState();
> // ...
> }
> }
> {code}
> The error I get at runtime is this:
> {noformat}
> Caused by: java.lang.ClassCastException: class 
> it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  cannot be cast to class it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao 
> (it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  and it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao are in unnamed 
> module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5a075a)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.retrieveAvailableProducts(FooPurchaseBean.groovy:217)
> at 
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at 
> it.dcssrl.shop.web.purchase.view.GenericServicePurchaseBean.resetState(GenericServicePurchaseBean.groovy:682)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.resetState(FooPurchaseBean.groovy:148)
>  [...]
> {noformat}
> If I remove the Groovy compiler optimization to enable Indy compilation, the 
> error happens all the same, but the stack trace does not have the line about 
> {{org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)}}.
> Please note that:
> - this problem does not happen with Groovy 2.5.15
> - it happens with Groovy 2.5.16, 2.5.17 and 2.5.18
> - it DOES NOT happen if compiling/running the application within Eclipse/WTP 
> and Groovy Eclipse plugin
> - the {{resetState()}} method above in the base class is marked with 
> {{@CompileDynamic}} because of another nasty problem I was not able to 
> isolate, which otherwise produces another {{ClassCastException}} at runtime, 
> although completely different from this one; this has been happening from 
> 2.5.13 at least (it was not occurring with 2.5.9)
> Any idea of what is going on? And of a possible not-too-dirty workaround 
> (apart from downgrading to Groovy 2.5.15)?



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


[jira] [Assigned] (GROOVY-10757) Regression from 2.5.16+: ClassCastException at runtime

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-10757:


Assignee: Eric Milles

> Regression from 2.5.16+: ClassCastException at runtime
> --
>
> Key: GROOVY-10757
> URL: https://issues.apache.org/jira/browse/GROOVY-10757
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 2.5.16, 2.5.17, 2.5.18
>Reporter: Mauro Molinari
>Assignee: Eric Milles
>Priority: Major
>
> I've found a very nasty bug in Groovy 2.5.16+.
> It's really hard to extract a simple test case, so I'll try to explain what 
> is going on as much as possible.
> I have a {{@CompileStatic}} Groovy class hierarchy. Compilation succeeds, but 
> a {{ClassCastException}} happens at runtime. The hierarchy is like this:
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> abstract class GenericServicePurchaseBean GenericServicePurchaseDao> implements Serializable {
> T dao
>     void setDao(final T dao) {
>         this.dao = dao
>     }
> protected abstract List retrieveAvailableProducts()
>   @CompileDynamic // see note below
>   void resetState() {
>   // ...
> retrieveAvailableProducts()
> // ...
> }
> }
> {code}
>  
> {code:groovy}
> @Named
> @CompileStatic
> @Scope('session')
> class FooPurchaseBean extends GenericServicePurchaseBean {
>   @Inject
>   @Named('fooPurchaseDao')
>   @Override
>   void setDao(final FooPurchaseDao dao) {
>   super.setDao(dao)
>   }
>   @Override
>   protected List retrieveAvailableProducts() {
>   dao.loadAllAvailableProductsForNewPurchase(customer)
>   }
>   @Override
>   void resetState() {
>   super.resetState();
> // ...
> }
> }
> {code}
> The error I get at runtime is this:
> {noformat}
> Caused by: java.lang.ClassCastException: class 
> it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  cannot be cast to class it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao 
> (it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
>  and it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao are in unnamed 
> module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5a075a)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.retrieveAvailableProducts(FooPurchaseBean.groovy:217)
> at 
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at 
> it.dcssrl.shop.web.purchase.view.GenericServicePurchaseBean.resetState(GenericServicePurchaseBean.groovy:682)
> at 
> it.dcssrl.shop.web.purchase.view.FooPurchaseBean.resetState(FooPurchaseBean.groovy:148)
>  [...]
> {noformat}
> If I remove the Groovy compiler optimization to enable Indy compilation, the 
> error happens all the same, but the stack trace does not have the line about 
> {{org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)}}.
> Please note that:
> - this problem does not happen with Groovy 2.5.15
> - it happens with Groovy 2.5.16, 2.5.17 and 2.5.18
> - it DOES NOT happen if compiling/running the application within Eclipse/WTP 
> and Groovy Eclipse plugin
> - the {{resetState()}} method above in the base class is marked with 
> {{@CompileDynamic}} because of another nasty problem I was not able to 
> isolate, which otherwise produces another {{ClassCastException}} at runtime, 
> although completely different from this one; this has been happening from 
> 2.5.13 at least (it was not occurring with 2.5.9)
> Any idea of what is going on? And of a possible not-too-dirty workaround 
> (apart from downgrading to Groovy 2.5.15)?



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


[jira] [Updated] (GROOVY-10120) STC: Guava Multimap#asMap bridge method

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10120:
-
Fix Version/s: 2.5.19

> STC: Guava Multimap#asMap bridge method
> ---
>
> Key: GROOVY-10120
> URL: https://issues.apache.org/jira/browse/GROOVY-10120
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.0, 3.0.5
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.5, 2.5.19, 3.0.13
>
>
> Consider the following:
> {code:java}
> @Grab('com.google.guava:guava:30.1.1-jre')
> import com.google.common.collect.*
> @groovy.transform.TypeChecked
> void test() {
> ListMultimap mmap = ArrayListMultimap.create()
> Map> map = mmap.asMap() // no STC error
> // ...
> }
> {code}
> Due to the presence of multiple bridge methods in {{ArrayListMultimap}}, 
> generics checking of {{asMap()}} is currently lacking.  The following are all 
> bridge methods in {{ArrayListMultimap}} (30.1.1):
> {code}
> asMap()
> equals(Object)
> put(Object,Object)
> replaceValues(Object,Iterable)
> removeAll(Object)
> get(Object)
> forEach(BiConsumer)
> entries()
> values()
> clear()
> containsKey(Object)
> size()
> createCollection() // non-synthetic returns List not Collection
> toString()
> hashCode()
> keys()
> keySet()
> putAll(Multimap)
> putAll(Object,Iterable)
> remove(Object,Object)
> containsEntry(Object,Object)
> containsValue(Object)
> isEmpty()
> {code}



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


[jira] [Updated] (GROOVY-10120) STC: Guava Multimap#asMap bridge method

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10120:
-
Fix Version/s: 3.0.13

> STC: Guava Multimap#asMap bridge method
> ---
>
> Key: GROOVY-10120
> URL: https://issues.apache.org/jira/browse/GROOVY-10120
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.0, 3.0.5
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.5, 3.0.13
>
>
> Consider the following:
> {code:java}
> @Grab('com.google.guava:guava:30.1.1-jre')
> import com.google.common.collect.*
> @groovy.transform.TypeChecked
> void test() {
> ListMultimap mmap = ArrayListMultimap.create()
> Map> map = mmap.asMap() // no STC error
> // ...
> }
> {code}
> Due to the presence of multiple bridge methods in {{ArrayListMultimap}}, 
> generics checking of {{asMap()}} is currently lacking.  The following are all 
> bridge methods in {{ArrayListMultimap}} (30.1.1):
> {code}
> asMap()
> equals(Object)
> put(Object,Object)
> replaceValues(Object,Iterable)
> removeAll(Object)
> get(Object)
> forEach(BiConsumer)
> entries()
> values()
> clear()
> containsKey(Object)
> size()
> createCollection() // non-synthetic returns List not Collection
> toString()
> hashCode()
> keys()
> keySet()
> putAll(Multimap)
> putAll(Object,Iterable)
> remove(Object,Object)
> containsEntry(Object,Object)
> containsValue(Object)
> isEmpty()
> {code}



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


[jira] [Updated] (GROOVY-10322) Type variable of function does not shadow the corresponding type variable of class

2022-09-14 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-10322:
-
Fix Version/s: 3.0.13

> Type variable of function does not shadow the corresponding type variable of 
> class
> --
>
> Key: GROOVY-10322
> URL: https://issues.apache.org/jira/browse/GROOVY-10322
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Reporter: Thodoris Sotiropoulos
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-beta-2, 3.0.13
>
>
> I have the following program
> {code:java}
> class A {
>T foo(T t) { return t; }
> }
> class B {
>   void bar(int x) {}
>   void test() {
> int x = (new A()).foo(1);
>   }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 11: [Static type checking] - Cannot find matching method 
> A#foo(int). Please check if the declared type is correct and if the method 
> exists.
>  @ line 11, column 13.
>int x = (new A()).foo(1);
>^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Tested against master



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


[jira] [Created] (GROOVY-10757) Regression from 2.5.16+: ClassCastException at runtime

2022-09-14 Thread Mauro Molinari (Jira)
Mauro Molinari created GROOVY-10757:
---

 Summary: Regression from 2.5.16+: ClassCastException at runtime
 Key: GROOVY-10757
 URL: https://issues.apache.org/jira/browse/GROOVY-10757
 Project: Groovy
  Issue Type: Bug
  Components: Compiler
Affects Versions: 2.5.18, 2.5.17, 2.5.16
Reporter: Mauro Molinari


I've found a very nasty bug in Groovy 2.5.16+.

It's really hard to extract a simple test case, so I'll try to explain what is 
going on as much as possible.

I have a {{@CompileStatic}} Groovy class hierarchy. Compilation succeeds, but a 
{{ClassCastException}} happens at runtime. The hierarchy is like this:

{code:groovy}
@Named
@CompileStatic
@Scope('session')
abstract class GenericServicePurchaseBean 
implements Serializable {
T dao

    void setDao(final T dao) {
        this.dao = dao
    }

protected abstract List retrieveAvailableProducts()

@CompileDynamic // see note below
void resetState() {
// ...
retrieveAvailableProducts()
// ...
}
}
{code}
 
{code:groovy}
@Named
@CompileStatic
@Scope('session')
class FooPurchaseBean extends GenericServicePurchaseBean {
@Inject
@Named('fooPurchaseDao')
@Override
void setDao(final FooPurchaseDao dao) {
super.setDao(dao)
}

@Override
protected List retrieveAvailableProducts() {
dao.loadAllAvailableProductsForNewPurchase(customer)
}

@Override
void resetState() {
super.resetState();
// ...
}
}
{code}

The error I get at runtime is this:

{noformat}
Caused by: java.lang.ClassCastException: class 
it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
 cannot be cast to class it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao 
(it.dcssrl.shop.web.purchase.view.dao.FooPurchaseDao$$EnhancerBySpringCGLIB$$271ceca2
 and it.dcssrl.shop.web.purchase.view.dao.BarPurchaseDao are in unnamed module 
of loader org.apache.catalina.loader.ParallelWebappClassLoader @5a075a)
at 
it.dcssrl.shop.web.purchase.view.FooPurchaseBean.retrieveAvailableProducts(FooPurchaseBean.groovy:217)
at 
org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
at 
it.dcssrl.shop.web.purchase.view.GenericServicePurchaseBean.resetState(GenericServicePurchaseBean.groovy:682)
at 
it.dcssrl.shop.web.purchase.view.FooPurchaseBean.resetState(FooPurchaseBean.groovy:148)
 [...]
{noformat}

If I remove the Groovy compiler optimization to enable Indy compilation, the 
error happens all the same, but the stack trace does not have the line about 
{{org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)}}.

Please note that:
- this problem does not happen with Groovy 2.5.15
- it happens with Groovy 2.5.16, 2.5.17 and 2.5.18
- it DOES NOT happen if compiling/running the application within Eclipse/WTP 
and Groovy Eclipse plugin
- the {{resetState()}} method above in the base class is marked with 
{{@CompileDynamic}} because of another nasty problem I was not able to isolate, 
which otherwise produces another {{ClassCastException}} at runtime, although 
completely different from this one; this has been happening from 2.5.13 at 
least (it was not occurring with 2.5.9)

Any idea of what is going on? And of a possible not-too-dirty workaround (apart 
from downgrading to Groovy 2.5.15)?



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