简体   繁体   中英

Java Bytecode compilation “Syntax error at line, instruction”

I am using the program JBE (Java Bytecode Editor) http://set.ee/jbe . I am trying compile bytecode to .class file but it keeps outputting errors due to (although I'm don't change anything)

Error: Syntax error at line 3088, instruction "wide"
Error: Syntax error at line 3090, instruction "wide"
Error: Syntax error at line 3096, instruction "wide"

This is part of the original:

new os
dup
sipush 399
bipush 42
invokespecial os/<init>(II)V
astore 255
ldc "center_tile_s"
invokestatic nz/cX(Ljava/lang/String;)Lor;
wide
astore 256
wide
aload 256
ldc 0.85
invokevirtual oi/j(F)V
aload 255
ldc "layer_591"
wide
aload 256
invokevirtual os/b(Ljava/lang/String;Loi;)V
ldc "center_tile_s"
invokestatic nz/cX(Ljava/lang/String;)Lor;
wide
astore 257
wide
aload 257
ldc 0.85
invokevirtual oi/j(F)V
wide
aload 257
iconst_0
bipush 20
invokevirtual oi/p(II)V
aload 255
ldc "layer_592"
wide
aload 257
invokevirtual os/b(Ljava/lang/String;Loi;)V

I am not familiar with JBE, but I suspect the problem is that the wide instructions are split over two lines.

Most Java bytecode assemblers expect it to be on a single line, eg wide astore 256 , because the two halves are part of the same instruction for all intents and purposes, and the encoding of the second part depends on whether it is wide or not.

If that is the case, and JBE is not outputting wide instruction in the format it itself expects, then this is a bug with JBE and you should report it.

On a side note, you may want to switch to editing bytecode with the Krakatau assembler/disassembler since it supports every known or documented classfile feature and the assembler has more helpful error messages. (Disclosure: I am the author of Krakatau)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM