Commit 3b35839a authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Add test for bug 28833829.

There doesn't appear to be a way to get smali to generate these
files so they were generated "by hand" by editing the dex-file
and changing its checksum.

bug: 28833829
Change-Id: I9daca7a02ee90bac5ae1bd5460175d7732bb290f
parent bc247509
......@@ -15,8 +15,15 @@
*/
package libcore.java.lang;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import junit.framework.TestCase;
import dalvik.system.PathClassLoader;
public class ClassTest extends TestCase {
interface Foo {
......@@ -51,6 +58,32 @@ public class ClassTest extends TestCase {
assertSame(Object.class, (new Integer[0]).getClass().getGenericSuperclass());
}
public void test_b28833829() throws Exception {
File f = File.createTempFile("temp_b28833829", ".dex");
try (InputStream is =
getClass().getClassLoader().getResourceAsStream("TestBug28833829.dex");
OutputStream os = new FileOutputStream(f)) {
byte[] buffer = new byte[8192];
int bytesRead = 0;
while ((bytesRead = is.read(buffer)) >= 0) {
os.write(buffer, 0, bytesRead);
}
}
PathClassLoader pcl = new PathClassLoader(f.getAbsolutePath(), null);
Class<?> cl = pcl.loadClass(
"libcore.java.lang.TestBadInnerClass_Outer$ClassTestBadInnerClass_InnerClass");
// Note that getName() and getSimpleName() are inconsistent here because for
// inner classes, the latter is fetched directly from the InnerClass
// annotation in the dex file. We do not perform any sort of consistency
// checks with the class name or the enclosing class name. Unfortunately, applications
// have come to rely on this behaviour.
assertEquals("libcore.java.lang.TestBadInnerClass_Outer$ClassTestBadInnerClass_InnerClass",
cl.getName());
assertEquals("TestBadInnerClass_InnerXXXXX", cl.getSimpleName());
}
interface A {
public static String name = "A";
}
......
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment