[ https://issues.apache.org/jira/browse/GROOVY-9315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16981695#comment-16981695 ]
Eric Milles edited comment on GROOVY-9315 at 11/25/19 4:48 PM: --------------------------------------------------------------- {code:java} bytecodeVersion = chooseBytecodeVersion(invokedynamic, config.isPreviewFeatures(), config.getTargetBytecode()); private static int chooseBytecodeVersion(final boolean invokedynamic, final boolean previewFeatures, final String targetBytecode) { Integer bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode); if (invokedynamic && bytecodeVersion < Opcodes.V1_8) { return Opcodes.V1_8; } else { if (null != bytecodeVersion) { return previewFeatures ? bytecodeVersion | Opcodes.V_PREVIEW : bytecodeVersion; } } throw new GroovyBugError("Bytecode version ["+targetBytecode+"] is not supported by the compiler"); } {code} was (Author: emilles): Here is how WriterController is handling it: ```java bytecodeVersion = chooseBytecodeVersion(invokedynamic, config.isPreviewFeatures(), config.getTargetBytecode()); private static int chooseBytecodeVersion(final boolean invokedynamic, final boolean previewFeatures, final String targetBytecode) { Integer bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode); if (invokedynamic && bytecodeVersion < Opcodes.V1_8) { return Opcodes.V1_8; } else { if (null != bytecodeVersion) { return previewFeatures ? bytecodeVersion | Opcodes.V_PREVIEW : bytecodeVersion; } } throw new GroovyBugError("Bytecode version ["+targetBytecode+"] is not supported by the compiler"); } ``` > 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)