RFR: 8159855: Create an SPI for tools
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Oct 5 03:24:12 UTC 2016
Hi Robert,
When you invoke jshell from the command line through the command line
launcher, there must surely be a simpler entry point that is invoked.
Command line entry points don't provide Java Preferences objects, for
example. That being said, I agree that jshell does require an input
stream, and that is not supported by this SPI.
If you want a richer API, why do you not export a public API for others
to access and use?
-- Jon
On 10/4/16 6:37 PM, Robert Field wrote:
> I like the idea of this SPI. And I'd like the jshell tool to
> launchable in this manner,
>
> Unfortunately the shape of the SPI would not allow for this. The
> current entry-point (which is in an internal package) is --
>
> /**
> * The constructor for the tool (used by tool launch via main and
> by test
> * harnesses to capture ins and outs.
> * @param cmdin command line input -- snippets and commands
> * @param cmdout command line output, feedback including errors
> * @param cmderr start-up errors and debugging info
> * @param console console control interaction
> * @param userin code execution input, or null to use IOContext
> * @param userout code execution output -- System.out.printf("hi")
> * @param usererr code execution error stream --
> System.err.printf("Oops")
> * @param prefs preferences to use
> * @param locale locale to use
> */
> public JShellTool(InputStream cmdin, PrintStream cmdout,
> PrintStream cmderr,
> PrintStream console,
> InputStream userin, PrintStream userout, PrintStream usererr,
> Preferences prefs, Locale locale)
>
> Some of these could defaulted, but not all.
>
> Any ideas?
>
> Thanks,
> Robert
>
>
>
> On 10/04/16 16:46, Jonathan Gibbons wrote:
>> Resend with non-mostly-empty subject line!
>>
>> -- Jon
>>
>> On 10/04/2016 04:39 PM, Jonathan Gibbons wrote:
>>> Core-libs folk,
>>>
>>> Please review the following change to add a new service provider class
>>> java.util.spi.ToolProvider
>>>
>>> which can be used provide simple "command-line" access to select JDK
>>> tools, without starting a new JVM.
>>>
>>> The following tools are updated to provide access through the new SPI:
>>> javac, javadoc, javap, jdeps
>>>
>>> It is expected that additional tools will also be updated to provide
>>> access,
>>> but that will be done separately.
>>>
>>> Compiler-dev folk may wish to review the changes to the langtools
>>> repository.
>>>
>>> JBS: https://bugs.openjdk.java.net/browse/JDK-8159855
>>> Webrev: http://cr.openjdk.java.net/~jjg/8159855/webrev.03/
>>> API:
>>> http://cr.openjdk.java.net/~jjg/8159855/api.02/java/util/spi/ToolProvider.html
>>>
>>> -- Jon
>>
>
More information about the compiler-dev
mailing list