We know that the Apex syntax is very similar to Java. I have observed that on some occasions, while running some Apex code, you may get a Java exception.

I assume that Apex runs on Java. But my question is: does Apex has its own runtime (presumably built on Java), or is the Apex source code transpiled into Java and then run in a JVM?

Also, is there any documentation on this?

1 Answer 1


The actual documentation for this process is internal only. You might get a glimpse if you were to sign a Non-Disclosure Agreement (but I wouldn't hold my breath). However, here's some fun reading: Patent US20110264861: Methods and systems for utilizing bytecode in an on-demand service environment including providing multi-tenant runtime environments and systems.

Of particular note:

In one embodiment, the Apex interpreter serves as a level of isolation between customer code and the host virtual machine (VM). The Apex interpreter may enforce governor limits and brokers requests to the underlying platform on behalf of customer code. In one embodiment, the Apex interpreter is not a full-fledged Java virtual machine. The Apex interpeter may delegate to a Java virtual machine (JVM) for various services. Garbage collection is an example of this. In one embodiment, the Apex interpreter is also able to delegate to the VM on a per type basis.

Apex Code runs in Java, but it is not a full VM, and will delegate various tasks such as garbage collection to the underlying Java VM. There's lots of juicy details as you would expect to find patent text.

Community Wiki. Please feel free to provide additional edits to this text. Thanks!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .