Быстро, просто, без рефлекшена!
public String getClassNameFromInputStream(InputStream is) {
Map strings = new HashMap<>();
Map classMap = new HashMap<>();
String ret = null;
try {
DataInputStream dis = new DataInputStream(is);
dis.skip(8);
int pool_count = dis.readShort();
int idx = 1;
while (pool_count - idx > 0) {
int type = dis.read();
switch (type) {
case 1:
int len = dis.readShort();
byte[] buf = new byte[len];
dis.read(buf);
strings.put(idx, new String(buf));
break;
case 7:
int index = dis.readShort();
classMap.put(idx, index);
break;
case 8:
case 16:
dis.skip(2);
break;
case 3:
case 4:
case 9:
case 10:
case 11:
case 12:
case 18:
dis.skip(4);
break;
case 5:
case 6:
dis.skip(8);
idx++;
break;
case 15:
dis.skip(3);
default:
System.out.println(idx + " unknown byte " + type);
}
idx++;
}
dis.skip(2);
int thisClass = dis.readShort();
dis.close();
ret = strings.get(classMap.get(thisClass)).replace('/', '.');
} catch (IOException e) {
}
return ret;
}