Java 类org.apache.commons.lang3.JavaVersion 实例源码

项目:rug-cli    文件:VersionUtils.java   
public static void validateJdkVersion() {
    boolean warn = false;
    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
        // We need 1.8.0_111 at least
        String version = SystemUtils.JAVA_VERSION;
        int ix = version.lastIndexOf('_');
        if (ix > 0) {
            int patch = Integer.valueOf(version.substring(ix + 1));
            if (patch < 111) {
                warn = true;
            }
        }
    }
    else {
        // Not even Java 1.8
        warn = true;
    }

    if (warn) {
        new Log(VersionUtils.class).info(Style.yellow(
                "Please update your Java™ Runtime Environment (JRE) from %s to version 1.8.0_111 or newer.",
                SystemUtils.JAVA_VERSION));
    }
}
项目:warp10-platform    文件:NOTBEFORE.java   
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  Object top = stack.pop();

  long instant;

  if (top instanceof String) {
    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
      instant = io.warp10.script.unary.TOTIMESTAMP.parseTimestamp(top.toString());
    } else {
      instant = fmt.parseDateTime((String) top).getMillis() * Constants.TIME_UNITS_PER_MS;
    }
  } else if (!(top instanceof Long)) {
    throw new WarpScriptException(getName() + " expects a timestamp or ISO8601 datetime string on top of the stack.");
  } else {
    instant = ((Number) top).longValue();
  }

  long now = TimeSource.getTime();

  if (now < instant) {
    throw new WarpScriptException("Current time is before '" + top + "'");
  }

  return stack;
}
项目:warp10-platform    文件:NOTAFTER.java   
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
  Object top = stack.pop();

  long instant;

  if (top instanceof String) {
    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
      instant = io.warp10.script.unary.TOTIMESTAMP.parseTimestamp(top.toString());
    } else {
      instant = fmt.parseDateTime((String) top).getMillis() * Constants.TIME_UNITS_PER_MS;
    }
  } else if (!(top instanceof Long)) {
    throw new WarpScriptException(getName() + " expects a timestamp or ISO8601 datetime string on top of the stack.");
  } else {
    instant = ((Number) top).longValue();
  }

  long now = TimeSource.getTime();

  if (now > instant) {
    throw new WarpScriptException("Current time is after '" + top + "'");
  }

  return stack;
}
项目:google-cloud-intellij    文件:AppEngineJavaeeSupportContributor.java   
@Override
public void setupFrameworkSupport(JavaeeFrameworkSupportContributionModel model) {
  AppEngineStandardFacet appEngineStandardFacet = model.getFacet(AppEngineStandardFacetType.ID);
  if (appEngineStandardFacet == null) {
    return;
  }

  if (appEngineStandardFacet.getRuntimeJavaVersion().equals(JavaVersion.JAVA_1_7)) {
    setWebXmlServletVersion(model.getModule());
  }

  Artifact artifactToDeploy = model.getExplodedEarArtifact();
  if (artifactToDeploy == null) {
    artifactToDeploy = model.getExplodedWarArtifact();
  }
  if (artifactToDeploy != null) {
    AppEngineStandardWebIntegration.getInstance()
        .setupRunConfigurations(artifactToDeploy, model.getModule(), model.getRunConfiguration());
  }
}
项目:google-cloud-intellij    文件:AppEngineStandardUnsupportedJavaVersionCheck.java   
private List<Module> findAppEngineModulesUsingUnsupportedLanguageLevel(final Project project) {
  final Module[] projectModules = ModuleManager.getInstance(project).getModules();
  final List<Module> invalidModules = new ArrayList<>();

  ApplicationManager.getApplication()
      .runReadAction(
          () -> {
            Arrays.stream(projectModules)
                .filter(this::usesJava8OrGreater)
                .filter(
                    module -> {
                      AppEngineStandardFacet facet =
                          AppEngineStandardFacet.getAppEngineFacetByModule(module);
                      return !(facet == null || facet.isNonStandardCompatEnvironment())
                          && facet.getRuntimeJavaVersion().compareTo(JavaVersion.JAVA_1_8) < 0;
                    })
                .forEach(invalidModules::add);
          });
  return invalidModules;
}
项目:gwt-commons-codec    文件:HmacAlgorithmsTest.java   
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
    List<Object[]> list = Arrays.asList(
    // @formatter:off
            new Object[][] { { HmacAlgorithms.HMAC_MD5, STANDARD_MD5_RESULT_BYTES, STANDARD_MD5_RESULT_STRING },
                    { HmacAlgorithms.HMAC_SHA_1, STANDARD_SHA1_RESULT_BYTES, STANDARD_SHA1_RESULT_STRING },
                    { HmacAlgorithms.HMAC_SHA_256, STANDARD_SHA256_RESULT_BYTES, STANDARD_SHA256_RESULT_STRING },
                    { HmacAlgorithms.HMAC_SHA_384, STANDARD_SHA384_RESULT_BYTES, STANDARD_SHA384_RESULT_STRING },
                    { HmacAlgorithms.HMAC_SHA_512, STANDARD_SHA512_RESULT_BYTES, STANDARD_SHA512_RESULT_STRING } });
    // @formatter:on
    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
        list = new ArrayList<Object[]>(list);
        list.add(new Object[] {HmacAlgorithms.HMAC_SHA_224, STANDARD_SHA224_RESULT_BYTES, STANDARD_SHA224_RESULT_STRING});
    }
    return list;
}
项目:CustomWorldGen    文件:BlamingTransformer.java   
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
{
    if( (version == Opcodes.V1_8 && !SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) ||
        (version == Opcodes.V1_7 && !SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)) )
    {
        if(classMap.containsKey(name)) blame(classMap.get(name), name);
        else orphanNaughtyClasses.add(name);
    }
}
项目:google-cloud-intellij    文件:AppEngineStandardFacet.java   
/**
 * Returns the {@link JavaVersion} of the Java runtime, as defined in the {@code
 * appengine-web.xml}.
 *
 * <p>If no runtime is specified in the {@code appengine-web.xml} or if the specified runtime is
 * not valid, {@link JavaVersion#JAVA_1_7} is returned.
 */
public JavaVersion getRuntimeJavaVersion() {
  AppEngineStandardWebApp appEngineStandardWebApp = getAppEngineStandardWebXml();
  if (appEngineStandardWebApp != null) {
    String runtimeString = appEngineStandardWebApp.getRuntime().getStringValue();
    JavaVersion runtimeVersion = RUNTIMES_MAP.get(runtimeString);
    if (runtimeVersion != null) {
      return runtimeVersion;
    }
  }

  // The default runtime is Java 7.
  return JavaVersion.JAVA_1_7;
}
项目:Java-Checker    文件:JavaCheckerReporter.java   
public static void reportOutdatedJava(JavaVersion minVersion){
    String consoleReport = getConsoleReport(minVersion);

    if (!ForgeCompatibility.tryLog(consoleReport)){
        System.out.println(consoleReport);
    }

    if (!GraphicsEnvironment.isHeadless() && ForgeCompatibility.isClientSide()){
        displayErrorPopup("Outdated Java", getHtmlReport(minVersion));
    }
}
项目:Java-Checker    文件:JavaCheckerReporter.java   
private static String getConsoleReport(JavaVersion minVersion){
    return
        "\n\n!! DO NOT REPORT !!\n\n"+
        "One of the mods requires Java "+minVersion+" or newer, you are using "+SystemUtils.JAVA_VERSION+".\n"+
        "Visit https://java.com/download/ for the latest version.\n"+
        "Please, uninstall the old version first to prevent further issues."+
        "\n\n!! DO NOT REPORT !!\n";
}
项目:Java-Checker    文件:JavaVersionChecker.java   
public static void run(JavaVersion minVersion){
    try{
        unsafeRun(minVersion);
    }catch(OutdatedJavaException me){
        throw me;
    }catch(ShadingException up){
        throw up;
    }catch(Throwable t){
        t.printStackTrace();
        System.out.println("Detected an unexpected error in Java Version Checker, ignoring since trying to run the game is more important.");
        System.out.println("If you crashed and happen to see this, please report the error above to: "+issueReportSite);
    }
}
项目:Java-Checker    文件:JavaVersionChecker.java   
private static void unsafeRun(JavaVersion minVersion){
    if (minVersion == null || !SystemUtils.isJavaVersionAtLeast(minVersion)){
        if (minVersion == null)minVersion = JavaVersion.JAVA_1_8; // debugging purposes

        JavaCheckerReporter.reportOutdatedJava(minVersion);
        throw new OutdatedJavaException();
    }
    else{
        if (isShaded() && !ForgeCompatibility.tryResetModState()){
            throw new ShadingException();
        }
    }
}
项目:HCoreLib    文件:InCompatibleJavaException.java   
/**
 * Runs Java version checker.
 *
 * @param javaVersion Java version to check for.
 * @return boolean result.
 */
public static boolean runCheck(JavaVersion javaVersion) {
    if (!SystemUtils.isJavaVersionAtLeast(javaVersion))
        throw new InCompatibleJavaException(String.format("Version: %s of java is not supported! Please update your Java to at least version %s!",
                SystemInfo.instance().getJavaVersion(), javaVersion.toString()));

    return true;
}
项目:HCoreLib    文件:HCoreLibMain.java   
@EventHandler
@Override
public void preInit(FMLPreInitializationEvent event) {
    tl = new TimeLapse();
    logHelper = new LogHelper(LibReference.MOD_ID);

    final boolean result = JavaCompatibility.runCheck(JavaVersion.JAVA_1_8);
    if (result)
        logHelper.info("Java version is compatible!");

    logHelper.info("Pre-init started, looking for config info!");
    configHandler = new ConfigHandler(event, LibReference.MOD_ID);
    configHandler.handleConfiguration();
    logHelper.info("Config info handled successfully! Applying changes now!");

    final Side side = FMLCommonHandler.instance().getEffectiveSide();
    if (side == Side.CLIENT) {
        logHelper.info("Attempting to inject data to mcmod.info file!");

        final McModInfoDataInjector mcModInfoDataInjector = new McModInfoDataInjector(event, logHelper);
        mcModInfoDataInjector.injectData(false, new String[] { "hockeyhurd" }, LibReference.MOD_ID, LibReference.VERSION, LibReference.HOMEPAGE_URL, null,
                "A simple library for all of hockeyhurd's mods and anyone who wishes to use this as well.");

        if (mcModInfoDataInjector.getResult())
            logHelper.info("Injection was successful!");
        else
            logHelper.warn("Injection was un-successful! mcmod.info is a liar!");
    }

    proxy.preInit();

    logHelper.info("Pre-init finished successfully after", tl.getEffectiveTimeSince(), "ms!");
}
项目:warp10-platform    文件:TIMECLIP.java   
@Override
protected Map<String, Object> retrieveParameters(WarpScriptStack stack) throws WarpScriptException {


  Object top = stack.pop();

  long start;

  boolean iso8601 = false;

  if (top instanceof String) {
    iso8601 = true;
    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
      start = io.warp10.script.unary.TOTIMESTAMP.parseTimestamp(top.toString());
    } else {
      start = fmt.parseDateTime(top.toString()).getMillis() * Constants.TIME_UNITS_PER_MS;
    }
  } else if (!(top instanceof Long)) {
    throw new WarpScriptException(getName() + " expects either an ISO8601 timestamp as the origin timestamp or a duration.");
  } else {
    start = (long) top;
  }

  long end;

  top = stack.pop();

  if (top instanceof String) {      
    if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
      end = io.warp10.script.unary.TOTIMESTAMP.parseTimestamp(top.toString());
    } else {
      end = fmt.parseDateTime(top.toString()).getMillis() * Constants.TIME_UNITS_PER_MS;
    }
  } else if (!(top instanceof Long)) {
    throw new WarpScriptException(getName() + " expects either an ISO8601 timestamp or a delta since Unix Epoch as 'now' parameter.");
  } else {
    end = (long) top;
  }

  if (!iso8601) {
    start = end - start + 1;
  }

  Map<String,Object> params = new HashMap<String, Object>();

  params.put(START, start);
  params.put(END, end);

  return params;
}
项目:Java-Checker    文件:Java8Checker.java   
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader){
    JavaVersionChecker.run(JavaVersion.JAVA_1_8);
}
项目:Java-Checker    文件:JavaCheckerReporter.java   
private static String getHtmlReport(JavaVersion minVersion){
    return
        "One of the mods requires Java "+minVersion+" or newer, you are using "+SystemUtils.JAVA_VERSION+".<br>"+
        "Visit <a href=\"https://java.com/download/\"><span style=\"color:blue\">https://java.com/download/</span></a> for the latest version.<br>"+
        "Please, uninstall the old version first to prevent further issues.";
}
项目:Java-Checker    文件:Java7Checker.java   
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader){
    JavaVersionChecker.run(JavaVersion.JAVA_1_7);
}
项目:junit-servers    文件:AtLeastJava8.java   
@Override
public boolean apply() {
    return SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8);
}
项目:gwt-commons-codec    文件:DigestUtilsTest.java   
private void assumeJava8() {
    Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8));
}
项目:logging-log4j2    文件:MongoDbTestTestRuleTestJava8.java   
@BeforeClass
public static void beforeClass() {
    Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8));
}
项目:logging-log4j2    文件:Java8Test.java   
@BeforeClass
public static void beforeClass() {
    Assume.assumeTrue(SystemUtils.JAVA_VERSION, SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8));
}
项目:logging-log4j2    文件:MongoDbTestTestRuleTestJava8.java   
@BeforeClass
public static void beforeClass() {
    Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8));
}
项目:logging-log4j2    文件:Java8Test.java   
@BeforeClass
public static void beforeClass() {
    Assume.assumeTrue(SystemUtils.JAVA_VERSION, SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8));
}
项目:nbone    文件:Test.java   
public static void main(String[] args) {

    System.out.println(JdkVersion.getJavaVersion());
    System.out.println(JavaVersion.JAVA_1_8);
    System.out.println(SpringVersion.getVersion());

}