5

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?

  • 2
    Similar question without accepted answer http://stackoverflow.com/questions/2135864/are-these-encoded-codes – HeDinges Nov 30 '10 at 10:09

6 Answers6

10

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.

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
  • That's got to be it. I'm 90% sure the code I'm looking at is decompiled code. Any way to piece together what was trying to occur here? Or is getting the original source the only option? –  Nov 30 '10 at 10:08
  • 1
    @Mark - Hard to tell. You can try to correct it by hand but you need to disassemble the byte code for this method and try to find out where the algorithm continues. 432 is a byte code index. I did it on some occasions, so yes, technically it's possible. – Andreas Dolk Nov 30 '10 at 10:10
  • 3
    See here: http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc7.html#jsr – clstrfsck Nov 30 '10 at 10:15
  • @spong, I only saw your link now, after I had added it to the answer. – Buhake Sindi Nov 30 '10 at 10:25
3

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
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.

dogbane
  • 266,786
  • 75
  • 396
  • 414
1

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.

darioo
  • 46,442
  • 10
  • 75
  • 103
  • Yeah, it was an example of what I found Googling, but I'm pretty sure what I'm looking at personally is decompiled code anyway, too. Interesting. –  Nov 30 '10 at 10:13
0

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.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
0

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.

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228