0

We're working on a map-reduce framework project from scratch. When receiving the .jar file to get classes, the generic types that we defined (key, value) caused a cast type problem.

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: java.lang.ClassCastException: keysvalues.Key1 cannot be cast to keysvalues.Key1

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
Karabatich
  • 11
  • 3
  • 2
    Show me your code please. – Nikolas Charalambidis Feb 29 '16 at 19:29
  • 4
    Sounds like a classloader issue. If two classloaders load the same `.class` file, then each of those loads will produce a different class -- even though everything about those classes (fields, methods, etc) is the same. And, just like you can't cast a String to a Map, you can't map a Key1 from one classloader to a Key1 from another classloader; they're different classes. – yshavit Feb 29 '16 at 19:40

0 Answers0