1

I am considering building an IntelliJ IDEA plugin for Salesforce Apex & Visualforce. To do so I need to find the Salesforce Apex language specification. I read other posts on the internet of similar requests of a couple of years old, but they don't include a satisfying answer. Things might have changed since then. Does anybody know I such a language specification is available. If so, where can I acquire it? Thanks so much!

1

There is no formal specification of the compiler since it is cloud native:

When a developer writes and saves Apex code to the platform, the platform application server first compiles the code into an abstract set of instructions that can be understood by the Apex runtime interpreter, and then saves those instructions as metadata.

When an end user triggers the execution of Apex, perhaps by clicking a button or accessing a Visualforce page, the platform application server retrieves the compiled instructions from the metadata and sends them through the runtime interpreter before returning the result. The end user observes no differences in execution time from standard platform requests.

Apex JIT Compiler

There is documentation for specific source code limits:

Description  							  Limit
Maximum number of characters for a class 			1 million
Maximum number of characters for a trigger 			1 million
Maximum amount of code used by all Apex code in an org 		 6 MB 
Method size limit 						65,535 bytecode
instructions in compiled form

As well as definitions of the different execution contexts:

A class is a template or blueprint from which Apex objects are created. Classes consist of other classes, user-defined methods, variables, exception types, and static initialization code. From Setup, enter Apex Classes in the Quick Find box, then select Apex Classes.

A trigger is Apex code that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted. Triggers are stored as metadata in Salesforce. A list of all triggers in your organization is located on the Apex Triggers page in Setup.

And deployment strategies:

Starting in Summer '18, each org's Apex code is now automatically recompiled in production when completing a metadata deploy, package install, or package upgrade. This change in behavior improves performance following metadata deploys and package updates. Previously, a deploy, install, or upgrade could leave an org with invalidated code, causing reduced performance while Apex was recompiled. This feature causes deployments to the org to invoke the Apex compiler and save the resulting bytecode as part of the deployment. A minimal increase in deployment times can occur, but Apex doesn't need to be recompiled on first run. So the slight increase in deployment time can prevent performance issues on first run.

However, if you see a lot of classes that need to be recompiled, you definitely want to make sure that deployment happens in off-hours!

As far as an IDE plugin, a similar question may be helpful.

References

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.