Or GroovyShell could set parent as Thread.currentThread().getContextClassLoader() instead of null in its constructors. This is what Groovysh does:
Groovysh(final ClassLoader classLoader, final Binding binding, final IO io) { this(classLoader, binding, io, createDefaultRegistrar(classLoader)) } Groovysh(final Binding binding, final IO io) { this(Thread.currentThread().contextClassLoader, binding, io) } Groovysh(final IO io) { this(new Binding(), io) } Groovysh() { this(new IO()) } ________________________________ From: Milles, Eric (TR Tech, Content & Ops) <eric.mil...@thomsonreuters.com> Sent: Friday, May 17, 2019 12:10 PM To: dev@groovy.apache.org Subject: Re: groovy.ui.GroovyMain and groovy.ui.Console classpath arguments If groovy.ui.GroovyMain<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_apache_groovy_blob_master_src_main_groovy_groovy_ui_GroovyMain.java&d=DwMFAw&c=4ZIZThykDLcoWk-GVjSLmy8-1Cr1I4FWIvbLFebwKgY&r=tPJuIuL_GkTEazjQW7vvl7mNWVGXn3yJD5LGBHYYHww&m=Y_BwmeZL0-T22zbwkzO8qUrKrZBt9_jF7ANr68ox44k&s=Wgf94N-cX7wvBG4QCqPjKhFRxCdk58rLjbxQilPgd3M&e=> passed the current class loader to the new GroovyShell as the parent loader, continuity could be maintained. Can anyone see a problem with this? private void processFiles() throws CompilationFailedException, IOException, URISyntaxException { GroovyShell groovy = new GroovyShell(/**/Thread.currentThread().getContextClassLoader(),/**/conf); setupContextClassLoader(groovy); private void processOnce() throws CompilationFailedException, IOException, URISyntaxException { GroovyShell groovy = new GroovyShell(/**/Thread.currentThread().getContextClassLoader(),/**/conf); setupContextClassLoader(groovy); ________________________________ From: Milles, Eric (TR Tech, Content & Ops) <eric.mil...@thomsonreuters.com> Sent: Friday, May 17, 2019 11:53 AM To: dev@groovy.apache.org Subject: Re: groovy.ui.GroovyMain and groovy.ui.Console classpath arguments FYI, GroovyStarter creates a RootLoader that is configured by its "--classpath" arguments. Then runs its "--main" class argument. When groovy.ui.GroovyMain is that main class, it resets the thread's context class loader from the RootLoader to a new loader provided by "new GroovyShell(new CompilerConfiguration(command line processing)).getClassLoader()". ________________________________ From: Milles, Eric (TR Tech, Content & Ops) <eric.mil...@thomsonreuters.com> Sent: Friday, May 17, 2019 11:47 AM To: dev@groovy.apache.org Subject: groovy.ui.GroovyMain and groovy.ui.Console classpath arguments Both GroovyMain and Console claim to accept "--classpath" arguments, however neither class has any processing for them. How are these arguments supported? Is GroovyMain or Console supposed to be able to be run programatically? What I am trying to do is use GroovyStarter to bootstrap a basic Java/Groovy environment that groovy.ui.GroovyMain (for scripts) or groovy.ui.Console (for interaction) can be run from. What I am finding is that the classpath given to GroovyStarter is not propagating to GroovyMain. So I try and move the "--classpath" arguments from GroovyStarter to GroovyMain and the latter just ignores them. I'd actually prefer if GroovyStarter properly transferred its classpath to its "--main" class.