CompilerConfiguration (@Nullable String targetBytecode) { CompilerConfiguration config = new CompilerConfiguration(); if (targetBytecode != null) { config.setTargetBytecode(targetBytecode); } if (config.getTargetBytecode() == null) { // unsupported value (e.g. "1.6" with older Groovyc versions which know only 1.5) // clear env because CompilerConfiguration constructor just sets the target bytecode to null on encountering invalid value in the env System.clearProperty(GroovyRtConstants.GROOVY_TARGET_BYTECODE); // now recreate conf taking the default from VM version config = new CompilerConfiguration(); if (config.getTargetBytecode() == null) { throw new AssertionError("Cannot determine bytecode target"); } } return config; }