Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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.

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.

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.

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.

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top