1

Possible Duplicate:
Is it possible to view bytecode of Class file?

I wanted to write some Java in eclipse, compile and then look at the resultant "assembly language" to see which code compiles to the fewest "instructions". I realise Java is different to C++, but is it possible to study some output from the compilation and compare to check for fastest code?

1
  • 3
    Bear in mind that "fewest instructions" != "fastest", and that the JIT will play a large role in what is ultimately fastest. Profiling is the best way to determine what's fastest under actual application execution. Commented Nov 25, 2011 at 19:53

4 Answers 4

2

You can look at the bytecode with the javap command.
But you must take into account, that the JVM performs JIT. Which means that depending on several things including command line arguments and runtime statistics, it will optimize the code on the fly.

Sign up to request clarification or add additional context in comments.

Comments

1

Check out javap.

Comments

0

You have to look at the bytecode produced by the compilation, exist an eclipse plugin (Bytecode Outline) that let you view the bytecode directly in eclipse.

Comments

0

The Java toolset comes with the Java class file disassembler, which you can use to du just that.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.