1

I'm working on some of the problems in Programming Pearls and I'd like to get a sense for the runtime of various programs in Java. However the optimizing compiler is making this difficult. Is there a way to run javac on a Mac without having the compiler make any optimizations?

2
  • 4
    Any optimizations made by javac are irrelevant, since the JRE will optimize the byte code at run-time. Commented Jan 2, 2011 at 7:47
  • The main optimisation the compiler does is expression evaluations e.g. 1 + 1 => 2 and "hi " + "there" => "hi there". It doesn't change the code. Commented Jan 2, 2011 at 9:45

1 Answer 1

9

@Andrew Thompson is correct, the JIT is the main source of optimizations with java.

To run java without the JIT:

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

1 Comment

Yep. In fact, javac does almost no optimization, even in obvious places. (Which of course is why it's fast.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.