Java Code Examples for com.sun.tools.javac.jvm.Target#values()
The following examples show how to use
com.sun.tools.javac.jvm.Target#values() .
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: SourceTargetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void run() throws Exception { try (FileWriter out = new FileWriter("C.java")) { out.write("class C { }"); } for (Source s: Source.values()) { test(s, null, "source", getKind(s, Source.MIN)); } for (Target t: Target.values()) { test(Source.values()[0], t, "target", getKind(t, Target.MIN)); } if (errors > 0) throw new Exception(errors + " errors occurred"); }
Example 2
Source File: ProfileOptionTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }
Example 3
Source File: ProfileOptionTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }
Example 4
Source File: ProfileOptionTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }
Example 5
Source File: ProfileOptionTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }
Example 6
Source File: ProfileOptionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@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: 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; } } } }
Example 7
Source File: ProfileOptionTest.java From hottub with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }
Example 8
Source File: ProfileOptionTest.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }
Example 9
Source File: ProfileOptionTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@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"); } } } } }