java.lang.Package.isCompatibleWith()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(221)

本文整理了Java中java.lang.Package.isCompatibleWith()方法的一些代码示例,展示了Package.isCompatibleWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.isCompatibleWith()方法的具体详情如下:
包路径:java.lang.Package
类名称:Package
方法名:isCompatibleWith

Package.isCompatibleWith介绍

[英]Indicates whether this package's specification version is compatible with the specified version string. Version strings are compared by comparing each dot separated part of the version as an integer.
[中]指示此包的规范版本是否与指定的版本字符串兼容。通过将版本的每个点分隔部分作为整数进行比较,来比较版本字符串。

代码示例

代码示例来源:origin: stackoverflow.com

Class<?> thirdPartyClass = org.apache.log4j.Logger.class;
if (thirdPartyClass.getPackage().isCompatibleWith("2.0")) {
  // Do stuff specific to Log4j 2
}

代码示例来源:origin: stackoverflow.com

if (System.class.getPackage().isCompatibleWith("1.6")) {
  System.out.println("Running in Java 1.6 or later.");
}

代码示例来源:origin: org.concordion/concordion

private static boolean isCompatible(String extensionClassName, String requiredSpecificationVersion) {
    boolean compatible;
    try {
      Class<?> extensionClass = Class.forName(extensionClassName);
      Package extensionPackage = extensionClass.getPackage();
      String specificationVersion = extensionPackage.getSpecificationVersion();
      compatible = specificationVersion != null && extensionPackage.isCompatibleWith(requiredSpecificationVersion);
    } catch (ClassNotFoundException expected) {
      compatible = true;  // Passes the check since it's not on classpath
    }
    return compatible;
  }
}

代码示例来源:origin: concordion/concordion

private static boolean isCompatible(String extensionClassName, String requiredSpecificationVersion) {
    boolean compatible;
    try {
      Class<?> extensionClass = Class.forName(extensionClassName);
      Package extensionPackage = extensionClass.getPackage();
      String specificationVersion = extensionPackage.getSpecificationVersion();
      compatible = specificationVersion != null && extensionPackage.isCompatibleWith(requiredSpecificationVersion);
    } catch (ClassNotFoundException expected) {
      compatible = true;  // Passes the check since it's not on classpath
    }
    return compatible;
  }
}

代码示例来源:origin: stackoverflow.com

public class Redirector
extends Applet {
  @Override
  public void start() {
    String newURL;

    Package pkg = Object.class.getPackage();
    if (pkg.isCompatibleWith("1.7")) {
      newURL = "java17.html";
    } else if (pkg.isCompatibleWith("1.6")) {
      newURL = "java16.html";
    } else if (pkg.isCompatibleWith("1.5")) {
      newURL = "java15.html";
    } else if (pkg.isCompatibleWith("1.4")) {
      newURL = "java14.html";
    } else {
      newURL = "java13.html";
    }

    try {
      getAppletContext().showDocument(new URL(newURL));
    } catch (MalformedURLException e) {
      showStatus(e.toString());
    }
  }
}

代码示例来源:origin: com.caucho/resin

name, version, manifestName));
else if (! pkg.isCompatibleWith(version)) {
 log.warning(L.l("installed {0} is not compatible with version `{1}'.  {2} requires version {1}.",
        name, version, manifestName));

代码示例来源:origin: baratine/baratine

name, version, manifestName));
else if (! pkg.isCompatibleWith(version)) {
 log.warning(L.l("installed {0} is not compatible with version `{1}'.  {2} requires version {1}.",
        name, version, manifestName));

代码示例来源:origin: net.jxta/jxta-jxse

formatOk = specMatches && javaLangPackage.isCompatibleWith(version);
} else if (STD_COMPAT_BINDING.equals(key) && STD_COMPAT_BINDING_VALUE.equals(val)) {
  bindingOk = true;

相关文章