You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/01/24 12:02:59 UTC
[groovy] 01/08: restore support for invokedynamic=true and
targetBytecode=1.7
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 7d52a4e0bd9ad109a680fb18bf4cda374405a507
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Jan 22 16:06:49 2020 -0600
restore support for invokedynamic=true and targetBytecode=1.7
(cherry picked from commit 09ecc4ddd5cff6cb383cbc0e1d856dd606dbb1a9)
---
.../groovy/classgen/asm/WriterController.java | 24 ++++++++++------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java b/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java
index 4c124a9..daf249c 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java
@@ -112,7 +112,7 @@ public class WriterController {
this.unaryExpressionHelper = new UnaryExpressionHelper(this);
if (optimizeForInt) {
this.fastPathBinaryExpHelper = new BinaryExpressionMultiTypeDispatcher(this);
- // todo: replace with a real fast path unary expression helper when available
+ // TODO: replace with a real fast path unary expression helper when available
this.fastPathUnaryExpressionHelper = new UnaryExpressionHelper(this);
} else {
this.fastPathBinaryExpHelper = this.binaryExpHelper;
@@ -140,10 +140,7 @@ public class WriterController {
}
private ClassVisitor createClassVisitor(final ClassVisitor cv) {
- if (!LOG_CLASSGEN) {
- return cv;
- }
- if (cv instanceof LoggableClassVisitor) {
+ if (!LOG_CLASSGEN || cv instanceof LoggableClassVisitor) {
return cv;
}
return new LoggableClassVisitor(cv);
@@ -151,16 +148,17 @@ public class WriterController {
private static int chooseBytecodeVersion(final boolean invokedynamic, final boolean previewFeatures, final String targetBytecode) {
Integer bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode);
+ if (bytecodeVersion == null) {
+ throw new GroovyBugError("Bytecode version [" + targetBytecode + "] is not supported by the compiler");
+ }
- if (invokedynamic && bytecodeVersion < Opcodes.V1_8) {
- return Opcodes.V1_8;
+ if (invokedynamic && bytecodeVersion <= Opcodes.V1_7) {
+ return Opcodes.V1_7; // invokedynamic added here
+ } else if (previewFeatures) {
+ return bytecodeVersion | Opcodes.V_PREVIEW;
} else {
- if (null != bytecodeVersion) {
- return previewFeatures ? bytecodeVersion | Opcodes.V_PREVIEW : bytecodeVersion;
- }
+ return bytecodeVersion;
}
-
- throw new GroovyBugError("Bytecode version ["+targetBytecode+"] is not supported by the compiler");
}
public AsmClassGenerator getAcg() {
@@ -260,7 +258,7 @@ public class WriterController {
this.constructorNode = null;
}
- public ConstructorNode getConstructorNode(){
+ public ConstructorNode getConstructorNode() {
return constructorNode;
}