• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.robolectric.internal.bytecode;
2 
3 import org.robolectric.util.JavaVersion;
4 
5 public class InvokeDynamic {
6   public static final boolean ENABLED = useInvokeDynamic();
7 
8   private static final String ENABLE_INVOKEDYNAMIC = "robolectric.invokedynamic.enable";
9   // We currently crash on versions earlier than 8u40 because of a bug in the C2 compiler.
10   // This seems to be the bug http://bugs.java.com/view_bug.do?bug_id=8059556 but I have been
11   // unable to pinpoint exactly why this affects us.
12   private static final String INVOKEDYNAMIC_MINIMUM_VERSION = "1.8.0_40";
13 
useInvokeDynamic()14   private static boolean useInvokeDynamic() {
15     String property = System.getProperty(ENABLE_INVOKEDYNAMIC);
16     if (property != null) {
17       return Boolean.valueOf(property);
18     } else {
19       JavaVersion javaVersion = new JavaVersion(System.getProperty("java.version"));
20       return javaVersion.compareTo(new JavaVersion(INVOKEDYNAMIC_MINIMUM_VERSION)) >= 0;
21     }
22   }
23 }
24