groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Jouvin (JIRA)" <>
Subject [jira] [Commented] (GROOVY-8227) Allow to specify Groovysh (and GroovyShell) class loader different from TCCL
Date Tue, 13 Jun 2017 09:43:00 GMT


Denis Jouvin commented on GROOVY-8227:

More specifically, the problem comes from the inner class {{VisitorClassLoader}} of the class

This class, which extends {{GroovyClassLoader}}, does not allow to specify a parent class
loader, and indead uses the default constructor of {{GroovyClassLoader}}, which in turn uses
the TCCL.

To correct the problem, a constructor should be added and {{ScriptVariableAnalyzer#getBoundVars}}
and {{Groovysh#evaluateWithStoredBoundVars}} at least should be modified to propagate the
class loader specified at the Groovysh level.

The problem is that I am not sure that this is the only place where the TCCL is used instead
of Groovysh specified class loader. A deeper analysis may be needed.

> Allow to specify Groovysh (and GroovyShell) class loader different from TCCL
> ----------------------------------------------------------------------------
>                 Key: GROOVY-8227
>                 URL:
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime, Groovysh
>    Affects Versions: 2.4.x, 2.5.x
>         Environment: OSGi (Karaf 2.x, 3.X or 4.x)
>            Reporter: Denis Jouvin
>              Labels: classloader, groovysh, groovyshell
>             Fix For: 2.4.x, 2.5.x
>   Original Estimate: 48h
>  Remaining Estimate: 48h
> Allthough the Groovy API seem to allow one to specify the class loader when instanciating
a Groovysh or GroovyShell, internally in some places Groovy will silently use the TCCL (thread
context class loader) and there is no way to avoid that without hacking Groovy and chasing
all the places where {{getThreadContextClassLoader()}} is used.
> This is problematic, especially in OSGi environement, since the TCCL is not compatible
with OSGi principles (i.e. every bundle has its own class loader), and also with some modern
modular containers similar to OSGi. When a class loader is specified in the GroovyShell or
Groovysh creation, Groovy should propagate that class loader correctly (or instanciate children
class loader of that specified class loader), and in no way use the TCCL.
> This may be a dupplicate of [Groovy 4895|]

This message was sent by Atlassian JIRA

View raw message