当前位置: 首页>>代码示例>>Java>>正文


Java Profile.values方法代码示例

本文整理汇总了Java中com.sun.tools.javac.jvm.Profile.values方法的典型用法代码示例。如果您正苦于以下问题:Java Profile.values方法的具体用法?Java Profile.values怎么用?Java Profile.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.jvm.Profile的用法示例。


在下文中一共展示了Profile.values方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClassesInProfiles

import com.sun.tools.javac.jvm.Profile; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:24,代码来源:ProfileOptionTest.java

示例2: testClassesInProfiles

import com.sun.tools.javac.jvm.Profile; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:ProfileOptionTest.java

示例3: testTargetProfileCombinations

import com.sun.tools.javac.jvm.Profile; //导入方法依赖的package包/类
@Test
void testTargetProfileCombinations() throws Exception {
    JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
    for (Target t: Target.values()) {
        switch (t) {
            case JDK1_1:
            case JDK1_2:
            case JDK1_3:
            case JDK1_4:
            case JDK1_5: // not supported
                continue;
        }

        for (Profile p: Profile.values()) {
            List<String> opts = new ArrayList<>();
            opts.addAll(Arrays.asList("-source", t.name, "-target", t.name));
            opts.add("-Xlint:-options"); // don't warn about no -bootclasspath
            if (p != Profile.DEFAULT)
                opts.addAll(Arrays.asList("-profile", p.name));

            IllegalStateException ise;
            StringWriter sw = new StringWriter();
            try {
                JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
                        Arrays.asList(fo));
                task.analyze();
                ise = null;
            } catch (IllegalStateException e) {
                ise = e;
            }

            // sadly, command line errors are not (yet?) reported to
            // the diag listener
            String out = sw.toString();
            if (!out.isEmpty())
                System.err.println(out.trim());

            switch (t) {
                case JDK1_8:
                    if (ise != null)
                        error("unexpected exception from compiler: " + ise);
                    break;
                case JDK1_9:
                case JDK1_10:
                    if (p == Profile.DEFAULT)
                        break;
                    if (ise == null)
                        error("IllegalStateException not thrown as expected");
                    else if (!ise.getMessage().contains("option -profile " +
                            "not allowed with target " + t.name)) {
                        error("exception not thrown as expected: " + ise);
                    }
                    break;
                default:
                    if (p == Profile.DEFAULT)
                        break;
                    if (ise == null)
                        error("IllegalStateException not thrown as expected");
                    else if (!ise.getMessage().contains("profile " + p.name
                                + " is not valid for target release " + t.name)) {
                        error("exception not thrown as expected: " + ise);
                    }
                    break;
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:68,代码来源:ProfileOptionTest.java

示例4: testTargetProfileCombinations

import com.sun.tools.javac.jvm.Profile; //导入方法依赖的package包/类
@Test
void testTargetProfileCombinations() throws Exception {
    JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
    for (Target t: Target.values()) {
        switch (t) {
            case JDK1_1:
            case JDK1_2:
            case JDK1_3:
            case JDK1_4:
            case JDK1_5: // not supported
                continue;
        }

        for (Profile p: Profile.values()) {
            List<String> opts = new ArrayList<>();
            opts.addAll(Arrays.asList("-source", t.name, "-target", t.name));
            opts.add("-Xlint:-options"); // don't warn about no -bootclasspath
            if (p != Profile.DEFAULT)
                opts.addAll(Arrays.asList("-profile", p.name));

            IllegalStateException ise;
            StringWriter sw = new StringWriter();
            try {
                JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
                        Arrays.asList(fo));
                task.analyze();
                ise = null;
            } catch (IllegalStateException e) {
                ise = e;
            }

            // sadly, command line errors are not (yet?) reported to
            // the diag listener
            String out = sw.toString();
            if (!out.isEmpty())
                System.err.println(out.trim());

            switch (t) {
                case JDK1_8:
                case JDK1_9:
                    if (ise != null)
                        error("unexpected exception from compiler: " + ise);
                    break;
                default:
                    if (p == Profile.DEFAULT)
                        break;
                    if (ise == null)
                        error("IllegalStateException not thrown as expected");
                    else if (!ise.getMessage().contains("profile " + p.name
                                + " is not valid for target release " + t.name)) {
                        error("exception not thrown as expected: " + ise);
                    }
            }
        }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:57,代码来源:ProfileOptionTest.java

示例5: testTargetProfileCombinations

import com.sun.tools.javac.jvm.Profile; //导入方法依赖的package包/类
@Test
void testTargetProfileCombinations() throws Exception {
    JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
    for (Target t: Target.values()) {
        switch (t) {
            case JDK1_1: case JDK1_2: // no equivalent -source
                continue;
        }

        for (Profile p: Profile.values()) {
            List<String> opts = new ArrayList<String>();
            opts.addAll(Arrays.asList("-source", t.name, "-target", t.name));
            opts.add("-Xlint:-options"); // dont warn about no -bootclasspath
            if (p != Profile.DEFAULT)
                opts.addAll(Arrays.asList("-profile", p.name));
            StringWriter sw = new StringWriter();
            JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
                    Arrays.asList(fo));
            task.analyze();

            // sadly, command line errors are not (yet?) reported to
            // the diag listener
            String out = sw.toString();
            if (!out.isEmpty())
                System.err.println(out.trim());

            switch (t) {
                case JDK1_8:
                    if (!out.isEmpty())
                        error("unexpected output from compiler");
                    break;
                default:
                    if (p != Profile.DEFAULT
                            && !out.contains("profile " + p.name
                                + " is not valid for target release " + t.name)) {
                        error("expected message not found");
                    }
            }
        }
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:42,代码来源:ProfileOptionTest.java


注:本文中的com.sun.tools.javac.jvm.Profile.values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。