3 Replies Latest reply on Jan 12, 2014 3:06 PM by navigateur

    ClassCastException: java.util.HashMap cannot be cast to mypackage.MyLinkedHashMap

    navigateur Newbie

      I have a class:

       

      {code}

      @Portable(aliasOf=Map.class)

      class MyLinkedHashMap extends LinkedHashMap<Something, SomethingElse> {

      ...

      {code}

      and I get:

       

      {code}ClassCastException: java.util.HashMap cannot be cast to mypackage.MyLinkedHashMap{code}

       

      ...upon trying to return one of these from the server side (but not during marshaller generation). I'm using 2.1.0.Beta1 and I'm not sure if this would've worked in previous versions.

      I was previously advised I should use List.class as an alias for a LinkedHashMap implementation to preserve ordering but that gives an invalid type error (cannot convert) during marshaller generation. The same is true for LinkedHashSet, which I also need.

       

      Solution?