You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "John Wagenleitner (JIRA)" <ji...@apache.org> on 2016/10/20 18:48:59 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=15592638#comment-15592638 ]
John Wagenleitner commented on GROOVY-7469:
-------------------------------------------
Running the following in GroovyConsole for version 2.3.10 and current works fine. Maybe the problem is with how I'm calling the method marked as failing, do you have a self-contained example?
{code}
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
}
}
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 }
}
}
assert FoodItem.builder().build()
{code}
> 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
> Labels: usertask
>
> 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)