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

Jochen Theodorou commented on GROOVY-11706:
-------------------------------------------

[~xyzboom]I think we can do an easy test to see if the FileSystemcompiler usage 
is seeing the Annoatations or not.  Just compile this:

{code:Java}
import org.jetbrains.annotations.NotNull

@groovy.transform.CompileStatic
def foo() {
  def theClass = NotNull.class
}
foo()
{code}
I added the CompilStatic only to enforce that NotNull.class is not seen as 
property expression. This should then fail compilation for not finding NotNull 
if the NotNull class is not available on the classpath. And it should not make 
a difference here if the class is an annotation or not.

Using JavaAwareCompilationUnit makes a difference in that it will create stubs 
for the groovy code, which also has to pass compilation - this time by the Java 
compiler. But from what I see there is no problem with the Java compiler.. 

It's just... the issue really puzzles me. If the class loader setup makes a 
difference and it is not the annotation, then it can be only the groovy version 
used that are different. Regardless of what you use to trigger compilation, the 
compiler is the same for all of them. 

> 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
>            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