Parcelable: Support CharSequence, IBinder/IInterface, objects, enums. Serialize Parcelable efficiently if possible
This commit is contained in:
+6
-2
@@ -43,10 +43,14 @@ abstract class AbstractParcelBoxTest : CodegenTestCase() {
|
||||
open protected fun getClassLoaderWithGeneratedFiles(): ClassLoader {
|
||||
return object : URLClassLoader(arrayOf(), this::class.java.classLoader) {
|
||||
init {
|
||||
for (classFile in classFileFactory.getClassFiles()) {
|
||||
for (classFile in classFileFactory.getClassFiles().sortedBy { it.relativePath }) {
|
||||
val bytes = classFile.asByteArray()
|
||||
val className = ClassNode().also { ClassReader(bytes).accept(it, ClassReader.EXPAND_FRAMES) }.name
|
||||
defineClass(className.replace('/', '.'), ByteBuffer.wrap(bytes), null as ProtectionDomain?)
|
||||
try {
|
||||
defineClass(className.replace('/', '.'), ByteBuffer.wrap(bytes), null as ProtectionDomain?)
|
||||
} catch (e: Throwable) {
|
||||
throw RuntimeException("Can't load class $className", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.android.parcel
|
||||
|
||||
import android.os.Bundle
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
@@ -43,4 +42,8 @@ class ParcelBoxTest : AbstractParcelBoxTest() {
|
||||
@Test fun bundle() = doTest("bundle")
|
||||
@Test fun sparseArrays() = doTest("sparseArrays")
|
||||
@Test fun customSimple() = doTest("customSimple")
|
||||
@Test fun charSequence() = doTest("charSequence")
|
||||
@Test fun enums() = doTest("enums")
|
||||
@Test fun objects() = doTest("objects")
|
||||
@Test fun nestedParcelable() = doTest("nestedParcelable")
|
||||
}
|
||||
+6
@@ -60,6 +60,12 @@ public class ParcelBytecodeListingTestGenerated extends AbstractParcelBytecodeLi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IBinderIInterface.kt")
|
||||
public void testIBinderIInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/IBinderIInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("listInsideList.kt")
|
||||
public void testListInsideList() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/android-extensions/android-extensions-compiler/testData/parcel/codegen/listInsideList.kt");
|
||||
|
||||
Reference in New Issue
Block a user