I'm writing a compiler that generates Jasmin code and want to create an array declaration as follows:
string[] name = { "asd", "asd" };
This currently generates the following code:
ldc 2 ; array size
newarray char ; create new array of chars
astore 8 ; store array at loc 8
ldc "asd" ; push value 1 onto stack
ldc 0 ; push index onto stack
aload 8 ; push array reference onto stack
aastore ; store value in array at index
ldc "asd" ; push value 2 onto stack
ldc 1 ; push index onto stack
aload 8 ; push array reference onto stack
aastore ; store value in array at index
I thought this was the correct way, but I'm getting the following error:
java.lang.VerifyError: (class: helloworld, method: main signature: ([Ljava/lang/String;)V) Expecting to find array of objects or arrays on stack
Am I pushing things onto the stack in the wrong order? Or should I use a different type than char at the newarray line. If so, What's the correct type to use for Strings?