RFR - JDK-8210550 - Applying String::align and String::indent at Compile Time
Remi Forax
forax at univ-mlv.fr
Mon Sep 10 21:45:04 UTC 2018
Hi Jim,
There is a big drawback of doing that in the compiler, if String::align or String::indent has a bug, users will have to recompile all their codes which is not something we are used to in Java.
Moreover, i'm not convinced by the arguments cited in the bug description
1) minimum space is used to represent the string in the class file and
2) zero runtime cost occurs.
For (1) it depends! String::indent can add more spaces so the original text may may smaller than the result of a call to indent.
For (2) there is no real performance penalty once the JIT (even c1) kicks in. Also, if we don't want to wait the JIT, using constant dynamic is another option.
There is is another issue, why String::strip is constant folded and not String::trim ?
Java 12 have not being used yet, so we do not know which method is popular and which is not, so who decide which method should be constant folded or not.
And in term of implementation,
- the javadoc should clearly reflect which methods is constant folded, by an annotation by example
- it will help all languages that consumes the JDK API (instead of each compiler maintaining its own set)
regards,
Rémi
----- Mail original -----
> De: "Jim Laskey" <james.laskey at oracle.com>
> À: "compiler-dev" <compiler-dev at openjdk.java.net>
> Envoyé: Lundi 10 Septembre 2018 18:52:45
> Objet: RFR - JDK-8210550 - Applying String::align and String::indent at Compile Time
> Please review the following webrev. This feature is a tied implementation of
> Raw String Literals and supporting String methods.
>
> Cheers,
>
> — Jim
>
> webrev: http://cr.openjdk.java.net/~jlaskey/8210550/webrev/index.html
> jbs: https://bugs.openjdk.java.net/browse/JDK-8210550
More information about the compiler-dev
mailing list