Skip to content

Commit

Permalink
Use JVM 1.7 bytecodes by default for JVM >= 1.7. Fixes #2077.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Oct 29, 2014
1 parent 0732187 commit 8942235
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Expand Up @@ -60,6 +60,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -1601,6 +1602,15 @@ public boolean shouldPrecompileAll() {
////////////////////////////////////////////////////////////////////////////
// Static configuration fields, used as defaults for new JRuby instances.
////////////////////////////////////////////////////////////////////////////

// NOTE: These BigDecimal fields must be initialized before calls to initGlobalJavaVersion

/** A BigDecimal representing 1.5, for Java spec version matching */
private static final BigDecimal BIGDECIMAL_1_5 = new BigDecimal("1.5");
/** A BigDecimal representing 1.6, for Java spec version matching */
private static final BigDecimal BIGDECIMAL_1_6 = new BigDecimal("1.6");
/** A BigDecimal representing 1.7, for Java spec version matching */
private static final BigDecimal BIGDECIMAL_1_7 = new BigDecimal("1.7");

/**
* The version to use for generated classes. Set to current JVM version by default
Expand Down Expand Up @@ -1842,18 +1852,17 @@ public boolean shouldPrecompileAll() {
////////////////////////////////////////////////////////////////////////////
// Static initializers
////////////////////////////////////////////////////////////////////////////

private static int initGlobalJavaVersion() {
String specVersion = Options.BYTECODE_VERSION.load();

// stack map calculation is failing for some compilation scenarios, so
// forcing both 1.5 and 1.6 to use 1.5 bytecode for the moment.
if (specVersion.equals("1.5")) {// || specVersion.equals("1.6")) {
return Opcodes.V1_5;
} else if (specVersion.equals("1.6")) {
return Opcodes.V1_6;
} else if (specVersion.equals("1.7") || specVersion.equals("1.8")) {
BigDecimal specDecimal = new BigDecimal(specVersion);

if (specDecimal.compareTo(BIGDECIMAL_1_7) >= 0) {
return Opcodes.V1_7;
} else if (specDecimal.compareTo(BIGDECIMAL_1_6) >= 0) {
return Opcodes.V1_6;
} else if (specDecimal.compareTo(BIGDECIMAL_1_5) >= 0) {
return Opcodes.V1_5;
} else {
throw new RuntimeException("unsupported Java version: " + specVersion);
}
Expand Down

0 comments on commit 8942235

Please sign in to comment.