< prev index next >
test/tools/javac/profiles/ProfileOptionTest.java
Print this page
*** 73,83 ****
@Test
void testInvalidProfile_API() throws Exception {
JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
String badName = "foo";
! List<String> opts = Arrays.asList("-profile", badName);
StringWriter sw = new StringWriter();
try {
JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
Arrays.asList(fo));
throw new Exception("expected exception not thrown");
--- 73,83 ----
@Test
void testInvalidProfile_API() throws Exception {
JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
String badName = "foo";
! List<String> opts = Arrays.asList("--release", "8", "-profile", badName);
StringWriter sw = new StringWriter();
try {
JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
Arrays.asList(fo));
throw new Exception("expected exception not thrown");
*** 87,97 ****
}
@Test
void testInvalidProfile_CommandLine() throws Exception {
String badName = "foo";
! String[] opts = { "-profile", badName };
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javac.Main.compile(opts, pw);
// sadly, command line errors are not (yet?) reported to
--- 87,97 ----
}
@Test
void testInvalidProfile_CommandLine() throws Exception {
String badName = "foo";
! String[] opts = { "--release", "8", "-profile", badName };
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javac.Main.compile(opts, pw);
// sadly, command line errors are not (yet?) reported to
*** 142,164 ****
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);
}
}
}
}
}
--- 142,174 ----
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;
}
}
}
}
*** 169,179 ****
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 = new ArrayList<>();
--- 179,189 ----
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<>();
*** 201,213 ****
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);
}
--- 211,226 ----
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);
}
< prev index next >