summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-10-07 01:22:17 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-07 01:22:17 +0000
commit3f75a9a0341599c228592895fe49527964b52dbf (patch)
treeaf6ed5e41a0af83f2be013a9fa630d79e2664717
parente5a9f9d066a7464a9d25d679c101c60fee03459a (diff)
parent3b2fe7eb9cab88d3957794cb0f14ddc10a57dc29 (diff)
downloadandroid_development-3f75a9a0341599c228592895fe49527964b52dbf.tar.gz
android_development-3f75a9a0341599c228592895fe49527964b52dbf.tar.bz2
android_development-3f75a9a0341599c228592895fe49527964b52dbf.zip
am 3b2fe7eb: Merge "Bug 17782530: Annotations using retention policy source remain in .class" into lmp-dev
* commit '3b2fe7eb9cab88d3957794cb0f14ddc10a57dc29': Bug 17782530: Annotations using retention policy source remain in .class
-rw-r--r--tools/rmtypedefs/src/com/android/tools/rmtypedefs/RmTypeDefs.java2
-rw-r--r--tools/rmtypedefs/test/com/android/tools/rmtypedefs/RmTypeDefsTest.java32
2 files changed, 32 insertions, 2 deletions
diff --git a/tools/rmtypedefs/src/com/android/tools/rmtypedefs/RmTypeDefs.java b/tools/rmtypedefs/src/com/android/tools/rmtypedefs/RmTypeDefs.java
index df7294195..ab6d1f7d1 100644
--- a/tools/rmtypedefs/src/com/android/tools/rmtypedefs/RmTypeDefs.java
+++ b/tools/rmtypedefs/src/com/android/tools/rmtypedefs/RmTypeDefs.java
@@ -183,7 +183,7 @@ public class RmTypeDefs {
assert parentFile != null : file;
File container = new File(parentFile, fileName.substring(0, index) + ".class");
if (container.exists()) {
- mAnnotationOuterClassFiles.add(file);
+ mAnnotationOuterClassFiles.add(container);
} else {
System.err.println("Warning: Could not find outer class " + container
+ " for typedef " + file);
diff --git a/tools/rmtypedefs/test/com/android/tools/rmtypedefs/RmTypeDefsTest.java b/tools/rmtypedefs/test/com/android/tools/rmtypedefs/RmTypeDefsTest.java
index 37a24ea5f..423d22b54 100644
--- a/tools/rmtypedefs/test/com/android/tools/rmtypedefs/RmTypeDefsTest.java
+++ b/tools/rmtypedefs/test/com/android/tools/rmtypedefs/RmTypeDefsTest.java
@@ -16,6 +16,9 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import static com.google.common.base.Charsets.UTF_8;
+import static java.io.File.separatorChar;
+
@SuppressWarnings("SpellCheckingInspection")
public class RmTypeDefsTest extends TestCase {
public void test() throws IOException {
@@ -169,10 +172,37 @@ public class RmTypeDefsTest extends TestCase {
+ " testDir/test/pkg/TestClass.java\n",
getDirectoryContents(dir));
+ // Make sure the Visibility symbol is completely gone from the outer class
+ assertDoesNotContainBytes(new File(dir,
+ "test/pkg/TestClass$StaticInnerClass.class".replace('/', separatorChar)),
+ "Visibility");
deleteDir(dir);
}
+ private void assertDoesNotContainBytes(File file, String sub) throws IOException {
+ byte[] contents = Files.toByteArray(file);
+ // Like the strings command, look for 4 or more consecutive printable characters
+ for (int i = 0, n = contents.length; i < n; i++) {
+ if (Character.isJavaIdentifierStart(contents[i])) {
+ for (int j = i + 1; j < n; j++) {
+ if (!Character.isJavaIdentifierPart(contents[j])) {
+ if (j > i + 4) {
+ int length = j - i - 1;
+ if (length == sub.length()) {
+ String symbol = new String(contents, i, length, UTF_8);
+ assertFalse("Found " + sub + " in class file " + file,
+ sub.equals(symbol));
+ }
+ }
+ i = j;
+ break;
+ }
+ }
+ }
+ }
+ }
+
String getDirectoryContents(File root) {
StringBuilder sb = new StringBuilder();
list(sb, root, "", 0, "testDir");
@@ -251,4 +281,4 @@ public class RmTypeDefsTest extends TestCase {
return mStatus;
}
}
-} \ No newline at end of file
+}