lundi 16 février 2015

Can't invoke HashMap's getEntry via reflection on Java 8

I have some legacy code (compiled and ran successfully with JDK 7u55) similar to the following:



private static class MyHashMap extends HashMap {
static Method getEntryMethod;

static {
try {
getEntryMethod = HashMap.class.getDeclaredMethod("getEntry", Object.class);
} catch (Exception e) {
e.printStackTrace();
}
}
}

public static void main(String[] args) {
MyHashMap myHashMap = new MyHashMap();
}


After trying to switch to JDK 8u31, it fails with:



java.lang.NoSuchMethodException: java.util.HashMap.getEntry(java.lang.Object)





Aucun commentaire:

Enregistrer un commentaire