Java Code Examples for com.sun.tools.javac.jvm.Profile#DEFAULT
The following examples show how to use
com.sun.tools.javac.jvm.Profile#DEFAULT .
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 TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 2
Source File: ProfileOptionTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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 3
Source File: ProfileOptionTest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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 4
Source File: ProfileOptionTest.java From hottub with GNU General Public License v2.0 | 6 votes |
@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 5
Source File: ProfileOptionTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 6
Source File: ProfileOptionTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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 7
Source File: ProfileOptionTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 8
Source File: ClassFinder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns any extra flags for a class symbol. * This information used to be provided using private annotations * in the class file in ct.sym; in time, this information will be * available from the module system. */ long getSupplementaryFlags(ClassSymbol c) { if (jrtIndex == null || !jrtIndex.isInJRT(c.classfile) || c.name == names.module_info) { return 0; } if (supplementaryFlags == null) { supplementaryFlags = new HashMap<>(); } Long flags = supplementaryFlags.get(c.packge()); if (flags == null) { long newFlags = 0; try { JRTIndex.CtSym ctSym = jrtIndex.getCtSym(c.packge().flatName()); Profile minProfile = Profile.DEFAULT; if (ctSym.proprietary) newFlags |= PROPRIETARY; if (ctSym.minProfile != null) minProfile = Profile.lookup(ctSym.minProfile); if (profile != Profile.DEFAULT && minProfile.value > profile.value) { newFlags |= NOT_IN_PROFILE; } } catch (IOException ignore) { } supplementaryFlags.put(c.packge(), flags = newFlags); } return flags; }
Example 9
Source File: ProfileOptionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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 10
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
void checkProfile(final DiagnosticPosition pos, final Symbol s) { if (profile != Profile.DEFAULT && (s.flags() & NOT_IN_PROFILE) != 0) { log.error(pos, Errors.NotInProfile(s, profile)); } }
Example 11
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 12
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 13
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 14
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 15
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 16
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 17
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"); } } } } }
Example 18
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"); } } } } }