/** Try to make a specification version from a string. * Deal with errors gracefully and try to recover something from it. * E.g. "1.4.0beta" is technically erroneous; correct to "1.4.0". */ private static SpecificationVersion makeSpec(String vers) { if (vers != null) { try { return new SpecificationVersion(vers); } catch (NumberFormatException nfe) { System.err.println("WARNING: invalid specification version: " + vers); // NOI18N } do { vers = vers.substring(0, vers.length() - 1); try { return new SpecificationVersion(vers); } catch (NumberFormatException nfe) { // ignore } } while (vers.length() > 0); } // Nothing decent in it at all; use zero. return new SpecificationVersion("0"); // NOI18N }
new SpecificationVersion(version); } catch (NumberFormatException nfe) { throw new IllegalArgumentException(nfe.toString());
@Override public SpecificationVersion getJavacardVersion() { return new SpecificationVersion ("9.9"); //NOI18N }
public J2MEProfile(String name, String version, String displayName, String type, String dependencies, String classPath, boolean def) { this(name, new SpecificationVersion(version), displayName, type, dependencies, classPath, def); }
private static SpecificationVersion computeVersion(String v) { int pos = -1; for (int i = 0; i < 3; i++) { pos = v.indexOf('.', pos + 1); if (pos == -1) { return new SpecificationVersion(v); } } return new SpecificationVersion(v.substring(0, pos)); }
@Override public Specification getSpecification() { return new Specification ("JCRE", //NOI18N new SpecificationVersion("1.6")); //NOI18N }
private static boolean isAcceptableSourceLevel(String minSourceLevel, String sourceLevel, Set acceptableSourceLevels) { if (minSourceLevel.equals(sourceLevel)) { return true; } SpecificationVersion minSpec = new SpecificationVersion(minSourceLevel); SpecificationVersion spec = new SpecificationVersion(sourceLevel); if (minSpec.compareTo(spec) > 0) { return false; } return acceptableSourceLevels.contains(sourceLevel); }
public Specification getSpecification() { if (spec == null) { spec = new Specification (PLATFORM_CDC, new SpecificationVersion(getClassVersion())); //NOI18N } return spec; }
private static String getCompilerType (ScalaPlatform platform) { assert platform != null; String prop = platform.getSystemProperties().get("java.specification.version"); //NOI18N assert prop != null; SpecificationVersion specificationVersion = new SpecificationVersion (prop); SpecificationVersion jdk13 = new SpecificationVersion("1.3"); //NOI18N int c = specificationVersion.compareTo (jdk13); if (c<0) { return CLASSIC; } else if (c == 0) { return JAVAC13; } else { return MODERN; } }
static boolean isDesignModeSupported(NbModuleProvider info) { try { SpecificationVersion current = info.getDependencyVersion("org.openide.windows"); if (current == null) { return false; } return current.compareTo(new SpecificationVersion("6.45")) >= 0; // NOI18N } catch (IOException ex) { Logger.getLogger(NewTCIterator.class.getName()).log(Level.INFO, null, ex); return false; } }
@Override public synchronized Specification getSpecification() { if (spec == null) { final HashSet<J2MEProfile> profs = new HashSet<J2MEProfile>(); for (int i=0; i<devices.length; i++) { final J2MEProfile[] profiles = devices[i].getProfiles(); profs.addAll(Arrays.asList(profiles)); } SpecificationVersion sv = new SpecificationVersion("8.0"); //NOI18N if (isMe3Platform()) { sv = new SpecificationVersion("3.0"); //NOI18N } spec = new Specification(SPECIFICATION_NAME, sv, NbBundle.getMessage(J2MEPlatform.class, "TXT_J2MEDisplayName"), profs.toArray(new Profile[profs.size()])); //NOI18N } return spec; }
private static JavaPlatform[] getJavaPlatforms(String level) { return JavaPlatformManager.getDefault().getPlatforms(null, new Specification("J2SE", new SpecificationVersion(level))); // NOI18N }
ModuleData(ObjectInput dis) throws IOException { try { this.codeName = dis.readUTF(); this.codeNameBase = dis.readUTF(); this.codeNameRelease = dis.readInt(); this.coveredPackages = readStrings(dis, new HashSet<String>(), true); this.dependencies = (Dependency[]) dis.readObject(); this.implVersion = dis.readUTF(); this.buildVersion = dis.readUTF(); this.provides = readStrings(dis); this.friendNames = readStrings(dis, new HashSet<String>(), false); this.specVers = new SpecificationVersion(dis.readUTF()); this.publicPackages = Module.PackageExport.read(dis); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } }
private java.util.List<PlatformKey> updatePlatformsList() { final java.util.List<PlatformKey> platformList = new ArrayList<PlatformKey>(); final SpecificationVersion targetLevel = new SpecificationVersion("1.8"); final SourceLevelQuery.Profile targetProfile = SourceLevelQuery.Profile.COMPACT1; if (targetLevel != null && targetProfile != null) { for (J2SERuntimePlatformProvider rpt : project.getLookup().lookupAll(J2SERuntimePlatformProvider.class)) { for (JavaPlatform jp : rpt.getPlatformType(targetLevel, targetProfile)) { platformList.add(PlatformKey.create(jp)); } } Collections.sort(platformList); } platformList.add(0, PlatformKey.createDefault()); final DefaultComboBoxModel<PlatformKey> model = new DefaultComboBoxModel<PlatformKey>(platformList.toArray(new PlatformKey[0])); comboBoxRuntimePlatform.setModel(model); return platformList; }
private static SpecificationVersion getDefaultSourceLevel () { if (defaultSourceLevel != null) { return defaultSourceLevel; } else { JavaPlatform defaultPlatform = JavaPlatformManager.getDefault().getDefaultPlatform(); SpecificationVersion v = defaultPlatform.getSpecification().getVersion(); if (v.equals(new SpecificationVersion("1.6")) || v.equals(new SpecificationVersion("1.7"))) { // #89131: these levels are not actually distinct from 1.5. - xxx not true, but may be acceptable to have 1.5 as default return new SpecificationVersion("1.5"); } else { return v; } } }
public boolean canUseMultiview() { try { SpecificationVersion v = getModuleInfo().getDependencyVersion("org.netbeans.core.multiview"); // NOI18N if (v == null) { return false; } SpecificationVersion l = getModuleInfo().getDependencyVersion("org.openide.loaders"); // NOI18N if (l == null) { return false; } return v.compareTo(new SpecificationVersion("1.24")) >= 0 // NOI18N && l.compareTo(new SpecificationVersion("7.26")) >= 0; // NOI18N } catch (IOException ex) { return false; } } public boolean isUseMultiview() {
/** Check whether a simple dependency is met. * Only applicable to Java dependencies. */ static boolean checkJavaDependency(Dependency dep) throws IllegalArgumentException { // Note that "any" comparison is not possible for this type. if (dep.getType() == Dependency.TYPE_JAVA) { if (dep.getName().equals(Dependency.JAVA_NAME)) { if (dep.getComparison() == Dependency.COMPARE_SPEC) { return new SpecificationVersion(dep.getVersion()).compareTo(Dependency.JAVA_SPEC) <= 0; } else { return dep.getVersion().equals(Dependency.JAVA_IMPL); } } else { if (dep.getComparison() == Dependency.COMPARE_SPEC) { return new SpecificationVersion(dep.getVersion()).compareTo(Dependency.VM_SPEC) <= 0; } else { return dep.getVersion().equals(Dependency.VM_IMPL); } } } else { throw new IllegalArgumentException(); } }
private static boolean canSetSourceLevel(String sourceLevel) { SpecificationVersion spec = JavaPlatformManager.getDefault().getDefaultPlatform().getSpecification().getVersion(); return spec.compareTo(new SpecificationVersion(sourceLevel)) >= 0; }
private static SpecificationVersion getPlatformSourceLevel(String fxPlatformName) { JavaPlatform platform = null; JavaPlatform[] platforms = JavaPlatformManager.getDefault().getInstalledPlatforms(); for (JavaPlatform javaPlatform : platforms) { String platformName = javaPlatform.getProperties().get(JavaFXPlatformUtils.PLATFORM_ANT_NAME); if (JFXProjectProperties.isEqual(platformName, fxPlatformName)) { platform = javaPlatform; break; } } if(platform == null) { // default JavaFX2 specification version is 1.6 return new SpecificationVersion("1.6"); // NOI18N } SpecificationVersion v = platform.getSpecification().getVersion(); return v; }
public boolean hasInvalidJdkVersion () { String javaSource = this.evaluator.getProperty("javac.source"); //NOI18N String javaTarget = this.evaluator.getProperty("javac.target"); //NOI18N if (javaSource == null && javaTarget == null) { //No need to check anything return false; } final String platformId = this.evaluator.getProperty("platform.active"); //NOI18N final JavaPlatform activePlatform = J2SEProjectUtil.getJavaActivePlatform (platformId); if (activePlatform == null) { return true; } SpecificationVersion platformVersion = activePlatform.getSpecification().getVersion(); try { return (javaSource != null && new SpecificationVersion (javaSource).compareTo(platformVersion)>0) || (javaTarget != null && new SpecificationVersion (javaTarget).compareTo(platformVersion)>0); } catch (NumberFormatException nfe) { ErrorManager.getDefault().log("Invalid javac.source: "+javaSource+" or javac.target: "+javaTarget+" of project:" +this.project.getProjectDirectory().getPath()); return true; } }