for (intj=0; j < jarEntries.size(); j++){ Object[] array = (Object[]) jarEntries.get(j); JarEntryentry= (JarEntry) array[0]; Stringname= entry.getName(); // make sure the directory entries are written to the jar file if (!entry.isDirectory()){ intindex=0; while ((index = name.indexOf("/", index + 1))>= 0){ Stringdirectory= name.substring(0, index+1); if (!directoriesWritten.contains(directory)){ directoriesWritten.add(directory); outJar.addDirectory(directory); } } } // write the entry itself outJar.addFile(entry.getName(), (byte[]) array[1]); }
if (inName.endsWith(CLASS_EXT)) { if (fileFilter == null || fileFilter.accepts(inName)){ // Write the obfuscated version of the class to the output Jar ClassFilecf= ClassFile.create(inStream); fireObfuscatingClass(Conversion.toJavaClass(cf.getName())); cf.remap(classTree, replaceClassNameStrings, log); StringoutName= createClassFileName(inName, cf) + CLASS_EXT; JarEntryoutEntry=newJarEntry(outName);
DataOutputStream classOutputStream; if (digestStrings == null){ digestStrings = newString[]{"SHA-1", "MD5"}; } MessageDigest[] digests = newMessageDigest[digestStrings.length]; // Create an OutputStream piped through a number of digest generators for the manifest classOutputStream = fillDigests(baos, digestStrings, digests);
// Dump the classfile, while creating the digests cf.write(classOutputStream); classOutputStream.flush(); Object[] entry = {outEntry, baos.toByteArray()}; jarEntries.add(entry); baos.reset(); // Now update the manifest entry for the class with new name and new digests updateManifest(i, inName, outName, digests); } }