summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDelphine Martin <delphinemartin@google.com>2015-10-20 15:46:51 +0200
committerDelphine Martin <delphinemartin@google.com>2015-10-22 12:38:57 +0200
commite9fecadd2f29bfe08578ed7b08ad0258889b70c3 (patch)
tree2849238f1509ce410f17acd4581ce3674ec4754a
parent55da27095daf538e77003c7a7b25af1cd34430e0 (diff)
downloadtoolchain_jack-e9fecadd2f29bfe08578ed7b08ad0258889b70c3.zip
toolchain_jack-e9fecadd2f29bfe08578ed7b08ad0258889b70c3.tar.gz
toolchain_jack-e9fecadd2f29bfe08578ed7b08ad0258889b70c3.tar.bz2
Allow to obfuscate a library with a mapping.
It is now possible to add a non-obfuscated library to the classpath and to obfuscate it with a mapping. + test using StringAdaptation Bug: 25128774 Change-Id: Ica0c9fed8b70358081799109e9d07ac4b96fc30d
-rw-r--r--jack-tests/tests/com/android/jack/shrob/ShrobRuntimeTests.java12
-rw-r--r--jack-tests/tests/com/android/jack/shrob/test048/dx/Tests.java29
-rw-r--r--jack-tests/tests/com/android/jack/shrob/test048/info.txt2
-rw-r--r--jack-tests/tests/com/android/jack/shrob/test048/jack/Test.java23
-rw-r--r--jack-tests/tests/com/android/jack/shrob/test048/lib/Library.java22
-rw-r--r--jack-tests/tests/com/android/jack/shrob/test048/mapping.txt1
-rw-r--r--jack-tests/tests/com/android/jack/shrob/test048/proguard.flags0016
-rw-r--r--jack/src/com/android/jack/shrob/obfuscation/MappingApplier.java2
8 files changed, 96 insertions, 1 deletions
diff --git a/jack-tests/tests/com/android/jack/shrob/ShrobRuntimeTests.java b/jack-tests/tests/com/android/jack/shrob/ShrobRuntimeTests.java
index 253ece3..74fd204 100644
--- a/jack-tests/tests/com/android/jack/shrob/ShrobRuntimeTests.java
+++ b/jack-tests/tests/com/android/jack/shrob/ShrobRuntimeTests.java
@@ -49,6 +49,13 @@ public class ShrobRuntimeTests extends RuntimeTest {
"com.android.jack.shrob.test030.dx.Tests").addProguardFlagsFileName("proguard.flags001")
.addProguardFlagsFileName("../dontobfuscate.flags");
+ private RuntimeTestInfo TEST048 =
+ new RuntimeTestInfo(
+ AbstractTestTools.getTestRootDir("com.android.jack.shrob.test048"),
+ "com.android.jack.shrob.test048.dx.Tests")
+ .addProguardFlagsFileName("proguard.flags001")
+ .setLibDirName("lib");
+
@Test
public void test011_1() throws Exception {
new RuntimeTestHelper(TEST011_1)
@@ -83,4 +90,9 @@ public class ShrobRuntimeTests extends RuntimeTest {
protected void fillRtTestInfos() {
}
+ @Test
+ public void test048() throws Exception {
+ new RuntimeTestHelper(TEST048)
+ .compileAndRunTest();
+ }
}
diff --git a/jack-tests/tests/com/android/jack/shrob/test048/dx/Tests.java b/jack-tests/tests/com/android/jack/shrob/test048/dx/Tests.java
new file mode 100644
index 0000000..c7ffb45
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/shrob/test048/dx/Tests.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2015 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.jack.shrob.test048.dx;
+
+import com.android.jack.shrob.test048.jack.Test;
+
+import junit.framework.Assert;
+
+public class Tests {
+ @org.junit.Test
+ public void test() {
+ Assert.assertEquals("renamedLibrary", Test.testMethod());
+ }
+}
+
diff --git a/jack-tests/tests/com/android/jack/shrob/test048/info.txt b/jack-tests/tests/com/android/jack/shrob/test048/info.txt
new file mode 100644
index 0000000..e69bc88
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/shrob/test048/info.txt
@@ -0,0 +1,2 @@
+This tests uses a non-obuscated library and applies a mapping to it while
+compiling a test app. \ No newline at end of file
diff --git a/jack-tests/tests/com/android/jack/shrob/test048/jack/Test.java b/jack-tests/tests/com/android/jack/shrob/test048/jack/Test.java
new file mode 100644
index 0000000..160dd21
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/shrob/test048/jack/Test.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2015 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.jack.shrob.test048.jack;
+
+public class Test {
+ public static String testMethod() {
+ return "com.android.jack.shrob.test048.lib.Library";
+ }
+}
diff --git a/jack-tests/tests/com/android/jack/shrob/test048/lib/Library.java b/jack-tests/tests/com/android/jack/shrob/test048/lib/Library.java
new file mode 100644
index 0000000..51bddec
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/shrob/test048/lib/Library.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 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.jack.shrob.test048.lib;
+
+public class Library {
+
+}
+
diff --git a/jack-tests/tests/com/android/jack/shrob/test048/mapping.txt b/jack-tests/tests/com/android/jack/shrob/test048/mapping.txt
new file mode 100644
index 0000000..9be324b
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/shrob/test048/mapping.txt
@@ -0,0 +1 @@
+com.android.jack.shrob.test048.lib.Library -> renamedLibrary:
diff --git a/jack-tests/tests/com/android/jack/shrob/test048/proguard.flags001 b/jack-tests/tests/com/android/jack/shrob/test048/proguard.flags001
new file mode 100644
index 0000000..24f0192
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/shrob/test048/proguard.flags001
@@ -0,0 +1,6 @@
+-dontshrink
+-applymapping mapping.txt
+
+-keepclasseswithmembers public class * {
+ public static java.lang.String testMethod();
+} \ No newline at end of file
diff --git a/jack/src/com/android/jack/shrob/obfuscation/MappingApplier.java b/jack/src/com/android/jack/shrob/obfuscation/MappingApplier.java
index 30b1bca..2016660 100644
--- a/jack/src/com/android/jack/shrob/obfuscation/MappingApplier.java
+++ b/jack/src/com/android/jack/shrob/obfuscation/MappingApplier.java
@@ -106,7 +106,7 @@ public class MappingApplier {
try {
String typeSignature = NamingTools.getTypeSignatureName(oldName);
type = (JClassOrInterface) lookup.getType(typeSignature);
- if (!session.getTypesToEmit().contains(type)) {
+ if (!session.getTypesToEmit().contains(type) && !type.isExternal()) {
logger.log(Level.WARNING, "{0}:{1}: Type {2} has a mapping but was removed",
new Object[] {mappingFile.getPath(), Integer.valueOf(lineNumber), oldName});
return null;