You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/04/28 17:34:00 UTC
[jira] [Assigned] (GROOVY-7700) Attribute access on same statically
compiled class should bypass ScriptBytecodeAdapter
[ https://issues.apache.org/jira/browse/GROOVY-7700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-7700:
-----------------------------------
Assignee: Eric Milles
> Attribute access on same statically compiled class should bypass ScriptBytecodeAdapter
> --------------------------------------------------------------------------------------
>
> Key: GROOVY-7700
> URL: https://issues.apache.org/jira/browse/GROOVY-7700
> Project: Groovy
> Issue Type: Improvement
> Components: Compiler, Static compilation
> Affects Versions: 2.4.5
> Reporter: Christopher Smith
> Assignee: Eric Milles
> Priority: Minor
>
> In Java, it's not unusual to directly access fields of another instance of the same class, for example in {{equals}}. In writing an AST transformation, I found that an attribute expression accessing a (private) field on the same class is written out as a convoluted call through {{ScriptBytecodeAdapter}}, which sends it through a roundabout trip through the metaclass:
> {code}
> Object localObject = null;ScriptBytecodeAdapter.setGroovyObjectField((SimpleEntity)ScriptBytecodeAdapter.castToType(localObject, SimpleEntity.class), OtherEntity.class, other, (String)"bar");
> {code}
> When the {{objectExpression}} of an attribute expression is on the same class as {{this}}, the compiler should use the trivial field access instruction, at least in static compilation mode.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)