AarAnalyzer extends JarAnalyzer { @Override public synchronized void analyze(final File _file) throws FileAnalysisException { try { this.aarWriter = new JarWriter(_file.toPath()); this.url = _file.getAbsolutePath().toString(); try { this.tmpDir = java.nio.file.Files.createTempDirectory("aar_analysis_"); } catch (IOException e) { throw new IllegalStateException("Unable to create temp directory", e); } this.aarWriter.extract(this.tmpDir); final File classes_jar = this.tmpDir.resolve(CLASSES_JAR).toFile(); if (classes_jar != null && FileUtil.isAccessibleFile(classes_jar.toPath())) { JarAnalyzer.insertClasspath(classes_jar.toPath().toAbsolutePath().toString()); this.jar = new JarFile(classes_jar, false, java.util.zip.ZipFile.OPEN_READ); this.jarWriter = new JarWriter(classes_jar.toPath()); } else { log.warn("No " + CLASSES_JAR + " found in [" + _file.toPath().toAbsolutePath() + "]"); } } catch (IllegalStateException e) { log.error("IllegalStateException when analyzing file [" + _file + "]: " + e.getMessage()); throw new FileAnalysisException( "Error when analyzing file [" + _file + "]: " + e.getMessage(), e); } catch (IOException e) { log.error("IOException when analyzing file [" + _file + "]: " + e.getMessage()); throw new FileAnalysisException( "Error when analyzing file [" + _file + "]: " + e.getMessage(), e); } catch (Exception e) { log.error("Exception when analyzing file [" + _file + "]: " + e.getMessage()); throw new FileAnalysisException( "Error when analyzing file [" + _file + "]: " + e.getMessage(), e); } }  @Override String[] getSupportedFileExtensions(); @Override synchronized void analyze(final File _file); @Override synchronized String getSHA1(); String getFileName();  }
@Test public void testAarAnalyzer() { try { final AarAnalyzer aa = new AarAnalyzer(); aa.analyze(new File("./src/test/resources/cucumber-android-4.3.0.aar")); final Set<ConstructId> cids = aa.getConstructIds(); assertTrue(!cids.isEmpty()); } catch (FileAnalysisException e) { e.printStackTrace(); assertTrue(false); } }