Remove duplicate Jack file warning
Replaced by assertions.
The warning isn't needed since Jill doesn't handle resources anymore.
Change-Id: Ice8bb4088ee2ec10fa8de507f72ce57280e70b01
diff --git a/jill/src/com/android/jill/frontend/java/DuplicateJackFileException.java b/jill/src/com/android/jill/frontend/java/DuplicateJackFileException.java
deleted file mode 100644
index 55239a2..0000000
--- a/jill/src/com/android/jill/frontend/java/DuplicateJackFileException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.jill.frontend.java;
-
-import javax.annotation.Nonnull;
-
-/**
- * Thrown when there are 2 Jack files with the same path.
- */
-public class DuplicateJackFileException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public DuplicateJackFileException() {
- super();
- }
-
- public DuplicateJackFileException(@Nonnull String message) {
- super(message);
- }
-}
diff --git a/jill/src/com/android/jill/frontend/java/JavaTransformer.java b/jill/src/com/android/jill/frontend/java/JavaTransformer.java
index ad6a6f0..dbadb87 100644
--- a/jill/src/com/android/jill/frontend/java/JavaTransformer.java
+++ b/jill/src/com/android/jill/frontend/java/JavaTransformer.java
@@ -119,8 +119,6 @@
FileInputStream fis = new FileInputStream(fileToTransform);
try {
transformToZip(fis, zos, null);
- } catch (DuplicateJackFileException e) {
- System.err.println(e.getMessage());
} finally {
fis.close();
}
@@ -130,8 +128,6 @@
FileInputStream fis = new FileInputStream(fileToTransform);
try {
transformToDir(fis, options.getOutput());
- } catch (DuplicateJackFileException e) {
- System.err.println(e.getMessage());
} finally {
fis.close();
}
@@ -224,16 +220,12 @@
JarEntry fileEntry = jarFile.getJarEntry(name);
if (!fileEntry.isDirectory()) {
InputStream is = jarFile.getInputStream(fileEntry);
- try {
- if (zos != null) {
- assert options.getOutputContainer() == ContainerType.ZIP;
- transformToZip(is, zos, jarFile);
- } else {
- assert options.getOutputContainer() == ContainerType.DIR;
- transformToDir(is, options.getOutput());
- }
- } catch (DuplicateJackFileException e) {
- System.err.println(e.getMessage());
+ if (zos != null) {
+ assert options.getOutputContainer() == ContainerType.ZIP;
+ transformToZip(is, zos, jarFile);
+ } else {
+ assert options.getOutputContainer() == ContainerType.DIR;
+ transformToDir(is, options.getOutput());
}
}
}
@@ -241,14 +233,10 @@
}
private void transformToZip(@Nonnull InputStream is, @Nonnull ZipOutputStream zipOutputStream,
- @CheckForNull JarFile jarFile) throws IOException, DuplicateJackFileException {
+ @CheckForNull JarFile jarFile) throws IOException {
ClassNode cn = getClassNode(is);
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.getOutput()
- + "' and thus won't be retransformed from class file.");
- }
+ assert (jarFile == null || jarFile.getEntry(filePath) == null);
try {
ZipEntry entry = new ZipEntry(filePath);
zipOutputStream.putNextEntry(entry);
@@ -259,15 +247,12 @@
}
private void transformToDir(@Nonnull InputStream is, @Nonnull File outputDir)
- throws IOException, DuplicateJackFileException {
+ throws IOException {
ClassNode cn = getClassNode(is);
String filePath = getFilePath(cn.name);
File outputFile = new File(outputDir, filePath);
- if (outputFile.exists()) {
- throw new DuplicateJackFileException("Jack file '" + outputFile.getAbsolutePath()
- + "' was already copied as a resource and thus won't be retransformed from class file.");
- }
+ assert !outputFile.exists();
FileOutputStream fos = null;
try {
createParentDirectories(outputFile);