Bundle.MSG_InvalidProfile())); } else { profile.setText(requiredProfile.getDisplayName());
sourceProfile != SourceLevelQuery.Profile.DEFAULT) { options.add("-profile"); //NOI18N, Limit JRE to required compact profile options.add(sourceProfile.getName());
if (JavaIndex.ensureAttributeValue(url, JRE_PROFILE, sourceLevel.getProfile().getName(), checkOnly)) { JavaIndex.LOG.fine("forcing reindex due to jre profile change"); //NOI18N vote = true;
final Profile profile = Profile.forName(profileName); res = profile != null ? Union2.<Profile,String>createFirst(profile) :
@NonNull private static Profile profileFromAnnotationComponent(@NullAllowed final AnnotationComponent ac) { if (ac == null) { return Profile.COMPACT1; } try { final ElementValue ev = ac.getValue(); if (!(ev instanceof PrimitiveElementValue)) { return Profile.COMPACT1; } final CPEntry cpEntry = ((PrimitiveElementValue)ev).getValue(); if (cpEntry.getTag() != 3) { return Profile.COMPACT1; } final int ordinal = (Integer) cpEntry.getValue(); if (ordinal <= 0) { return Profile.COMPACT1; } final Profile[] values = Profile.values(); if (ordinal >= values.length) { return Profile.DEFAULT; } return values[ordinal-1]; } catch (NumberFormatException nfe) { return Profile.COMPACT1; } } }
private void validateBinaryFile( @NonNull final FileObject fo, @NonNull final ViolationCollector collector) { final Profile profileToCheck = context.getRequredProfile(); final TypeCache tc = context.getTypeCache(); try { try (InputStream in = fo.getInputStream()) { ClassFile cf = new ClassFile(in); for (ClassName className : cf.getAllClassNames()) { final Profile p = tc.profileForType(className); if (p != null && profileToCheck.compareTo(p) < 0) { collector.reportProfileViolation( new Violation( root, p, map(fo), ElementHandleAccessor.getInstance().create(ElementKind.CLASS, className.getInternalName().replace('/', '.')) //NOI18N )); } } } } catch (IOException ioe) { LOG.log( Level.INFO, "Cannot validate file: {0}", //NOI18N FileUtil.getFileDisplayName(fo)); } }
@Override protected void validate(@NonNull final ViolationCollector collector) { if (context.isCancelled()) { return; } Profile current = null; if (context.shouldValidate(Validation.BINARIES_BY_MANIFEST)) { final Union2<Profile,String> res = findProfileInManifest(root); if (!res.hasFirst()) { //Invalid value of profile in manifest of dependent jar collector.reportProfileViolation(new Violation(root, null, null, null)); return; } current = res.first(); if (current != Profile.DEFAULT && current.compareTo(context.getRequredProfile()) > 0) { //Hiher profile in manifest of dependent jar collector.reportProfileViolation(new Violation(root, res.first(), null, null)); return; } } if (context.shouldValidate(Validation.BINARIES_BY_CLASS_FILES)) { if (current == null || current == Profile.DEFAULT) { validateBinaryRoot(root, collector); } } }
@Override public boolean equals(@NullAllowed Object other) { if (other == this) { return true; } if (!(other instanceof ProfileResolver)) { return false; } final ProfileResolver otherResolver = (ProfileResolver) other; final FileObject projDir = antProjectHelper.getProjectDirectory(); final FileObject otherProjDir = otherResolver.antProjectHelper.getProjectDirectory(); return currentProfile.equals(otherResolver.currentProfile) && (projDir == null ? otherProjDir == null : projDir.equals(otherProjDir)); } }
@Override public Component getListCellRendererComponent( @NonNull final JList jlist, @NullAllowed Object o, final int i, final boolean bln, final boolean bln1) { if (o instanceof Profile) { o = ((Profile)o).getDisplayName(); } return super.getListCellRendererComponent(jlist, o, i, bln, bln1); } }
@Override public int hashCode() { int res = 17; final FileObject projDir = antProjectHelper.getProjectDirectory(); res = res * 31 + (projDir == null ? 0 : projDir.toURI().hashCode()); res = res * 31 + currentProfile.hashCode(); return res; }
@CheckForNull static Profile max (@NullAllowed Profile a, @NullAllowed Profile b) { if (b == null) { return a; } if (a == null) { return b; } return a.compareTo(b) <= 0 ? b : a; }