[ 
https://issues.apache.org/jira/browse/GROOVY-11706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18035813#comment-18035813
 ] 

Xiaotian Ma commented on GROOVY-11706:
--------------------------------------

[~blackdrag] Hello, I think I have found the cause of the issue. The Groovy 
compiler prioritizes looking for class files in the JVM where the compiler is 
located, thus ignoring the .java files I placed in the source code path. When I 
compiled using the command line, the JVM that was started did not have the 
classes for NotNull and Nullable loaded. However, when I loaded the compiler 
using a classloader, the older version of org.jetbrains.annotations (version 
13.0) in that environment was prioritized and identified by the compiler. This 
behavior is quite different from the Kotlin compiler, which does not search for 
a specific class in the JVM environment where the compiler itself is running. 
So I fell into a thinking misunderstanding. This discovery might be helpful for 
the bootstrapping of the Groovy compiler.

> How to run Groovy compiler via class loader without altering thread context 
> classloader?
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-11706
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11706
>             Project: Groovy
>          Issue Type: Question
>          Components: Compiler
>            Reporter: Xiaotian Ma
>            Assignee: Jochen Theodorou
>            Priority: Major
>         Attachments: screenshot-1.png
>
>
> When using direct reflection access to the main method of the 
> FileSystemCompiler class, some transformer classes do not seem to load 
> correctly. (The error is: Could not find class for Transformation Processor 
> org.codehaus.groovy.transform.trait.TraitASTTransformation declared by 
> groovy.transform.Trait)
> My original requirement was to use code instead of accessing multiple Groovy 
> compilers simultaneously from the command line. Since different versions 
> cannot coexist, I need to use classLoader to isolate them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to