在 javac 中禁用 StringBuilder 优化 [英] Disable StringBuilder optimisation in javac

查看:23
本文介绍了在 javac 中禁用 StringBuilder 优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在 Java 中使用普通字符串连接时,javac 将优化它,它可以使用 StringBuilder 代替(或 Java 5 之前的 StringBuffer.)

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

在我的情况下,关闭所有这些会非常有帮助,只需让字符串连接使用 String 上的沼泽标准追加"方法.这种优化是完全融入"到 javac 的,还是有办法完全禁用它?

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?

推荐答案

我不是 javac 专家,但它似乎是在 Gen.java 文件来自第 1793 行.

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

这篇关于在 javac 中禁用 StringBuilder 优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆