What does the jsr keyword mean?

巧了我就是萌 提交于 2019-12-04 03:29:46

问题


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, saying it's not a statement and that a semicolon is expected after the keyword jsr.

I did some Googling, and I found some code containing the same thing, which leads me to believe it's there intentionally (even though they weren't able to get it to compile either). So what does jsr do? How does one get code containing it to compile?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


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.



来源:https://stackoverflow.com/questions/4312426/what-does-the-jsr-keyword-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!