Samuel Rowe
Samuel Rowe

Reputation: 192

What's the difference between jsr_w and wide instructions in Java bytecode?

According to the Java byte code specification 9, the wide instruction modifies the behavior of another instruction. Thus, an instruction can extend the size of certain input data, say for example, the indexes into the constant pool. But then, the specification also provides the jsr_w. What is the main difference between jsr_w and using wide jsr in conjunction?

Upvotes: 2

Views: 300

Answers (1)

Antimony
Antimony

Reputation: 39451

There's no such thing as wide jsr. wide can only be used with iload, fload, aload, lload, dload, istore, fstore, astore, lstore, dstore, ret, and iinc.

Technically, there's no such thing as jsr_wide either, but there is jsr_w, which is the wide variant of jsr. Likewise, there's also goto and goto_w.

So to answer the question, one of them is illegal and the other is the accepted way to use a larger jump offset for a jsr instruction.

Upvotes: 4

Related Questions