Class Substitutions

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

public final class Substitutions extends org.teavm.extension.spi.substitution.SimpleSubstitutionPolicy
Points the reachable parts of java.net at the ones in this package.

Found through META-INF/services, which is how the compiler's own class library registers its substitutions. A project compiles against the real classes from the JDK, and the references are rewritten when the program is compiled to WebAssembly, so a library that opens a socket or makes a request the ordinary way needs no change and no shim.

URL, URLConnection and HttpURLConnection exist in the class library and are replaced rather than supplied: its versions are wired to XMLHttpRequest, which this platform does not have, so they compile and then fail on the first request. Socket, InetAddress and the java.net.http client are absent from it and are supplied.

Only the classes named here are substituted. ServerSocket and DatagramSocket are deliberately absent: the platform can accept no inbound connection and speaks no UDP, so a program using either should fail while it is being built rather than throw once it is running.

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)