com.sun.tools.javac.jvm.Profile Java Examples

The following examples show how to use com.sun.tools.javac.jvm.Profile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProfileOptionTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void initTestClasses() {
    // The following table assumes the existence of specific classes
    // in specific profiles, as defined in the Java SE 8 spec.
    init(Profile.COMPACT1,
            java.lang.String.class);

    init(Profile.COMPACT2,
            javax.xml.XMLConstants.class);

    init(Profile.COMPACT3,
            javax.sql.rowset.Predicate.class,
            com.sun.security.auth.PolicyFile.class); // specifically included in 3

    init(Profile.DEFAULT,
            java.beans.BeanInfo.class,
            javax.management.remote.rmi._RMIServer_Stub.class); // specifically excluded in 3
}
 
Example #2
Source File: ProfileOptionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void initTestClasses() {
    // The following table assumes the existence of specific classes
    // in specific profiles, as defined in the Java SE 8 spec.
    init(Profile.COMPACT1,
            java.lang.String.class);

    init(Profile.COMPACT2,
            javax.xml.XMLConstants.class);

    init(Profile.COMPACT3,
            javax.sql.rowset.Predicate.class,
            com.sun.security.auth.PolicyFile.class); // specifically included in 3

    init(Profile.DEFAULT,
            java.beans.BeanInfo.class,
            javax.management.remote.rmi._RMIServer_Stub.class); // specifically excluded in 3
}
 
Example #3
Source File: ProfileIndexFrameWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Profiles profiles, String text,
        String tableSummary, Content body) {
    Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
            profilesLabel);
    Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(profilesLabel);
    String profileName;
    for (int i = 1; i < profiles.getProfileCount(); i++) {
        profileName = (Profile.lookup(i)).name;
        // If the profile has valid packages to be documented, add it to the
        // left-frame generated for profile index.
        if (configuration.shouldDocumentProfile(profileName))
            ul.addContent(getProfile(profileName));
    }
    div.addContent(ul);
    body.addContent(div);
}
 
Example #4
Source File: ProfileOptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void initTestClasses() {
    // The following table assumes the existence of specific classes
    // in specific profiles, as defined in the Java SE 8 spec.
    init(Profile.COMPACT1,
            java.lang.String.class);

    init(Profile.COMPACT2,
            javax.xml.XMLConstants.class);

    //init(Profile.COMPACT3,
    //        javax.sql.rowset.Predicate.class,
    //        com.sun.security.auth.PolicyFile.class); // specifically included in 3

    init(Profile.COMPACT3,
            javax.sql.rowset.Predicate.class);

    init(Profile.DEFAULT,
            java.beans.BeanInfo.class);
}
 
Example #5
Source File: ProfileIndexFrameWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Profiles profiles, String text,
        String tableSummary, Content body) {
    Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
            profilesLabel);
    Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(profilesLabel);
    String profileName;
    for (int i = 1; i < profiles.getProfileCount(); i++) {
        profileName = (Profile.lookup(i)).name;
        // If the profile has valid packages to be documented, add it to the
        // left-frame generated for profile index.
        if (configuration.shouldDocumentProfile(profileName))
            ul.addContent(getProfile(profileName));
    }
    div.addContent(ul);
    body.addContent(div);
}
 
Example #6
Source File: PackageIndexWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Content profileSummary, Content body) {
    Content h2 = HtmlTree.HEADING(HtmlTag.H2, profileSummary);
    Content profilesDiv = HtmlTree.DIV(h2);
    Content ul = new HtmlTree(HtmlTag.UL);
    String profileName;
    for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
        profileName = Profile.lookup(i).name;
        // If the profile has valid packages to be documented, add it to the
        // profiles list on overview-summary.html page.
        if (configuration.shouldDocumentProfile(profileName)) {
            Content profileLinkContent = getTargetProfileLink("classFrame",
                    new StringContent(profileName), profileName);
            Content li = HtmlTree.LI(profileLinkContent);
            ul.addContent(li);
        }
    }
    profilesDiv.addContent(ul);
    Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
    body.addContent(div);
}
 
Example #7
Source File: ProfileOptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void initTestClasses() {
    // The following table assumes the existence of specific classes
    // in specific profiles, as defined in the Java SE 8 spec.
    init(Profile.COMPACT1,
            java.lang.String.class);

    init(Profile.COMPACT2,
            javax.xml.XMLConstants.class);

    init(Profile.COMPACT3,
            javax.sql.rowset.Predicate.class,
            com.sun.security.auth.PolicyFile.class); // specifically included in 3

    init(Profile.DEFAULT,
            java.beans.BeanInfo.class,
            javax.management.remote.rmi._RMIServer_Stub.class); // specifically excluded in 3
}
 
Example #8
Source File: ProfileOptionTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testClassesInProfiles() throws Exception {
    for (Profile p: Profile.values()) {
        for (Map.Entry<Profile, List<JavaFileObject>> e: testClasses.entrySet()) {
            for (JavaFileObject fo: e.getValue()) {
                DiagnosticCollector<JavaFileObject> dl =
                        new DiagnosticCollector<JavaFileObject>();
                List<String> opts = (p == Profile.DEFAULT)
                        ? Collections.<String>emptyList()
                        : Arrays.asList("-profile", p.name);
                JavacTask task = (JavacTask) javac.getTask(null, fm, dl, opts, null,
                        Arrays.asList(fo));
                task.analyze();

                List<String> expectDiagCodes = (p.value >= e.getKey().value)
                        ? Collections.<String>emptyList()
                        : Arrays.asList("compiler.err.not.in.profile");

                checkDiags(opts + " " + fo.getName(), dl.getDiagnostics(), expectDiagCodes);
            }
        }
    }
}
 
Example #9
Source File: ProfileIndexFrameWriter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Profiles profiles, String text,
        String tableSummary, Content body) {
    Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
            profilesLabel);
    Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(profilesLabel);
    String profileName;
    for (int i = 1; i < profiles.getProfileCount(); i++) {
        profileName = (Profile.lookup(i)).name;
        // If the profile has valid packages to be documented, add it to the
        // left-frame generated for profile index.
        if (configuration.shouldDocumentProfile(profileName))
            ul.addContent(getProfile(profileName));
    }
    div.addContent(ul);
    body.addContent(div);
}
 
Example #10
Source File: ProfileIndexFrameWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Profiles profiles, String text,
        String tableSummary, Content body) {
    Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
            profilesLabel);
    Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(profilesLabel);
    String profileName;
    for (int i = 1; i < profiles.getProfileCount(); i++) {
        profileName = (Profile.lookup(i)).name;
        // If the profile has valid packages to be documented, add it to the
        // left-frame generated for profile index.
        if (configuration.shouldDocumentProfile(profileName))
            ul.addContent(getProfile(profileName));
    }
    div.addContent(ul);
    body.addContent(div);
}
 
Example #11
Source File: PackageIndexWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Content profileSummary, Content body) {
    Content h2 = HtmlTree.HEADING(HtmlTag.H2, profileSummary);
    Content profilesDiv = HtmlTree.DIV(h2);
    Content ul = new HtmlTree(HtmlTag.UL);
    String profileName;
    for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
        profileName = Profile.lookup(i).name;
        // If the profile has valid packages to be documented, add it to the
        // profiles list on overview-summary.html page.
        if (configuration.shouldDocumentProfile(profileName)) {
            Content profileLinkContent = getTargetProfileLink("classFrame",
                    new StringContent(profileName), profileName);
            Content li = HtmlTree.LI(profileLinkContent);
            ul.addContent(li);
        }
    }
    profilesDiv.addContent(ul);
    Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
    body.addContent(div);
}
 
Example #12
Source File: ProfileIndexFrameWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void addProfilesList(Profiles profiles, String text,
        String tableSummary, Content body) {
    Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
            profilesLabel);
    Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(profilesLabel);
    String profileName;
    for (int i = 1; i < profiles.getProfileCount(); i++) {
        profileName = (Profile.lookup(i)).name;
        // If the profile has valid packages to be documented, add it to the
        // left-frame generated for profile index.
        if (configuration.shouldDocumentProfile(profileName))
            ul.addContent(getProfile(profileName));
    }
    div.addContent(ul);
    body.addContent(div);
}
 
Example #13
Source File: ProfileOptionTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void init(Profile p, Class<?>... classes) {
    List<JavaFileObject> srcs = new ArrayList<JavaFileObject>();
    for (Class<?> c: classes) {
        String name = "T" + c.getSimpleName();
        String src =
                "class T" + name + "{" + "\n" +
                "    Class<?> c = " + c.getName() + ".class;\n" +
                "}";
        srcs.add(new StringJavaFileObject(name + ".java", src));
    }
    testClasses.put(p, srcs);
}
 
Example #14
Source File: ProfilePackageSummaryBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a new ProfilePackageSummaryBuilder.
 *
 * @param context  the build context.
 * @param pkg the profile package being documented.
 * @param profilePackageWriter the doclet specific writer that will output the
 *        result.
 * @param profile the profile being documented.
 */
private ProfilePackageSummaryBuilder(Context context,
        PackageDoc pkg, ProfilePackageSummaryWriter profilePackageWriter,
        Profile profile) {
    super(context);
    this.packageDoc = pkg;
    this.profilePackageWriter = profilePackageWriter;
    this.profileName = profile.name;
    this.profileValue = profile.value;
}
 
Example #15
Source File: AbstractDiagnosticFormatter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Format a single argument of a given diagnostic.
 *
 * @param d diagnostic whose argument is to be formatted
 * @param arg argument to be formatted
 * @param l locale object to be used for i18n
 * @return string representation of the diagnostic argument
 */
protected String formatArgument(JCDiagnostic d, Object arg, Locale l) {
    if (arg instanceof JCDiagnostic) {
        String s = null;
        depth++;
        try {
            s = formatMessage((JCDiagnostic)arg, l);
        }
        finally {
            depth--;
        }
        return s;
    }
    else if (arg instanceof JCExpression) {
        return expr2String((JCExpression)arg);
    }
    else if (arg instanceof Iterable<?>) {
        return formatIterable(d, (Iterable<?>)arg, l);
    }
    else if (arg instanceof Type) {
        return printer.visit((Type)arg, l);
    }
    else if (arg instanceof Symbol) {
        return printer.visit((Symbol)arg, l);
    }
    else if (arg instanceof JavaFileObject) {
        return ((JavaFileObject)arg).getName();
    }
    else if (arg instanceof Profile) {
        return ((Profile)arg).name;
    }
    else if (arg instanceof Formattable) {
        return ((Formattable)arg).toString(l, messages);
    }
    else {
        return String.valueOf(arg);
    }
}
 
Example #16
Source File: MetaKeywords.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the profile keywords.
 *
 * @param profile the profile being documented
 */
public String[] getMetaKeywords(Profile profile) {
    if( configuration.keywords ) {
        String profileName = profile.name;
        return new String[] { profileName + " " + "profile" };
    } else {
        return new String[] {};
    }
}
 
Example #17
Source File: AbstractDiagnosticFormatter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Format a single argument of a given diagnostic.
 *
 * @param d diagnostic whose argument is to be formatted
 * @param arg argument to be formatted
 * @param l locale object to be used for i18n
 * @return string representation of the diagnostic argument
 */
protected String formatArgument(JCDiagnostic d, Object arg, Locale l) {
    if (arg instanceof JCDiagnostic) {
        String s = null;
        depth++;
        try {
            s = formatMessage((JCDiagnostic)arg, l);
        }
        finally {
            depth--;
        }
        return s;
    }
    else if (arg instanceof JCExpression) {
        return expr2String((JCExpression)arg);
    }
    else if (arg instanceof Iterable<?>) {
        return formatIterable(d, (Iterable<?>)arg, l);
    }
    else if (arg instanceof Type) {
        return printer.visit((Type)arg, l);
    }
    else if (arg instanceof Symbol) {
        return printer.visit((Symbol)arg, l);
    }
    else if (arg instanceof JavaFileObject) {
        return ((JavaFileObject)arg).getName();
    }
    else if (arg instanceof Profile) {
        return ((Profile)arg).name;
    }
    else if (arg instanceof Formattable) {
        return ((Formattable)arg).toString(l, messages);
    }
    else {
        return String.valueOf(arg);
    }
}
 
Example #18
Source File: ProfileOptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void init(Profile p, Class<?>... classes) {
    List<JavaFileObject> srcs = new ArrayList<JavaFileObject>();
    for (Class<?> c: classes) {
        String name = "T" + c.getSimpleName();
        String src =
                "class T" + name + "{" + "\n" +
                "    Class<?> c = " + c.getName() + ".class;\n" +
                "}";
        srcs.add(new StringJavaFileObject(name + ".java", src));
    }
    testClasses.put(p, srcs);
}
 
Example #19
Source File: ProfileOptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
void testClassesInProfiles() throws Exception {
    for (Profile p: Profile.values()) {
        for (Map.Entry<Profile, List<JavaFileObject>> e: testClasses.entrySet()) {
            for (JavaFileObject fo: e.getValue()) {
                DiagnosticCollector<JavaFileObject> dl =
                        new DiagnosticCollector<JavaFileObject>();
                List<String> opts = (p == Profile.DEFAULT)
                        ? Collections.<String>emptyList()
                        : Arrays.asList("--release", "8", "-profile", p.name);
                JavacTask task = (JavacTask) javac.getTask(null, fm, dl, opts, null,
                        Arrays.asList(fo));
                task.analyze();

                List<String> expectDiagCodes = new ArrayList<>();
                if (fo.getName().equals("TPolicyFile.java")) {
                    expectDiagCodes.add("compiler.warn.has.been.deprecated.for.removal");
                }

                if (p.value < e.getKey().value) {
                    expectDiagCodes.add("compiler.err.not.in.profile");
                }

                checkDiags(opts + " " + fo.getName(), dl.getDiagnostics(), expectDiagCodes);
            }
        }
    }
}
 
Example #20
Source File: MetaKeywords.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the profile keywords.
 *
 * @param profile the profile being documented
 */
public String[] getMetaKeywords(Profile profile) {
    if( configuration.keywords ) {
        String profileName = profile.name;
        return new String[] { profileName + " " + "profile" };
    } else {
        return new String[] {};
    }
}
 
Example #21
Source File: ProfilePackageFrameWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a profile package summary page for the left-hand bottom frame. Construct
 * the ProfilePackageFrameWriter object and then uses it generate the file.
 *
 * @param configuration the current configuration of the doclet.
 * @param packageDoc The package for which "profilename-package-frame.html" is to be generated.
 * @param profileValue the value of the profile being documented
 */
public static void generate(ConfigurationImpl configuration,
        PackageDoc packageDoc, int profileValue) {
    ProfilePackageFrameWriter profpackgen;
    try {
        String profileName = Profile.lookup(profileValue).name;
        profpackgen = new ProfilePackageFrameWriter(configuration, packageDoc,
                profileName);
        StringBuilder winTitle = new StringBuilder(profileName);
        String sep = " - ";
        winTitle.append(sep);
        String pkgName = Util.getPackageName(packageDoc);
        winTitle.append(pkgName);
        Content body = profpackgen.getBody(false,
                profpackgen.getWindowTitle(winTitle.toString()));
        Content profName = new StringContent(profileName);
        Content sepContent = new StringContent(sep);
        Content pkgNameContent = new RawHtml(pkgName);
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
                profpackgen.getTargetProfileLink("classFrame", profName, profileName));
        heading.addContent(sepContent);
        heading.addContent(profpackgen.getTargetProfilePackageLink(packageDoc,
                "classFrame", pkgNameContent, profileName));
        body.addContent(heading);
        HtmlTree div = new HtmlTree(HtmlTag.DIV);
        div.addStyle(HtmlStyle.indexContainer);
        profpackgen.addClassListing(div, profileValue);
        body.addContent(div);
        profpackgen.printHtmlDocument(
                configuration.metakeywords.getMetaKeywords(packageDoc), false, body);
        profpackgen.close();
    } catch (IOException exc) {
        configuration.standardmessage.error(
                "doclet.exception_encountered",
                exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
        throw new DocletAbortException(exc);
    }
}
 
Example #22
Source File: MetaKeywords.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the profile keywords.
 *
 * @param profile the profile being documented
 */
public String[] getMetaKeywords(Profile profile) {
    if( configuration.keywords ) {
        String profileName = profile.name;
        return new String[] { profileName + " " + "profile" };
    } else {
        return new String[] {};
    }
}
 
Example #23
Source File: ProfilePackageFrameWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a profile package summary page for the left-hand bottom frame. Construct
 * the ProfilePackageFrameWriter object and then uses it generate the file.
 *
 * @param configuration the current configuration of the doclet.
 * @param packageDoc The package for which "profilename-package-frame.html" is to be generated.
 * @param profileValue the value of the profile being documented
 */
public static void generate(ConfigurationImpl configuration,
        PackageDoc packageDoc, int profileValue) {
    ProfilePackageFrameWriter profpackgen;
    try {
        String profileName = Profile.lookup(profileValue).name;
        profpackgen = new ProfilePackageFrameWriter(configuration, packageDoc,
                profileName);
        StringBuilder winTitle = new StringBuilder(profileName);
        String sep = " - ";
        winTitle.append(sep);
        String pkgName = Util.getPackageName(packageDoc);
        winTitle.append(pkgName);
        Content body = profpackgen.getBody(false,
                profpackgen.getWindowTitle(winTitle.toString()));
        Content profName = new StringContent(profileName);
        Content sepContent = new StringContent(sep);
        Content pkgNameContent = new RawHtml(pkgName);
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
                profpackgen.getTargetProfileLink("classFrame", profName, profileName));
        heading.addContent(sepContent);
        heading.addContent(profpackgen.getTargetProfilePackageLink(packageDoc,
                "classFrame", pkgNameContent, profileName));
        body.addContent(heading);
        HtmlTree div = new HtmlTree(HtmlTag.DIV);
        div.addStyle(HtmlStyle.indexContainer);
        profpackgen.addClassListing(div, profileValue);
        body.addContent(div);
        profpackgen.printHtmlDocument(
                configuration.metakeywords.getMetaKeywords(packageDoc), false, body);
        profpackgen.close();
    } catch (IOException exc) {
        configuration.standardmessage.error(
                "doclet.exception_encountered",
                exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
        throw new DocletAbortException(exc);
    }
}
 
Example #24
Source File: ProfileOptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void init(Profile p, Class<?>... classes) {
    List<JavaFileObject> srcs = new ArrayList<JavaFileObject>();
    for (Class<?> c: classes) {
        String name = "T" + c.getSimpleName();
        String src =
                "class T" + name + "{" + "\n" +
                "    Class<?> c = " + c.getName() + ".class;\n" +
                "}";
        srcs.add(new StringJavaFileObject(name + ".java", src));
    }
    testClasses.put(p, srcs);
}
 
Example #25
Source File: ProfileOptionTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void init(Profile p, Class<?>... classes) {
    List<JavaFileObject> srcs = new ArrayList<JavaFileObject>();
    for (Class<?> c: classes) {
        String name = "T" + c.getSimpleName();
        String src =
                "class T" + name + "{" + "\n" +
                "    Class<?> c = " + c.getName() + ".class;\n" +
                "}";
        srcs.add(new StringJavaFileObject(name + ".java", src));
    }
    testClasses.put(p, srcs);
}
 
Example #26
Source File: AbstractDiagnosticFormatter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Format a single argument of a given diagnostic.
 *
 * @param d diagnostic whose argument is to be formatted
 * @param arg argument to be formatted
 * @param l locale object to be used for i18n
 * @return string representation of the diagnostic argument
 */
protected String formatArgument(JCDiagnostic d, Object arg, Locale l) {
    if (arg instanceof JCDiagnostic) {
        String s = null;
        depth++;
        try {
            s = formatMessage((JCDiagnostic)arg, l);
        }
        finally {
            depth--;
        }
        return s;
    }
    else if (arg instanceof JCExpression) {
        return expr2String((JCExpression)arg);
    }
    else if (arg instanceof Iterable<?>) {
        return formatIterable(d, (Iterable<?>)arg, l);
    }
    else if (arg instanceof Type) {
        return printer.visit((Type)arg, l);
    }
    else if (arg instanceof Symbol) {
        return printer.visit((Symbol)arg, l);
    }
    else if (arg instanceof JavaFileObject) {
        return ((JavaFileObject)arg).getName();
    }
    else if (arg instanceof Profile) {
        return ((Profile)arg).name;
    }
    else if (arg instanceof Formattable) {
        return ((Formattable)arg).toString(l, messages);
    }
    else {
        return String.valueOf(arg);
    }
}
 
Example #27
Source File: ProfilePackageFrameWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a profile package summary page for the left-hand bottom frame. Construct
 * the ProfilePackageFrameWriter object and then uses it generate the file.
 *
 * @param configuration the current configuration of the doclet.
 * @param packageDoc The package for which "profilename-package-frame.html" is to be generated.
 * @param profileValue the value of the profile being documented
 */
public static void generate(ConfigurationImpl configuration,
        PackageDoc packageDoc, int profileValue) {
    ProfilePackageFrameWriter profpackgen;
    try {
        String profileName = Profile.lookup(profileValue).name;
        profpackgen = new ProfilePackageFrameWriter(configuration, packageDoc,
                profileName);
        StringBuilder winTitle = new StringBuilder(profileName);
        String sep = " - ";
        winTitle.append(sep);
        String pkgName = Util.getPackageName(packageDoc);
        winTitle.append(pkgName);
        Content body = profpackgen.getBody(false,
                profpackgen.getWindowTitle(winTitle.toString()));
        Content profName = new StringContent(profileName);
        Content sepContent = new StringContent(sep);
        Content pkgNameContent = new RawHtml(pkgName);
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
                profpackgen.getTargetProfileLink("classFrame", profName, profileName));
        heading.addContent(sepContent);
        heading.addContent(profpackgen.getTargetProfilePackageLink(packageDoc,
                "classFrame", pkgNameContent, profileName));
        body.addContent(heading);
        HtmlTree div = new HtmlTree(HtmlTag.DIV);
        div.addStyle(HtmlStyle.indexContainer);
        profpackgen.addClassListing(div, profileValue);
        body.addContent(div);
        profpackgen.printHtmlDocument(
                configuration.metakeywords.getMetaKeywords(packageDoc), false, body);
        profpackgen.close();
    } catch (IOException exc) {
        configuration.standardmessage.error(
                "doclet.exception_encountered",
                exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
        throw new DocletAbortException(exc);
    }
}
 
Example #28
Source File: ProfilePackageSummaryBuilder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a new ProfilePackageSummaryBuilder.
 *
 * @param context  the build context.
 * @param pkg the profile package being documented.
 * @param profilePackageWriter the doclet specific writer that will output the
 *        result.
 * @param profile the profile being documented.
 */
private ProfilePackageSummaryBuilder(Context context,
        PackageDoc pkg, ProfilePackageSummaryWriter profilePackageWriter,
        Profile profile) {
    super(context);
    this.packageDoc = pkg;
    this.profilePackageWriter = profilePackageWriter;
    this.profileName = profile.name;
    this.profileValue = profile.value;
}
 
Example #29
Source File: ProfileOptionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void init(Profile p, Class<?>... classes) {
    List<JavaFileObject> srcs = new ArrayList<JavaFileObject>();
    for (Class<?> c: classes) {
        String name = "T" + c.getSimpleName();
        String src =
                "class T" + name + "{" + "\n" +
                "    Class<?> c = " + c.getName() + ".class;\n" +
                "}";
        srcs.add(new StringJavaFileObject(name + ".java", src));
    }
    testClasses.put(p, srcs);
}
 
Example #30
Source File: MetaKeywords.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the profile keywords.
 *
 * @param profile the profile being documented
 */
public String[] getMetaKeywords(Profile profile) {
    if( configuration.keywords ) {
        String profileName = profile.name;
        return new String[] { profileName + " " + "profile" };
    } else {
        return new String[] {};
    }
}