Merge "Bug 17782530: Annotations using retention policy source remain in .class" into lmp-dev
This commit is contained in:
@@ -183,7 +183,7 @@ public class RmTypeDefs {
|
|||||||
assert parentFile != null : file;
|
assert parentFile != null : file;
|
||||||
File container = new File(parentFile, fileName.substring(0, index) + ".class");
|
File container = new File(parentFile, fileName.substring(0, index) + ".class");
|
||||||
if (container.exists()) {
|
if (container.exists()) {
|
||||||
mAnnotationOuterClassFiles.add(file);
|
mAnnotationOuterClassFiles.add(container);
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Warning: Could not find outer class " + container
|
System.err.println("Warning: Could not find outer class " + container
|
||||||
+ " for typedef " + file);
|
+ " for typedef " + file);
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.base.Charsets.UTF_8;
|
||||||
|
import static java.io.File.separatorChar;
|
||||||
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
public class RmTypeDefsTest extends TestCase {
|
public class RmTypeDefsTest extends TestCase {
|
||||||
public void test() throws IOException {
|
public void test() throws IOException {
|
||||||
@@ -169,10 +172,37 @@ public class RmTypeDefsTest extends TestCase {
|
|||||||
+ " testDir/test/pkg/TestClass.java\n",
|
+ " testDir/test/pkg/TestClass.java\n",
|
||||||
getDirectoryContents(dir));
|
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);
|
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) {
|
String getDirectoryContents(File root) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
list(sb, root, "", 0, "testDir");
|
list(sb, root, "", 0, "testDir");
|
||||||
|
|||||||
Reference in New Issue
Block a user