9

I'm having an issue in my Java application where the JIT breaks the code. If I disable the JIT, everything works fine, but runs 10-20x slower.

Is there any way to disable the JIT for a specific method or class?

Edit: I'm using Ubuntu 10.10, getting the same results both with:

OpenJDK Runtime Environment (IcedTea6 1.9) (6b20-1.9-0ubuntu1)
OpenJDK 64-Bit Server VM (build 17.0-b16, mixed mode)

and:

Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
6
  • Did you file a bug already? Or did you find an existing bug, which describes your problem? Commented Oct 23, 2010 at 14:20
  • Sounds very unlikely that it's due to the JIT, no? Couldn't it be due to a race-condition (since the timing changes when you disable jit)... Commented Oct 23, 2010 at 14:34
  • I'm only using a single thread. I'm busy looking into the bug, but don't really have the time right now. The bug occurs consistently after a specific method has been compiled by the JIT. For now I'm just setting the -XX:CompileThreshold option high enough. Commented Oct 23, 2010 at 14:53
  • Have you tried a later version of the JDK ? Commented Oct 23, 2010 at 16:13
  • 2
    Blaming the JVM should usually be pretty far down the list :) Commented Oct 23, 2010 at 17:00

2 Answers 2

10

The following option works on my JVMs, to exclude a specific method:

-X:CompileCommand=exclude,the/package/and/Class,methodName
Sign up to request clarification or add additional context in comments.

3 Comments

Sun/Oracle Java 6 and above use -XX:CompileCommand option. See java options for more information, specifically for v8.
Sorry to dig up such an old post; if I were to use this with a named inner class would I delimit it as com/domain/package/Outer/Inner or com/domain/package/Outer$Inner?
I encountered the same problem today. After some experimenting, it seems that we should use com/domain/package/Outer$Inner.
6

Yes, there is one. You can supply the affected classes you want to exclude JIT compilation at start-up:

-Xjit:exclude={package/class.method|package/class.method}

2 Comments

I get "Unrecognized option: -Xjit:exclude={...} Could not create the Java virtual machine."
-X options are nonstandard. They may change between versions, and are dependent on your JVM

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.