public InputStream getBytecode() throws IOException { if (mjar.isMjar()) { // JarFile handles it for us :) final ZipEntry entry = jar.getJarEntry(this.entry.getName()); if (entry != null) { return jar.getInputStream(entry); } } return jar.getInputStream(entry); } }
public void load(final InputStream is) throws IOException { if (!SUPPORT_MJAR) { return; } load(new Manifest(is)); }
private static int findMJarVersion() { if (!SUPPORT_MJAR) { return -1; } final int version = major(System.getProperty("java.version")); final Integer jarVersion = major(System.getProperty("jdk.util.jar.version")); if (jarVersion > 0) { return Math.min(version, jarVersion); } return Math.min(7/*unexpected but just in case*/, version); }
public InputStream getBytecode(String className) throws IOException, ClassNotFoundException { int pos = className.indexOf("<"); if (pos > -1) { className = className.substring(0, pos); } pos = className.indexOf(">"); if (pos > -1) { className = className.substring(0, pos); } if (!className.endsWith(".class")) { className = className.replace('.', '/') + ".class"; } if (mjar.isMjar()) { final MJarSupport.Clazz resource = mjar.getClasses().get(className); if (resource != null) { className = resource.getPath() + ".class"; } } URL resource = loader.getResource(className); if (resource != null) return new BufferedInputStream(resource.openStream()); throw new ClassNotFoundException(className); }
private void scanDir(File dir, List<String> classNames, String packageName) { File[] files = dir.listFiles(); // using /tmp/. as dir we can get null if (files == null) { return; } for (File file : files) { if (file.isDirectory()) { scanDir(file, classNames, packageName + file.getName() + "."); } else if (file.getName().endsWith(".class")) { String name = file.getName(); name = name.substring(0, name.length() - 6); if (name.contains(".") || name.equals("module-info") /*todo?*/) continue; if (packageName.startsWith("META-INF.versions")) { if (mjar.isMjar()) { mjar.visit(packageName + name); continue; } } classNames.add(packageName + name); } } }
public InputStream getBytecode(String className) throws IOException, ClassNotFoundException { int pos = className.indexOf("<"); if (pos > -1) { className = className.substring(0, pos); } pos = className.indexOf(">"); if (pos > -1) { className = className.substring(0, pos); } if (!className.endsWith(".class")) { className = className.replace('.', '/') + ".class"; } if (mjar.isMjar()) { final MJarSupport.Clazz resource = mjar.getClasses().get(className); if (resource != null) { className = resource.getPath() + ".class"; } } URL resource = loader.getResource(className); if (resource != null) return new BufferedInputStream(resource.openStream()); throw new ClassNotFoundException(className); }
private void scanDir(File dir, List<String> classNames, String packageName) { File[] files = dir.listFiles(); // using /tmp/. as dir we can get null if (files == null) { return; } for (File file : files) { if (file.isDirectory()) { scanDir(file, classNames, packageName + file.getName() + "."); } else if (file.getName().endsWith(".class")) { String name = file.getName(); name = name.substring(0, name.length() - 6); if (name.contains(".") || name.equals("module-info") /*todo?*/) continue; if (packageName.startsWith("META-INF.versions")) { if (mjar.isMjar()) { mjar.visit(packageName + name); continue; } } classNames.add(packageName + name); } } }
public void load(final InputStream is) throws IOException { if (!SUPPORT_MJAR) { return; } load(new Manifest(is)); }
private static int findMJarVersion() { if (!SUPPORT_MJAR) { return -1; } final int version = major(System.getProperty("java.version")); final Integer jarVersion = major(System.getProperty("jdk.util.jar.version")); if (jarVersion > 0) { return Math.min(version, jarVersion); } return Math.min(7/*unexpected but just in case*/, version); }
public InputStream getBytecode() throws IOException { if (mjar.isMjar()) { // JarFile handles it for us :) final ZipEntry entry = jar.getJarEntry(this.entry.getName()); if (entry != null) { return jar.getInputStream(entry); } } return jar.getInputStream(entry); } }
public Iterator<String> _iterator() { if (list != null) return list.iterator(); final File manifest = new File(dir, "META-INF/MANIFEST.MF"); if (manifest.exists()) { InputStream is = null; try { is = new FileInputStream(manifest); mjar.load(is); } catch (final IOException e) { // no-op } finally { if (is != null) { try { is.close(); } catch (final IOException e) { // no-op } } } } list = file(dir); return list.iterator(); }
public Iterator<String> _iterator() { if (list != null) return list.iterator(); final File manifest = new File(dir, "META-INF/MANIFEST.MF"); if (manifest.exists()) { InputStream is = null; try { is = new FileInputStream(manifest); mjar.load(is); } catch (final IOException e) { // no-op } finally { if (is != null) { try { is.close(); } catch (final IOException e) { // no-op } } } } list = file(dir); return list.iterator(); }