summaryrefslogtreecommitdiffstats
path: root/jill
diff options
context:
space:
mode:
authormikaelpeltier <mikaelpeltier@google.com>2015-03-04 11:48:56 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-03-04 11:48:56 +0000
commita8fa1311f2e251b484d6fdbbdf20c8f6447d171c (patch)
tree4172a6af1afce53669574bfaf99255e146f257ee /jill
parenta8d2a1be50845fe9e0586662e015928d3e2ca68c (diff)
parent15cf518caaae85c93d9eaad87699b9c88730f0b5 (diff)
downloadtoolchain_jill-a8fa1311f2e251b484d6fdbbdf20c8f6447d171c.zip
toolchain_jill-a8fa1311f2e251b484d6fdbbdf20c8f6447d171c.tar.gz
toolchain_jill-a8fa1311f2e251b484d6fdbbdf20c8f6447d171c.tar.bz2
Merge "Update and modified Jill API" into ub-jack
Diffstat (limited to 'jill')
-rw-r--r--jill/src/com/android/jill/Options.java36
-rw-r--r--jill/src/com/android/jill/frontend/java/JavaTransformer.java22
-rw-r--r--jill/tests/com/android/jill/Core.java6
3 files changed, 35 insertions, 29 deletions
diff --git a/jill/src/com/android/jill/Options.java b/jill/src/com/android/jill/Options.java
index 7b41c57..2b0afac 100644
--- a/jill/src/com/android/jill/Options.java
+++ b/jill/src/com/android/jill/Options.java
@@ -48,12 +48,12 @@ public class Options {
@CheckForNull
@Option(name = "--output", usage = "output file", metaVar = "FILE")
- protected File outputDirOrZip;
+ protected File output;
@Option(name = "--version", usage = "display version")
protected boolean version;
- protected ContainerType container = ContainerType.ZIP;
+ private final ContainerType outputContainer = ContainerType.ZIP;
@Option(name = "--no-debug", usage = "disable debug info emission")
protected boolean disableEmitDebugInfo = false;
@@ -68,8 +68,8 @@ public class Options {
} else {
throw new IllegalOptionsException("Input file not provided");
}
- if (outputDirOrZip != null) {
- if (container == ContainerType.DIR) {
+ if (output != null) {
+ if (outputContainer == ContainerType.DIR) {
checkOutputDir();
}
} else {
@@ -81,10 +81,14 @@ public class Options {
this.binaryFile = binaryFile;
}
+ public void setOutput(@Nonnull File output) {
+ this.output = output;
+ }
+
@Nonnull
- public File getOutputDir() {
- assert outputDirOrZip != null;
- return outputDirOrZip;
+ public File getOutput() {
+ assert output != null;
+ return output;
}
@Nonnull
@@ -113,9 +117,13 @@ public class Options {
return !disableEmitDebugInfo;
}
+ public void setEmitDebugInfo(boolean emitDebugInfo) {
+ disableEmitDebugInfo = !emitDebugInfo;
+ }
+
@Nonnull
- public ContainerType getContainer() {
- return container;
+ public ContainerType getOutputContainer() {
+ return outputContainer;
}
private void checkBinaryFileValidity() throws IllegalOptionsException {
@@ -143,15 +151,15 @@ public class Options {
}
private void checkOutputDir() throws IllegalOptionsException {
- assert outputDirOrZip != null;
+ assert output != null;
- if (!outputDirOrZip.exists()) {
- throw new IllegalOptionsException(outputDirOrZip.getName() + " does not exist.");
+ if (!output.exists()) {
+ throw new IllegalOptionsException(output.getName() + " does not exist.");
}
- if (!outputDirOrZip.canRead() || !outputDirOrZip.canWrite()) {
+ if (!output.canRead() || !output.canWrite()) {
throw new IllegalOptionsException("The specified output folder '"
- + outputDirOrZip.getAbsolutePath()
+ + output.getAbsolutePath()
+ "' for jack files cannot be written to or read from.");
}
}
diff --git a/jill/src/com/android/jill/frontend/java/JavaTransformer.java b/jill/src/com/android/jill/frontend/java/JavaTransformer.java
index 93fe27e..ad6a6f0 100644
--- a/jill/src/com/android/jill/frontend/java/JavaTransformer.java
+++ b/jill/src/com/android/jill/frontend/java/JavaTransformer.java
@@ -113,8 +113,8 @@ public class JavaTransformer {
public void transform(@Nonnull List<File> javaBinaryFiles) {
ZipOutputStream zos = null;
try {
- if (options.getContainer() == ContainerType.ZIP) {
- zos = new ZipOutputStream(new FileOutputStream(options.getOutputDir()));
+ if (options.getOutputContainer() == ContainerType.ZIP) {
+ zos = new ZipOutputStream(new FileOutputStream(options.getOutput()));
for (File fileToTransform : javaBinaryFiles) {
FileInputStream fis = new FileInputStream(fileToTransform);
try {
@@ -129,7 +129,7 @@ public class JavaTransformer {
for (File fileToTransform : javaBinaryFiles) {
FileInputStream fis = new FileInputStream(fileToTransform);
try {
- transformToDir(fis, options.getOutputDir());
+ transformToDir(fis, options.getOutput());
} catch (DuplicateJackFileException e) {
System.err.println(e.getMessage());
} finally {
@@ -154,8 +154,8 @@ public class JavaTransformer {
public void transform(@Nonnull JarFile jarFile) {
ZipOutputStream zos = null;
try {
- if (options.getContainer() == ContainerType.ZIP) {
- zos = new ZipOutputStream(new FileOutputStream(options.getOutputDir()));
+ if (options.getOutputContainer() == ContainerType.ZIP) {
+ zos = new ZipOutputStream(new FileOutputStream(options.getOutput()));
}
transformJavaFiles(jarFile, zos);
dumpJackLibraryProperties(zos);
@@ -176,7 +176,7 @@ public class JavaTransformer {
if (zos != null) {
dumpPropertiesToZip(zos, jackLibraryProperties);
} else {
- dumpPropertiesToFile(new File(options.getOutputDir(), JACK_LIBRARY_PROPERTIES),
+ dumpPropertiesToFile(new File(options.getOutput(), JACK_LIBRARY_PROPERTIES),
jackLibraryProperties);
}
}
@@ -194,7 +194,7 @@ public class JavaTransformer {
private void dumpPropertiesToFile(@Nonnull File outputFile,
@Nonnull Properties libraryProperties) {
- File outputDir = options.getOutputDir();
+ File outputDir = options.getOutput();
File libraryPropertiesFile = new File(outputDir, JACK_LIBRARY_PROPERTIES);
FileOutputStream fos = null;
try {
@@ -226,11 +226,11 @@ public class JavaTransformer {
InputStream is = jarFile.getInputStream(fileEntry);
try {
if (zos != null) {
- assert options.getContainer() == ContainerType.ZIP;
+ assert options.getOutputContainer() == ContainerType.ZIP;
transformToZip(is, zos, jarFile);
} else {
- assert options.getContainer() == ContainerType.DIR;
- transformToDir(is, options.getOutputDir());
+ assert options.getOutputContainer() == ContainerType.DIR;
+ transformToDir(is, options.getOutput());
}
} catch (DuplicateJackFileException e) {
System.err.println(e.getMessage());
@@ -246,7 +246,7 @@ public class JavaTransformer {
String filePath = getFilePath(cn.name);
if (jarFile != null && jarFile.getEntry(filePath) != null) {
throw new DuplicateJackFileException("Jack file '" + filePath
- + "' was already copied as a resource to archive '" + options.getOutputDir()
+ + "' was already copied as a resource to archive '" + options.getOutput()
+ "' and thus won't be retransformed from class file.");
}
try {
diff --git a/jill/tests/com/android/jill/Core.java b/jill/tests/com/android/jill/Core.java
index af433ec..2c00fec 100644
--- a/jill/tests/com/android/jill/Core.java
+++ b/jill/tests/com/android/jill/Core.java
@@ -39,8 +39,7 @@ public class Core {
options.setBinaryFile(new File(TestsProperties.getAndroidRootDir().getPath()
+ "/out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar"));
options.setVerbose(true);
- options.container = ContainerType.DIR;
- options.outputDirOrZip = AbstractTestTools.createTempDir();
+ options.output = AbstractTestTools.createTempFile("jillTest", ".zip");
new Jill(options, "0.1").process(options.getBinaryFile());
}
@@ -50,8 +49,7 @@ public class Core {
options.setBinaryFile(new File(TestsProperties.getAndroidRootDir().getPath()
+ "/out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes/"));
options.setVerbose(true);
- options.container = ContainerType.DIR;
- options.outputDirOrZip = AbstractTestTools.createTempDir();
+ options.output = AbstractTestTools.createTempFile("jillTest", ".zip");
new Jill(options, "0.1").process(options.getBinaryFile());
}
}