ClassVersionAssertOutcome (ClassInfo info) { ClassLoader classLoader = info.clazz.getClassLoader(); if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader(); //NOTE: also include the Java 9+ locations under META-INF String resourceName = info.name + ".class"; try (InputStream is = classLoader.getResourceAsStream(resourceName)) { if (is == null) { return ClassVersionAssertOutcome.NOT_FOUND; } try (DataInputStream dis = new DataInputStream(is)) { if (dis.readInt() != 0xcafebabe) { return ClassVersionAssertOutcome.ERROR; } /*int minor = */ dis.readUnsignedShort(); int major = dis.readUnsignedShort(); if (major <= 49) { info.myTooOldClassVersion = major; /* Java 1.4 48 Java 5 49 Java 6 50 Java 7 51 Java 8 52 Java 9 53 */ return ClassVersionAssertOutcome.TOO_OLD; } return ClassVersionAssertOutcome.OK; } } catch (Throwable e) { log("Failed to read bytes of " + info.name, e); return ClassVersionAssertOutcome.ERROR; } }