@Nullable private InputStream inputStreamFor(String fullname) { return classLoader.getResourceAsStream(Convert.bytecodeName(fullname) + ".class"); }
@Nullable private InputStream inputStreamFor(String fullname) { return classLoader.getResourceAsStream(Convert.bytecodeName(fullname) + ".class"); }
/** * Read bytes representing class with name passed as an argument. Modify the class version in bytecode so ASM can read * returned array without issues. * * @param className canonical name of the class (e.g. org.acme.Foo ) * @return bytes or null if class is not found */ @CheckForNull public byte[] getBytesForClass(String className) { try (InputStream is = getResourceAsStream(Convert.bytecodeName(className) + ".class")) { if (is == null) { return null; } return ByteStreams.toByteArray(is); } catch (IOException e) { throw new AnalysisException("An IOException occurred in SonarJava classLoader.",e); } }
/** * Read bytes representing class with name passed as an argument. Modify the class version in bytecode so ASM can read * returned array without issues. * * @param className canonical name of the class (e.g. org.acme.Foo ) * @return bytes or null if class is not found */ @CheckForNull public byte[] getBytesForClass(String className) { try (InputStream is = getResourceAsStream(Convert.bytecodeName(className) + ".class")) { if (is == null) { return null; } return ByteStreams.toByteArray(is); } catch (IOException e) { throw new AnalysisException("An IOException occurred in SonarJava classLoader.",e); } }