/** * Return the version of Java this class is running under. * @return the version of Java as a String, e.g. "1.1" . * @see org.apache.tools.ant.util.JavaEnvUtils#getJavaVersion * @deprecated since 1.5.x. * Use org.apache.tools.ant.util.JavaEnvUtils instead. */ @Deprecated public static String getJavaVersion() { return JavaEnvUtils.getJavaVersion(); }
/** * add any libraries that come with different java versions * here */ public void addJavaLibraries() { Vector packages = JavaEnvUtils.getJrePackages(); Enumeration e = packages.elements(); while (e.hasMoreElements()) { String packageName = (String) e.nextElement(); addSystemPackageRoot(packageName); } }
/** * Whether the iiop and idl switches are supported. * * <p>This implementation returns false if running on Java 11 * onwards and true otherwise.</p> * @return true if the iiop and idl switches are supported * @since Ant 1.10.3 */ protected boolean areIiopAndIdlSupported() { return !JavaEnvUtils.isAtLeastJavaVersion("11"); }
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; }
jExecutable = findInDir(JAVA_HOME + "/sh", command); jExecutable = findInDir(JAVA_HOME + "/bin", command); return addExtension(command);
/** * Constructor uses the VM we are running on now. */ public CommandlineJava() { setVm(JavaEnvUtils.getJreExecutable("java")); setVmversion(JavaEnvUtils.getJavaVersion()); }
/** * 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); }
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,"
/** * Shall we assume command line switches for the given version of Java? * @since Ant 1.8.3 */ private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) { return javacXY.equals(attributes.getCompilerVersion()) || (JavaEnvUtils.isJavaVersion(javaEnvVersionXY) && ("classic".equals(attributes.getCompilerVersion()) || "modern".equals(attributes.getCompilerVersion()) || "extJavac".equals(attributes.getCompilerVersion()))); }
/** * get a vector of strings of packages built into * that platforms runtime jar(s) * @return list of packages. */ public static Vector<String> getJrePackages() { if (jrePackages == null) { buildJrePackages(); } return jrePackages; }
/** * Look for an executable in a given directory. * * @return null if the executable cannot be found. */ private static File findInDir(String dirName, String commandName) { File dir = FILE_UTILS.normalize(dirName); File executable = null; if (dir.exists()) { executable = new File(dir, addExtension(commandName)); if (!executable.exists()) { executable = null; } } return executable; }
if (!JavaEnvUtils.isJavaVersion("1.0") && !JavaEnvUtils.isJavaVersion("1.1"))
createClasspathArgument(cmd, sourcepath); final String javaVersion = JavaEnvUtils.getJavaVersion(); String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$ if (this.memoryInitialSize != null) {
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"); } } } }
/** * add any libraries that come with different java versions * here */ public void addJavaLibraries() { JavaEnvUtils.getJrePackages().forEach(this::addSystemPackageRoot); }
createClasspathArgument(cmd, classpath); final String javaVersion = JavaEnvUtils.getJavaVersion(); String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$ if (this.memoryInitialSize != null) {
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); } } } }
/** * add any libraries that come with different java versions * here */ public void addJavaLibraries() { Vector packages = JavaEnvUtils.getJrePackages(); Enumeration e = packages.elements(); while (e.hasMoreElements()) { String packageName = (String) e.nextElement(); addSystemPackageRoot(packageName); } }
createClasspathArgument(cmd, sourcepath); final String javaVersion = JavaEnvUtils.getJavaVersion(); String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$ if (this.memoryInitialSize != null) {
if (isAtLeastJavaVersion(JAVA_1_1)) { jrePackages.addElement("javax"); if (isAtLeastJavaVersion(JAVA_1_2)) { jrePackages.addElement("com.sun.java"); jrePackages.addElement("com.sun.image"); if (isAtLeastJavaVersion(JAVA_1_3)) { jrePackages.addElement("org.omg"); jrePackages.addElement("com.sun.corba"); jrePackages.addElement("sunw.util"); if (isAtLeastJavaVersion(JAVA_1_4)) { if (javaVersionNumber == VERSION_1_4) { jrePackages.addElement("org.apache.crimson"); jrePackages.addElement("org.xml.sax"); if (isAtLeastJavaVersion(JAVA_1_5)) { if (isAtLeastJavaVersion(JAVA_1_7)) { jrePackages.addElement("jdk");