Class ImportLimits
java.lang.Object
io.github.brantunger.unruly.api.language.ImportLimits
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
FieldsModifier and TypeFieldDescriptionstatic final intThe most characters (UTF-16 units) an import may have: 1,000, fixed for 2.x.static final intThe most dot-separated parts an import may have: 64, fixed for 2.x. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringimportSizeProblem(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.
-
Field Details
-
MAX_IMPORT_LENGTH
public static final int MAX_IMPORT_LENGTHThe 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_PARTSThe 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
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, asCan'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 1000if the import has more than 1000 characters, elseit has N dot-separated parts, and an import may have at most 64if it has more than 64 parts, elsenull: the engine accepts it as far as its size goes- Throws:
NullPointerException- ifnameisnull
-