Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

(Class<Map<String, String>>) Map.class -> Cannot cast (certainly!)

843793Mar 9 2010 — edited Mar 9 2010
Hello all,

tried to search for this topic, but by "class AND generic" you find a lot, but not what you are searching for...

Here's the problem:
There's this Mapping-Framework "Dozer" (http://dozer.sourceforge.net/), and you can extend the class "DozerConverter":
public abstract class DozerConverter<A, B> implements ConfigurableCustomConverter {
  // ...
  public DozerConverter(Class<A> prototypeA, Class<B> prototypeB) {
    this.prototypeA = prototypeA;
    this.prototypeB = prototypeB;
  }
  // ...
}
Now I want to write a converter that converts a Map<String, String> to an Object (don't blame me for that - there's this old crappy code and I got to deal with it). My problem is how to call the super-class:
public class MyMapObjectConverter extends DozerConverter<Map<String, String>, Object> {
    // ...
    public MyMapObjectConverter() {

        super((Class<Map<String, String>>) Map.class, Object.class); // doesn't work

        // super(Map.class, Object.class); // doesn't work either
        // super(Map<String, String>.class, Object.class); // doesn't work either
    }
    // ...
}
I'm a bit clueless at the moment. How to call the super-constructor in a valid way?

Thank you very much for any hint!

Best regards
lotk
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2010
Added on Mar 9 2010
7 comments
5,195 views