You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2015/06/16 10:11:01 UTC

[jira] [Commented] (GROOVY-7469) ClassCastException in groovy 2.3.10. See description section for more information

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

Jochen Theodorou commented on GROOVY-7469:
------------------------------------------

the code above is missing at least several closing brackets, but also the constructor for FoodItem. Without the signature of that method it is impossible to know why he problem happens. The error message itself would also be very helpful

> ClassCastException in groovy 2.3.10. See description section for more information
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-7469
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7469
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.3.10
>            Reporter: Vijaykumar
>
> Hi Team,
> I'm facing an issue with groovy version 2.3.10. I'm doing the version upgrade from 2.2.2 to 2.3.10.
> The existing code is working in groovy 2.2.2 and the same code throws an exception (ClassCastException) in groovy 2.3.10.
> //FoodItem Class -- start
> Class FoodItem extends Item 
> {
>         static Construct builder() {
>         new Construct() 
>         }
>   static class Construct
>   {
>   Item.Construct build
>   Construct() {
>             build = new   Item.Construct() { }
>    }
>    FoodItem build() {
>         new FoodItem (build.map)  // This line throws the classcastexception
>     }
> }
> //FoodItem Class -- End
> // Item class -- start
> abstract class Item 
> {
>  protected TreeMap map
>     protected Item() {
>         this.map = [:]
>     }
>     protected Item(TreeMap map) {
>         this.map = [:]
>         if (map != null) {
>             this.map = map
>         }
>     }
>     protected Item(Map map) {
>         this.map = [:]
>         if (map != null) {
>             this.map = new TreeMap(map)
>         }
>     }
>     TreeMap getMap() { this.map }
> abstract protected static class Construct {
>  protected TreeMap map
>         protected Construct() {
>             this.map = [:]
>         }
>         protected Construct(Item item) {
>             this.map = item.map as TreeMap
>         }
> }
> // Item class -- End



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