本文整理汇总了Java中com.sun.tools.javac.jvm.Profile.DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java Profile.DEFAULT属性的具体用法?Java Profile.DEFAULT怎么用?Java Profile.DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.tools.javac.jvm.Profile
的用法示例。
在下文中一共展示了Profile.DEFAULT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClassesInProfiles
@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);
}
}
}
}
示例2: getSupplementaryFlags
/**
* 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;
}
示例3: testClassesInProfiles
@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);
}
}
}
}
示例4: testTargetProfileCombinations
@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;
}
}
}
}
示例5: testTargetProfileCombinations
@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);
}
}
}
}
}
示例6: testTargetProfileCombinations
@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");
}
}
}
}
}