< prev index next >
test/compiler/compilercontrol/share/scenario/JcmdStateBuilder.java
Print this page
rev 9430 : [mq]: PrintDirectives
rev 9150 : 8066166: JEP-JDK-8046155: Test task: dcmd tests
Summary: Tests for diagnostic command in CompilerControl
Reviewed-by: kvn
*** 34,61 ****
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
public class JcmdStateBuilder implements StateBuilder<JcmdCommand> {
private static final List<Pair<Executable, Callable<?>>> METHODS
= new PoolHelper().getAllMethods();
private final Map<Executable, State> stateMap = new HashMap<>();
private final DirectiveBuilder directiveBuilder;
private Map<MethodDescriptor, List<CompileCommand>> matchBlocks
= new LinkedHashMap<>();
- private List<JcmdCommand> commands = new ArrayList<>();
private boolean isFileValid = true;
public JcmdStateBuilder(String fileName) {
directiveBuilder = new DirectiveBuilder(fileName);
}
@Override
public void add(JcmdCommand compileCommand) {
- commands.add(compileCommand);
switch (compileCommand.jcmdType) {
case ADD:
directiveBuilder.add(compileCommand);
addCommand(compileCommand);
break;
--- 34,60 ----
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+ import java.util.stream.Collectors;
public class JcmdStateBuilder implements StateBuilder<JcmdCommand> {
private static final List<Pair<Executable, Callable<?>>> METHODS
= new PoolHelper().getAllMethods();
private final Map<Executable, State> stateMap = new HashMap<>();
private final DirectiveBuilder directiveBuilder;
private Map<MethodDescriptor, List<CompileCommand>> matchBlocks
= new LinkedHashMap<>();
private boolean isFileValid = true;
public JcmdStateBuilder(String fileName) {
directiveBuilder = new DirectiveBuilder(fileName);
}
@Override
public void add(JcmdCommand compileCommand) {
switch (compileCommand.jcmdType) {
case ADD:
directiveBuilder.add(compileCommand);
addCommand(compileCommand);
break;
*** 157,164 ****
return new ArrayList<>();
}
@Override
public List<JcmdCommand> getCompileCommands() {
! return commands;
}
}
--- 156,172 ----
return new ArrayList<>();
}
@Override
public List<JcmdCommand> getCompileCommands() {
! if (isFileValid) {
! return matchBlocks.keySet().stream()
! /* only method descriptor is required
! to check print_directives */
! .map(md -> new JcmdCommand(null, md, null, null,
! Scenario.JcmdType.ADD))
! .collect(Collectors.toList());
! } else {
! return new ArrayList<>();
! }
}
}
< prev index next >