You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (Jira)" <ji...@apache.org> on 2019/11/25 08:24:00 UTC
[jira] [Comment Edited] (GROOVY-9315) Bump bytecode version to 1.8
[ https://issues.apache.org/jira/browse/GROOVY-9315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16981217#comment-16981217 ]
Daniel Sun edited comment on GROOVY-9315 at 11/25/19 8:23 AM:
--------------------------------------------------------------
bq. That place should be CompilerConfiguration.setTargetBytecode.
{{CompilerConfiguration#targetBytecode}} is something like 1.4, 1.8, which is can not be used in ASM API directly. So we have to map the {{targetBytecode}} to ASM's targetBytecode, e.g. {{Opcodes.V1_4}}, {{Opcodes.V1_8}}. The mapping logic is implemented in {{CompilerConfiguration.setTargetBytecode}} too:
{code:java}
public void setTargetBytecode(String version) {
setTargetBytecodeIfValid(version);
}
private void setTargetBytecodeIfValid(String version) {
if (JDK_TO_BYTECODE_VERSION_MAP.containsKey(version)) {
this.targetBytecode = version;
this.asmTargetBytecode = JDK_TO_BYTECODE_VERSION_MAP.get(this.targetBytecode); // set ASM targetBytecode
}
}
{code}
As for {{asmTargetBytecode}}, it has only getter.
bq. What is the difference between "parse mode" and "compute mode"?
compute mode is for {{ClassWriter}}, e.g. {{ClassWriter.COMPUTE_FRAMES}}
and parse mode is for {{ClassReader}}, e.g. {{ClassReader.SKIP_FRAMES}}
bq. Can this wait for Groovy 3.0.1 or Groovy 4?
If you have more suggestions, we should have time to tweak the PR before Groovy 3.0.0-rc-2 release.
was (Author: daniel_sun):
bq. That place should be CompilerConfiguration.setTargetBytecode.
{{CompilerConfiguration#targetBytecode}} is something like 1.4, 1.8, which is can not be used in ASM API directly. So we have to map the {{targetBytecode}} to ASM's targetBytecode, e.g. {{Opcodes.V1_4}}, {{Opcodes.V1_8}}.
bq. What is the difference between "parse mode" and "compute mode"?
compute mode is for {{ClassWriter}}, e.g. {{ClassWriter.COMPUTE_FRAMES}}
and parse mode is for {{ClassReader}}, e.g. {{ClassReader.SKIP_FRAMES}}
bq. Can this wait for Groovy 3.0.1 or Groovy 4?
If you have more suggestions, we should have time to tweak the PR before Groovy 3.0.0-rc-2 release.
> Bump bytecode version to 1.8
> ----------------------------
>
> Key: GROOVY-9315
> URL: https://issues.apache.org/jira/browse/GROOVY-9315
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 3.0.0-rc-2
>
> Time Spent: 2h
> Remaining Estimate: 0h
>
> Groovy 3.0.0 requires Java 8+ and supports Java8 language features, so it's better to use its relevant class file version, i.e. 1.8
> In the old codebase, we can not manage the bytecode version well, for example, we use many bytecode versions to generate bytecode, some very old bytecode versions like {{1.3}} are still used.
> What I propose to do is manage the default bytecode code version in a place, same for its relevant compute mode and parse mode. If we want to change them, just modify only one place.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)