Disable StringBuilder optimisation in javac

非 Y 不嫁゛ 提交于 2019-12-12 15:16:03

问题


When using normal string concatenation in Java, javac will optimise this where it can to use StringBuilder instead (or StringBuffer before Java 5.)

In my case, it'd be incredibly helpful to switch all this off, and just have string concatenation use the bog standard "append" method on String instead. Is this optimisation fully "baked in" to javac, or is there a way to disable it at all?


回答1:


I'm not a javac expert but it seems to be hardcoded in javac in the Gen.java file from line 1793.




回答2:


Take alook at this link its eclipse related but if your using eclipse you may find some configration related to optimizing options like unused local variables and co, hope you will find something helpful.

Alternatively this assembler may help you It takes ASCII descriptions of Java classes, written in a simple assembler-like syntax using the Java Virtual Machine instruction set. It converts them into binary Java class files, suitable for loading by a Java runtime system.



来源:https://stackoverflow.com/questions/14854395/disable-stringbuilder-optimisation-in-javac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!