What does the jsr keyword mean?

前端 未结 6 1287
栀梦
栀梦 2021-01-18 20:21

I\'m looking at some Java code, and I\'ve noticed the following:

if (!foo(bar, baz, qux)) {
    i = 0; jsr 433;
}

javac chokes on it, sayin

相关标签:
6条回答
  • 2021-01-18 21:05

    You are most likely looking at the results of decompiling some code which the decompiler wasn't able to cope with. JSR is the mnemonic for the jump subroutine bytecode; see this page for a listing. So jsr 432 may mean call a private method at bytecode address 432. However, the decompiler cannot figure that out, so maybe the method is synthetic, or something else is going on.

    EDIT

    Googled example you found is definitely decompiler output, and it looks like the part with the JSRs is either cause by obfuscation, byte code modification / generation, or by a decompiler stuffup.

    0 讨论(0)
  • 2021-01-18 21:08

    JSR (which stands for Jump Subroutine) is part of the Java Virtual Machine Specification. It's a instruction set for the JVM.

    Brief description

    The address of the opcode of the instruction immediately following this jsr instruction is pushed onto the operand stack as a value of type returnAddress.

    This can be found on the JVM book 2nd edition.

    0 讨论(0)
  • 2021-01-18 21:11

    JSR stands for Java Specification Request.

    There's probably a typo in that code and it should have been

    if (!foo(bar, baz, qux)) {
        i = 0; //jsr 433;
    }
    

    It seems to me that somebody did a non working checkin for some reason.

    But, looking at that code, it looks awfully artificial, so it's probably decompiled code, as Andreas_D already stated.

    Mini update: check the bottom comment:

    /* Location:           C:\Users\Matteo\Downloads\FreeDownApplet.signed.jar
     * Qualified Name:     FreeDownApplet
     * JD-Core Version:    0.5.4
     */
    

    From this, I'd say somebody made a signed jar file that was obfuscated, and whoever posted that code decompiled it.

    Update 2: Googling "JD core" yields http://java.decompiler.free.fr/ as the first result.

    0 讨论(0)
  • 2021-01-18 21:16

    jsr 433 is not a valid Java statement. It is a VM instruction which stands for "Jump to Sub Routine" (See the VM Spec for more information). The decompiler inserted it because it didn't understand the bytecode instruction (perhaps it was obfuscated) and so couldn't decompile it into valid Java source.

    0 讨论(0)
  • 2021-01-18 21:19

    It is not in the list of Java keywords. So I don't believe it has any meaning. And I doubt it's possible to compile it.

    0 讨论(0)
  • 2021-01-18 21:25

    I'm close to sure that this code is coming from a Java decompiler.

    The JSR 432 smells like a decompiler note, where the decompiler found a "jump" code but doesn't have a clue on how to express it in java language.

    0 讨论(0)
提交回复
热议问题