/** * Creates a instrumented version of the given class if possible. * * @param buffer definition of the class * @param name a name used for exception messages * @return instrumented definition * @throws IOException if the class can't be analyzed */ public byte[] instrument(final byte[] buffer, final String name) throws IOException { try { if (Java9Support.isPatchRequired(buffer)) { final byte[] result = instrument(new ClassReader(Java9Support.downgrade(buffer))); Java9Support.upgrade(result); return result; } else { return instrument(new ClassReader(buffer)); } } catch (final RuntimeException e) { throw instrumentError(name, e); } }