diff options
Diffstat (limited to 'jill')
-rw-r--r-- | jill/Android.mk | 5 | ||||
-rw-r--r-- | jill/src/com/android/jill/backend/jayce/JayceWriter.java | 5 | ||||
-rw-r--r-- | jill/src/com/android/jill/backend/jayce/Token.java | 2 | ||||
-rw-r--r-- | jill/src/com/android/jill/frontend/java/JavaTransformer.java | 112 |
4 files changed, 29 insertions, 95 deletions
diff --git a/jill/Android.mk b/jill/Android.mk index 0e7fc96..1c0065e 100644 --- a/jill/Android.mk +++ b/jill/Android.mk @@ -32,8 +32,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ args4j-jack \ schedlib -LOCAL_JAVA_RESOURCE_FILES := $(intermediates)/rsc/jill.properties - include $(BUILD_HOST_JAVA_LIBRARY) # Include this library in the build server's output directory @@ -57,7 +55,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ args4j-jack \ schedlib -LOCAL_JAVA_RESOURCE_FILES := $(intermediates)/rsc/jill.properties LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt include $(BUILD_HOST_JAVA_LIBRARY) @@ -99,7 +96,7 @@ include $(BUILD_HOST_JAVA_LIBRARY) LIB_JILL_UNIT_TESTS := $(LOCAL_BUILT_MODULE) -local_unit_libs := $(call java-lib-files,core-hostdex junit4-hostdex-jack,true) +local_unit_libs := $(call java-lib-files,core-libart-hostdex junit4-hostdex-jack,true) .PHONY: test-jill test-jill-unit: PRIVATE_RUN_TESTS := ./run-jill-unit-tests diff --git a/jill/src/com/android/jill/backend/jayce/JayceWriter.java b/jill/src/com/android/jill/backend/jayce/JayceWriter.java index f40f8db..07e418b 100644 --- a/jill/src/com/android/jill/backend/jayce/JayceWriter.java +++ b/jill/src/com/android/jill/backend/jayce/JayceWriter.java @@ -220,11 +220,6 @@ public class JayceWriter { writeStringInternal(id); } - public void writeHeader(@Nonnull String header) throws IOException { - writers.peek().writeBytes(header); - writeSpace(); - } - private void writeStringInternal(@CheckForNull String string) throws IOException { writers.peek().writeUTF(string); } diff --git a/jill/src/com/android/jill/backend/jayce/Token.java b/jill/src/com/android/jill/backend/jayce/Token.java index 7d6b4a8..e7c8f2f 100644 --- a/jill/src/com/android/jill/backend/jayce/Token.java +++ b/jill/src/com/android/jill/backend/jayce/Token.java @@ -134,7 +134,7 @@ public enum Token { PREFIX_INC_OPERATION("prefix-inc"), PREFIX_NEG_OPERATION("neg"), PREFIX_NOT_OPERATION("not"), - PROGRAM("program"), + RESERVED("reserved"), REINTERPRETCAST_OPERATION("reinterpret-cast"), RETURN_STATEMENT("return"), SHL_OPERATION("<<"), diff --git a/jill/src/com/android/jill/frontend/java/JavaTransformer.java b/jill/src/com/android/jill/frontend/java/JavaTransformer.java index 04b610b..d3bc6eb 100644 --- a/jill/src/com/android/jill/frontend/java/JavaTransformer.java +++ b/jill/src/com/android/jill/frontend/java/JavaTransformer.java @@ -48,16 +48,16 @@ import javax.annotation.Nonnull; public class JavaTransformer { @Nonnull - private static final String LIB_MAJOR_VERSION = "0"; + private static final String LIB_MAJOR_VERSION = "1"; @Nonnull - private static final String LIB_MINOR_VERSION = "0"; + private static final String LIB_MINOR_VERSION = "1"; @Nonnull private static final String JAYCE_MAJOR_VERSION = "2"; @Nonnull - private static final String JAYCE_MINOR_VERSION = "14"; + private static final String JAYCE_MINOR_VERSION = "15"; @Nonnull private static final String KEY_LIB_MAJOR_VERSION = "lib.version.major"; @@ -90,12 +90,24 @@ public class JavaTransformer { @Nonnull private static final String JAYCE_FILE_EXTENSION = ".jayce"; + + @Nonnull + private static final String JAYCE_PREFIX_INTO_LIB = "jayce"; + @Nonnull private static final char TYPE_NAME_SEPARATOR = '/'; + @Nonnull + private final Properties jackLibraryProperties; + public JavaTransformer(@Nonnull String version, @Nonnull Options options) { this.version = version; this.options = options; + jackLibraryProperties = new Properties(); + jackLibraryProperties.put(KEY_LIB_EMITTER, "jill"); + jackLibraryProperties.put(KEY_LIB_EMITTER_VERSION, version); + jackLibraryProperties.put(KEY_LIB_MAJOR_VERSION, LIB_MAJOR_VERSION); + jackLibraryProperties.put(KEY_LIB_MINOR_VERSION, LIB_MINOR_VERSION); } public void transform(@Nonnull List<File> javaBinaryFiles) { @@ -103,7 +115,6 @@ public class JavaTransformer { try { if (options.getContainer() == ContainerType.ZIP) { zos = new ZipOutputStream(new FileOutputStream(options.getOutputDir())); - dumpJackLibraryProperties(zos); for (File fileToTransform : javaBinaryFiles) { FileInputStream fis = new FileInputStream(fileToTransform); try { @@ -115,7 +126,6 @@ public class JavaTransformer { } } } else { - dumpJackLibraryProperties(zos); for (File fileToTransform : javaBinaryFiles) { FileInputStream fis = new FileInputStream(fileToTransform); try { @@ -127,6 +137,7 @@ public class JavaTransformer { } } } + dumpJackLibraryProperties(zos); } catch (IOException e) { throw new JillException("Transformation failure.", e); } finally { @@ -146,9 +157,8 @@ public class JavaTransformer { if (options.getContainer() == ContainerType.ZIP) { zos = new ZipOutputStream(new FileOutputStream(options.getOutputDir())); } - dumpJackLibraryProperties(zos); - copyResources(jarFile, zos); transformJavaFiles(jarFile, zos); + dumpJackLibraryProperties(zos); } catch (Exception e) { throw new JillException("Failed to transform " + jarFile.getName(), e); } finally { @@ -163,15 +173,6 @@ public class JavaTransformer { } private void dumpJackLibraryProperties(@CheckForNull ZipOutputStream zos) { - Properties jackLibraryProperties = new Properties(); - jackLibraryProperties.put(KEY_LIB_EMITTER, "jill"); - jackLibraryProperties.put(KEY_LIB_EMITTER_VERSION, version); - jackLibraryProperties.put(KEY_LIB_MAJOR_VERSION, LIB_MAJOR_VERSION); - jackLibraryProperties.put(KEY_LIB_MINOR_VERSION, LIB_MINOR_VERSION); - jackLibraryProperties.put(KEY_JAYCE, String.valueOf(true)); - jackLibraryProperties.put(KEY_JAYCE_MAJOR_VERSION, JAYCE_MAJOR_VERSION); - jackLibraryProperties.put(KEY_JAYCE_MINOR_VERSION, JAYCE_MINOR_VERSION); - if (zos != null) { dumpPropertiesToZip(zos, jackLibraryProperties); } else { @@ -239,68 +240,6 @@ public class JavaTransformer { } } - private void copyResources(@Nonnull JarFile jarFile, @CheckForNull ZipOutputStream zos) - throws IOException { - final Enumeration<JarEntry> entries = jarFile.entries(); - while (entries.hasMoreElements()) { - final JarEntry entry = entries.nextElement(); - String name = entry.getName(); - if (!FileUtils.isJavaBinaryFile(name) && !name.equals(JACK_LIBRARY_PROPERTIES)) { - JarEntry fileEntry = jarFile.getJarEntry(name); - if (!fileEntry.isDirectory()) { - InputStream is = jarFile.getInputStream(fileEntry); - if (zos != null) { - assert options.getContainer() == ContainerType.ZIP; - copyResourceToZip(is, zos, name); - } else { - assert options.getContainer() == ContainerType.DIR; - copyResourceToDir(is, options.getOutputDir(), name); - } - } - } - } - } - - private void copyResourceToZip(InputStream is, ZipOutputStream zipOutputStream, String name) { - try { - ZipEntry zipEntry = new ZipEntry(name); - zipOutputStream.putNextEntry(zipEntry); - copyResource(is, zipOutputStream, name); - } catch (Exception e) { - throw new JillException("Error writing resource " + name, e); - } - } - - private void copyResourceToDir(InputStream is, File outputDir, String name) { - OutputStream resourceOS = null; - try { - File outputFile = new File(outputDir, name); - createParentDirectories(outputFile); - resourceOS = new FileOutputStream(outputFile); - copyResource(is, resourceOS, name); - } catch (Exception e) { - throw new JillException("Error writing resource " + name, e); - } finally { - if (resourceOS != null) { - try { - resourceOS.close(); - } catch (IOException e) { - throw new JillException("Error closing output resource " + name, e); - } - } - } - } - - private void copyResource(InputStream is, OutputStream os, String name) throws IOException { - OutputStream resourceOS = null; - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = is.read(buffer)) >= 0) { - os.write(buffer, 0, bytesRead); - } - os.flush(); - } - private void transformToZip(@Nonnull InputStream is, @Nonnull ZipOutputStream zipOutputStream, @CheckForNull JarFile jarFile) throws IOException, DuplicateJackFileException { ClassNode cn = getClassNode(is); @@ -366,18 +305,16 @@ public class JavaTransformer { } } - private JayceWriter createWriter(@Nonnull OutputStream os) throws IOException { + private JayceWriter createWriter(@Nonnull OutputStream os) { JayceWriter writer = new JayceWriter(os); - - writer.writeHeader( - "jayce(" + JAYCE_MAJOR_VERSION + "." + JAYCE_MINOR_VERSION + " \"jill " + version + "\")"); - - return writer; + setJayceProperties(); + return writer; } @Nonnull private static String getFilePath(@Nonnull String typeBinaryName) { - return typeBinaryName.replace(TYPE_NAME_SEPARATOR, File.separatorChar) + JAYCE_FILE_EXTENSION; + return JAYCE_PREFIX_INTO_LIB + File.separatorChar + + typeBinaryName.replace(TYPE_NAME_SEPARATOR, File.separatorChar) + JAYCE_FILE_EXTENSION; } @Nonnull @@ -389,4 +326,9 @@ public class JavaTransformer { return cn; } + private void setJayceProperties() { + jackLibraryProperties.put(KEY_JAYCE, String.valueOf(true)); + jackLibraryProperties.put(KEY_JAYCE_MAJOR_VERSION, JAYCE_MAJOR_VERSION); + jackLibraryProperties.put(KEY_JAYCE_MINOR_VERSION, JAYCE_MINOR_VERSION); + } } |