本文整理汇总了Java中org.apache.tools.ant.util.JavaEnvUtils.isAtLeastJavaVersion方法的典型用法代码示例。如果您正苦于以下问题:Java JavaEnvUtils.isAtLeastJavaVersion方法的具体用法?Java JavaEnvUtils.isAtLeastJavaVersion怎么用?Java JavaEnvUtils.isAtLeastJavaVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.util.JavaEnvUtils
的用法示例。
在下文中一共展示了JavaEnvUtils.isAtLeastJavaVersion方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
@Override
public void execute() throws BuildException {
String src = getSource();
if (src.matches("\\d+")) {
src = "1." + src;
}
if (!JavaEnvUtils.isAtLeastJavaVersion(src)) {
log("Cannot handle -source " + src + " from this VM; forking " + maybeFork, Project.MSG_WARN);
super.setFork(true);
super.setExecutable(maybeFork);
}
generatedClassesDir = new File(getDestdir().getParentFile(), getDestdir().getName() + "-generated");
if (!usingExplicitIncludes) {
cleanUpStaleClasses();
}
cleanUpDependDebris();
super.execute();
}
示例2: configureForRedirectExtension
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
/**
* If we end up using the JDK's own TraX factory on Java 9+, then
* set the features and attributes necessary to allow redirect
* extensions to be used.
* @since Ant 1.9.8
*/
protected void configureForRedirectExtension() {
XSLTProcess.Factory factory = createFactory();
String factoryName = factory.getName();
if (factoryName == null) {
try {
factoryName = TransformerFactory.newInstance().getClass().getName();
} catch (TransformerFactoryConfigurationError exc) {
throw new BuildException(exc);
}
}
if (JDK_INTERNAL_FACTORY.equals(factoryName)
&& JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
factory.addFeature(new XSLTProcess.Factory.Feature(
"http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions",
true));
}
}
示例3: eval
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
/**
* Evaluate the condition.
* @return true if there enough free space.
* @throws BuildException if there is a problem.
*/
@Override
public boolean eval() throws BuildException {
validate();
try {
if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
//reflection to avoid bootstrap/build problems
File fs = new File(partition);
ReflectWrapper w = new ReflectWrapper(fs);
long free = w.<Long> invoke("getFreeSpace").longValue();
return free >= StringUtils.parseHumanSizes(needed);
}
throw new BuildException(
"HasFreeSpace condition not supported on Java5 or less.");
} catch (Exception e) {
throw new BuildException(e);
}
}
示例4: assumedJavaVersion
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
private String assumedJavaVersion() {
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
return JAVAC14;
}
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
return JAVAC15;
}
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
return JAVAC16;
}
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
return JAVAC17;
}
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
return JAVAC18;
}
if (JavaEnvUtils.isAtLeastJavaVersion("10")) {
return JAVAC10_PLUS;
}
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_9)) {
return JAVAC9;
}
return CLASSIC;
}
示例5: setJavaVersionProperty
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
/**
* Set the <code>ant.java.version</code> property and tests for
* unsupported JVM versions. If the version is supported,
* verbose log messages are generated to record the Java version
* and operating system name.
*
* @exception BuildException if this Java version is not supported.
*
* @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion
*/
public void setJavaVersionProperty() throws BuildException {
final String javaVersion = JavaEnvUtils.getJavaVersion();
setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);
// sanity check
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_8)) {
throw new BuildException("Ant cannot work on Java prior to 1.8");
}
log("Detected Java version: " + javaVersion + " in: "
+ System.getProperty("java.home"), MSG_VERBOSE);
log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
}
示例6: getAdapter
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
/**
* Creates the JavahAdapter based on the user choice and
* potentially the VM vendor.
*
* @param choice the user choice (if any).
* @param log a ProjectComponent instance used to access Ant's
* logging system.
* @param classpath the classpath to use when looking up an
* adapter class
* @return The adapter to use.
* @throws BuildException if there is an error.
* @since Ant 1.8.0
*/
public static JavahAdapter getAdapter(String choice,
ProjectComponent log,
Path classpath)
throws BuildException {
if ((JavaEnvUtils.isKaffe() && choice == null)
|| Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
return new Kaffeh();
}
if ((JavaEnvUtils.isGij() && choice == null)
|| Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
return new Gcjh();
}
if (JavaEnvUtils.isAtLeastJavaVersion("10") &&
(choice == null || ForkingJavah.IMPLEMENTATION_NAME.equals(choice))) {
throw new BuildException("javah does not exist under Java 10 and higher,"
+ " use the javac task with nativeHeaderDir instead");
}
if (ForkingJavah.IMPLEMENTATION_NAME.equals(choice)) {
return new ForkingJavah();
}
if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) {
return new SunJavah();
}
if (choice != null) {
return resolveClassName(choice,
// Memory leak in line below
log.getProject()
.createClassLoader(classpath));
}
return new ForkingJavah();
}
示例7: applyReflectionHackForExtensionMethods
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
private void applyReflectionHackForExtensionMethods() {
// Jigsaw doesn't allow reflection to work, so we can stop trying
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
try { // #51668, #52382
final Field _isNotSecureProcessing = tfactory.getClass().getDeclaredField("_isNotSecureProcessing");
_isNotSecureProcessing.setAccessible(true);
_isNotSecureProcessing.set(tfactory, Boolean.TRUE);
} catch (final Exception x) {
if (project != null) {
project.log(x.toString(), Project.MSG_DEBUG);
}
}
}
}
示例8: assumeJava9Plus
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
/**
* Shall we assume JDK 9+ command line switches?
* @return true if JDK 9+
* @since Ant 1.10.2
*/
protected boolean assumeJava9Plus() {
return "javac1.9".equals(attributes.getCompilerVersion())
|| "javac9".equals(attributes.getCompilerVersion())
|| "javac10+".equals(attributes.getCompilerVersion())
|| (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)
&& ("classic".equals(attributes.getCompilerVersion())
|| "modern".equals(attributes.getCompilerVersion())
|| "extJavac".equals(attributes.getCompilerVersion())));
}
示例9: verifyArguments
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
private void verifyArguments(Commandline cmd) {
if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
for (String arg : cmd.getArguments()) {
if ("-Xnew".equals(arg)) {
throw new BuildException("JDK9 has removed support for -Xnew");
}
}
}
}
示例10: getRmic
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
/**
* Based on the parameter passed in, this method creates the necessary
* factory desired.
*
* <p>The current mapping for rmic names are as follows:</p>
* <ul><li>sun = SUN's rmic
* <li>kaffe = Kaffe's rmic
* <li><i>a fully qualified classname</i> = the name of a rmic
* adapter
* <li>weblogic = weblogic compiler
* <li>forking = Sun's RMIC by forking a new JVM
* </ul>
*
* @param rmicType either the name of the desired rmic, or the
* full classname of the rmic's adapter.
* @param task a task to log through.
* @param classpath the classpath to use when looking up an
* adapter class
* @return the compiler adapter
* @throws BuildException if the rmic type could not be resolved into
* a rmic adapter.
* @since Ant 1.8.0
*/
public static RmicAdapter getRmic(String rmicType, Task task,
Path classpath)
throws BuildException {
//handle default specially by choosing the sun or kaffe compiler
if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.length() == 0) {
if (KaffeRmic.isAvailable()) {
rmicType = KaffeRmic.COMPILER_NAME;
} else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
rmicType = ForkingSunRmic.COMPILER_NAME;
} else {
rmicType = SunRmic.COMPILER_NAME;
}
}
if (SunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
return new SunRmic();
}
if (KaffeRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
return new KaffeRmic();
}
if (WLRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
return new WLRmic();
}
if (ForkingSunRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
return new ForkingSunRmic();
}
if (XNewRmic.COMPILER_NAME.equalsIgnoreCase(rmicType)) {
return new XNewRmic();
}
//no match?
return resolveClassName(rmicType,
// Memory leak in line below
task.getProject().createClassLoader(classpath));
}
示例11: xnewTest
import org.apache.tools.ant.util.JavaEnvUtils; //导入方法依赖的package包/类
private void xnewTest(String target) {
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
buildRule.executeTarget(target);
} else {
try {
buildRule.executeTarget(target);
fail("Target should have thrown a BuildException");
} catch (BuildException ex) {
assertEquals("JDK9 has removed support for -Xnew", ex.getMessage());
}
}
}