Skip to content

Commit 56c38bb

Browse files
committed
improvements for getComponentType()
1 parent a0d56dd commit 56c38bb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/de/inetsoftware/jwebassembly/module/TypeManager.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,22 @@ public class TypeManager {
6969
static final int TYPE_DESCRIPTION_INSTANCEOF_OFFSET = 4;
7070

7171
/**
72-
* Byte position in the type description that contains the offset to class name idx. Length 4 bytes.
72+
* Byte position in the type description that contains the offset to class name idx in the string constant table. Length 4 bytes.
7373
*/
7474
static final int TYPE_DESCRIPTION_TYPE_NAME = 8;
7575

76+
/**
77+
* Byte position in the type description that contains the type of the array (component type). Length 4 bytes.
78+
*/
79+
static final int TYPE_DESCRIPTION_ARRAY_TYPE = 12;
80+
7681
/**
7782
* The reserved position on start of the vtable:
7883
* <li>offset of interface call table (itable)
7984
* <li>offset of instanceof list
85+
* <li>offset of class name idx in the string constant table
8086
*/
81-
private static final int VTABLE_FIRST_FUNCTION_INDEX = 3;
87+
private static final int VTABLE_FIRST_FUNCTION_INDEX = 4;
8288

8389
private static final FunctionName CLASS_CONSTANT_FUNCTION = new FunctionName( "java/lang/Class.classConstant(I)Ljava/lang/Class;" );
8490

@@ -833,6 +839,9 @@ public void writeToStream( ByteArrayOutputStream dataStream, ToIntFunction<Funct
833839
// header position TYPE_DESCRIPTION_TYPE_NAME
834840
header.writeInt32( classNameIdx ); // string id of the className
835841

842+
// header position TYPE_DESCRIPTION_ARRAY_TYPE
843+
header.writeInt32( -1 );
844+
836845
data.writeTo( dataStream );
837846
}
838847

0 commit comments

Comments
 (0)