Class Linker
- Direct Known Subclasses:
AbstractLinker
,SoycReportLinker
LinkerOrder
annotation to determine
the relative ordering of the Linkers. Exact order of Linker execution will be
determined by the order of add-linker
tags in the module
configuration. Each Linker should also be annotated with Shardable
;
non-shardable linkers are deprecated and will eventually not be supported.
A new instance of a linker is created each time a module is compiled or
during hosted mode when a module first loads (or is refreshed). During a
compile, link(TreeLogger, LinkerContext, ArtifactSet)
is called
exactly once on each non-shardable linker, and the artifact set will contain
any and all generated artifacts. For shardable linkers,
link(TreeLogger, LinkerContext, ArtifactSet, boolean)
is called once
for each compiled permutation and once after all compiles are finished. The
precise artifacts supplied differ with each call and are described in the
method's documentation.
When hosted mode starts for a module, it calls
link(TreeLogger, LinkerContext, ArtifactSet)
for non-shardable
linkers and link(TreeLogger, LinkerContext, ArtifactSet, boolean)
for shardable ones, passing false
as the
onePermutation
argument. If any artifacts are subsequently
generated during the course of running hosted mode,
relink(TreeLogger, LinkerContext, ArtifactSet)
will be called with
the new artifacts.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract String
Returns a human-readable String describing the Linker.final boolean
Check whether this class is considered a shardable linker.link
(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) This method is invoked for linkers not annotated withShardable
.link
(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation) This method is invoked for linkers annotated withShardable
.relink
(TreeLogger logger, LinkerContext context, ArtifactSet newArtifacts) Re-invoke the Linker with newly generated artifacts.boolean
supportsDevModeInJunit
(LinkerContext context) Returnstrue
if this linker supports DevMode.
-
Constructor Details
-
Linker
public Linker()
-
-
Method Details
-
getDescription
Returns a human-readable String describing the Linker. -
isShardable
public final boolean isShardable()Check whether this class is considered a shardable linker. A linker is shardable if it either implements theShardable
annotation or it has a field namedgwtIsShardable
. If such a field is present, it doesn't matter what value the field holds. The latter mechanism is only intended to support linkers that must compile against older versions of GWT. -
link
public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException This method is invoked for linkers not annotated withShardable
. It sees all artifacts across the whole compile and can modify them arbitrarily. This method is only called if the linker is not annotated withShardable
.- Parameters:
logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentartifacts
- an unmodifiable view of the artifacts to link- Returns:
- the artifacts that should be propagated through the linker chain
- Throws:
UnableToCompleteException
- if compilation violates assumptions made by the Linker or for errors encountered by the Linker
-
link
public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation) throws UnableToCompleteException This method is invoked for linkers annotated with
Shardable
. It is called at two points during compilation: after the compile of each permutation, and after all compilation has finished. TheonePermutation
istrue
for a per-permutation call andfalse
for a global final-link call.For one-permutation calls, this method is passed all artifacts generated for just the one permutation. For the global call at the end of compilation, this method sees artifacts for the whole compilation, but with two modifications intended to support builds on computer clusters:
- All EmittedArtifacts have been converted to BinaryEmittedArtifacts
- All artifacts not marked as
Transferable
have been discarded.
- Parameters:
logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentartifacts
- an unmodifiable view of the artifacts to linkonePermutation
- true for a one-permutation call- Returns:
- the artifacts that should be propagated through the linker chain
- Throws:
UnableToCompleteException
- if compilation violates assumptions made by the Linker or for errors encountered by the Linker
-
relink
public ArtifactSet relink(TreeLogger logger, LinkerContext context, ArtifactSet newArtifacts) throws UnableToCompleteException Re-invoke the Linker with newly generated artifacts. Linkers that need to reference the original artifact set passed intolink(TreeLogger, LinkerContext, ArtifactSet)
should retain a copy of the original artifact set in an instance variable.- Parameters:
logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentnewArtifacts
- an unmodifiable view of the newly generated artifacts- Returns:
- the new artifacts that should be propagated through the linker chain; it is not necessary to return any artifacts from the original link (or previous calls to relink) that have not been modified
- Throws:
UnableToCompleteException
- if compilation violates assumptions made by the Linker or for errors encountered by the Linker
-
supportsDevModeInJunit
Returnstrue
if this linker supports DevMode.- Parameters:
context
- a LinkerContext
-