/** * Determines if the vm version will run the currently compiled code based on the compiler compliance lvl * @param vm the vm install * @param compliance the current compiler compliance level * @return true if the selected vm will run the current code, false otherwise * @since 3.3 */ private boolean supportsCurrentCompliance(IVMInstall vm, String compliance) { if(vm instanceof AbstractVMInstall) { AbstractVMInstall install = (AbstractVMInstall) vm; String vmver = install.getJavaVersion(); if(vmver == null) { //if we cannot get a version from the VM we must return true, and let the runtime //error sort it out return true; } int val = compliance.compareTo(vmver); return val < 0 || val == 0; } return false; }
/** * Compares the version of vm and a version of the Java platform. * * @param vm * IVMInstall to be compared * @param ver * version to be compared * @return the value {@code 0} if both versions are the same; a value less than {@code 0} if <code>vm</code> is smaller than <code>ver</code>; and * a value greater than {@code 0} if <code>vm</code> is higher than <code>ver</code>; a value {@code -1} in case of any exceptions; * * @since 3.10 */ public static int compareJavaVersions(IVMInstall vm, String ver) { if (vm instanceof AbstractVMInstall) { AbstractVMInstall install = (AbstractVMInstall) vm; String vmver = install.getJavaVersion(); if (vmver == null) { return -1; } // versionToJdkLevel only handles 3 char versions = 1.5, 1.6, 1.7, etc if (vmver.length() > 3) { vmver = vmver.substring(0, 3); } return JavaCore.compareJavaVersions(vmver, ver); } return -1; } /**
/** * Examines the project and install for presence of module and execution support. * * @param config * runner configuration * @param vmInstall * VM install * @return <code>true</code> if project is a module and uses JRE version 9 or more, or <code>false</code> otherwise * @since 3.10 */ protected boolean isModular(VMRunnerConfiguration config, IVMInstall vmInstall) { if (config.getModuleDescription() != null && config.getModuleDescription().length() > 0 && vmInstall instanceof AbstractVMInstall) { AbstractVMInstall install = (AbstractVMInstall) vmInstall; String vmver = install.getJavaVersion(); // versionToJdkLevel only handles 3 char versions = 1.5, 1.6, 1.9, etc if (vmver.length() > 3) { vmver = vmver.substring(0, 3); } if (JavaCore.compareJavaVersions(vmver, JavaCore.VERSION_9) >= 0) { return true; } } return false; } }
IVMInstall vm1= JavaRuntime.getVMInstall(elem.getPath()); if (vm1 instanceof AbstractVMInstall) { v1= ((AbstractVMInstall) vm1).getJavaVersion(); v2= ((AbstractVMInstall) vm2).getJavaVersion();
if(vm instanceof AbstractVMInstall) { AbstractVMInstall install = (AbstractVMInstall) vm; String vmver = install.getJavaVersion(); if(vmver != null) { int val = compliance.compareTo(vmver);
String jreVer = vmi.getJavaVersion(); if (jreVer == null) { abort(