@Test public void testParseZip() throws IOException { Map<String, ClassReader> map = new TreeMap<String, ClassReader>(); Map<String, InputStream> filesFound = new TreeMap<String, InputStream>(); mAa.parseZip(mOsJarPath, map, filesFound); assertArrayEquals(new String[] { "java.lang.JavaClass", "mock_android.dummy.InnerTest", "mock_android.dummy.InnerTest$DerivingClass", "mock_android.dummy.InnerTest$MyGenerics1", "mock_android.dummy.InnerTest$MyIntEnum", "mock_android.dummy.InnerTest$MyStaticInnerClass", "mock_android.dummy.InnerTest$NotStaticInner1", "mock_android.dummy.InnerTest$NotStaticInner2", "mock_android.util.EmptyArray", "mock_android.view.View", "mock_android.view.ViewGroup", "mock_android.view.ViewGroup$LayoutParams", "mock_android.view.ViewGroup$MarginLayoutParams", "mock_android.widget.LinearLayout", "mock_android.widget.LinearLayout$LayoutParams", "mock_android.widget.TableLayout", "mock_android.widget.TableLayout$LayoutParams" }, map.keySet().toArray()); assertArrayEquals(new String[] {"mock_android/data/dataFile"}, filesFound.keySet().toArray()); }
void parseZip(List<String> jarPathList, Map<String, ClassReader> classes, Map<String, InputStream> filesFound) throws IOException { if (classes == null || filesFound == null) { return; } Pattern[] includeFilePatterns = new Pattern[mIncludeFileGlobs.length]; for (int i = 0; i < mIncludeFileGlobs.length; ++i) { includeFilePatterns[i] = getPatternFromGlob(mIncludeFileGlobs[i]); } for (String jarPath : jarPathList) { ZipFile zip = new ZipFile(jarPath); Enumeration<? extends ZipEntry> entries = zip.entries(); ZipEntry entry; while (entries.hasMoreElements()) { entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { ClassReader cr = new ClassReader(zip.getInputStream(entry)); String className = classReaderToClassName(cr); classes.put(className, cr); } else { for (Pattern includeFilePattern : includeFilePatterns) { if (includeFilePattern.matcher(entry.getName()).matches()) { filesFound.put(entry.getName(), zip.getInputStream(entry)); break; } } } } } }
AsmAnalyzer { void parseZip(List<String> jarPathList, Map<String, ClassReader> classes, Map<String, InputStream> filesFound) throws IOException { if (classes == null || filesFound == null) { return; } Pattern[] includeFilePatterns = new Pattern[mIncludeFileGlobs.length]; for (int i = 0; i < mIncludeFileGlobs.length; ++i) { includeFilePatterns[i] = getPatternFromGlob(mIncludeFileGlobs[i]); } for (String jarPath : jarPathList) { ZipFile zip = new ZipFile(jarPath); Enumeration<? extends ZipEntry> entries = zip.entries(); ZipEntry entry; while (entries.hasMoreElements()) { entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { ClassReader cr = new ClassReader(zip.getInputStream(entry)); String className = classReaderToClassName(cr); classes.put(className, cr); } else { for (Pattern includeFilePattern : includeFilePatterns) { if (includeFilePattern.matcher(entry.getName()).matches()) { filesFound.put(entry.getName(), zip.getInputStream(entry)); break; } } } } } } }
AsmAnalyzer { void parseZip(List<String> jarPathList, Map<String, ClassReader> classes, Map<String, InputStream> filesFound) throws IOException { if (classes == null || filesFound == null) { return; } Pattern[] includeFilePatterns = new Pattern[mIncludeFileGlobs.length]; for (int i = 0; i < mIncludeFileGlobs.length; ++i) { includeFilePatterns[i] = getPatternFromGlob(mIncludeFileGlobs[i]); } for (String jarPath : jarPathList) { ZipFile zip = new ZipFile(jarPath); Enumeration<? extends ZipEntry> entries = zip.entries(); ZipEntry entry; while (entries.hasMoreElements()) { entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { ClassReader cr = new ClassReader(zip.getInputStream(entry)); String className = classReaderToClassName(cr); classes.put(className, cr); } else { for (Pattern includeFilePattern : includeFilePatterns) { if (includeFilePattern.matcher(entry.getName()).matches()) { filesFound.put(entry.getName(), zip.getInputStream(entry)); break; } } } } } } AsmAnalyzer(Log log, List<String> osJarPath, AsmGenerator gen,
            String[] deriveFrom, String[] includeGlobs, Set<String> excludeClasses,
            String[] includeFileGlobs); }
AsmAnalyzer { void parseZip(List<String> jarPathList, Map<String, ClassReader> classes, Map<String, InputStream> filesFound) throws IOException { if (classes == null || filesFound == null) { return; } Pattern[] includeFilePatterns = new Pattern[mIncludeFileGlobs.length]; for (int i = 0; i < mIncludeFileGlobs.length; ++i) { includeFilePatterns[i] = getPatternFromGlob(mIncludeFileGlobs[i]); } for (String jarPath : jarPathList) { ZipFile zip = new ZipFile(jarPath); Enumeration<? extends ZipEntry> entries = zip.entries(); ZipEntry entry; while (entries.hasMoreElements()) { entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { ClassReader cr = new ClassReader(zip.getInputStream(entry)); String className = classReaderToClassName(cr); classes.put(className, cr); } else { for (Pattern includeFilePattern : includeFilePatterns) { if (includeFilePattern.matcher(entry.getName()).matches()) { filesFound.put(entry.getName(), zip.getInputStream(entry)); break; } } } } } } AsmAnalyzer(Log log, List<String> osJarPath, AsmGenerator gen,
            String[] deriveFrom, String[] includeGlobs, Set<String> excludeClasses,
            String[] includeFileGlobs); void analyze(); }
AsmAnalyzer { void parseZip(List<String> jarPathList, Map<String, ClassReader> classes, Map<String, InputStream> filesFound) throws IOException { if (classes == null || filesFound == null) { return; } Pattern[] includeFilePatterns = new Pattern[mIncludeFileGlobs.length]; for (int i = 0; i < mIncludeFileGlobs.length; ++i) { includeFilePatterns[i] = getPatternFromGlob(mIncludeFileGlobs[i]); } for (String jarPath : jarPathList) { ZipFile zip = new ZipFile(jarPath); Enumeration<? extends ZipEntry> entries = zip.entries(); ZipEntry entry; while (entries.hasMoreElements()) { entry = entries.nextElement(); if (entry.getName().endsWith(".class")) { ClassReader cr = new ClassReader(zip.getInputStream(entry)); String className = classReaderToClassName(cr); classes.put(className, cr); } else { for (Pattern includeFilePattern : includeFilePatterns) { if (includeFilePattern.matcher(entry.getName()).matches()) { filesFound.put(entry.getName(), zip.getInputStream(entry)); break; } } } } } } AsmAnalyzer(Log log, List<String> osJarPath, AsmGenerator gen,
            String[] deriveFrom, String[] includeGlobs, Set<String> excludeClasses,
            String[] includeFileGlobs); void analyze();  }