Macros are not part of the standard Java language, and I donβt know which macro preprocessor is supported by the main Java tools, IDEs, etc. Therefore, if you use macros in your Java code, you should expect some βpainβ. For instance,
- Source code debuggers won't let you set breakpoints relative to source code.
- If you share your Java code with a macro, many Java developers are likely to cuddle in them and / or complain about the need to install / use additional tools.
There are many examples of third-party preprocessors for Java; e.g. Jatha , OpenJava , PrintMacroJ , JavaMacros and so on ... (But have you ever come across a project that uses any of them?)
Macros allow me to force embed, but allow me to control non-macro code.
True But the JIT compiler can probably do a better job than you can in determining what should be inlined. He will know (for sure) how big the chunks are, and he will have runtime statistics at the frequency of execution, branch prediction, etc., which are not available to you.
Please note that there are some Hotspot JVM settings that may affect optimizer decisions when embedding; see this page and scan for "inlin". For example, there is one which, apparently, allows you to increase the upper size threshold for the body of the inline method.
source share