java.lang.Object
io.github.brantunger.unruly.api.language.ImportLimits

public final class ImportLimits extends Object
How large an import may be, as the engine bounds the imports it is built with, for a language that reads an import in an expression's own text: it bounds that import the same way, and rejects it with the same reason, rather than keeping a copy of the limits that could drift. The engine rejects an import before any class loader sees it, because a parallel-capable class loader, such as the JDK's application class loader, keeps an object for each name it is asked for, for as long as it lives, and because a name that isn't a class is looked up again with each dot from the right replaced by $, so the work grows with the number of parts.

The limits and the reason's wording are fixed for 2.x. The class is stateless, and importSizeProblem(java.lang.String) allocates only the reason it returns.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The most characters (UTF-16 units) an import may have: 1,000, fixed for 2.x.
    static final int
    The most dot-separated parts an import may have: 64, fixed for 2.x.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable String
    Says why an import is too large to look up, if it is, as the engine says it: too long, or else with too many parts, counting its dots as separators whatever is between them, so an empty import has one part.

    Methods inherited from class java.lang.Object

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

    • MAX_IMPORT_LENGTH

      public static final int MAX_IMPORT_LENGTH
      The most characters (UTF-16 units) an import may have: 1,000, fixed for 2.x. javac inlines it into the classes that read it.
      See Also:
    • MAX_IMPORT_PARTS

      public static final int MAX_IMPORT_PARTS
      The most dot-separated parts an import may have: 64, fixed for 2.x. javac inlines it into the classes that read it.
      See Also:
  • Method Details

    • importSizeProblem

      public static @Nullable String importSizeProblem(String name)
      Says why an import is too large to look up, if it is, as the engine says it: too long, or else with too many parts, counting its dots as separators whatever is between them, so an empty import has one part. The engine writes the reason after the quoted import, as Can't import ' + quote(name) + ': + the reason; a language that rejects an inline import the same way reports it with the engine's words.
      Parameters:
      name - The import, as the expression or the builder writes it
      Returns:
      it has N characters, and an import may have at most 1000 if the import has more than 1000 characters, else it has N dot-separated parts, and an import may have at most 64 if it has more than 64 parts, else null: the engine accepts it as far as its size goes
      Throws:
      NullPointerException - if name is null