Class Substitutions

java.lang.Object
org.teavm.extension.spi.substitution.SimpleSubstitutionPolicy
dev.gmitch215.bytebox.text.Substitutions
All Implemented Interfaces:
org.teavm.extension.spi.substitution.SubstitutionPolicy

public final class Substitutions extends org.teavm.extension.spi.substitution.SimpleSubstitutionPolicy
Points java.util.Formatter and what it needs at the ones in this package.

Found through META-INF/services, which is how the compiler's own class library registers its substitutions. String.format and printf both go through java.util.Formatter, so replacing it is what makes them cost what they cost here.

The class library's DoubleAnalyzer, which Double.toString and every string concatenation of a double write digits from, is pointed at DoubleAnalyzer, its copy that picks the shortest digits exactly, and its DoubleSynthesizer, which DecimalFormat reads a number with, at DoubleSynthesizer. Its FloatAnalyzer, which Float.toString writes from, is pointed at FloatAnalyzer. Double.parseDouble and Float.parseFloat no longer come through either: ParsePlugin sends them to Parse.

IllegalFormatException comes along because its constructors are package-private in the class library, so the two subclasses it is missing cannot be written anywhere else. Formattable comes along because its one method takes a formatter.

Since:
1.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    contribute(org.teavm.extension.spi.substitution.SubstitutionSink sink)
     

    Methods inherited from class org.teavm.extension.spi.substitution.SimpleSubstitutionPolicy

    inPackage, inPackage, named, namePattern, not

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Substitutions

      public Substitutions()
  • Method Details

    • contribute

      public void contribute(org.teavm.extension.spi.substitution.SubstitutionSink sink)