Class AbstractOptimizer<T extends IOptimizerTarget>
java.lang.Object
com.pnfsoftware.jeb.core.AbstractPlugin
com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
IPlugin
,IOptimizer<T>
- Direct Known Subclasses:
AbstractCOptimizer
,AbstractEOptimizer
public abstract class AbstractOptimizer<T extends IOptimizerTarget>
extends AbstractPlugin
implements IOptimizer<T>
Skeleton for a generic artifact optimizer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ILogger
Public logger accessible by the implementing optimizer.Fields inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
DEAD_CODE_REMOVER, DEOBFUSCATOR, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_STANDARD
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Retrieve the optional master optimizer that manages this optimizer.getName()
Retrieve basic information about the plugin, such as name, version, author, and organization.int
This method is used for on-demand optimizers only.final double
The standard implementation provides astandard priority of 0
.Specify the minimum bar requested from the orchestrator in order to run.getTags()
Get the optimizer tags.getType()
Retrieve the type of this optimizer.protected void
void
Set an optional master optimizer that manages this optimizer.protected void
protected void
setPreferredExecutionStage
(int preferredExecStage) Use only for typeOptimizerType.ON_DEMAND
.protected void
setPriority
(double priority) Set the optimizer priority.protected void
setRequiredModeThreshold
(OptimizerMode threshold) Set the threshold.protected void
setType
(OptimizerType type) Set the type of optimizer.Methods inherited from class com.pnfsoftware.jeb.core.AbstractPlugin
dispose, getData, setData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
performOnTarget
-
Field Details
-
logger
Public logger accessible by the implementing optimizer. Writing to the logger should be favored over writing directly tostdout
.
-
-
Constructor Details
-
AbstractOptimizer
public AbstractOptimizer() -
AbstractOptimizer
-
-
Method Details
-
setName
-
getName
-
getPluginInformation
Description copied from interface:IPlugin
Retrieve basic information about the plugin, such as name, version, author, and organization.- Specified by:
getPluginInformation
in interfaceIPlugin
- Returns:
- the plugin information
-
setMasterOptimizer
Description copied from interface:IOptimizer
Set an optional master optimizer that manages this optimizer.- Specified by:
setMasterOptimizer
in interfaceIOptimizer<T extends IOptimizerTarget>
- Parameters:
mo
- optional
-
getMasterOptimizer
Description copied from interface:IOptimizer
Retrieve the optional master optimizer that manages this optimizer.- Specified by:
getMasterOptimizer
in interfaceIOptimizer<T extends IOptimizerTarget>
- Returns:
- optional reference
-
setType
Set the type of optimizer. The default isOptimizerType.NORMAL
. Optimizers with a typeOptimizerType.ON_DEMAND
must also set theirpreferred execution stage
(else they will never run).- Parameters:
type
-
-
getRequiredModeThreshold
Description copied from interface:IOptimizer
Specify the minimum bar requested from the orchestrator in order to run. If that bar is not met, the orchestrator should not run the optimizer. Refer toAbstractMasterOptimizer
for existing thresholds.- Specified by:
getRequiredModeThreshold
in interfaceIOptimizer<T extends IOptimizerTarget>
- Returns:
-
setRequiredModeThreshold
Set the threshold. The default valueAbstractMasterOptimizer#MODE_NORMAL
.- Parameters:
threshold
-
-
getType
Description copied from interface:IOptimizer
Retrieve the type of this optimizer.- Specified by:
getType
in interfaceIOptimizer<T extends IOptimizerTarget>
- Returns:
-
addTag
-
removeTag
-
getTags
Description copied from interface:IOptimizer
Get the optimizer tags. An optimizer may have 0, 1, or more tags. A tag is a non-null, non-empty string.- Specified by:
getTags
in interfaceIOptimizer<T extends IOptimizerTarget>
- Returns:
- a collection of tags; may be empty (tags are optional), but never null
-
setPreferredExecutionStage
protected void setPreferredExecutionStage(int preferredExecStage) Use only for typeOptimizerType.ON_DEMAND
. Disregarded for other types. Leave to 0 for pure on-demand.- Parameters:
preferredExecStage
- id such that abs(id) is in [1, 99] ; use positive value for post-stage execution, negative value for pre-stage execution
-
getPreferredExecutionStage
public int getPreferredExecutionStage()Description copied from interface:IOptimizer
This method is used for on-demand optimizers only.- Specified by:
getPreferredExecutionStage
in interfaceIOptimizer<T extends IOptimizerTarget>
- Returns:
-
setPriority
protected void setPriority(double priority) Set the optimizer priority. To be used by the constructor.- Parameters:
priority
- the new priority (high means higher priority). When optimizers are managed and run by an orchestrator, the optimizers with a higher priority are run before those having a lower priority. The default priority is 0.
-
getPriority
public final double getPriority()The standard implementation provides astandard priority of 0
.- Specified by:
getPriority
in interfaceIOptimizer<T extends IOptimizerTarget>
- Returns:
- the optimizer priority
-