You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Daniil Ovchinnikov <da...@jetbrains.com> on 2019/01/14 17:23:50 UTC
ASM class resolution
Hi all -
So I’ve been investigating https://youtrack.jetbrains.com/issue/IDEA-204305 for a while now
and found out that getClassNode() in anonymous ClassWriter in CompilationUnit#createClassVisitor
still uses class loader to obtain class node instead of relying on AsmReferenceResolver.
Is this expected?
—
Daniil Ovchinnikov
JetBrains
Re: ASM class resolution
Posted by Daniil Ovchinnikov <da...@jetbrains.com>.
Thank you Jochen and Paul for looking into it.
At first I’ve tried this exact code and it fixes my test case, but then it differs from the code in AsmReferenceResolver
only by logic for inner classes, and I have strong feeling that the exact same code should be reused.
I’m leaving this up to you.
In the meanwhile I’ve added an ability to disable ‘asmResolving’ via optimization options map in IntelliJ.
—
Daniil Ovchinnikov
JetBrains
> On 15 Jan 2019, at 11:38, Paul King <pa...@asert.com.au> wrote:
>
> The tests still pass replacing the try/catch with:
> ClassNodeResolver.LookupResult lookupResult = getClassNodeResolver().resolveName(name, CompilationUnit.this);
> return lookupResult == null ? null : lookupResult.getClassNode();
> Not sure whether returning null will cause a problem but if so it isn't triggered by our current test suite.
>
> Cheers, Paul.
>
>
Re: ASM class resolution
Posted by Paul King <pa...@asert.com.au>.
The tests still pass replacing the try/catch with:
ClassNodeResolver.LookupResult lookupResult =
getClassNodeResolver().resolveName(name, CompilationUnit.this);
return lookupResult == null ? null : lookupResult.getClassNode();
Not sure whether returning null will cause a problem but if so it isn't
triggered by our current test suite.
Cheers, Paul.
Re: ASM class resolution
Posted by Jochen Theodorou <bl...@gmx.org>.
On 14.01.19 18:23, Daniil Ovchinnikov wrote:
> Hi all -
>
> So I’ve been investigating https://youtrack.jetbrains.com/issue/IDEA-204305 for a while now
> and found out that getClassNode() in anonymous ClassWriter in CompilationUnit#createClassVisitor
> still uses class loader to obtain class node instead of relying on AsmReferenceResolver.
>
> Is this expected?
You mean this here:
https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L899
you are correct in that this is wrong and should instead use
getClassNodeResolver().
bye Jochen