Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable StringBuilder optimisation in javac

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?

like image 675
Michael Berry Avatar asked Apr 01 '26 05:04

Michael Berry


1 Answers

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

like image 189
assylias Avatar answered Apr 02 '26 18:04

assylias