Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java @ 22234:959f658b918d
Truffle/Instrumentation: generify Instrumenter.install(Tool) in the type of the tool.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 21 Sep 2015 17:03:27 -0700 |
parents | 1f19e3cada3d |
children | df222c4e9bd9 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java Mon Sep 21 16:29:45 2015 -0700 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrumenter.java Mon Sep 21 17:03:27 2015 -0700 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -122,7 +123,7 @@ * language-agnostic management of individual execution environments is added to the platform, * installation will be (optionally) specific to a single execution environment. */ - public abstract static class Tool { + public abstract static class Tool<T extends Tool<?>> { // TODO (mlvdv) still thinking about the most appropriate name for this class of tools private ToolState toolState = ToolState.UNINSTALLED; @@ -234,7 +235,7 @@ private final Object vm; /** Tools that have been created, but not yet disposed. */ - private final Set<Tool> tools = Collections.synchronizedSet(new LinkedHashSet<Tool>()); + Set<Tool<? extends Tool<?>>> tools = new HashSet<>(); private final Set<ASTProber> astProbers = Collections.synchronizedSet(new LinkedHashSet<ASTProber>()); @@ -544,10 +545,12 @@ /** * Connects the tool to some part of the Truffle runtime, and enable data collection to start. * + * @return the tool * @throws IllegalStateException if the tool has previously been installed or has been disposed. */ - public void install(Tool tool) { + public <T extends Tool<?>> T install(T tool) { tool.install(this); + return tool; } @SuppressWarnings("unused")