Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/main/java/org/codehaus/gmavenplus/util/GroovyCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.CodeSource;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -250,6 +251,21 @@ public class GroovyCompiler {
*/
protected static final Version JAVA_12 = new Version(12);

/**
* The mapping of javac target to Groovy target bytecode.
*/
private static final Map<String, String> JAVAC_TARGET_TO_TARGET_BYTECODE;

static {
Map<String, String> javacTargetToTargetBytecode = new HashMap<>();
javacTargetToTargetBytecode.put("5", "1.5");
javacTargetToTargetBytecode.put("6", "1.6");
javacTargetToTargetBytecode.put("7", "1.7");
javacTargetToTargetBytecode.put("8", "1.8");
javacTargetToTargetBytecode.put("1.9", "9");
JAVAC_TARGET_TO_TARGET_BYTECODE = Collections.unmodifiableMap(javacTargetToTargetBytecode);
}

private final ClassWrangler classWrangler;
private final Log log;

Expand Down Expand Up @@ -758,13 +774,7 @@ protected void verifyGroovyVersionSupportsTargetBytecode(String targetBytecode)
}

public static String translateJavacTargetToTargetBytecode(String targetBytecode) {
Map<String, String> javacTargetToTargetBytecode = new HashMap<>();
javacTargetToTargetBytecode.put("5", "1.5");
javacTargetToTargetBytecode.put("6", "1.6");
javacTargetToTargetBytecode.put("7", "1.7");
javacTargetToTargetBytecode.put("8", "1.8");
javacTargetToTargetBytecode.put("1.9", "9");
return javacTargetToTargetBytecode.getOrDefault(targetBytecode, targetBytecode);
return JAVAC_TARGET_TO_TARGET_BYTECODE.getOrDefault(targetBytecode, targetBytecode);
}

protected boolean isJavaSupportIndy() {
Expand Down
Loading