implement Class.getComponentType(), WIP

This commit is contained in:
Volker Berlin 2020-05-31 11:39:57 +02:00
parent 3f89240a8b
commit 67f8fd4355
2 changed files with 16 additions and 0 deletions

View File

@ -173,6 +173,14 @@ class ReplacementForClass {
return null;
}
/**
* Replacement of the native Java methods getComponentType()
*/
ReplacementForClass getComponentType() {
int classIdx = getIntFromMemory( vtable + TypeManager.TYPE_DESCRIPTION_ARRAY_TYPE );
return classIdx >= 0 ? classConstant( classIdx ) : null;
}
/**
* Replacement of the native Java methods
*

View File

@ -63,6 +63,7 @@ public class StructsNonGC extends AbstractBaseTest {
addParam( list, script, "classClassName" );
addParam( list, script, "classConst" );
addParam( list, script, "intClassName" );
addParam( list, script, "getComponentType" );
addParam( list, script, "branchWithObjectResult" );
}
rule.setTestParameters( list );
@ -218,6 +219,13 @@ public class StructsNonGC extends AbstractBaseTest {
return JSObject.domString( clazz.getName() );
}
@Export
static boolean getComponentType() {
Class<?> clazz = byte.class;
clazz = clazz.getComponentType();
return clazz == null;
}
@Export
static int branchWithObjectResult() {
Integer val1 = 42;