@Override public void analyze(final File _file) throws FileAnalysisException { try { this.jar = new JarFile(_file, false, java.util.zip.ZipFile.OPEN_READ); this.jarWriter = new JarWriter(_file.toPath()); this.url = _file.getAbsolutePath().toString(); } 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); } }
/** * Called during the construction in order to have some classes frozen. * @return */ private final void freezeClasses() { try { final JavaMethodId jmi = JavaId.parseMethodQName("com.sap.Test.test()"); final ConstructUsage cu = new ConstructUsage(jmi, null, -1); final Loader l = new Loader(this.getClass().getClassLoader()); final Configuration cfg = VulasConfiguration.getGlobal().getConfiguration(); ConstructIdUtil.getInstance(); final JarWriter jw = new JarWriter(Paths.get(DynamicTransformer.class.getClassLoader().getResource(DynamicTransformer.class.getName().replace('.', '/') + ".class").toString())); final JarAnalyzer ja = new JarAnalyzer(); ja.analyze(Paths.get(DynamicTransformer.class.getClassLoader().getResource(DynamicTransformer.class.getName().replace('.', '/') + ".class").toString()).toFile()); } // Getting an exception does not matter in the context of freezing some classes catch(Exception e) {;} }
try { final JarWriter jw = new JarWriter(_to_append);
for(Path lib: libs) { try { writer = new JarWriter(lib); if(writer.hasEntry("vulas-core.properties") && !writer.isRewrittenByVulas()) {