mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 09:34:38 +02:00
8062348: langtools tests should close file manager (group 1)
Reviewed-by: darcy
This commit is contained in:
parent
b587478f7c
commit
8bd23f1681
145 changed files with 2701 additions and 2452 deletions
|
@ -77,41 +77,42 @@ public class RunCodingRules {
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null)) {
|
||||||
DiagnosticListener<JavaFileObject> noErrors = diagnostic -> {
|
DiagnosticListener<JavaFileObject> noErrors = diagnostic -> {
|
||||||
Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString());
|
Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
List<File> crulesFiles = Files.walk(crulesDir)
|
List<File> crulesFiles = Files.walk(crulesDir)
|
||||||
.filter(entry -> entry.getFileName().toString().endsWith(".java"))
|
.filter(entry -> entry.getFileName().toString().endsWith(".java"))
|
||||||
.filter(entry -> entry.getParent().endsWith("crules"))
|
.filter(entry -> entry.getParent().endsWith("crules"))
|
||||||
.map(entry -> entry.toFile())
|
.map(entry -> entry.toFile())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Path crulesTarget = targetDir.resolve("crules");
|
Path crulesTarget = targetDir.resolve("crules");
|
||||||
Files.createDirectories(crulesTarget);
|
Files.createDirectories(crulesTarget);
|
||||||
List<String> crulesOptions = Arrays.asList("-d", crulesTarget.toString());
|
List<String> crulesOptions = Arrays.asList("-d", crulesTarget.toString());
|
||||||
javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
|
javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
|
||||||
fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
|
fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
|
||||||
Path registration = crulesTarget.resolve("META-INF/services/com.sun.source.util.Plugin");
|
Path registration = crulesTarget.resolve("META-INF/services/com.sun.source.util.Plugin");
|
||||||
Files.createDirectories(registration.getParent());
|
Files.createDirectories(registration.getParent());
|
||||||
try (Writer metaInfServices = Files.newBufferedWriter(registration, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
try (Writer metaInfServices = Files.newBufferedWriter(registration, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
||||||
metaInfServices.write("crules.CodingRulesAnalyzerPlugin\n");
|
metaInfServices.write("crules.CodingRulesAnalyzerPlugin\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<File> sources = sourceDirs.stream()
|
||||||
|
.flatMap(dir -> silentFilesWalk(dir))
|
||||||
|
.filter(entry -> entry.getFileName().toString().endsWith(".java"))
|
||||||
|
.map(p -> p.toFile())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
Path sourceTarget = targetDir.resolve("classes");
|
||||||
|
Files.createDirectories(sourceTarget);
|
||||||
|
String processorPath = crulesTarget.toString() + File.pathSeparator + crulesDir.toString();
|
||||||
|
List<String> options = Arrays.asList("-d", sourceTarget.toString(),
|
||||||
|
"-processorpath", processorPath, "-Xplugin:coding_rules");
|
||||||
|
javaCompiler.getTask(null, fm, noErrors, options, null,
|
||||||
|
fm.getJavaFileObjectsFromFiles(sources)).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> sources = sourceDirs.stream()
|
|
||||||
.flatMap(dir -> silentFilesWalk(dir))
|
|
||||||
.filter(entry -> entry.getFileName().toString().endsWith(".java"))
|
|
||||||
.map(p -> p.toFile())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
Path sourceTarget = targetDir.resolve("classes");
|
|
||||||
Files.createDirectories(sourceTarget);
|
|
||||||
String processorPath = crulesTarget.toString() + File.pathSeparator + crulesDir.toString();
|
|
||||||
List<String> options = Arrays.asList("-d", sourceTarget.toString(),
|
|
||||||
"-processorpath", processorPath, "-Xplugin:coding_rules");
|
|
||||||
javaCompiler.getTask(null, fm, noErrors, options, null,
|
|
||||||
fm.getJavaFileObjectsFromFiles(sources)).call();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<Path> silentFilesWalk(Path dir) throws IllegalStateException {
|
Stream<Path> silentFilesWalk(Path dir) throws IllegalStateException {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -113,58 +113,59 @@ public class T6341866 {
|
||||||
|
|
||||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
MyDiagListener dl = new MyDiagListener();
|
MyDiagListener dl = new MyDiagListener();
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||||
|
|
||||||
// Note: class A references class B, so compile A if we want implicit compilation
|
// Note: class A references class B, so compile A if we want implicit compilation
|
||||||
File file = (implicitType != ImplicitType.NONE) ? a_java : b_java;
|
File file = (implicitType != ImplicitType.NONE) ? a_java : b_java;
|
||||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
|
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
|
||||||
|
|
||||||
//System.err.println("compile: " + opts + " " + files);
|
//System.err.println("compile: " + opts + " " + files);
|
||||||
|
|
||||||
boolean ok = javac.getTask(null, fm, dl, opts, null, files).call();
|
boolean ok = javac.getTask(null, fm, dl, opts, null, files).call();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
error("compilation failed");
|
error("compilation failed");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check implicit compilation results if necessary
|
|
||||||
if (implicitType != ImplicitType.NONE) {
|
|
||||||
boolean expectClass = (implicitType != ImplicitType.OPT_NONE);
|
|
||||||
if (b_class.exists() != expectClass) {
|
|
||||||
if (b_class.exists())
|
|
||||||
error("B implicitly compiled unexpectedly");
|
|
||||||
else
|
|
||||||
error("B not impliictly compiled");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check message key results
|
// check implicit compilation results if necessary
|
||||||
String expectKey = null;
|
if (implicitType != ImplicitType.NONE) {
|
||||||
if (implicitType == ImplicitType.OPT_UNSET) {
|
boolean expectClass = (implicitType != ImplicitType.OPT_NONE);
|
||||||
switch (annoType) {
|
if (b_class.exists() != expectClass) {
|
||||||
case SERVICE:
|
if (b_class.exists())
|
||||||
expectKey = "compiler.warn.proc.use.proc.or.implicit";
|
error("B implicitly compiled unexpectedly");
|
||||||
break;
|
else
|
||||||
case SPECIFY:
|
error("B not impliictly compiled");
|
||||||
expectKey = "compiler.warn.proc.use.implicit";
|
return false;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (expectKey == null) {
|
// check message key results
|
||||||
if (dl.diagCodes.size() != 0) {
|
String expectKey = null;
|
||||||
error("no diagnostics expected");
|
if (implicitType == ImplicitType.OPT_UNSET) {
|
||||||
return false;
|
switch (annoType) {
|
||||||
|
case SERVICE:
|
||||||
|
expectKey = "compiler.warn.proc.use.proc.or.implicit";
|
||||||
|
break;
|
||||||
|
case SPECIFY:
|
||||||
|
expectKey = "compiler.warn.proc.use.implicit";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!(dl.diagCodes.size() == 1 && dl.diagCodes.get(0).equals(expectKey))) {
|
|
||||||
error("unexpected diagnostics generated");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if (expectKey == null) {
|
||||||
|
if (dl.diagCodes.size() != 0) {
|
||||||
|
error("no diagnostics expected");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(dl.diagCodes.size() == 1 && dl.diagCodes.get(0).equals(expectKey))) {
|
||||||
|
error("unexpected diagnostics generated");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createProcessorServices(String name) throws IOException {
|
static void createProcessorServices(String name) throws IOException {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -58,8 +58,7 @@ public class T6400872 {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
System.err.println("compile...");
|
System.err.println("compile...");
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
try {
|
|
||||||
Iterable<? extends JavaFileObject> fileObjects =
|
Iterable<? extends JavaFileObject> fileObjects =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
|
||||||
|
|
||||||
|
@ -78,8 +77,6 @@ public class T6400872 {
|
||||||
compiler.getTask(null, fm, null, options, null, fileObjects);
|
compiler.getTask(null, fm, null, options, null, fileObjects);
|
||||||
if (!task.call())
|
if (!task.call())
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
} finally {
|
|
||||||
fm.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,25 +54,26 @@ abstract class Checker {
|
||||||
};
|
};
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(getFiles(testSrc, fileNames));
|
fm.getJavaFileObjectsFromFiles(getFiles(testSrc, fileNames));
|
||||||
task = tool.getTask(null, fm, dl, null, null, files);
|
task = tool.getTask(null, fm, dl, null, null, files);
|
||||||
Iterable<? extends CompilationUnitTree> units = task.parse();
|
Iterable<? extends CompilationUnitTree> units = task.parse();
|
||||||
|
|
||||||
if (errors)
|
if (errors)
|
||||||
throw new AssertionError("errors occurred creating trees");
|
throw new AssertionError("errors occurred creating trees");
|
||||||
|
|
||||||
ScopeScanner s = new ScopeScanner();
|
ScopeScanner s = new ScopeScanner();
|
||||||
for (CompilationUnitTree unit: units) {
|
for (CompilationUnitTree unit: units) {
|
||||||
TreePath p = new TreePath(unit);
|
TreePath p = new TreePath(unit);
|
||||||
s.scan(p, getTrees());
|
s.scan(p, getTrees());
|
||||||
additionalChecks(getTrees(), unit);
|
additionalChecks(getTrees(), unit);
|
||||||
|
}
|
||||||
|
task = null;
|
||||||
|
|
||||||
|
if (errors)
|
||||||
|
throw new AssertionError("errors occurred checking scopes");
|
||||||
}
|
}
|
||||||
task = null;
|
|
||||||
|
|
||||||
if (errors)
|
|
||||||
throw new AssertionError("errors occurred checking scopes");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// default impl: split ref at ";" and call checkLocal(scope, ref_segment) on scope and its enclosing scopes
|
// default impl: split ref at ";" and call checkLocal(scope, ref_segment) on scope and its enclosing scopes
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -40,30 +40,31 @@ public class T6440583 {
|
||||||
String testSrc = System.getProperty("test.src", ".");
|
String testSrc = System.getProperty("test.src", ".");
|
||||||
String testClasses = System.getProperty("test.classes", ".");
|
String testClasses = System.getProperty("test.classes", ".");
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
|
||||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||||
|
|
||||||
Iterable<? extends Tree> trees = task.parse();
|
Iterable<? extends Tree> trees = task.parse();
|
||||||
|
|
||||||
TreeScanner<Boolean,Void> checker = new TreeScanner<Boolean,Void>() {
|
TreeScanner<Boolean,Void> checker = new TreeScanner<Boolean,Void>() {
|
||||||
public Boolean visitErroneous(ErroneousTree tree, Void ignore) {
|
public Boolean visitErroneous(ErroneousTree tree, Void ignore) {
|
||||||
JCErroneous etree = (JCErroneous) tree;
|
JCErroneous etree = (JCErroneous) tree;
|
||||||
List<? extends Tree> errs = etree.getErrorTrees();
|
List<? extends Tree> errs = etree.getErrorTrees();
|
||||||
System.err.println("errs: " + errs);
|
System.err.println("errs: " + errs);
|
||||||
if (errs == null || errs.size() == 0)
|
if (errs == null || errs.size() == 0)
|
||||||
throw new AssertionError("no error trees found");
|
throw new AssertionError("no error trees found");
|
||||||
found = true;
|
found = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (Tree tree: trees)
|
for (Tree tree: trees)
|
||||||
checker.scan(tree, null);
|
checker.scan(tree, null);
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
throw new AssertionError("no ErroneousTree nodes found");
|
throw new AssertionError("no ErroneousTree nodes found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean found;
|
private static boolean found;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -54,38 +54,39 @@ public class Test {
|
||||||
|
|
||||||
void test(File test) throws Exception {
|
void test(File test) throws Exception {
|
||||||
JavacTool tool1 = JavacTool.create();
|
JavacTool tool1 = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool1.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool1.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(test);
|
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(test);
|
||||||
|
|
||||||
// parse test file into a tree, and write it out to a stringbuffer using Pretty
|
// parse test file into a tree, and write it out to a stringbuffer using Pretty
|
||||||
JavacTask t1 = tool1.getTask(null, fm, null, null, null, files);
|
JavacTask t1 = tool1.getTask(null, fm, null, null, null, files);
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
Iterable<? extends CompilationUnitTree> trees = t1.parse();
|
Iterable<? extends CompilationUnitTree> trees = t1.parse();
|
||||||
for (CompilationUnitTree tree: trees) {
|
for (CompilationUnitTree tree: trees) {
|
||||||
new Pretty(pw, true).printExpr((JCTree) tree);
|
new Pretty(pw, true).printExpr((JCTree) tree);
|
||||||
}
|
|
||||||
pw.close();
|
|
||||||
|
|
||||||
final String out = sw.toString();
|
|
||||||
System.err.println("generated code:\n" + out + "\n");
|
|
||||||
|
|
||||||
// verify the generated code is valid Java by compiling it
|
|
||||||
JavacTool tool2 = JavacTool.create();
|
|
||||||
JavaFileObject fo = new SimpleJavaFileObject(URI.create("output"), JavaFileObject.Kind.SOURCE) {
|
|
||||||
@Override
|
|
||||||
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
};
|
pw.close();
|
||||||
JavacTask t2 = tool2.getTask(null, fm, null, null, null, Collections.singleton(fo));
|
|
||||||
boolean ok = t2.call();
|
|
||||||
if (!ok)
|
|
||||||
throw new Exception("compilation of generated code failed");
|
|
||||||
|
|
||||||
File expectedClass = new File(test.getName().replace(".java", ".class"));
|
final String out = sw.toString();
|
||||||
if (!expectedClass.exists())
|
System.err.println("generated code:\n" + out + "\n");
|
||||||
throw new Exception(expectedClass + " not found");
|
|
||||||
|
// verify the generated code is valid Java by compiling it
|
||||||
|
JavacTool tool2 = JavacTool.create();
|
||||||
|
JavaFileObject fo = new SimpleJavaFileObject(URI.create("output"), JavaFileObject.Kind.SOURCE) {
|
||||||
|
@Override
|
||||||
|
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JavacTask t2 = tool2.getTask(null, fm, null, null, null, Collections.singleton(fo));
|
||||||
|
boolean ok = t2.call();
|
||||||
|
if (!ok)
|
||||||
|
throw new Exception("compilation of generated code failed");
|
||||||
|
|
||||||
|
File expectedClass = new File(test.getName().replace(".java", ".class"));
|
||||||
|
if (!expectedClass.exists())
|
||||||
|
throw new Exception(expectedClass + " not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -49,9 +49,6 @@ public class T7003595 {
|
||||||
|
|
||||||
/** global decls ***/
|
/** global decls ***/
|
||||||
|
|
||||||
// Create a single file manager and reuse it for each compile to save time.
|
|
||||||
static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
|
|
||||||
|
|
||||||
//statistics
|
//statistics
|
||||||
static int checkCount = 0;
|
static int checkCount = 0;
|
||||||
|
|
||||||
|
@ -112,15 +109,18 @@ public class T7003595 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
for (ClassKind ck1 : ClassKind.values()) {
|
// Create a single file manager and reuse it for each compile to save time.
|
||||||
String cname1 = "C1";
|
try (StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
|
||||||
for (ClassKind ck2 : ClassKind.values()) {
|
for (ClassKind ck1 : ClassKind.values()) {
|
||||||
if (!ck1.isAllowed(ck2)) continue;
|
String cname1 = "C1";
|
||||||
String cname2 = "C2";
|
for (ClassKind ck2 : ClassKind.values()) {
|
||||||
for (ClassKind ck3 : ClassKind.values()) {
|
if (!ck1.isAllowed(ck2)) continue;
|
||||||
if (!ck2.isAllowed(ck3)) continue;
|
String cname2 = "C2";
|
||||||
String cname3 = "C3";
|
for (ClassKind ck3 : ClassKind.values()) {
|
||||||
new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
|
if (!ck2.isAllowed(ck3)) continue;
|
||||||
|
String cname3 = "C3";
|
||||||
|
new T7003595(fm, new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,10 @@ public class T7003595 {
|
||||||
|
|
||||||
ClassKind[] cks;
|
ClassKind[] cks;
|
||||||
String[] cnames;
|
String[] cnames;
|
||||||
|
StandardJavaFileManager fm;
|
||||||
|
|
||||||
T7003595(ClassKind[] cks, String[] cnames) {
|
T7003595(StandardJavaFileManager fm, ClassKind[] cks, String[] cnames) {
|
||||||
|
this.fm = fm;
|
||||||
this.cks = cks;
|
this.cks = cks;
|
||||||
this.cnames = cnames;
|
this.cnames = cnames;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -100,13 +100,14 @@ public class TestCircularClassfile {
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (SourceKind sk1 : SourceKind.values()) {
|
for (SourceKind sk1 : SourceKind.values()) {
|
||||||
for (SourceKind sk2 : SourceKind.values()) {
|
for (SourceKind sk2 : SourceKind.values()) {
|
||||||
for (TestKind tk : TestKind.values()) {
|
for (TestKind tk : TestKind.values()) {
|
||||||
for (ClientKind ck : ClientKind.values()) {
|
for (ClientKind ck : ClientKind.values()) {
|
||||||
new TestCircularClassfile("sub_"+count++, sk1, sk2, tk, ck).check(comp, fm);
|
new TestCircularClassfile("sub_"+count++, sk1, sk2, tk, ck).check(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -96,10 +96,11 @@ public class T7142086 {
|
||||||
void run(List<JavaFileObject> sources) throws Exception {
|
void run(List<JavaFileObject> sources) throws Exception {
|
||||||
DiagnosticChecker dc = new DiagnosticChecker();
|
DiagnosticChecker dc = new DiagnosticChecker();
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
|
JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
|
||||||
null, null, sources);
|
null, null, sources);
|
||||||
ct.analyze();
|
ct.analyze();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
|
static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -54,31 +54,32 @@ public class NoStringToLower {
|
||||||
*/
|
*/
|
||||||
boolean run(String... args) throws Exception {
|
boolean run(String... args) throws Exception {
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
JavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
JavaFileManager.Location javacLoc = findJavacLocation(fm);
|
JavaFileManager.Location javacLoc = findJavacLocation(fm);
|
||||||
String[] pkgs = {
|
String[] pkgs = {
|
||||||
"javax.annotation.processing",
|
"javax.annotation.processing",
|
||||||
"javax.lang.model",
|
"javax.lang.model",
|
||||||
"javax.tools",
|
"javax.tools",
|
||||||
"com.sun.source",
|
"com.sun.source",
|
||||||
"com.sun.tools.classfile",
|
"com.sun.tools.classfile",
|
||||||
"com.sun.tools.doclet",
|
"com.sun.tools.doclet",
|
||||||
"com.sun.tools.doclint",
|
"com.sun.tools.doclint",
|
||||||
"com.sun.tools.javac",
|
"com.sun.tools.javac",
|
||||||
"com.sun.tools.javadoc",
|
"com.sun.tools.javadoc",
|
||||||
"com.sun.tools.javah",
|
"com.sun.tools.javah",
|
||||||
"com.sun.tools.javap",
|
"com.sun.tools.javap",
|
||||||
"com.sun.tools.jdeps",
|
"com.sun.tools.jdeps",
|
||||||
"com.sun.tools.sjavac"
|
"com.sun.tools.sjavac"
|
||||||
};
|
};
|
||||||
for (String pkg: pkgs) {
|
for (String pkg: pkgs) {
|
||||||
for (JavaFileObject fo: fm.list(javacLoc,
|
for (JavaFileObject fo: fm.list(javacLoc,
|
||||||
pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
|
pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
|
||||||
scan(fo);
|
scan(fo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (errors == 0);
|
return (errors == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// depending on how the test is run, javac may be on bootclasspath or classpath
|
// depending on how the test is run, javac may be on bootclasspath or classpath
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -71,28 +71,29 @@ public class JarFromManifestFailure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compile(File classOutDir, Iterable<File> classPath, File... files) {
|
static void compile(File classOutDir, Iterable<File> classPath, File... files) throws IOException {
|
||||||
System.err.println("compile...");
|
System.err.println("compile...");
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> fileObjects =
|
Iterable<? extends JavaFileObject> fileObjects =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
|
||||||
|
|
||||||
List<String> options = new ArrayList<String>();
|
List<String> options = new ArrayList<String>();
|
||||||
if (classOutDir != null) {
|
if (classOutDir != null) {
|
||||||
options.add("-d");
|
options.add("-d");
|
||||||
options.add(classOutDir.getPath());
|
options.add(classOutDir.getPath());
|
||||||
}
|
}
|
||||||
if (classPath != null) {
|
if (classPath != null) {
|
||||||
options.add("-classpath");
|
options.add("-classpath");
|
||||||
options.add(join(classPath, File.pathSeparator));
|
options.add(join(classPath, File.pathSeparator));
|
||||||
}
|
}
|
||||||
options.add("-verbose");
|
options.add("-verbose");
|
||||||
|
|
||||||
JavaCompiler.CompilationTask task =
|
JavaCompiler.CompilationTask task =
|
||||||
compiler.getTask(null, fm, null, options, null, fileObjects);
|
compiler.getTask(null, fm, null, options, null, fileObjects);
|
||||||
if (!task.call())
|
if (!task.call())
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jar(File jar, Iterable<File> classPath, File base, File... files)
|
static void jar(File jar, Iterable<File> classPath, File base, File... files)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -116,17 +116,18 @@ public class TestCompileJARInClassPath {
|
||||||
|
|
||||||
javax.tools.JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
javax.tools.JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
||||||
StandardJavaFileManager stdFileManager = javac.getStandardFileManager(diagnostics, null, null);
|
try (StandardJavaFileManager stdFileManager = javac.getStandardFileManager(diagnostics, null, null)) {
|
||||||
|
|
||||||
List<File> files = new ArrayList<>();
|
List<File> files = new ArrayList<>();
|
||||||
files.add(clientJarFile);
|
files.add(clientJarFile);
|
||||||
|
|
||||||
stdFileManager.setLocation(StandardLocation.CLASS_PATH, files);
|
stdFileManager.setLocation(StandardLocation.CLASS_PATH, files);
|
||||||
|
|
||||||
Iterable<? extends JavaFileObject> sourceFiles = stdFileManager.getJavaFileObjects(sourceFileToCompile);
|
Iterable<? extends JavaFileObject> sourceFiles = stdFileManager.getJavaFileObjects(sourceFileToCompile);
|
||||||
|
|
||||||
if (!javac.getTask(null, stdFileManager, diagnostics, null, null, sourceFiles).call()) {
|
if (!javac.getTask(null, stdFileManager, diagnostics, null, null, sourceFiles).call()) {
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -44,10 +44,11 @@ public class T6265400 {
|
||||||
throw new NullPointerException(SILLY_BILLY);
|
throw new NullPointerException(SILLY_BILLY);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromStrings(Arrays.asList("badfile.java"));
|
fm.getJavaFileObjectsFromStrings(Arrays.asList("badfile.java"));
|
||||||
javac.getTask(null, fm, dl, null, null, files).call();
|
javac.getTask(null, fm, dl, null, null, files).call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) {
|
catch (RuntimeException e) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -44,13 +44,14 @@ public class T6340549 {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
jfm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
|
jfm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(".")));
|
||||||
|
|
||||||
for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH,
|
for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH,
|
||||||
"", EnumSet.of(Kind.OTHER), false)) {
|
"", EnumSet.of(Kind.OTHER), false)) {
|
||||||
if (new File(jfo.getName()).isDirectory()) {
|
if (new File(jfo.getName()).isDirectory()) {
|
||||||
throw new AssertionError("Found directory: " + jfo);
|
throw new AssertionError("Found directory: " + jfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -38,52 +38,52 @@ public class T6351767 {
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
|
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
JavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
|
try (JavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
// test null
|
// test null
|
||||||
try {
|
try {
|
||||||
jfm.list(StandardLocation.SOURCE_PATH, null, EnumSet.of(Kind.SOURCE), false);
|
jfm.list(StandardLocation.SOURCE_PATH, null, EnumSet.of(Kind.SOURCE), false);
|
||||||
error("NPE not thrown");
|
error("NPE not thrown");
|
||||||
}
|
}
|
||||||
catch (NullPointerException e) {
|
catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
// test null fileKinds
|
// test null fileKinds
|
||||||
try {
|
try {
|
||||||
jfm.list(StandardLocation.SOURCE_PATH, "", null, false);
|
jfm.list(StandardLocation.SOURCE_PATH, "", null, false);
|
||||||
error("NPE not thrown");
|
error("NPE not thrown");
|
||||||
}
|
}
|
||||||
catch (NullPointerException e) {
|
catch (NullPointerException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
// test good package
|
// test good package
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
||||||
"java.lang",
|
"java.lang",
|
||||||
EnumSet.of(Kind.CLASS),
|
EnumSet.of(Kind.CLASS),
|
||||||
false)) {
|
false)) {
|
||||||
System.err.println("found " + jfo.toUri());
|
System.err.println("found " + jfo.toUri());
|
||||||
if (jfo.isNameCompatible("Object", Kind.CLASS))
|
if (jfo.isNameCompatible("Object", Kind.CLASS))
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
error("expected file, java/lang/Object.class, not found");
|
error("expected file, java/lang/Object.class, not found");
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
// test good package (VM name)
|
// test good package (VM name)
|
||||||
for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
||||||
"java/lang",
|
"java/lang",
|
||||||
EnumSet.of(Kind.CLASS),
|
EnumSet.of(Kind.CLASS),
|
||||||
false)) {
|
false)) {
|
||||||
System.err.println("found " + jfo.toUri());
|
System.err.println("found " + jfo.toUri());
|
||||||
if (jfo.isNameCompatible("Object", Kind.CLASS))
|
if (jfo.isNameCompatible("Object", Kind.CLASS))
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
error("expected file, java/lang/Object.class, not found");
|
||||||
}
|
}
|
||||||
if (!found)
|
|
||||||
error("expected file, java/lang/Object.class, not found");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error(String msg) {
|
static void error(String msg) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -57,17 +57,18 @@ public class T6361619 extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> f =
|
Iterable<? extends JavaFileObject> f =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir,
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir,
|
||||||
self + ".java")));
|
self + ".java")));
|
||||||
|
|
||||||
JavacTask task = tool.getTask(out, fm, dl, flags, null, f);
|
JavacTask task = tool.getTask(out, fm, dl, flags, null, f);
|
||||||
MyTaskListener tl = new MyTaskListener(task);
|
MyTaskListener tl = new MyTaskListener(task);
|
||||||
task.setTaskListener(tl);
|
task.setTaskListener(tl);
|
||||||
|
|
||||||
// should complete, without exceptions
|
// should complete, without exceptions
|
||||||
task.call();
|
task.call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
|
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
|
||||||
|
|
|
@ -44,24 +44,25 @@ public class T6395974 {
|
||||||
String testSrc = System.getProperty("test.src");
|
String testSrc = System.getProperty("test.src");
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<?extends JavaFileObject> f =
|
Iterable<?extends JavaFileObject> f =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self + ".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self + ".java")));
|
||||||
|
|
||||||
PrintWriter out = new PrintWriter(System.err, true);
|
PrintWriter out = new PrintWriter(System.err, true);
|
||||||
|
|
||||||
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out,
|
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out,
|
||||||
fm,
|
fm,
|
||||||
null,
|
null,
|
||||||
Arrays.asList("-processor",
|
Arrays.asList("-processor",
|
||||||
"Foo.java"),
|
"Foo.java"),
|
||||||
null,
|
null,
|
||||||
f);
|
f);
|
||||||
|
|
||||||
MyTaskListener tl = new MyTaskListener();
|
MyTaskListener tl = new MyTaskListener();
|
||||||
task.setTaskListener(tl);
|
task.setTaskListener(tl);
|
||||||
|
|
||||||
task.call();
|
task.call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MyTaskListener implements TaskListener {
|
static class MyTaskListener implements TaskListener {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -42,14 +42,15 @@ public abstract class T6397044 {
|
||||||
String srcDir = System.getProperty("test.src", ".");
|
String srcDir = System.getProperty("test.src", ".");
|
||||||
String self = T6397044.class.getName();
|
String self = T6397044.class.getName();
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files
|
Iterable<? extends JavaFileObject> files
|
||||||
= fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcDir, self + ".java")));
|
= fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcDir, self + ".java")));
|
||||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||||
Checker checker = new Checker();
|
Checker checker = new Checker();
|
||||||
for (CompilationUnitTree tree: trees)
|
for (CompilationUnitTree tree: trees)
|
||||||
checker.check(tree);
|
checker.check(tree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int x_public;
|
public int x_public;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -40,29 +40,30 @@ public class T6397286 {
|
||||||
String self = T6397286.class.getName();
|
String self = T6397286.class.getName();
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||||
|
|
||||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||||
task.setTaskListener(new TaskListener() {
|
task.setTaskListener(new TaskListener() {
|
||||||
public void started(TaskEvent e) {
|
public void started(TaskEvent e) {
|
||||||
throw new TaskEventError(e);
|
throw new TaskEventError(e);
|
||||||
}
|
}
|
||||||
public void finished(TaskEvent e) {
|
public void finished(TaskEvent e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
task.call();
|
task.call();
|
||||||
throw new AssertionError("no exception thrown");
|
throw new AssertionError("no exception thrown");
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
if (e.getCause() instanceof TaskEventError) {
|
if (e.getCause() instanceof TaskEventError) {
|
||||||
TaskEventError tee = (TaskEventError) e.getCause();
|
TaskEventError tee = (TaskEventError) e.getCause();
|
||||||
System.err.println("Exception thrown for " + tee.event + " as expected");
|
System.err.println("Exception thrown for " + tee.event + " as expected");
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new AssertionError("TaskEventError not thrown");
|
throw new AssertionError("TaskEventError not thrown");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -51,24 +51,25 @@ public class T6403466 extends AbstractProcessor {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
|
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||||
|
|
||||||
Iterable<String> options = Arrays.asList("-processorpath", testClassDir,
|
Iterable<String> options = Arrays.asList("-processorpath", testClassDir,
|
||||||
"-processor", self,
|
"-processor", self,
|
||||||
"-s", ".",
|
"-s", ".",
|
||||||
"-d", ".");
|
"-d", ".");
|
||||||
JavacTask task = tool.getTask(out, fm, null, options, null, files);
|
JavacTask task = tool.getTask(out, fm, null, options, null, files);
|
||||||
|
|
||||||
VerifyingTaskListener vtl = new VerifyingTaskListener(new File(testSrcDir, self + ".out"));
|
VerifyingTaskListener vtl = new VerifyingTaskListener(new File(testSrcDir, self + ".out"));
|
||||||
task.setTaskListener(vtl);
|
task.setTaskListener(vtl);
|
||||||
|
|
||||||
if (!task.call())
|
if (!task.call())
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
|
|
||||||
if (vtl.iter.hasNext() || vtl.errors)
|
if (vtl.iter.hasNext() || vtl.errors)
|
||||||
throw new AssertionError("comparison against golden file failed.");
|
throw new AssertionError("comparison against golden file failed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
|
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
|
||||||
|
|
|
@ -33,21 +33,22 @@ public class T6406771 extends AbstractProcessor {
|
||||||
|
|
||||||
// White-space after this point does not matter
|
// White-space after this point does not matter
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws IOException {
|
||||||
String self = T6406771.class.getName();
|
String self = T6406771.class.getName();
|
||||||
String testSrc = System.getProperty("test.src");
|
String testSrc = System.getProperty("test.src");
|
||||||
String testClasses = System.getProperty("test.classes");
|
String testClasses = System.getProperty("test.classes");
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
|
JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
|
||||||
|
|
||||||
List<String> opts = Arrays.asList("-d", ".", "-processorpath", testClasses, "-processor", self, "-proc:only");
|
List<String> opts = Arrays.asList("-d", ".", "-processorpath", testClasses, "-processor", self, "-proc:only");
|
||||||
|
|
||||||
JavacTask task = tool.getTask(null, fm, null, opts, null, Arrays.asList(f));
|
JavacTask task = tool.getTask(null, fm, null, opts, null, Arrays.asList(f));
|
||||||
|
|
||||||
if (!task.call())
|
if (!task.call())
|
||||||
throw new AssertionError("failed");
|
throw new AssertionError("failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment rEnv) {
|
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment rEnv) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -37,20 +37,21 @@ public class T6407066 {
|
||||||
String testClasses = System.getProperty("test.classes", ".");
|
String testClasses = System.getProperty("test.classes", ".");
|
||||||
|
|
||||||
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager jfm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager jfm = tool.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
List<File> path = new ArrayList<File>();
|
List<File> path = new ArrayList<File>();
|
||||||
path.add(new File("BadDirectory"));
|
path.add(new File("BadDirectory"));
|
||||||
path.add(new File(testSrc));
|
path.add(new File(testSrc));
|
||||||
path.add(new File("BadFile.jar"));
|
path.add(new File("BadFile.jar"));
|
||||||
|
|
||||||
jfm.setLocation(StandardLocation.SOURCE_PATH, path);
|
jfm.setLocation(StandardLocation.SOURCE_PATH, path);
|
||||||
|
|
||||||
List<File> path2 = new ArrayList<File>();
|
List<File> path2 = new ArrayList<File>();
|
||||||
for (File f: jfm.getLocation(StandardLocation.SOURCE_PATH))
|
for (File f: jfm.getLocation(StandardLocation.SOURCE_PATH))
|
||||||
path2.add(f);
|
path2.add(f);
|
||||||
|
|
||||||
if (!path.equals(path2))
|
if (!path.equals(path2))
|
||||||
throw new AssertionError("path not preserved");
|
throw new AssertionError("path not preserved");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -44,21 +44,22 @@ public class T6410706 {
|
||||||
String testClasses = System.getProperty("test.classes", ".");
|
String testClasses = System.getProperty("test.classes", ".");
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
MyDiagListener dl = new MyDiagListener();
|
MyDiagListener dl = new MyDiagListener();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(testClasses)));
|
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(testClasses)));
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6410706.class.getName()+".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6410706.class.getName()+".java")));
|
||||||
JavacTask task = tool.getTask(null, fm, dl, null, null, files);
|
JavacTask task = tool.getTask(null, fm, dl, null, null, files);
|
||||||
task.parse();
|
task.parse();
|
||||||
task.analyze();
|
task.analyze();
|
||||||
task.generate();
|
task.generate();
|
||||||
|
|
||||||
// expect 2 notes:
|
// expect 2 notes:
|
||||||
// Note: T6410706.java uses or overrides a deprecated API.
|
// Note: T6410706.java uses or overrides a deprecated API.
|
||||||
// Note: Recompile with -Xlint:deprecation for details.
|
// Note: Recompile with -Xlint:deprecation for details.
|
||||||
|
|
||||||
if (dl.notes != 2)
|
if (dl.notes != 2)
|
||||||
throw new AssertionError(dl.notes + " notes given");
|
throw new AssertionError(dl.notes + " notes given");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MyDiagListener implements DiagnosticListener<JavaFileObject>
|
private static class MyDiagListener implements DiagnosticListener<JavaFileObject>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -55,33 +55,34 @@ public class T6458823 {
|
||||||
}
|
}
|
||||||
DiagnosticCollector<JavaFileObject> diagColl =
|
DiagnosticCollector<JavaFileObject> diagColl =
|
||||||
new DiagnosticCollector<JavaFileObject>();
|
new DiagnosticCollector<JavaFileObject>();
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
List<String> options = new ArrayList<String>();
|
List<String> options = new ArrayList<String>();
|
||||||
options.add("-processor");
|
options.add("-processor");
|
||||||
options.add("MyProcessor");
|
options.add("MyProcessor");
|
||||||
options.add("-proc:only");
|
options.add("-proc:only");
|
||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<File>();
|
||||||
files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
|
files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
|
||||||
final CompilationTask task = compiler.getTask(null, fm, diagColl,
|
final CompilationTask task = compiler.getTask(null, fm, diagColl,
|
||||||
options, null, fm.getJavaFileObjectsFromFiles(files));
|
options, null, fm.getJavaFileObjectsFromFiles(files));
|
||||||
task.call();
|
task.call();
|
||||||
int diagCount = 0;
|
int diagCount = 0;
|
||||||
for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
|
for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
|
||||||
if (diag.getKind() != Diagnostic.Kind.WARNING) {
|
if (diag.getKind() != Diagnostic.Kind.WARNING) {
|
||||||
throw new AssertionError("Only warnings expected");
|
throw new AssertionError("Only warnings expected");
|
||||||
|
}
|
||||||
|
System.out.println(diag);
|
||||||
|
if (diag.getPosition() == Diagnostic.NOPOS) {
|
||||||
|
throw new AssertionError("No position info in message");
|
||||||
|
}
|
||||||
|
if (diag.getSource() == null) {
|
||||||
|
throw new AssertionError("No source info in message");
|
||||||
|
}
|
||||||
|
diagCount++;
|
||||||
}
|
}
|
||||||
System.out.println(diag);
|
if (diagCount != 2) {
|
||||||
if (diag.getPosition() == Diagnostic.NOPOS) {
|
throw new AssertionError("unexpected number of warnings: " +
|
||||||
throw new AssertionError("No position info in message");
|
diagCount + ", expected: 2");
|
||||||
}
|
}
|
||||||
if (diag.getSource() == null) {
|
|
||||||
throw new AssertionError("No source info in message");
|
|
||||||
}
|
|
||||||
diagCount++;
|
|
||||||
}
|
|
||||||
if (diagCount != 2) {
|
|
||||||
throw new AssertionError("unexpected number of warnings: " +
|
|
||||||
diagCount + ", expected: 2");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -47,29 +47,30 @@ public class T6665791 {
|
||||||
write(test_java, test);
|
write(test_java, test);
|
||||||
|
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager manager =
|
try (StandardJavaFileManager manager =
|
||||||
compiler.getStandardFileManager(null, null, null);
|
compiler.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> units = manager.getJavaFileObjects(test_java);
|
Iterable<? extends JavaFileObject> units = manager.getJavaFileObjects(test_java);
|
||||||
final StringWriter sw = new StringWriter();
|
final StringWriter sw = new StringWriter();
|
||||||
JavacTask task = (JavacTask) compiler.getTask(sw, manager, null, null,
|
JavacTask task = (JavacTask) compiler.getTask(sw, manager, null, null,
|
||||||
null, units);
|
null, units);
|
||||||
|
|
||||||
new TreeScanner<Boolean, Void>() {
|
new TreeScanner<Boolean, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean visitClass(ClassTree arg0, Void arg1) {
|
public Boolean visitClass(ClassTree arg0, Void arg1) {
|
||||||
sw.write(arg0.toString());
|
sw.write(arg0.toString());
|
||||||
return super.visitClass(arg0, arg1);
|
return super.visitClass(arg0, arg1);
|
||||||
|
}
|
||||||
|
}.scan(task.parse(), null);
|
||||||
|
|
||||||
|
System.out.println("output:");
|
||||||
|
System.out.println(sw.toString());
|
||||||
|
String found = sw.toString().replaceAll("\\s+", " ").trim();
|
||||||
|
String expect = test.replaceAll("\\s+", " ").trim();
|
||||||
|
if (!expect.equals(found)) {
|
||||||
|
System.out.println("expect: " + expect);
|
||||||
|
System.out.println("found: " + found);
|
||||||
|
throw new Exception("unexpected output");
|
||||||
}
|
}
|
||||||
}.scan(task.parse(), null);
|
|
||||||
|
|
||||||
System.out.println("output:");
|
|
||||||
System.out.println(sw.toString());
|
|
||||||
String found = sw.toString().replaceAll("\\s+", " ").trim();
|
|
||||||
String expect = test.replaceAll("\\s+", " ").trim();
|
|
||||||
if (!expect.equals(found)) {
|
|
||||||
System.out.println("expect: " + expect);
|
|
||||||
System.out.println("found: " + found);
|
|
||||||
throw new Exception("unexpected output");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,46 +45,47 @@ public class T6705935 {
|
||||||
java_home = java_home.getParentFile();
|
java_home = java_home.getParentFile();
|
||||||
|
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
//System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));
|
//System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));
|
||||||
|
|
||||||
for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
||||||
"java.lang",
|
"java.lang",
|
||||||
Collections.singleton(JavaFileObject.Kind.CLASS),
|
Collections.singleton(JavaFileObject.Kind.CLASS),
|
||||||
false)) {
|
false)) {
|
||||||
test++;
|
test++;
|
||||||
|
|
||||||
|
if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
|
||||||
|
System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
|
||||||
|
skip++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//System.err.println(fo.getName());
|
||||||
|
String p = fo.getName();
|
||||||
|
int bra = p.indexOf("(");
|
||||||
|
int ket = p.indexOf(")");
|
||||||
|
//System.err.println(bra + "," + ket + "," + p.length());
|
||||||
|
if (bra == -1 || ket != p.length() -1)
|
||||||
|
throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
|
||||||
|
String part1 = p.substring(0, bra);
|
||||||
|
String part2 = p.substring(bra + 1, ket);
|
||||||
|
//System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
|
||||||
|
if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
|
||||||
|
throw new Exception("bad path: " + p);
|
||||||
|
|
||||||
if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
|
|
||||||
System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
|
|
||||||
skip++;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.err.println(fo.getName());
|
if (test == 0)
|
||||||
String p = fo.getName();
|
throw new Exception("no files found");
|
||||||
int bra = p.indexOf("(");
|
|
||||||
int ket = p.indexOf(")");
|
|
||||||
//System.err.println(bra + "," + ket + "," + p.length());
|
|
||||||
if (bra == -1 || ket != p.length() -1)
|
|
||||||
throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
|
|
||||||
String part1 = p.substring(0, bra);
|
|
||||||
String part2 = p.substring(bra + 1, ket);
|
|
||||||
//System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
|
|
||||||
if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
|
|
||||||
throw new Exception("bad path: " + p);
|
|
||||||
|
|
||||||
|
if (skip == 0)
|
||||||
|
System.out.println(test + " files found");
|
||||||
|
else
|
||||||
|
System.out.println(test + " files found, " + skip + " files skipped");
|
||||||
|
|
||||||
|
if (test == skip)
|
||||||
|
System.out.println("Warning: all files skipped; no platform classes found in zip files.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test == 0)
|
|
||||||
throw new Exception("no files found");
|
|
||||||
|
|
||||||
if (skip == 0)
|
|
||||||
System.out.println(test + " files found");
|
|
||||||
else
|
|
||||||
System.out.println(test + " files found, " + skip + " files skipped");
|
|
||||||
|
|
||||||
if (test == skip)
|
|
||||||
System.out.println("Warning: all files skipped; no platform classes found in zip files.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> List<T> asList(Iterable<? extends T> items) {
|
private <T> List<T> asList(Iterable<? extends T> items) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -37,14 +37,15 @@ public class T6900149 {
|
||||||
DiagnosticCollector<JavaFileObject> diag =
|
DiagnosticCollector<JavaFileObject> diag =
|
||||||
new DiagnosticCollector<JavaFileObject>();
|
new DiagnosticCollector<JavaFileObject>();
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm =
|
try (StandardJavaFileManager fm =
|
||||||
compiler.getStandardFileManager(null, null, null);
|
compiler.getStandardFileManager(null, null, null)) {
|
||||||
File emptyFile = createTempFile("Empty.java");
|
File emptyFile = createTempFile("Empty.java");
|
||||||
File[] files = new File[] { emptyFile, emptyFile };
|
File[] files = new File[] { emptyFile, emptyFile };
|
||||||
CompilationTask task = compiler.getTask(null, fm, diag,
|
CompilationTask task = compiler.getTask(null, fm, diag,
|
||||||
null, null, fm.getJavaFileObjects(files));
|
null, null, fm.getJavaFileObjects(files));
|
||||||
if (! task.call()) {
|
if (! task.call()) {
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -44,14 +44,15 @@ public class T6956462 {
|
||||||
if (compiler == null) {
|
if (compiler == null) {
|
||||||
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
|
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
|
||||||
}
|
}
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<File>();
|
||||||
files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
|
files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
|
||||||
final CompilationTask task = compiler.getTask(null, fm, null,
|
final CompilationTask task = compiler.getTask(null, fm, null,
|
||||||
null, null, fm.getJavaFileObjectsFromFiles(files));
|
null, null, fm.getJavaFileObjectsFromFiles(files));
|
||||||
JavacTask javacTask = (JavacTask) task;
|
JavacTask javacTask = (JavacTask) task;
|
||||||
for (CompilationUnitTree cu : javacTask.parse()) {
|
for (CompilationUnitTree cu : javacTask.parse()) {
|
||||||
cu.accept(new MyVisitor(javacTask), null);
|
cu.accept(new MyVisitor(javacTask), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -96,34 +96,35 @@ public class T6956638 {
|
||||||
List<String> compileOptions = Arrays.asList("-d", classesDir.getPath());
|
List<String> compileOptions = Arrays.asList("-d", classesDir.getPath());
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
|
DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
|
||||||
StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticCollector, null, null);
|
try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticCollector, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> sourceFileObjects = fileManager.getJavaFileObjects(sourceFiles);
|
Iterable<? extends JavaFileObject> sourceFileObjects = fileManager.getJavaFileObjects(sourceFiles);
|
||||||
System.err.println("1- javac given java source JavaFileObjects " + sourceFileObjects);
|
System.err.println("1- javac given java source JavaFileObjects " + sourceFileObjects);
|
||||||
JavaCompiler.CompilationTask task = compiler.getTask(compilerOutputStream, fileManager, null, compileOptions, null, sourceFileObjects);
|
JavaCompiler.CompilationTask task = compiler.getTask(compilerOutputStream, fileManager, null, compileOptions, null, sourceFileObjects);
|
||||||
JavacTask javacTask = (JavacTask) task;
|
JavacTask javacTask = (JavacTask) task;
|
||||||
|
|
||||||
Iterable<? extends CompilationUnitTree> parsedTrees = javacTask.parse();
|
Iterable<? extends CompilationUnitTree> parsedTrees = javacTask.parse();
|
||||||
Iterable<? extends Element> analyzedTrees = javacTask.analyze();
|
Iterable<? extends Element> analyzedTrees = javacTask.analyze();
|
||||||
Iterable<? extends JavaFileObject> generatedFiles = javacTask.generate();
|
Iterable<? extends JavaFileObject> generatedFiles = javacTask.generate();
|
||||||
|
|
||||||
System.err.println("2- parsed:" + size(parsedTrees) + " analysed:" + size(analyzedTrees) + " generated:" + size(generatedFiles));
|
System.err.println("2- parsed:" + size(parsedTrees) + " analysed:" + size(analyzedTrees) + " generated:" + size(generatedFiles));
|
||||||
|
|
||||||
System.err.print("3-");
|
System.err.print("3-");
|
||||||
for (JavaFileObject f : generatedFiles)
|
for (JavaFileObject f : generatedFiles)
|
||||||
System.err.print(" " + f);
|
System.err.print(" " + f);
|
||||||
System.err.println("");
|
System.err.println("");
|
||||||
|
|
||||||
System.err.print("5-");
|
System.err.print("5-");
|
||||||
for (File f : classesDir.listFiles())
|
for (File f : classesDir.listFiles())
|
||||||
System.err.print(" " + f);
|
System.err.print(" " + f);
|
||||||
System.err.println("");
|
System.err.println("");
|
||||||
|
|
||||||
System.err.println("----");
|
System.err.println("----");
|
||||||
System.err.println(compilerOutputStream.toString());
|
System.err.println(compilerOutputStream.toString());
|
||||||
|
|
||||||
if (size(generatedFiles) != size(parsedTrees)) {
|
if (size(generatedFiles) != size(parsedTrees)) {
|
||||||
throw new Exception("wrong number of files generated: " + size(generatedFiles)
|
throw new Exception("wrong number of files generated: " + size(generatedFiles)
|
||||||
+ " expected: " + size(parsedTrees));
|
+ " expected: " + size(parsedTrees));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -58,28 +58,29 @@ public class Bug {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null);
|
try (StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null)) {
|
||||||
|
|
||||||
List<String> opts = new ArrayList<String>();
|
List<String> opts = new ArrayList<String>();
|
||||||
opts.add("-proc:only");
|
opts.add("-proc:only");
|
||||||
opts.add("-processor");
|
opts.add("-processor");
|
||||||
opts.add("AnnoProcessor");
|
opts.add("AnnoProcessor");
|
||||||
|
|
||||||
boolean xxx;
|
boolean xxx;
|
||||||
|
|
||||||
System.err.println("\n-- " + name);
|
System.err.println("\n-- " + name);
|
||||||
task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null);
|
task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null);
|
||||||
xxx = task2.call();
|
xxx = task2.call();
|
||||||
|
|
||||||
String out = sw.toString();
|
String out = sw.toString();
|
||||||
System.err.println(out);
|
System.err.println(out);
|
||||||
if (out.contains("Assert")) {
|
if (out.contains("Assert")) {
|
||||||
System.err.println("--Failed: Assertion failure");
|
System.err.println("--Failed: Assertion failure");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
if (!out.contains(expectedMsg)) {
|
if (!out.contains(expectedMsg)) {
|
||||||
System.err.println("--Failed: Expected diagnostic not found");
|
System.err.println("--Failed: Expected diagnostic not found");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,6 +45,7 @@ import javax.lang.model.SourceVersion;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.tools.Diagnostic;
|
import javax.tools.Diagnostic;
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
|
import javax.tools.StandardJavaFileManager;
|
||||||
import javax.tools.ToolProvider;
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
public class T7159016 {
|
public class T7159016 {
|
||||||
|
@ -58,11 +59,13 @@ public class T7159016 {
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
|
||||||
JavaCompiler.CompilationTask task = jc.getTask(null, null, null, null, null,
|
try (StandardJavaFileManager fm = jc.getStandardFileManager(null, null, null)) {
|
||||||
jc.getStandardFileManager(null, null, null).getJavaFileObjects(src));
|
JavaCompiler.CompilationTask task = jc.getTask(null, fm, null, null, null,
|
||||||
task.setProcessors(Collections.singleton(new Proc()));
|
fm.getJavaFileObjects(src));
|
||||||
if (!task.call()) {
|
task.setProcessors(Collections.singleton(new Proc()));
|
||||||
throw new Error("Test failed");
|
if (!task.call()) {
|
||||||
|
throw new Error("Test failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -179,18 +179,19 @@ public class DetectMutableStaticFields {
|
||||||
ConstantPoolException,
|
ConstantPoolException,
|
||||||
InvalidDescriptor {
|
InvalidDescriptor {
|
||||||
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
JavaFileManager.Location location =
|
JavaFileManager.Location location =
|
||||||
StandardLocation.locationFor(resource.getPath());
|
StandardLocation.locationFor(resource.getPath());
|
||||||
fm.setLocation(location, com.sun.tools.javac.util.List.of(
|
fm.setLocation(location, com.sun.tools.javac.util.List.of(
|
||||||
new File(resource.getPath())));
|
new File(resource.getPath())));
|
||||||
|
|
||||||
for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
|
for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
|
||||||
String className = fm.inferBinaryName(location, file);
|
String className = fm.inferBinaryName(location, file);
|
||||||
int index = className.lastIndexOf('.');
|
int index = className.lastIndexOf('.');
|
||||||
String pckName = index == -1 ? "" : className.substring(0, index);
|
String pckName = index == -1 ? "" : className.substring(0, index);
|
||||||
if (shouldAnalyzePackage(pckName)) {
|
if (shouldAnalyzePackage(pckName)) {
|
||||||
analyzeClassFile(ClassFile.read(file.openInputStream()));
|
analyzeClassFile(ClassFile.read(file.openInputStream()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -132,73 +132,74 @@ public class ParameterNamesAreNotCopiedToAnonymousInitTest {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg);
|
Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg);
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> fos =
|
Iterable<? extends JavaFileObject> fos =
|
||||||
fm.getJavaFileObjectsFromFiles(
|
fm.getJavaFileObjectsFromFiles(
|
||||||
Arrays.asList(new File(System.getProperty("test.src"),
|
Arrays.asList(new File(System.getProperty("test.src"),
|
||||||
this.getClass().getName() + ".java")));
|
this.getClass().getName() + ".java")));
|
||||||
JavacTask task = (JavacTask) c.getTask(null, fm, null,
|
JavacTask task = (JavacTask) c.getTask(null, fm, null,
|
||||||
Arrays.asList("-d", System.getProperty("user.dir")), null, fos);
|
Arrays.asList("-d", System.getProperty("user.dir")), null, fos);
|
||||||
|
|
||||||
BasicJavacTask impl = (BasicJavacTask)task;
|
BasicJavacTask impl = (BasicJavacTask)task;
|
||||||
Context context = impl.getContext();
|
Context context = impl.getContext();
|
||||||
final Names names = Names.instance(context);
|
final Names names = Names.instance(context);
|
||||||
|
|
||||||
task.addTaskListener(new TaskListener() {
|
task.addTaskListener(new TaskListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void started(TaskEvent e) {}
|
public void started(TaskEvent e) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finished(TaskEvent e) {
|
public void finished(TaskEvent e) {
|
||||||
class TheTreeScanner extends TreeScanner {
|
class TheTreeScanner extends TreeScanner {
|
||||||
boolean foundAndCorrect = false;
|
boolean foundAndCorrect = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitMethodDef(JCTree.JCMethodDecl tree) {
|
public void visitMethodDef(JCTree.JCMethodDecl tree) {
|
||||||
ClassSymbol clazz = (ClassSymbol)tree.sym.owner;
|
ClassSymbol clazz = (ClassSymbol)tree.sym.owner;
|
||||||
if (clazz.owner.name.toString().equals(classOwnerName) &&
|
if (clazz.owner.name.toString().equals(classOwnerName) &&
|
||||||
tree.sym.name == names.init) {
|
tree.sym.name == names.init) {
|
||||||
|
|
||||||
int currentParamPos = 0;
|
int currentParamPos = 0;
|
||||||
int paramArrayIndex = 0;
|
int paramArrayIndex = 0;
|
||||||
|
|
||||||
List<VarSymbol> params = tree.sym.params;
|
List<VarSymbol> params = tree.sym.params;
|
||||||
while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) {
|
while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) {
|
||||||
VarSymbol param = params.head;
|
VarSymbol param = params.head;
|
||||||
if (currentParamPos == paramsToCheck.get(paramArrayIndex)) {
|
if (currentParamPos == paramsToCheck.get(paramArrayIndex)) {
|
||||||
if (!param.name.toString()
|
if (!param.name.toString()
|
||||||
.equals(paramNames.get(paramArrayIndex))) {
|
.equals(paramNames.get(paramArrayIndex))) {
|
||||||
error(paramNameNotCopiedAssertionMsg);
|
error(paramNameNotCopiedAssertionMsg);
|
||||||
|
}
|
||||||
|
paramArrayIndex++;
|
||||||
}
|
}
|
||||||
paramArrayIndex++;
|
currentParamPos++;
|
||||||
|
params = params.tail;
|
||||||
}
|
}
|
||||||
currentParamPos++;
|
foundAndCorrect = paramArrayIndex >= paramsToCheck.size();
|
||||||
params = params.tail;
|
|
||||||
}
|
}
|
||||||
foundAndCorrect = paramArrayIndex >= paramsToCheck.size();
|
super.visitMethodDef(tree);
|
||||||
}
|
}
|
||||||
super.visitMethodDef(tree);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (e.getKind() == TaskEvent.Kind.ANALYZE) {
|
if (e.getKind() == TaskEvent.Kind.ANALYZE) {
|
||||||
CompilationUnitTree compUnitTree = e.getCompilationUnit();
|
CompilationUnitTree compUnitTree = e.getCompilationUnit();
|
||||||
boolean foundAndCorrect = false;
|
boolean foundAndCorrect = false;
|
||||||
for (Tree tree : compUnitTree.getTypeDecls()) {
|
for (Tree tree : compUnitTree.getTypeDecls()) {
|
||||||
TheTreeScanner scanner = new TheTreeScanner();
|
TheTreeScanner scanner = new TheTreeScanner();
|
||||||
scanner.scan((JCTree) tree);
|
scanner.scan((JCTree) tree);
|
||||||
foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect;
|
foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect;
|
||||||
}
|
}
|
||||||
if (!foundAndCorrect) {
|
if (!foundAndCorrect) {
|
||||||
error(seekMethodNotFound);
|
error(seekMethodNotFound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!task.call()) {
|
||||||
|
error(compilationFailed);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (!task.call()) {
|
|
||||||
error(compilationFailed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -117,16 +117,17 @@ public class InterruptedExceptionTest {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (XlintOption xlint : XlintOption.values()) {
|
for (XlintOption xlint : XlintOption.values()) {
|
||||||
for (SuppressLevel suppress_decl : SuppressLevel.values()) {
|
for (SuppressLevel suppress_decl : SuppressLevel.values()) {
|
||||||
for (SuppressLevel suppress_use : SuppressLevel.values()) {
|
for (SuppressLevel suppress_use : SuppressLevel.values()) {
|
||||||
for (ClassKind ck : ClassKind.values()) {
|
for (ClassKind ck : ClassKind.values()) {
|
||||||
for (ExceptionKind ek_decl : ExceptionKind.values()) {
|
for (ExceptionKind ek_decl : ExceptionKind.values()) {
|
||||||
for (ExceptionKind ek_use : ExceptionKind.values()) {
|
for (ExceptionKind ek_use : ExceptionKind.values()) {
|
||||||
new InterruptedExceptionTest(xlint, suppress_decl,
|
new InterruptedExceptionTest(xlint, suppress_decl,
|
||||||
suppress_use, ck, ek_decl, ek_use).run(comp, fm);
|
suppress_use, ck, ek_decl, ek_use).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -161,20 +161,24 @@ public class UnusedResourcesTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
for (XlintOption xlint : XlintOption.values()) {
|
try {
|
||||||
for (SuppressLevel suppressLevel : SuppressLevel.values()) {
|
for (XlintOption xlint : XlintOption.values()) {
|
||||||
for (ResourceUsage usage1 : ResourceUsage.values()) {
|
for (SuppressLevel suppressLevel : SuppressLevel.values()) {
|
||||||
for (ResourceUsage usage2 : ResourceUsage.values()) {
|
for (ResourceUsage usage1 : ResourceUsage.values()) {
|
||||||
for (ResourceUsage usage3 : ResourceUsage.values()) {
|
for (ResourceUsage usage2 : ResourceUsage.values()) {
|
||||||
test(xlint,
|
for (ResourceUsage usage3 : ResourceUsage.values()) {
|
||||||
suppressLevel,
|
test(xlint,
|
||||||
usage1,
|
suppressLevel,
|
||||||
usage2,
|
usage1,
|
||||||
usage3);
|
usage2,
|
||||||
|
usage3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -41,38 +41,39 @@ public class VerifyAnnotationsAttributed {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
File testFile = new File(testSrc, args[0]);
|
File testFile = new File(testSrc, args[0]);
|
||||||
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
|
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
|
||||||
JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
|
try (JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
|
||||||
JavacTask task = JavacTool.create().getTask(null,
|
JavacTask task = JavacTool.create().getTask(null,
|
||||||
fm,
|
fm,
|
||||||
null,
|
null,
|
||||||
Collections.<String>emptyList(),
|
Collections.<String>emptyList(),
|
||||||
null,
|
null,
|
||||||
fm.getJavaFileObjects(testFile));
|
fm.getJavaFileObjects(testFile));
|
||||||
final Trees trees = Trees.instance(task);
|
final Trees trees = Trees.instance(task);
|
||||||
final CompilationUnitTree cut = task.parse().iterator().next();
|
final CompilationUnitTree cut = task.parse().iterator().next();
|
||||||
task.analyze();
|
task.analyze();
|
||||||
|
|
||||||
//ensure all the annotation attributes are annotated meaningfully
|
//ensure all the annotation attributes are annotated meaningfully
|
||||||
//all the attributes in the test file should contain either an identifier
|
//all the attributes in the test file should contain either an identifier
|
||||||
//or a select, so only checking those for a reasonable Element/Symbol.
|
//or a select, so only checking those for a reasonable Element/Symbol.
|
||||||
new TreePathScanner<Void, Void>() {
|
new TreePathScanner<Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void visitIdentifier(IdentifierTree node, Void p) {
|
public Void visitIdentifier(IdentifierTree node, Void p) {
|
||||||
verifyAttributedMeaningfully();
|
verifyAttributedMeaningfully();
|
||||||
return super.visitIdentifier(node, p);
|
return super.visitIdentifier(node, p);
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Void visitMemberSelect(MemberSelectTree node, Void p) {
|
|
||||||
verifyAttributedMeaningfully();
|
|
||||||
return super.visitMemberSelect(node, p);
|
|
||||||
}
|
|
||||||
private void verifyAttributedMeaningfully() {
|
|
||||||
Element el = trees.getElement(getCurrentPath());
|
|
||||||
|
|
||||||
if (el == null || el.getKind() == ElementKind.OTHER) {
|
|
||||||
throw new IllegalStateException("Not attributed properly: " + getCurrentPath().getParentPath().getLeaf());
|
|
||||||
}
|
}
|
||||||
}
|
@Override
|
||||||
}.scan(cut, null);
|
public Void visitMemberSelect(MemberSelectTree node, Void p) {
|
||||||
|
verifyAttributedMeaningfully();
|
||||||
|
return super.visitMemberSelect(node, p);
|
||||||
|
}
|
||||||
|
private void verifyAttributedMeaningfully() {
|
||||||
|
Element el = trees.getElement(getCurrentPath());
|
||||||
|
|
||||||
|
if (el == null || el.getKind() == ElementKind.OTHER) {
|
||||||
|
throw new IllegalStateException("Not attributed properly: " + getCurrentPath().getParentPath().getLeaf());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.scan(cut, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -102,29 +102,31 @@ public class Helper {
|
||||||
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
|
throw new RuntimeException("can't get javax.tools.JavaCompiler!");
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
|
// Assuming filesCount can maximum be 2 and if true, one file is package-info.java
|
||||||
// Assuming filesCount can maximum be 2 and if true, one file is package-info.java
|
if (isPkgInfoPresent(files)) {
|
||||||
if (isPkgInfoPresent(files)) {
|
JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
|
||||||
JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
|
try {
|
||||||
try {
|
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
|
||||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
|
task.generate();
|
||||||
task.generate();
|
} catch (IOException ioe) {
|
||||||
} catch (IOException ioe) {
|
throw new RuntimeException("Compilation failed for package level tests", ioe);
|
||||||
throw new RuntimeException("Compilation failed for package level tests", ioe);
|
|
||||||
}
|
|
||||||
int err = 0;
|
|
||||||
for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
|
|
||||||
if(d.getKind() == Diagnostic.Kind.ERROR) {
|
|
||||||
err++;
|
|
||||||
}
|
}
|
||||||
|
int err = 0;
|
||||||
|
for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
|
||||||
|
if(d.getKind() == Diagnostic.Kind.ERROR) {
|
||||||
|
err++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok = (err == 0);
|
||||||
|
} else {
|
||||||
|
CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
|
||||||
|
ok = task.call();
|
||||||
}
|
}
|
||||||
ok = (err == 0);
|
return ok;
|
||||||
} else {
|
} catch (IOException e) {
|
||||||
CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
|
throw new Error(e);
|
||||||
ok = task.call();
|
|
||||||
}
|
}
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private boolean isPkgInfoPresent(Iterable<? extends JavaFileObject> files) {
|
static private boolean isPkgInfoPresent(Iterable<? extends JavaFileObject> files) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -46,18 +46,18 @@ public class AnnotatedArrayOrder {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
PrintWriter out = new PrintWriter(System.out, true);
|
PrintWriter out = new PrintWriter(System.out, true);
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
Iterable<? extends JavaFileObject> f =
|
Iterable<? extends JavaFileObject> f =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java")));
|
||||||
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
||||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
Scanner s = new Scanner();
|
|
||||||
for (CompilationUnitTree t: trees)
|
|
||||||
s.scan(t, null);
|
|
||||||
|
|
||||||
|
Scanner s = new Scanner();
|
||||||
|
for (CompilationUnitTree t: trees)
|
||||||
|
s.scan(t, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Scanner extends TreeScanner<Void,Void> {
|
private static class Scanner extends TreeScanner<Void,Void> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -48,18 +48,18 @@ public class ArrayCreationTree {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
PrintWriter out = new PrintWriter(System.out, true);
|
PrintWriter out = new PrintWriter(System.out, true);
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
Iterable<? extends JavaFileObject> f =
|
Iterable<? extends JavaFileObject> f =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayCreationTree.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayCreationTree.java")));
|
||||||
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
||||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
Scanner s = new Scanner();
|
|
||||||
for (CompilationUnitTree t: trees)
|
|
||||||
s.scan(t, null);
|
|
||||||
|
|
||||||
|
Scanner s = new Scanner();
|
||||||
|
for (CompilationUnitTree t: trees)
|
||||||
|
s.scan(t, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Scanner extends TreeScanner<Void,Void> {
|
private static class Scanner extends TreeScanner<Void,Void> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -47,18 +47,18 @@ public class ArrayPositionConsistency {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
PrintWriter out = new PrintWriter(System.out, true);
|
PrintWriter out = new PrintWriter(System.out, true);
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
Iterable<? extends JavaFileObject> f =
|
Iterable<? extends JavaFileObject> f =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayPositionConsistency.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayPositionConsistency.java")));
|
||||||
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
||||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
Scanner s = new Scanner();
|
|
||||||
for (CompilationUnitTree t: trees)
|
|
||||||
s.scan(t, null);
|
|
||||||
|
|
||||||
|
Scanner s = new Scanner();
|
||||||
|
for (CompilationUnitTree t: trees)
|
||||||
|
s.scan(t, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Scanner extends TreeScanner<Void,Void> {
|
private static class Scanner extends TreeScanner<Void,Void> {
|
||||||
|
|
|
@ -72,77 +72,78 @@ public class CheckErrorsForSource7 {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
File testFile = new File(testSrc, args[0]);
|
File testFile = new File(testSrc, args[0]);
|
||||||
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
|
if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
|
||||||
JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
|
try (JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
//gather spans of the @TA annotations into typeAnnotationSpans:
|
//gather spans of the @TA annotations into typeAnnotationSpans:
|
||||||
JavacTask task = JavacTool.create().getTask(null,
|
JavacTask task = JavacTool.create().getTask(null,
|
||||||
fm,
|
fm,
|
||||||
null,
|
null,
|
||||||
Collections.<String>emptyList(),
|
Collections.<String>emptyList(),
|
||||||
null,
|
null,
|
||||||
fm.getJavaFileObjects(testFile));
|
fm.getJavaFileObjects(testFile));
|
||||||
final Trees trees = Trees.instance(task);
|
final Trees trees = Trees.instance(task);
|
||||||
final CompilationUnitTree cut = task.parse().iterator().next();
|
final CompilationUnitTree cut = task.parse().iterator().next();
|
||||||
final List<int[]> typeAnnotationSpans = new ArrayList<>();
|
final List<int[]> typeAnnotationSpans = new ArrayList<>();
|
||||||
|
|
||||||
new TreePathScanner<Void, Void>() {
|
new TreePathScanner<Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void visitAnnotation(AnnotationTree node, Void p) {
|
public Void visitAnnotation(AnnotationTree node, Void p) {
|
||||||
if (node.getAnnotationType().getKind() == Kind.IDENTIFIER &&
|
if (node.getAnnotationType().getKind() == Kind.IDENTIFIER &&
|
||||||
((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) {
|
((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) {
|
||||||
int start = (int) trees.getSourcePositions().getStartPosition(cut, node);
|
int start = (int) trees.getSourcePositions().getStartPosition(cut, node);
|
||||||
int end = (int) trees.getSourcePositions().getEndPosition(cut, node);
|
int end = (int) trees.getSourcePositions().getEndPosition(cut, node);
|
||||||
typeAnnotationSpans.add(new int[] {start, end});
|
typeAnnotationSpans.add(new int[] {start, end});
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.scan(cut, null);
|
|
||||||
|
|
||||||
//sort the spans in the reverse order, to simplify removing them from the source:
|
|
||||||
Collections.sort(typeAnnotationSpans, new Comparator<int[]>() {
|
|
||||||
@Override
|
|
||||||
public int compare(int[] o1, int[] o2) {
|
|
||||||
return o2[0] - o1[0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//verify the errors are produce correctly:
|
|
||||||
String originalSource = cut.getSourceFile().getCharContent(false).toString();
|
|
||||||
|
|
||||||
for (int[] toKeep : typeAnnotationSpans) {
|
|
||||||
//prepare updated source code by removing all the annotations except the toKeep one:
|
|
||||||
String updated = originalSource;
|
|
||||||
|
|
||||||
for (int[] span : typeAnnotationSpans) {
|
|
||||||
if (span == toKeep) continue;
|
|
||||||
|
|
||||||
updated = updated.substring(0, span[0]) + updated.substring(span[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//parse and verify:
|
|
||||||
JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated);
|
|
||||||
DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>();
|
|
||||||
JavacTask task2 = JavacTool.create().getTask(null,
|
|
||||||
fm,
|
|
||||||
errors,
|
|
||||||
Arrays.asList("-source", "7"),
|
|
||||||
null,
|
|
||||||
Arrays.asList(updatedFile));
|
|
||||||
task2.parse();
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
|
|
||||||
for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) {
|
|
||||||
if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) {
|
|
||||||
if (found) {
|
|
||||||
throw new IllegalStateException("More than one expected error found.");
|
|
||||||
}
|
}
|
||||||
found = true;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}.scan(cut, null);
|
||||||
|
|
||||||
if (!found)
|
//sort the spans in the reverse order, to simplify removing them from the source:
|
||||||
throw new IllegalStateException("Did not produce proper errors for: " + updated);
|
Collections.sort(typeAnnotationSpans, new Comparator<int[]>() {
|
||||||
|
@Override
|
||||||
|
public int compare(int[] o1, int[] o2) {
|
||||||
|
return o2[0] - o1[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//verify the errors are produce correctly:
|
||||||
|
String originalSource = cut.getSourceFile().getCharContent(false).toString();
|
||||||
|
|
||||||
|
for (int[] toKeep : typeAnnotationSpans) {
|
||||||
|
//prepare updated source code by removing all the annotations except the toKeep one:
|
||||||
|
String updated = originalSource;
|
||||||
|
|
||||||
|
for (int[] span : typeAnnotationSpans) {
|
||||||
|
if (span == toKeep) continue;
|
||||||
|
|
||||||
|
updated = updated.substring(0, span[0]) + updated.substring(span[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//parse and verify:
|
||||||
|
JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated);
|
||||||
|
DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>();
|
||||||
|
JavacTask task2 = JavacTool.create().getTask(null,
|
||||||
|
fm,
|
||||||
|
errors,
|
||||||
|
Arrays.asList("-source", "7"),
|
||||||
|
null,
|
||||||
|
Arrays.asList(updatedFile));
|
||||||
|
task2.parse();
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
|
for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) {
|
||||||
|
if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) {
|
||||||
|
if (found) {
|
||||||
|
throw new IllegalStateException("More than one expected error found.");
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
throw new IllegalStateException("Did not produce proper errors for: " + updated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -46,21 +46,22 @@ public class T6420409 {
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
final StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
fm.setLocation(SOURCE_PATH, Arrays.asList(test_classes)); // switcheroo !!!
|
fm.setLocation(SOURCE_PATH, Arrays.asList(test_classes)); // switcheroo !!!
|
||||||
fm.setLocation(CLASS_PATH, Arrays.asList(test_src));
|
fm.setLocation(CLASS_PATH, Arrays.asList(test_src));
|
||||||
fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
|
fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
|
||||||
final Iterable<? extends JavaFileObject> compilationUnits =
|
final Iterable<? extends JavaFileObject> compilationUnits =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(test_src, "T6420409.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(test_src, "T6420409.java")));
|
||||||
tool.getTask(null,
|
tool.getTask(null,
|
||||||
fm,
|
fm,
|
||||||
null,
|
null,
|
||||||
Arrays.asList("-proc:none"),
|
Arrays.asList("-proc:none"),
|
||||||
null,
|
null,
|
||||||
compilationUnits).call();
|
compilationUnits).call();
|
||||||
test(fm.getLocation(CLASS_PATH), test_src, CLASS_PATH);
|
test(fm.getLocation(CLASS_PATH), test_src, CLASS_PATH);
|
||||||
test(fm.getLocation(SOURCE_PATH), test_classes, SOURCE_PATH);
|
test(fm.getLocation(SOURCE_PATH), test_classes, SOURCE_PATH);
|
||||||
test(fm.getLocation(CLASS_OUTPUT), test_classes, CLASS_OUTPUT);
|
test(fm.getLocation(CLASS_OUTPUT), test_classes, CLASS_OUTPUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test(Iterable<? extends File> path, File file, Location location) {
|
static void test(Iterable<? extends File> path, File file, Location location) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -38,15 +38,16 @@ public class T6420464 {
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager mgr = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager mgr = compiler.getStandardFileManager(null, null, null)) {
|
||||||
mgr.setLocation(StandardLocation.SOURCE_PATH, Collections.singleton(test_src));
|
mgr.setLocation(StandardLocation.SOURCE_PATH, Collections.singleton(test_src));
|
||||||
JavaFileObject f = mgr.getJavaFileForInput(StandardLocation.SOURCE_PATH,
|
JavaFileObject f = mgr.getJavaFileForInput(StandardLocation.SOURCE_PATH,
|
||||||
"T6420464",
|
"T6420464",
|
||||||
JavaFileObject.Kind.SOURCE);
|
JavaFileObject.Kind.SOURCE);
|
||||||
if (!f.isNameCompatible("T6420464", JavaFileObject.Kind.SOURCE))
|
if (!f.isNameCompatible("T6420464", JavaFileObject.Kind.SOURCE))
|
||||||
throw new AssertionError("isNameCompatible(SOURCE) fails on " + f.toUri());
|
throw new AssertionError("isNameCompatible(SOURCE) fails on " + f.toUri());
|
||||||
if (f.isNameCompatible("T6420464", JavaFileObject.Kind.OTHER))
|
if (f.isNameCompatible("T6420464", JavaFileObject.Kind.OTHER))
|
||||||
throw new AssertionError("isNameCompatible(OTHER) fails on " + f.toUri());
|
throw new AssertionError("isNameCompatible(OTHER) fails on " + f.toUri());
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -39,18 +39,19 @@ public class T6431435 {
|
||||||
String testSrc = System.getProperty("test.src", ".");
|
String testSrc = System.getProperty("test.src", ".");
|
||||||
String testClasses = System.getProperty("test.classes", ".");
|
String testClasses = System.getProperty("test.classes", ".");
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
||||||
fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(new File(testSrc)));
|
fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(new File(testSrc)));
|
||||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
|
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
|
||||||
new File(testSrc, "A.java")));
|
new File(testSrc, "A.java")));
|
||||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
ok &= check("parse", task.parse(), 1); // A.java
|
ok &= check("parse", task.parse(), 1); // A.java
|
||||||
ok &= check("analyze", task.analyze(), 3); // A, Foo, p.B
|
ok &= check("analyze", task.analyze(), 3); // A, Foo, p.B
|
||||||
ok &= check("generate", task.generate(), 5); // A, Foo, Foo$Baz, Foo$1, p.B
|
ok &= check("generate", task.generate(), 5); // A, Foo, Foo$Baz, Foo$1, p.B
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw new AssertionError("Test failed");
|
throw new AssertionError("Test failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean check(String name, Iterable<?> iter, int expect) {
|
private static boolean check(String name, Iterable<?> iter, int expect) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -66,10 +66,11 @@ public class T7086261 {
|
||||||
|
|
||||||
void test() throws Throwable {
|
void test() throws Throwable {
|
||||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
JavaFileManager jfm = javac.getStandardFileManager(null, null, null);
|
try (JavaFileManager jfm = javac.getStandardFileManager(null, null, null)) {
|
||||||
JavaCompiler.CompilationTask task =
|
JavaCompiler.CompilationTask task =
|
||||||
javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource()));
|
javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource()));
|
||||||
task.call();
|
task.call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -83,14 +83,15 @@ public class Test {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
File thisFile = new File(testSrc, getClass().getName() + ".java");
|
File thisFile = new File(testSrc, getClass().getName() + ".java");
|
||||||
JavacTool javac = JavacTool.create();
|
JavacTool javac = JavacTool.create();
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
|
||||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
||||||
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
|
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
|
||||||
testAnnoProcessor(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
|
testAnnoProcessor(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
|
||||||
testTaskListener(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
|
testTaskListener(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
|
||||||
|
|
||||||
if (errors > 0)
|
if (errors > 0)
|
||||||
throw new Exception(errors + " errors occurred");
|
throw new Exception(errors + " errors occurred");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm,
|
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -39,17 +39,18 @@ import static javax.tools.JavaFileObject.Kind.CLASS;
|
||||||
public class Sibling {
|
public class Sibling {
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
JavaFileObject sibling =
|
JavaFileObject sibling =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java")))
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java")))
|
||||||
.iterator().next();
|
.iterator().next();
|
||||||
JavaFileObject classFile = fm.getJavaFileForOutput(CLASS_OUTPUT,
|
JavaFileObject classFile = fm.getJavaFileForOutput(CLASS_OUTPUT,
|
||||||
"foo.bar.baz.Test",
|
"foo.bar.baz.Test",
|
||||||
CLASS,
|
CLASS,
|
||||||
sibling);
|
sibling);
|
||||||
File file = new File("Test.class").getAbsoluteFile();
|
File file = new File("Test.class").getAbsoluteFile();
|
||||||
if (!classFile.toUri().equals(file.toURI()))
|
if (!classFile.toUri().equals(file.toURI()))
|
||||||
throw new AssertionError("Expected " + file.toURI() + ", got " +
|
throw new AssertionError("Expected " + file.toURI() + ", got " +
|
||||||
classFile.toUri());
|
classFile.toUri());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -33,7 +33,7 @@ import java.util.Arrays;
|
||||||
import javax.tools.*;
|
import javax.tools.*;
|
||||||
|
|
||||||
public class T6258271 {
|
public class T6258271 {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) throws IOException {
|
||||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
|
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
|
||||||
public void report(Diagnostic<? extends JavaFileObject> message) {
|
public void report(Diagnostic<? extends JavaFileObject> message) {
|
||||||
|
@ -43,9 +43,10 @@ public class T6258271 {
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java"));
|
fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java"));
|
||||||
javac.getTask(null, fm, dl, null, null, files).call();
|
javac.getTask(null, fm, dl, null, null, files).call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -29,11 +29,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.tools.*;
|
import javax.tools.*;
|
||||||
|
|
||||||
public class T6265137 {
|
public class T6265137 {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) throws IOException {
|
||||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
|
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
|
||||||
public void report(Diagnostic<? extends JavaFileObject> message) {
|
public void report(Diagnostic<? extends JavaFileObject> message) {
|
||||||
|
@ -45,10 +46,11 @@ public class T6265137 {
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||||
String srcdir = System.getProperty("test.src");
|
String srcdir = System.getProperty("test.src");
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
|
||||||
javac.getTask(null, fm, dl, Arrays.asList("-target","9"), null, files).call();
|
javac.getTask(null, fm, dl, Arrays.asList("-target","9"), null, files).call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -87,10 +87,18 @@ public class T6306137 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void close() throws IOException {
|
||||||
|
fm.close();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
T6306137 self = new T6306137();
|
T6306137 self = new T6306137();
|
||||||
self.test("utf-8", true);
|
try {
|
||||||
self.test("ascii", false);
|
self.test("utf-8", true);
|
||||||
self.test("utf-8", true);
|
self.test("ascii", false);
|
||||||
|
self.test("utf-8", true);
|
||||||
|
} finally {
|
||||||
|
self.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,17 +45,18 @@ public class T6345974 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
PrintWriter out = new PrintWriter(System.out, true);
|
PrintWriter out = new PrintWriter(System.out, true);
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
File testSrc = new File(System.getProperty("test.src"));
|
File testSrc = new File(System.getProperty("test.src"));
|
||||||
Iterable<? extends JavaFileObject> f =
|
Iterable<? extends JavaFileObject> f =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "T6345974.java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "T6345974.java")));
|
||||||
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
JavacTask task = tool.getTask(out, fm, null, null, null, f);
|
||||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
Scanner s = new Scanner();
|
Scanner s = new Scanner();
|
||||||
for (CompilationUnitTree t: trees)
|
for (CompilationUnitTree t: trees)
|
||||||
s.scan(t, null);
|
s.scan(t, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Scanner extends TreeScanner<Void,Void> {
|
private static class Scanner extends TreeScanner<Void,Void> {
|
||||||
|
|
|
@ -33,42 +33,43 @@ import com.sun.source.util.*;
|
||||||
|
|
||||||
public class T6357331
|
public class T6357331
|
||||||
{
|
{
|
||||||
public static void main(String... args) {
|
public static void main(String... args) throws IOException {
|
||||||
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
PrintWriter out = new PrintWriter(new StringWriter());
|
PrintWriter out = new PrintWriter(new StringWriter());
|
||||||
List<String> opts = Arrays.asList("-d", ".");
|
List<String> opts = Arrays.asList("-d", ".");
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
File thisFile = new File(System.getProperty("test.src"), "T6357331.java");
|
File thisFile = new File(System.getProperty("test.src"), "T6357331.java");
|
||||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
|
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
|
||||||
final JavacTask task = (JavacTask) (tool.getTask(out, fm, null, opts, null, files));
|
final JavacTask task = (JavacTask) (tool.getTask(out, fm, null, opts, null, files));
|
||||||
|
|
||||||
// set a listener to verify that IllegalStateException is not thrown
|
// set a listener to verify that IllegalStateException is not thrown
|
||||||
// during the compilation
|
// during the compilation
|
||||||
task.setTaskListener(new TaskListener() {
|
task.setTaskListener(new TaskListener() {
|
||||||
public void started(TaskEvent e) {
|
public void started(TaskEvent e) {
|
||||||
task.getElements();
|
task.getElements();
|
||||||
task.getTypes();
|
task.getTypes();
|
||||||
}
|
}
|
||||||
public void finished(TaskEvent e) { }
|
public void finished(TaskEvent e) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
task.call();
|
task.call();
|
||||||
|
|
||||||
// now the compilation is over, we expect IllegalStateException (not NPE)
|
// now the compilation is over, we expect IllegalStateException (not NPE)
|
||||||
try {
|
try {
|
||||||
task.getElements();
|
task.getElements();
|
||||||
throw new AssertionError("IllegalStateException not thrown");
|
throw new AssertionError("IllegalStateException not thrown");
|
||||||
}
|
}
|
||||||
catch (IllegalStateException e) {
|
catch (IllegalStateException e) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
task.getTypes();
|
task.getTypes();
|
||||||
throw new AssertionError("IllegalStateException not thrown");
|
throw new AssertionError("IllegalStateException not thrown");
|
||||||
}
|
}
|
||||||
catch (IllegalStateException e) {
|
catch (IllegalStateException e) {
|
||||||
// expected
|
// expected
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -44,16 +44,17 @@ import javax.tools.*;
|
||||||
public class T6358786 {
|
public class T6358786 {
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
String srcdir = System.getProperty("test.src");
|
String srcdir = System.getProperty("test.src");
|
||||||
File file = new File(srcdir, args[0]);
|
File file = new File(srcdir, args[0]);
|
||||||
JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
|
JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
|
||||||
Elements elements = task.getElements();
|
Elements elements = task.getElements();
|
||||||
for (TypeElement clazz : task.enter(task.parse())) {
|
for (TypeElement clazz : task.enter(task.parse())) {
|
||||||
String doc = elements.getDocComment(clazz);
|
String doc = elements.getDocComment(clazz);
|
||||||
if (doc == null)
|
if (doc == null)
|
||||||
throw new AssertionError(clazz.getSimpleName() + ": no doc comment");
|
throw new AssertionError(clazz.getSimpleName() + ": no doc comment");
|
||||||
System.out.format("%s: %s%n", clazz.getSimpleName(), doc);
|
System.out.format("%s: %s%n", clazz.getSimpleName(), doc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -36,34 +36,35 @@ import static javax.tools.JavaFileObject.Kind.*;
|
||||||
public class T6358955 {
|
public class T6358955 {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
File dir = new File("temp" + args.hashCode());
|
File dir = new File("temp" + args.hashCode());
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
dir.mkdir();
|
dir.mkdir();
|
||||||
if (!dir.isDirectory())
|
if (!dir.isDirectory())
|
||||||
throw new AssertionError("Not a directory " + dir);
|
throw new AssertionError("Not a directory " + dir);
|
||||||
|
|
||||||
try {
|
|
||||||
jfm.setLocation(StandardLocation.CLASS_OUTPUT,
|
|
||||||
Arrays.asList(dir.getCanonicalFile().getParentFile()));
|
|
||||||
try {
|
try {
|
||||||
jfm.getFileForInput(StandardLocation.CLASS_OUTPUT, "", dir.getPath());
|
jfm.setLocation(StandardLocation.CLASS_OUTPUT,
|
||||||
throw new AssertionError("IllegalArgumentException not thrown");
|
Arrays.asList(dir.getCanonicalFile().getParentFile()));
|
||||||
} catch (IllegalArgumentException e) {
|
try {
|
||||||
System.out.println("OK: " + e.getLocalizedMessage());
|
jfm.getFileForInput(StandardLocation.CLASS_OUTPUT, "", dir.getPath());
|
||||||
}
|
throw new AssertionError("IllegalArgumentException not thrown");
|
||||||
try {
|
} catch (IllegalArgumentException e) {
|
||||||
jfm.getJavaFileObjectsFromFiles(Arrays.asList(dir));
|
System.out.println("OK: " + e.getLocalizedMessage());
|
||||||
throw new AssertionError("IllegalArgumentException not thrown");
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
try {
|
||||||
System.out.println("OK: " + e.getLocalizedMessage());
|
jfm.getJavaFileObjectsFromFiles(Arrays.asList(dir));
|
||||||
}
|
throw new AssertionError("IllegalArgumentException not thrown");
|
||||||
} finally {
|
} catch (IllegalArgumentException e) {
|
||||||
try {
|
System.out.println("OK: " + e.getLocalizedMessage());
|
||||||
dir.delete(); // cleanup
|
}
|
||||||
} catch (Throwable t) {
|
} finally {
|
||||||
t.printStackTrace();
|
try {
|
||||||
|
dir.delete(); // cleanup
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -38,21 +38,22 @@ public class T6392782 {
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
String testSrc = System.getProperty("test.src", ".");
|
String testSrc = System.getProperty("test.src", ".");
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6392782.class.getName()+".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6392782.class.getName()+".java")));
|
||||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||||
Iterable<? extends Tree> trees = task.parse();
|
Iterable<? extends Tree> trees = task.parse();
|
||||||
TreeScanner<Integer,Void> scanner = new MyScanner();
|
TreeScanner<Integer,Void> scanner = new MyScanner();
|
||||||
check(scanner, 6, scanner.scan(trees, null));
|
check(scanner, 6, scanner.scan(trees, null));
|
||||||
|
|
||||||
CountNodes nodeCounter = new CountNodes();
|
CountNodes nodeCounter = new CountNodes();
|
||||||
// 359 nodes with the regular parser; 360 nodes with EndPosParser
|
// 359 nodes with the regular parser; 360 nodes with EndPosParser
|
||||||
// We automatically switch to EndPosParser when calling JavacTask.parse()
|
// We automatically switch to EndPosParser when calling JavacTask.parse()
|
||||||
check(nodeCounter, 360, nodeCounter.scan(trees, null));
|
check(nodeCounter, 362, nodeCounter.scan(trees, null));
|
||||||
|
|
||||||
CountIdentifiers idCounter = new CountIdentifiers();
|
CountIdentifiers idCounter = new CountIdentifiers();
|
||||||
check(idCounter, 107, idCounter.scan(trees, null));
|
check(idCounter, 107, idCounter.scan(trees, null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void check(TreeScanner<?,?> scanner, int expect, int found) {
|
private static void check(TreeScanner<?,?> scanner, int expect, int found) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -65,16 +65,15 @@ public class T6397104 {
|
||||||
void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)
|
void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
StandardJavaFileManager fm;
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
if (hasLocation) {
|
if (hasLocation) {
|
||||||
for (Location location : StandardLocation.values()) {
|
for (Location location : StandardLocation.values()) {
|
||||||
fm = tool.getStandardFileManager(null, null, null);
|
fm.setLocation(location, Arrays.asList(new File(".")));
|
||||||
fm.setLocation(location, Arrays.asList(new File(".")));
|
test(fm, location, siblingFile, relName, expectedPath);
|
||||||
test(fm, location, siblingFile, relName, expectedPath);
|
}
|
||||||
|
} else {
|
||||||
|
test(fm, CLASS_OUTPUT, siblingFile, relName, expectedPath);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fm = tool.getStandardFileManager(null, null, null);
|
|
||||||
test(fm, CLASS_OUTPUT, siblingFile, relName, expectedPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,22 +28,24 @@
|
||||||
* @author Peter von der Ah\u00e9
|
* @author Peter von der Ah\u00e9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import javax.tools.*;
|
import javax.tools.*;
|
||||||
import static javax.tools.StandardLocation.*;
|
import static javax.tools.StandardLocation.*;
|
||||||
|
|
||||||
public class T6400205 {
|
public class T6400205 {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) throws IOException {
|
||||||
JavaFileManager fm =
|
try (JavaFileManager fm =
|
||||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||||
try {
|
try {
|
||||||
fm.getClassLoader(null);
|
fm.getClassLoader(null);
|
||||||
throw new AssertionError("NullPointerException not thrown");
|
throw new AssertionError("NullPointerException not thrown");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// expected result
|
// expected result
|
||||||
|
}
|
||||||
|
ClassLoader cl = fm.getClassLoader(locationFor("bogus"));
|
||||||
|
if (cl != null)
|
||||||
|
throw new AssertionError("non-null class loader for bogus location");
|
||||||
|
System.err.println("Test PASSED.");
|
||||||
}
|
}
|
||||||
ClassLoader cl = fm.getClassLoader(locationFor("bogus"));
|
|
||||||
if (cl != null)
|
|
||||||
throw new AssertionError("non-null class loader for bogus location");
|
|
||||||
System.err.println("Test PASSED.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -61,28 +61,29 @@ public class T6400207 {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
JavaFileManager fm =
|
try (JavaFileManager fm =
|
||||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||||
JavaFileManager.Location bogusLocation = locationFor("bogus");
|
JavaFileManager.Location bogusLocation = locationFor("bogus");
|
||||||
JavaFileManager.Location knownLocation = CLASS_PATH;
|
JavaFileManager.Location knownLocation = CLASS_PATH;
|
||||||
String packageName = "java.lang";
|
String packageName = "java.lang";
|
||||||
Set<JavaFileObject.Kind> kinds = EnumSet.of(CLASS);
|
Set<JavaFileObject.Kind> kinds = EnumSet.of(CLASS);
|
||||||
|
|
||||||
for (StandardLocation location : StandardLocation.values()) {
|
for (StandardLocation location : StandardLocation.values()) {
|
||||||
if (location != locationFor(location.getName()))
|
if (location != locationFor(location.getName()))
|
||||||
throw new AssertionError(location + " != locationFor(" +
|
throw new AssertionError(location + " != locationFor(" +
|
||||||
location.getName() + ")");
|
location.getName() + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
testList(fm, null, null, null);
|
||||||
|
testList(fm, bogusLocation, packageName, kinds);
|
||||||
|
testList(fm, knownLocation, packageName, kinds);
|
||||||
|
testList(fm, null, packageName, kinds);
|
||||||
|
testList(fm, knownLocation, null, kinds);
|
||||||
|
testList(fm, knownLocation, packageName, null);
|
||||||
|
testList(fm, bogusLocation, null, kinds);
|
||||||
|
testList(fm, bogusLocation, packageName, null);
|
||||||
|
|
||||||
|
System.err.println("Test PASSED.");
|
||||||
}
|
}
|
||||||
|
|
||||||
testList(fm, null, null, null);
|
|
||||||
testList(fm, bogusLocation, packageName, kinds);
|
|
||||||
testList(fm, knownLocation, packageName, kinds);
|
|
||||||
testList(fm, null, packageName, kinds);
|
|
||||||
testList(fm, knownLocation, null, kinds);
|
|
||||||
testList(fm, knownLocation, packageName, null);
|
|
||||||
testList(fm, bogusLocation, null, kinds);
|
|
||||||
testList(fm, bogusLocation, packageName, null);
|
|
||||||
|
|
||||||
System.err.println("Test PASSED.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -64,22 +64,23 @@ public class T6412669 extends AbstractProcessor {
|
||||||
//System.err.println("toolsClasses: " + toolsClasses);
|
//System.err.println("toolsClasses: " + toolsClasses);
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses, toolsClasses));
|
fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses, toolsClasses));
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java")));
|
||||||
String[] opts = { "-proc:only", "-processor", T6412669.class.getName()};
|
String[] opts = { "-proc:only", "-processor", T6412669.class.getName()};
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
|
JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
|
||||||
boolean ok = task.call();
|
boolean ok = task.call();
|
||||||
String out = sw.toString();
|
String out = sw.toString();
|
||||||
if (!out.isEmpty())
|
if (!out.isEmpty())
|
||||||
System.err.println(out);
|
System.err.println(out);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw new AssertionError("compilation of test program failed");
|
throw new AssertionError("compilation of test program failed");
|
||||||
// verify we found an annotated element to exercise the SourcePositions API
|
// verify we found an annotated element to exercise the SourcePositions API
|
||||||
if (!out.contains("processing element"))
|
if (!out.contains("processing element"))
|
||||||
throw new AssertionError("expected text not found in compilation output");
|
throw new AssertionError("expected text not found in compilation output");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -35,17 +35,18 @@ import javax.tools.*;
|
||||||
public class T6419926 {
|
public class T6419926 {
|
||||||
public static void main(String[] argv) throws Exception {
|
public static void main(String[] argv) throws Exception {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>(), null, null);
|
try (StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>(), null, null)) {
|
||||||
System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
|
System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
|
||||||
mgr.setLocation(StandardLocation.CLASS_OUTPUT,
|
mgr.setLocation(StandardLocation.CLASS_OUTPUT,
|
||||||
Collections.singleton(new File(".")));
|
Collections.singleton(new File(".")));
|
||||||
|
|
||||||
FileObject fo = mgr.getFileForOutput(StandardLocation.CLASS_OUTPUT,
|
FileObject fo = mgr.getFileForOutput(StandardLocation.CLASS_OUTPUT,
|
||||||
"", "file.to.delete", null);
|
"", "file.to.delete", null);
|
||||||
URI uri = fo.toUri();
|
URI uri = fo.toUri();
|
||||||
System.out.println( uri );
|
System.out.println( uri );
|
||||||
|
|
||||||
if (!"file".equals(uri.getScheme()))
|
if (!"file".equals(uri.getScheme()))
|
||||||
throw new Exception("unexpected scheme for uri: " + uri.getScheme());
|
throw new Exception("unexpected scheme for uri: " + uri.getScheme());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -134,21 +134,22 @@
|
||||||
System.err.println("test task API: " + pcp);
|
System.err.println("test task API: " + pcp);
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
if (pcp != null)
|
if (pcp != null)
|
||||||
fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
|
fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
|
||||||
|
|
||||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
|
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
JavacTask task = tool.getTask(pw, fm, null, null, null, files);
|
JavacTask task = tool.getTask(pw, fm, null, null, null, files);
|
||||||
boolean ok = task.call();
|
boolean ok = task.call();
|
||||||
String out = showOutput(sw.toString());
|
String out = showOutput(sw.toString());
|
||||||
|
|
||||||
checkCompilationOK(ok);
|
checkCompilationOK(ok);
|
||||||
checkOutput(out, expectWarnings);
|
checkOutput(out, expectWarnings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----- utility methods
|
//----- utility methods
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -39,18 +39,18 @@ public class T6431879 {
|
||||||
String testSrc = System.getProperty("test.src", ".");
|
String testSrc = System.getProperty("test.src", ".");
|
||||||
String testClasses = System.getProperty("test.classes", ".");
|
String testClasses = System.getProperty("test.classes", ".");
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6431879.class.getName()+".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6431879.class.getName()+".java")));
|
||||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||||
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
Iterable<? extends CompilationUnitTree> trees = task.parse();
|
||||||
TreeScanner<Void,Trees> dependencyScanner = new DependencyScanner();
|
TreeScanner<Void,Trees> dependencyScanner = new DependencyScanner();
|
||||||
Trees treeUtil = Trees.instance(task);
|
Trees treeUtil = Trees.instance(task);
|
||||||
for (CompilationUnitTree unit : trees) {
|
for (CompilationUnitTree unit : trees) {
|
||||||
//System.err.println("scan " + unit);
|
//System.err.println("scan " + unit);
|
||||||
dependencyScanner.scan(unit, treeUtil);
|
dependencyScanner.scan(unit, treeUtil);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DependencyScanner<R,P> extends TreePathScanner<R,P> {
|
private static class DependencyScanner<R,P> extends TreePathScanner<R,P> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -42,14 +42,15 @@ public class T6483788 {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
File jar = createJar();
|
File jar = createJar();
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
fm.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(jar));
|
fm.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(jar));
|
||||||
JavaFileObject fo = fm.getJavaFileForInput(StandardLocation.CLASS_PATH, "dummy", JavaFileObject.Kind.CLASS);
|
JavaFileObject fo = fm.getJavaFileForInput(StandardLocation.CLASS_PATH, "dummy", JavaFileObject.Kind.CLASS);
|
||||||
System.err.println("file: " + fo);
|
System.err.println("file: " + fo);
|
||||||
URI uri = fo.toUri();
|
URI uri = fo.toUri();
|
||||||
System.err.println("uri: " + uri);
|
System.err.println("uri: " + uri);
|
||||||
if (uri.toString().contains(" "))
|
if (uri.toString().contains(" "))
|
||||||
throw new Exception("unexpected space character found");
|
throw new Exception("unexpected space character found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File createJar() throws IOException {
|
File createJar() throws IOException {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -46,16 +46,18 @@ public class T6501502 {
|
||||||
// we test a number of platform-independent paths.
|
// we test a number of platform-independent paths.
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
fm = c.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager sfm = c.getStandardFileManager(null, null, null)) {
|
||||||
System.err.println(System.getProperties());
|
fm = sfm;
|
||||||
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
|
System.err.println(System.getProperties());
|
||||||
File testSrcDir = new File(System.getProperty("test.src"));
|
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
|
||||||
File testClassesDir = new File(System.getProperty("test.classes"));
|
File testSrcDir = new File(System.getProperty("test.src"));
|
||||||
test(new File("abc.tmp"));
|
File testClassesDir = new File(System.getProperty("test.classes"));
|
||||||
test(new File(tmpDir, "bad.file"));
|
test(new File("abc.tmp"));
|
||||||
test(new File(testSrcDir, "T6501501.java"));
|
test(new File(tmpDir, "bad.file"));
|
||||||
test(new File(testClassesDir, "T6501501.class"));
|
test(new File(testSrcDir, "T6501501.java"));
|
||||||
test(new File("a b"));
|
test(new File(testClassesDir, "T6501501.class"));
|
||||||
|
test(new File("a b"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test(File f) throws Exception {
|
void test(File f) throws Exception {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -56,34 +56,36 @@ public class TestClientCodeWrapper extends JavacTestingAbstractProcessor {
|
||||||
*/
|
*/
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
defaultFileManager = compiler.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
|
defaultFileManager = fm;
|
||||||
|
|
||||||
for (Method m: getMethodsExcept(JavaFileManager.class, "close", "getJavaFileForInput")) {
|
for (Method m: getMethodsExcept(JavaFileManager.class, "close", "getJavaFileForInput")) {
|
||||||
test(m);
|
test(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method m: getMethodsExcept(FileObject.class, "delete")) {
|
||||||
|
test(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method m: getMethods(JavaFileObject.class)) {
|
||||||
|
test(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method m: getMethodsExcept(Processor.class, "getCompletions")) {
|
||||||
|
test(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method m: DiagnosticListener.class.getDeclaredMethods()) {
|
||||||
|
test(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method m: TaskListener.class.getDeclaredMethods()) {
|
||||||
|
test(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors > 0)
|
||||||
|
throw new Exception(errors + " errors occurred");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Method m: getMethodsExcept(FileObject.class, "delete")) {
|
|
||||||
test(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Method m: getMethods(JavaFileObject.class)) {
|
|
||||||
test(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Method m: getMethodsExcept(Processor.class, "getCompletions")) {
|
|
||||||
test(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Method m: DiagnosticListener.class.getDeclaredMethods()) {
|
|
||||||
test(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Method m: TaskListener.class.getDeclaredMethods()) {
|
|
||||||
test(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errors > 0)
|
|
||||||
throw new Exception(errors + " errors occurred");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a sorted set of the methods declared on a class. */
|
/** Get a sorted set of the methods declared on a class. */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -52,23 +52,23 @@ public class TestDocComments {
|
||||||
File file = new File(testSrc, "TestDocComments.java");
|
File file = new File(testSrc, "TestDocComments.java");
|
||||||
|
|
||||||
JavacTool tool = JavacTool.create();
|
JavacTool tool = JavacTool.create();
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
Iterable<? extends JavaFileObject> fileObjects = fm.getJavaFileObjects(file);
|
||||||
|
JavacTask task = tool.getTask(pw, fm, null, null, null, fileObjects);
|
||||||
|
Iterable<? extends CompilationUnitTree> units = task.parse();
|
||||||
|
Trees trees = Trees.instance(task);
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
CommentScanner s = new CommentScanner();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
int n = s.scan(units, trees);
|
||||||
Iterable<? extends JavaFileObject> fileObjects = fm.getJavaFileObjects(file);
|
|
||||||
JavacTask task = tool.getTask(pw, fm, null, null, null, fileObjects);
|
|
||||||
Iterable<? extends CompilationUnitTree> units = task.parse();
|
|
||||||
Trees trees = Trees.instance(task);
|
|
||||||
|
|
||||||
CommentScanner s = new CommentScanner();
|
if (n != 12)
|
||||||
int n = s.scan(units, trees);
|
error("Unexpected number of doc comments found: " + n);
|
||||||
|
|
||||||
if (n != 12)
|
if (errors > 0)
|
||||||
error("Unexpected number of doc comments found: " + n);
|
throw new Exception(errors + " errors occurred");
|
||||||
|
}
|
||||||
if (errors > 0)
|
|
||||||
throw new Exception(errors + " errors occurred");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -50,31 +50,32 @@ public class TestGetElementReference {
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
File source = new File(System.getProperty("test.src", "."), "TestGetElementReferenceData.java").getAbsoluteFile();
|
File source = new File(System.getProperty("test.src", "."), "TestGetElementReferenceData.java").getAbsoluteFile();
|
||||||
StandardJavaFileManager fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||||
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
|
||||||
JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov"), null, fm.getJavaFileObjects(source));
|
JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov"), null, fm.getJavaFileObjects(source));
|
||||||
Trees trees = Trees.instance(ct);
|
Trees trees = Trees.instance(ct);
|
||||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
CompilationUnitTree cut = ct.parse().iterator().next();
|
||||||
|
|
||||||
ct.analyze();
|
ct.analyze();
|
||||||
|
|
||||||
for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
|
for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
|
||||||
if (d.getKind() == Diagnostic.Kind.ERROR) {
|
if (d.getKind() == Diagnostic.Kind.ERROR) {
|
||||||
throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
|
throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Pattern p = Pattern.compile("/\\*getElement:(.*?)\\*/");
|
Pattern p = Pattern.compile("/\\*getElement:(.*?)\\*/");
|
||||||
Matcher m = p.matcher(cut.getSourceFile().getCharContent(false));
|
Matcher m = p.matcher(cut.getSourceFile().getCharContent(false));
|
||||||
|
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
TreePath tp = pathFor(trees, cut, m.start() - 1);
|
TreePath tp = pathFor(trees, cut, m.start() - 1);
|
||||||
Element found = trees.getElement(tp);
|
Element found = trees.getElement(tp);
|
||||||
String expected = m.group(1);
|
String expected = m.group(1);
|
||||||
String actual = found != null ? found.getKind() + ":" + symbolToString(found) : "<null>";
|
String actual = found != null ? found.getKind() + ":" + symbolToString(found) : "<null>";
|
||||||
|
|
||||||
if (!expected.equals(actual)) {
|
if (!expected.equals(actual)) {
|
||||||
throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
|
throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
import com.sun.source.tree.IdentifierTree;
|
import com.sun.source.tree.IdentifierTree;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -51,24 +52,25 @@ import javax.lang.model.SourceVersion;
|
||||||
|
|
||||||
@SupportedAnnotationTypes("*")
|
@SupportedAnnotationTypes("*")
|
||||||
public class TestGetScope extends AbstractProcessor {
|
public class TestGetScope extends AbstractProcessor {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) throws IOException {
|
||||||
new TestGetScope().run();
|
new TestGetScope().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() throws IOException {
|
||||||
File srcDir = new File(System.getProperty("test.src"));
|
File srcDir = new File(System.getProperty("test.src"));
|
||||||
File thisFile = new File(srcDir, getClass().getName() + ".java");
|
File thisFile = new File(srcDir, getClass().getName() + ".java");
|
||||||
|
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
List<String> opts = Arrays.asList("-proc:only", "-doe");
|
List<String> opts = Arrays.asList("-proc:only", "-doe");
|
||||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
|
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
|
||||||
JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files);
|
JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files);
|
||||||
t.setProcessors(Collections.singleton(this));
|
t.setProcessors(Collections.singleton(this));
|
||||||
boolean ok = t.call();
|
boolean ok = t.call();
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw new Error("compilation failed");
|
throw new Error("compilation failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -41,8 +41,8 @@ import javax.tools.ToolProvider;
|
||||||
|
|
||||||
public class TestJavacTask {
|
public class TestJavacTask {
|
||||||
static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
|
static final StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||||
static JavacTaskImpl getTask(File... file) {
|
static JavacTaskImpl getTask(File... file) {
|
||||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(file));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(file));
|
||||||
return (JavacTaskImpl)compiler.getTask(null, fm, null, null, null, files);
|
return (JavacTaskImpl)compiler.getTask(null, fm, null, null, null, files);
|
||||||
|
@ -69,7 +69,11 @@ public class TestJavacTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
basicTest(args);
|
try {
|
||||||
checkKindError();
|
basicTest(args);
|
||||||
|
checkKindError();
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,15 +67,18 @@ public class TestJavacTask_Lock {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
comp = ToolProvider.getSystemJavaCompiler();
|
comp = ToolProvider.getSystemJavaCompiler();
|
||||||
fm = comp.getStandardFileManager(null, null, null);
|
fm = comp.getStandardFileManager(null, null, null);
|
||||||
|
try {
|
||||||
for (MethodKind first: MethodKind.values()) {
|
for (MethodKind first: MethodKind.values()) {
|
||||||
for (MethodKind second: MethodKind.values()) {
|
for (MethodKind second: MethodKind.values()) {
|
||||||
test(first, second);
|
test(first, second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (errors > 0)
|
if (errors > 0)
|
||||||
throw new Exception(errors + " errors found");
|
throw new Exception(errors + " errors found");
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test(MethodKind first, MethodKind second) {
|
void test(MethodKind first, MethodKind second) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -68,16 +68,19 @@ public class TestJavacTask_Multiple {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||||
for (TestKind tk: TestKind.values()) {
|
try {
|
||||||
test(comp, fm, tk);
|
for (TestKind tk: TestKind.values()) {
|
||||||
}
|
test(comp, fm, tk);
|
||||||
|
}
|
||||||
|
|
||||||
int expect = TestKind.values().length * MAX_TASKS;
|
int expect = TestKind.values().length * MAX_TASKS;
|
||||||
if (count != expect) {
|
if (count != expect) {
|
||||||
throw new Exception("Unexpected number of tests completed: " + count
|
throw new Exception("Unexpected number of tests completed: " + count
|
||||||
+ ", expected: " + expect);
|
+ ", expected: " + expect);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test(JavaCompiler comp, StandardJavaFileManager fm, TestKind tk) {
|
void test(JavaCompiler comp, StandardJavaFileManager fm, TestKind tk) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,14 +45,17 @@ public class TestJavacTask_ParseAttrGen {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
comp = ToolProvider.getSystemJavaCompiler();
|
comp = ToolProvider.getSystemJavaCompiler();
|
||||||
fm = comp.getStandardFileManager(null, null, null);
|
fm = comp.getStandardFileManager(null, null, null);
|
||||||
|
try {
|
||||||
final boolean[] booleanValues = { false, true };
|
final boolean[] booleanValues = { false, true };
|
||||||
for (boolean pk: booleanValues) {
|
for (boolean pk: booleanValues) {
|
||||||
for (boolean ak: booleanValues) {
|
for (boolean ak: booleanValues) {
|
||||||
for (boolean gk: booleanValues) {
|
for (boolean gk: booleanValues) {
|
||||||
test(pk, ak, gk);
|
test(pk, ak, gk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,30 +76,33 @@ public class TestSearchPaths {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
compiler = ToolProvider.getSystemJavaCompiler();
|
compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
fileManager = compiler.getStandardFileManager(null, null, null);
|
fileManager = compiler.getStandardFileManager(null, null, null);
|
||||||
|
try {
|
||||||
|
// basic output path
|
||||||
|
testClassOutput();
|
||||||
|
|
||||||
// basic output path
|
// basic search paths
|
||||||
testClassOutput();
|
testClassPath();
|
||||||
|
testSourcePath();
|
||||||
|
testPlatformClassPath();
|
||||||
|
|
||||||
// basic search paths
|
// annotation processing
|
||||||
testClassPath();
|
testAnnotationProcessorPath();
|
||||||
testSourcePath();
|
testSourceOutput();
|
||||||
testPlatformClassPath();
|
|
||||||
|
|
||||||
// annotation processing
|
// javah equivalent
|
||||||
testAnnotationProcessorPath();
|
testNativeHeaderOutput();
|
||||||
testSourceOutput();
|
|
||||||
|
|
||||||
// javah equivalent
|
// future-proof: guard against new StandardLocations being added
|
||||||
testNativeHeaderOutput();
|
if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
|
||||||
|
error("not all standard locations have been tested");
|
||||||
|
out.println("not yet tested: " + EnumSet.complementOf(tested));
|
||||||
|
}
|
||||||
|
|
||||||
// future-proof: guard against new StandardLocations being added
|
if (errors > 0) {
|
||||||
if (!tested.equals(EnumSet.allOf(StandardLocation.class))) {
|
throw new Exception(errors + " errors occurred");
|
||||||
error("not all standard locations have been tested");
|
}
|
||||||
out.println("not yet tested: " + EnumSet.complementOf(tested));
|
} finally {
|
||||||
}
|
fileManager.close();
|
||||||
|
|
||||||
if (errors > 0) {
|
|
||||||
throw new Exception(errors + " errors occurred");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -105,17 +105,18 @@ public class TestTreePath extends AbstractProcessor {
|
||||||
|
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fileManager
|
try (StandardJavaFileManager fileManager
|
||||||
= compiler.getStandardFileManager(null, null, null);
|
= compiler.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> tests
|
Iterable<? extends JavaFileObject> tests
|
||||||
= fileManager.getJavaFileObjects(writeTestFile());
|
= fileManager.getJavaFileObjects(writeTestFile());
|
||||||
|
|
||||||
JavaCompiler.CompilationTask task =
|
JavaCompiler.CompilationTask task =
|
||||||
ToolProvider.getSystemJavaCompiler().getTask(
|
ToolProvider.getSystemJavaCompiler().getTask(
|
||||||
null, null, null,
|
null, null, null,
|
||||||
Arrays.asList("-processor", this.getClass().getName()), null,
|
Arrays.asList("-processor", this.getClass().getName()), null,
|
||||||
tests);
|
tests);
|
||||||
task.call();
|
task.call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
|
@ -74,29 +74,30 @@ public class TestTrees extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> files =
|
Iterable<? extends JavaFileObject> files =
|
||||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||||
|
|
||||||
Iterable<String> opts = Arrays.asList("-d", ".", "-XDcompilePolicy=simple");
|
Iterable<String> opts = Arrays.asList("-d", ".", "-XDcompilePolicy=simple");
|
||||||
|
|
||||||
System.err.println("simple compilation, no processing");
|
System.err.println("simple compilation, no processing");
|
||||||
JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
|
JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
|
||||||
task.setTaskListener(new MyTaskListener(task));
|
task.setTaskListener(new MyTaskListener(task));
|
||||||
if (!task.call())
|
if (!task.call())
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
|
|
||||||
opts = Arrays.asList("-d", ".", "-processorpath", testClassDir, "-processor", self,
|
opts = Arrays.asList("-d", ".", "-processorpath", testClassDir, "-processor", self,
|
||||||
"-XDcompilePolicy=simple");
|
"-XDcompilePolicy=simple");
|
||||||
|
|
||||||
System.err.println();
|
System.err.println();
|
||||||
System.err.println("compilation with processing");
|
System.err.println("compilation with processing");
|
||||||
task = tool.getTask(out, fm, dl,opts, null, files);
|
task = tool.getTask(out, fm, dl,opts, null, files);
|
||||||
if (!task.call())
|
if (!task.call())
|
||||||
throw new AssertionError("compilation failed");
|
throw new AssertionError("compilation failed");
|
||||||
|
|
||||||
if (errors > 0)
|
if (errors > 0)
|
||||||
throw new AssertionError(errors + " errors occurred");
|
throw new AssertionError(errors + " errors occurred");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testElement(Trees trees, Element e) {
|
void testElement(Trees trees, Element e) {
|
||||||
|
|
|
@ -73,18 +73,19 @@ public class CompileEvent {
|
||||||
assertOutput(out.toString());
|
assertOutput(out.toString());
|
||||||
|
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
|
Iterable<? extends JavaFileObject> testFileObjects = fm.getJavaFileObjects(test);
|
||||||
|
|
||||||
//test events fired to listeners registered from plugins
|
//test events fired to listeners registered from plugins
|
||||||
//when starting compiler using JavaCompiler.getTask(...).call
|
//when starting compiler using JavaCompiler.getTask(...).call
|
||||||
List<String> options =
|
List<String> options =
|
||||||
Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
|
Arrays.asList("-Xplugin:compile-event", "-processorpath", testClasses);
|
||||||
out = new StringWriter();
|
out = new StringWriter();
|
||||||
boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
|
boolean compResult = comp.getTask(out, null, null, options, null, testFileObjects).call();
|
||||||
if (!compResult)
|
if (!compResult)
|
||||||
throw new AssertionError("Compilation failed unexpectedly.");
|
throw new AssertionError("Compilation failed unexpectedly.");
|
||||||
assertOutput(out.toString());
|
assertOutput(out.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertOutput(String found) {
|
void assertOutput(String found) {
|
||||||
|
|
|
@ -44,7 +44,12 @@ public class EventsBalancedTest {
|
||||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
||||||
new EventsBalancedTest().test();
|
EventsBalancedTest t = new EventsBalancedTest();
|
||||||
|
try {
|
||||||
|
t.test();
|
||||||
|
} finally {
|
||||||
|
t.fm.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test() throws IOException {
|
void test() throws IOException {
|
||||||
|
|
|
@ -203,7 +203,12 @@ public class TestSimpleAddRemove {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
new TestSimpleAddRemove().run();
|
TestSimpleAddRemove t = new TestSimpleAddRemove();
|
||||||
|
try {
|
||||||
|
t.run();
|
||||||
|
} finally {
|
||||||
|
t.fm.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
|
JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -104,35 +104,36 @@ public class IntersectionTypeParserTest {
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (CastKind ck : CastKind.values()) {
|
for (CastKind ck : CastKind.values()) {
|
||||||
for (TypeKind t1 : TypeKind.values()) {
|
for (TypeKind t1 : TypeKind.values()) {
|
||||||
for (ArrayKind ak1 : ArrayKind.values()) {
|
for (ArrayKind ak1 : ArrayKind.values()) {
|
||||||
Type typ1 = new Type(t1, ak1);
|
Type typ1 = new Type(t1, ak1);
|
||||||
if (ck.nBounds == 1) {
|
if (ck.nBounds == 1) {
|
||||||
new IntersectionTypeParserTest(ck, typ1).run(comp, fm);
|
new IntersectionTypeParserTest(ck, typ1).run(comp, fm);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (TypeKind t2 : TypeKind.values()) {
|
for (TypeKind t2 : TypeKind.values()) {
|
||||||
for (ArrayKind ak2 : ArrayKind.values()) {
|
for (ArrayKind ak2 : ArrayKind.values()) {
|
||||||
Type typ2 = new Type(t2, ak2);
|
Type typ2 = new Type(t2, ak2);
|
||||||
if (ck.nBounds == 2) {
|
if (ck.nBounds == 2) {
|
||||||
new IntersectionTypeParserTest(ck, typ1, typ2).run(comp, fm);
|
new IntersectionTypeParserTest(ck, typ1, typ2).run(comp, fm);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (TypeKind t3 : TypeKind.values()) {
|
for (TypeKind t3 : TypeKind.values()) {
|
||||||
for (ArrayKind ak3 : ArrayKind.values()) {
|
for (ArrayKind ak3 : ArrayKind.values()) {
|
||||||
Type typ3 = new Type(t3, ak3);
|
Type typ3 = new Type(t3, ak3);
|
||||||
new IntersectionTypeParserTest(ck, typ1, typ2, typ3).run(comp, fm);
|
new IntersectionTypeParserTest(ck, typ1, typ2, typ3).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CastKind ck;
|
CastKind ck;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -68,39 +68,40 @@ public class T7031108 extends JavacTestingAbstractProcessor {
|
||||||
|
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
// step 1: compile test classes
|
// step 1: compile test classes
|
||||||
File cwd = new File(".");
|
File cwd = new File(".");
|
||||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(cwd));
|
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(cwd));
|
||||||
compile(comp, fm, null, null, pC);
|
compile(comp, fm, null, null, pC);
|
||||||
|
|
||||||
// step 2: verify functioning of processor
|
// step 2: verify functioning of processor
|
||||||
fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
|
fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
|
||||||
fm.getLocation(StandardLocation.CLASS_PATH));
|
fm.getLocation(StandardLocation.CLASS_PATH));
|
||||||
fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(cwd));
|
fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(cwd));
|
||||||
compile(comp, fm, null, getClass().getName(), dummy);
|
compile(comp, fm, null, getClass().getName(), dummy);
|
||||||
|
|
||||||
File pC_class = new File(new File("p"), "C.class");
|
File pC_class = new File(new File("p"), "C.class");
|
||||||
pC_class.delete();
|
pC_class.delete();
|
||||||
|
|
||||||
DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
|
DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
|
||||||
compile(comp, fm, dc, getClass().getName(), dummy);
|
compile(comp, fm, dc, getClass().getName(), dummy);
|
||||||
List<Diagnostic<? extends JavaFileObject>> diags =dc.getDiagnostics();
|
List<Diagnostic<? extends JavaFileObject>> diags =dc.getDiagnostics();
|
||||||
|
|
||||||
System.err.println(diags);
|
System.err.println(diags);
|
||||||
switch (diags.size()) {
|
switch (diags.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
throw new Exception("no diagnostics received");
|
throw new Exception("no diagnostics received");
|
||||||
case 1:
|
case 1:
|
||||||
String code = diags.get(0).getCode();
|
String code = diags.get(0).getCode();
|
||||||
String expect = "compiler.err.proc.cant.access.1";
|
String expect = "compiler.err.proc.cant.access.1";
|
||||||
if (!expect.equals(code))
|
if (!expect.equals(code))
|
||||||
throw new Exception("unexpected diag code: " + code
|
throw new Exception("unexpected diag code: " + code
|
||||||
+ ", expected: " + expect);
|
+ ", expected: " + expect);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("unexpected diags received");
|
throw new Exception("unexpected diags received");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -54,31 +54,32 @@ public class DefaultMethodFlags {
|
||||||
|
|
||||||
void checkDefaultMethodFlags() throws IOException {
|
void checkDefaultMethodFlags() throws IOException {
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
Iterable<? extends JavaFileObject> fos =
|
Iterable<? extends JavaFileObject> fos =
|
||||||
fm.getJavaFileObjectsFromFiles(
|
fm.getJavaFileObjectsFromFiles(
|
||||||
Arrays.asList(new File(
|
Arrays.asList(new File(
|
||||||
System.getProperty("test.src"),
|
System.getProperty("test.src"),
|
||||||
this.getClass().getSimpleName() + ".java")));
|
this.getClass().getSimpleName() + ".java")));
|
||||||
JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, fos);
|
JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, fos);
|
||||||
|
|
||||||
task.addTaskListener(new TaskListener() {
|
task.addTaskListener(new TaskListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void started(TaskEvent e) {}
|
public void started(TaskEvent e) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finished(TaskEvent e) {
|
public void finished(TaskEvent e) {
|
||||||
if (e.getKind() == TaskEvent.Kind.ANALYZE) {
|
if (e.getKind() == TaskEvent.Kind.ANALYZE) {
|
||||||
TypeElement te = e.getTypeElement();
|
TypeElement te = e.getTypeElement();
|
||||||
if (te.getSimpleName().toString().equals("I")) {
|
if (te.getSimpleName().toString().equals("I")) {
|
||||||
checkDefaultInterface(te);
|
checkDefaultInterface(te);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
task.analyze();
|
task.analyze();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkDefaultInterface(TypeElement te) {
|
void checkDefaultInterface(TypeElement te) {
|
||||||
|
|
|
@ -123,18 +123,19 @@ public class InterfaceMethodHidingTest {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (MethodKind mk1 : MethodKind.values()) {
|
for (MethodKind mk1 : MethodKind.values()) {
|
||||||
for (SignatureKind sk1 : SignatureKind.values()) {
|
for (SignatureKind sk1 : SignatureKind.values()) {
|
||||||
for (BodyExpr be1 : BodyExpr.values()) {
|
for (BodyExpr be1 : BodyExpr.values()) {
|
||||||
for (MethodKind mk2 : MethodKind.values()) {
|
for (MethodKind mk2 : MethodKind.values()) {
|
||||||
for (SignatureKind sk2 : SignatureKind.values()) {
|
for (SignatureKind sk2 : SignatureKind.values()) {
|
||||||
for (BodyExpr be2 : BodyExpr.values()) {
|
for (BodyExpr be2 : BodyExpr.values()) {
|
||||||
for (MethodKind mk3 : MethodKind.values()) {
|
for (MethodKind mk3 : MethodKind.values()) {
|
||||||
for (SignatureKind sk3 : SignatureKind.values()) {
|
for (SignatureKind sk3 : SignatureKind.values()) {
|
||||||
for (BodyExpr be3 : BodyExpr.values()) {
|
for (BodyExpr be3 : BodyExpr.values()) {
|
||||||
new InterfaceMethodHidingTest(mk1, mk2, mk3, sk1, sk2, sk3, be1, be2, be3).run(comp, fm);
|
new InterfaceMethodHidingTest(mk1, mk2, mk3, sk1, sk2, sk3, be1, be2, be3).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,8 +144,8 @@ public class InterfaceMethodHidingTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodKind mk1, mk2, mk3;
|
MethodKind mk1, mk2, mk3;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -188,20 +188,21 @@ public class TestDefaultMethodsSyntax {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (VersionKind vk : VersionKind.values()) {
|
for (VersionKind vk : VersionKind.values()) {
|
||||||
for (EnclosingKind ek : EnclosingKind.values()) {
|
for (EnclosingKind ek : EnclosingKind.values()) {
|
||||||
for (MethodKind mk : MethodKind.values()) {
|
for (MethodKind mk : MethodKind.values()) {
|
||||||
for (ModifierKind modk1 : ModifierKind.values()) {
|
for (ModifierKind modk1 : ModifierKind.values()) {
|
||||||
for (ModifierKind modk2 : ModifierKind.values()) {
|
for (ModifierKind modk2 : ModifierKind.values()) {
|
||||||
new TestDefaultMethodsSyntax(vk, ek, mk, modk1, modk2).run(comp, fm);
|
new TestDefaultMethodsSyntax(vk, ek, mk, modk1, modk2).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionKind vk;
|
VersionKind vk;
|
||||||
|
|
|
@ -313,27 +313,28 @@ public class CheckResourceKeys {
|
||||||
Set<String> getCodeStrings() throws IOException {
|
Set<String> getCodeStrings() throws IOException {
|
||||||
Set<String> results = new TreeSet<String>();
|
Set<String> results = new TreeSet<String>();
|
||||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||||
JavaFileManager fm = c.getStandardFileManager(null, null, null);
|
try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||||
JavaFileManager.Location javacLoc = findJavacLocation(fm);
|
JavaFileManager.Location javacLoc = findJavacLocation(fm);
|
||||||
String[] pkgs = {
|
String[] pkgs = {
|
||||||
"javax.annotation.processing",
|
"javax.annotation.processing",
|
||||||
"javax.lang.model",
|
"javax.lang.model",
|
||||||
"javax.tools",
|
"javax.tools",
|
||||||
"com.sun.source",
|
"com.sun.source",
|
||||||
"com.sun.tools.javac"
|
"com.sun.tools.javac"
|
||||||
};
|
};
|
||||||
for (String pkg: pkgs) {
|
for (String pkg: pkgs) {
|
||||||
for (JavaFileObject fo: fm.list(javacLoc,
|
for (JavaFileObject fo: fm.list(javacLoc,
|
||||||
pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
|
pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
|
||||||
String name = fo.getName();
|
String name = fo.getName();
|
||||||
// ignore resource files, and files which are not really part of javac
|
// ignore resource files, and files which are not really part of javac
|
||||||
if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*")
|
if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*")
|
||||||
|| name.matches(".*CreateSymbols\\.class.*"))
|
|| name.matches(".*CreateSymbols\\.class.*"))
|
||||||
continue;
|
continue;
|
||||||
scan(fo, results);
|
scan(fo, results);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// depending on how the test is run, javac may be on bootclasspath or classpath
|
// depending on how the test is run, javac may be on bootclasspath or classpath
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -109,44 +109,48 @@ public class DocLintTest {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
javac = ToolProvider.getSystemJavaCompiler();
|
javac = ToolProvider.getSystemJavaCompiler();
|
||||||
fm = javac.getStandardFileManager(null, null, null);
|
fm = javac.getStandardFileManager(null, null, null);
|
||||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
try {
|
||||||
file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
|
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
||||||
@Override
|
file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
|
||||||
public CharSequence getCharContent(boolean ignoreEncoding) {
|
@Override
|
||||||
return code;
|
public CharSequence getCharContent(boolean ignoreEncoding) {
|
||||||
}
|
return code;
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
test(Collections.<String>emptyList(),
|
test(Collections.<String>emptyList(),
|
||||||
Main.Result.OK,
|
Main.Result.OK,
|
||||||
EnumSet.noneOf(Message.class));
|
EnumSet.noneOf(Message.class));
|
||||||
|
|
||||||
test(Arrays.asList("-Xdoclint:none"),
|
test(Arrays.asList("-Xdoclint:none"),
|
||||||
Main.Result.OK,
|
Main.Result.OK,
|
||||||
EnumSet.noneOf(Message.class));
|
EnumSet.noneOf(Message.class));
|
||||||
|
|
||||||
test(Arrays.asList(rawDiags, "-Xdoclint"),
|
test(Arrays.asList(rawDiags, "-Xdoclint"),
|
||||||
Main.Result.ERROR,
|
Main.Result.ERROR,
|
||||||
EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
|
EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
|
||||||
|
|
||||||
test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
|
test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
|
||||||
Main.Result.OK,
|
Main.Result.OK,
|
||||||
EnumSet.of(Message.DL_WRN12));
|
EnumSet.of(Message.DL_WRN12));
|
||||||
|
|
||||||
test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
|
test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
|
||||||
Main.Result.ERROR,
|
Main.Result.ERROR,
|
||||||
EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
|
EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
|
||||||
|
|
||||||
test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
|
test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
|
||||||
Main.Result.ERROR,
|
Main.Result.ERROR,
|
||||||
EnumSet.of(Message.DL_ERR9));
|
EnumSet.of(Message.DL_ERR9));
|
||||||
|
|
||||||
test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
|
test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
|
||||||
Main.Result.CMDERR,
|
Main.Result.CMDERR,
|
||||||
EnumSet.of(Message.OPT_BADARG));
|
EnumSet.of(Message.OPT_BADARG));
|
||||||
|
|
||||||
if (errors > 0)
|
if (errors > 0)
|
||||||
throw new Exception(errors + " errors occurred");
|
throw new Exception(errors + " errors occurred");
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {
|
void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -66,22 +66,23 @@ public class DocTreePathScannerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
JavacTool javac = JavacTool.create();
|
JavacTool javac = JavacTool.create();
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
|
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
|
||||||
|
|
||||||
JavacTask t = javac.getTask(null, fm, null, null, null, fos);
|
JavacTask t = javac.getTask(null, fm, null, null, null, fos);
|
||||||
DocTrees trees = DocTrees.instance(t);
|
DocTrees trees = DocTrees.instance(t);
|
||||||
|
|
||||||
Iterable<? extends CompilationUnitTree> units = t.parse();
|
Iterable<? extends CompilationUnitTree> units = t.parse();
|
||||||
|
|
||||||
DeclScanner ds = new DeclScanner(trees);
|
DeclScanner ds = new DeclScanner(trees);
|
||||||
for (CompilationUnitTree unit: units) {
|
for (CompilationUnitTree unit: units) {
|
||||||
ds.scan(unit, null);
|
ds.scan(unit, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors > 0)
|
||||||
|
throw new Exception(errors + " errors occurred");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors > 0)
|
|
||||||
throw new Exception(errors + " errors occurred");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(String msg) {
|
void error(String msg) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -66,28 +66,29 @@ public class SimpleDocTreeVisitorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
JavacTool javac = JavacTool.create();
|
JavacTool javac = JavacTool.create();
|
||||||
StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
|
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
|
||||||
|
|
||||||
JavacTask t = javac.getTask(null, fm, null, null, null, fos);
|
JavacTask t = javac.getTask(null, fm, null, null, null, fos);
|
||||||
DocTrees trees = DocTrees.instance(t);
|
DocTrees trees = DocTrees.instance(t);
|
||||||
|
|
||||||
Iterable<? extends CompilationUnitTree> units = t.parse();
|
Iterable<? extends CompilationUnitTree> units = t.parse();
|
||||||
|
|
||||||
Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class);
|
Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class);
|
||||||
DeclScanner ds = new DeclScanner(trees, found);
|
DeclScanner ds = new DeclScanner(trees, found);
|
||||||
for (CompilationUnitTree unit: units) {
|
for (CompilationUnitTree unit: units) {
|
||||||
ds.scan(unit, null);
|
ds.scan(unit, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DocTree.Kind k: DocTree.Kind.values()) {
|
||||||
|
if (!found.contains(k) && k != DocTree.Kind.OTHER)
|
||||||
|
error("not found: " + k);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors > 0)
|
||||||
|
throw new Exception(errors + " errors occurred");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DocTree.Kind k: DocTree.Kind.values()) {
|
|
||||||
if (!found.contains(k) && k != DocTree.Kind.OTHER)
|
|
||||||
error("not found: " + k);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errors > 0)
|
|
||||||
throw new Exception(errors + " errors occurred");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void error(String msg) {
|
void error(String msg) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -47,6 +47,7 @@ import javax.lang.model.element.TypeElement;
|
||||||
import javax.tools.Diagnostic.Kind;
|
import javax.tools.Diagnostic.Kind;
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
import javax.tools.JavaCompiler.CompilationTask;
|
import javax.tools.JavaCompiler.CompilationTask;
|
||||||
|
import javax.tools.StandardJavaFileManager;
|
||||||
import javax.tools.StandardLocation;
|
import javax.tools.StandardLocation;
|
||||||
import javax.tools.ToolProvider;
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
|
@ -75,34 +76,36 @@ public class T7068451 {
|
||||||
System.err.println("FIRST compilation");
|
System.err.println("FIRST compilation");
|
||||||
System.err.println();
|
System.err.println();
|
||||||
|
|
||||||
CompilationTask task = compiler.getTask(null, null, null, opts, null,
|
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||||
compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
|
CompilationTask task = compiler.getTask(null, fm, null, opts, null,
|
||||||
task.setProcessors(Collections.singleton(new Proc("first")));
|
fm.getJavaFileObjects(input));
|
||||||
check("compilation", task.call());
|
task.setProcessors(Collections.singleton(new Proc("first")));
|
||||||
|
check("compilation", task.call());
|
||||||
|
|
||||||
writeFile(tmp, "X.java", "package p; class X { { p.C.second(); } }");
|
writeFile(tmp, "X.java", "package p; class X { { p.C.second(); } }");
|
||||||
|
|
||||||
//Thread.sleep(2000);
|
//Thread.sleep(2000);
|
||||||
|
|
||||||
System.err.println();
|
System.err.println();
|
||||||
System.err.println("SECOND compilation");
|
System.err.println("SECOND compilation");
|
||||||
System.err.println();
|
System.err.println();
|
||||||
|
|
||||||
task = compiler.getTask(null, null, null, opts, null,
|
task = compiler.getTask(null, fm, null, opts, null,
|
||||||
compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
|
fm.getJavaFileObjects(input));
|
||||||
task.setProcessors(Collections.singleton(new Proc("second")));
|
task.setProcessors(Collections.singleton(new Proc("second")));
|
||||||
check("compilation", task.call());
|
check("compilation", task.call());
|
||||||
|
|
||||||
//Thread.sleep(2000);
|
//Thread.sleep(2000);
|
||||||
|
|
||||||
System.err.println();
|
System.err.println();
|
||||||
System.err.println("SECOND compilation, REPEATED");
|
System.err.println("SECOND compilation, REPEATED");
|
||||||
System.err.println();
|
System.err.println();
|
||||||
|
|
||||||
task = compiler.getTask(null, null, null, opts, null,
|
task = compiler.getTask(null, fm, null, opts, null,
|
||||||
compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
|
fm.getJavaFileObjects(input));
|
||||||
task.setProcessors(Collections.singleton(new Proc("second")));
|
task.setProcessors(Collections.singleton(new Proc("second")));
|
||||||
check("compilation", task.call());
|
check("compilation", task.call());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(String msg, boolean ok) {
|
void check(String msg, boolean ok) {
|
||||||
|
|
|
@ -76,18 +76,21 @@ public class LVTHarness {
|
||||||
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
try {
|
||||||
|
String testDir = System.getProperty("test.src");
|
||||||
|
fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests")));
|
||||||
|
|
||||||
String testDir = System.getProperty("test.src");
|
// Make sure classes are written to scratch dir.
|
||||||
fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests")));
|
fm.setLocation(CLASS_OUTPUT, Arrays.asList(new File(".")));
|
||||||
|
|
||||||
// Make sure classes are written to scratch dir.
|
for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(SOURCE), true)) {
|
||||||
fm.setLocation(CLASS_OUTPUT, Arrays.asList(new File(".")));
|
new LVTHarness(jfo).check();
|
||||||
|
}
|
||||||
for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(SOURCE), true)) {
|
if (nerrors > 0) {
|
||||||
new LVTHarness(jfo).check();
|
throw new AssertionError("Errors were found");
|
||||||
}
|
}
|
||||||
if (nerrors > 0) {
|
} finally {
|
||||||
throw new AssertionError("Errors were found");
|
fm.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -70,19 +70,23 @@ public class BridgeHarness {
|
||||||
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
//set sourcepath
|
try {
|
||||||
fm.setLocation(SOURCE_PATH,
|
//set sourcepath
|
||||||
Arrays.asList(new File(System.getProperty("test.src"), "tests")));
|
fm.setLocation(SOURCE_PATH,
|
||||||
//set output (-d)
|
Arrays.asList(new File(System.getProperty("test.src"), "tests")));
|
||||||
fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
|
//set output (-d)
|
||||||
Arrays.asList(new File(System.getProperty("user.dir"))));
|
fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
|
||||||
for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
|
Arrays.asList(new File(System.getProperty("user.dir"))));
|
||||||
//for each source, compile and check against annotations
|
for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
|
||||||
new BridgeHarness(jfo).compileAndCheck();
|
//for each source, compile and check against annotations
|
||||||
}
|
new BridgeHarness(jfo).compileAndCheck();
|
||||||
//if there were errors, fail
|
}
|
||||||
if (nerrors > 0) {
|
//if there were errors, fail
|
||||||
throw new AssertionError("Errors were found");
|
if (nerrors > 0) {
|
||||||
|
throw new AssertionError("Errors were found");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -150,17 +150,17 @@ public class GenericConstructorAndDiamondTest {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
for (BoundKind boundKind : BoundKind.values()) {
|
||||||
for (BoundKind boundKind : BoundKind.values()) {
|
for (ConstructorKind constructorKind : ConstructorKind.values()) {
|
||||||
for (ConstructorKind constructorKind : ConstructorKind.values()) {
|
for (TypeArgumentKind declArgKind : TypeArgumentKind.values()) {
|
||||||
for (TypeArgumentKind declArgKind : TypeArgumentKind.values()) {
|
for (TypeArgArity arity : TypeArgArity.values()) {
|
||||||
for (TypeArgArity arity : TypeArgArity.values()) {
|
for (TypeArgumentKind useArgKind : TypeArgumentKind.values()) {
|
||||||
for (TypeArgumentKind useArgKind : TypeArgumentKind.values()) {
|
for (TypeArgumentKind diamondArgKind : TypeArgumentKind.values()) {
|
||||||
for (TypeArgumentKind diamondArgKind : TypeArgumentKind.values()) {
|
for (ArgumentKind argKind : ArgumentKind.values()) {
|
||||||
for (ArgumentKind argKind : ArgumentKind.values()) {
|
new GenericConstructorAndDiamondTest(boundKind, constructorKind,
|
||||||
new GenericConstructorAndDiamondTest(boundKind, constructorKind,
|
declArgKind, arity, useArgKind, diamondArgKind, argKind).run(comp, fm);
|
||||||
declArgKind, arity, useArgKind, diamondArgKind, argKind).run(comp, fm);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -78,26 +78,27 @@ public class ParserTest {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (TypeQualifierArity arity : TypeQualifierArity.values()) {
|
for (TypeQualifierArity arity : TypeQualifierArity.values()) {
|
||||||
for (TypeArgumentKind tak1 : TypeArgumentKind.values()) {
|
for (TypeArgumentKind tak1 : TypeArgumentKind.values()) {
|
||||||
if (arity == TypeQualifierArity.ONE) {
|
if (arity == TypeQualifierArity.ONE) {
|
||||||
new ParserTest(arity, tak1).run(comp, fm);
|
new ParserTest(arity, tak1).run(comp, fm);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (TypeArgumentKind tak2 : TypeArgumentKind.values()) {
|
|
||||||
if (arity == TypeQualifierArity.TWO) {
|
|
||||||
new ParserTest(arity, tak1, tak2).run(comp, fm);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (TypeArgumentKind tak3 : TypeArgumentKind.values()) {
|
for (TypeArgumentKind tak2 : TypeArgumentKind.values()) {
|
||||||
if (arity == TypeQualifierArity.THREE) {
|
if (arity == TypeQualifierArity.TWO) {
|
||||||
new ParserTest(arity, tak1, tak2, tak3).run(comp, fm);
|
new ParserTest(arity, tak1, tak2).run(comp, fm);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (TypeArgumentKind tak4 : TypeArgumentKind.values()) {
|
for (TypeArgumentKind tak3 : TypeArgumentKind.values()) {
|
||||||
new ParserTest(arity, tak1, tak2, tak3, tak4).run(comp, fm);
|
if (arity == TypeQualifierArity.THREE) {
|
||||||
|
new ParserTest(arity, tak1, tak2, tak3).run(comp, fm);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (TypeArgumentKind tak4 : TypeArgumentKind.values()) {
|
||||||
|
new ParserTest(arity, tak1, tak2, tak3, tak4).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -86,18 +86,19 @@ public class T7086601b {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (TypeKind a1 : TypeKind.values()) {
|
for (TypeKind a1 : TypeKind.values()) {
|
||||||
for (TypeKind a2 : TypeKind.values()) {
|
for (TypeKind a2 : TypeKind.values()) {
|
||||||
for (TypeKind a3 : TypeKind.values()) {
|
for (TypeKind a3 : TypeKind.values()) {
|
||||||
for (MethodCallKind mck : MethodCallKind.values()) {
|
for (MethodCallKind mck : MethodCallKind.values()) {
|
||||||
new T7086601b(a1, a2, a3, mck).run(comp, fm);
|
new T7086601b(a1, a2, a3, mck).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeKind a1;
|
TypeKind a1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -105,18 +105,19 @@ public class BadLambdaExpr {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (ParameterListKind plk : ParameterListKind.values()) {
|
for (ParameterListKind plk : ParameterListKind.values()) {
|
||||||
for (ParameterKind pk : ParameterKind.values()) {
|
for (ParameterKind pk : ParameterKind.values()) {
|
||||||
for (ArrowKind ak : ArrowKind.values()) {
|
for (ArrowKind ak : ArrowKind.values()) {
|
||||||
for (ExprKind ek : ExprKind.values()) {
|
for (ExprKind ek : ExprKind.values()) {
|
||||||
new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
|
new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterListKind plk;
|
ParameterListKind plk;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -114,22 +114,23 @@ public class TestSelfRef {
|
||||||
|
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (EnclosingKind ek : EnclosingKind.values()) {
|
for (EnclosingKind ek : EnclosingKind.values()) {
|
||||||
for (SiteKind sk : SiteKind.values()) {
|
for (SiteKind sk : SiteKind.values()) {
|
||||||
if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
|
if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
|
||||||
continue;
|
continue;
|
||||||
for (InnerKind ik : InnerKind.values()) {
|
for (InnerKind ik : InnerKind.values()) {
|
||||||
if (ik != InnerKind.NONE && sk == SiteKind.NONE)
|
if (ik != InnerKind.NONE && sk == SiteKind.NONE)
|
||||||
break;
|
break;
|
||||||
for (RefKind rk : RefKind.values()) {
|
for (RefKind rk : RefKind.values()) {
|
||||||
new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
|
new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EnclosingKind ek;
|
EnclosingKind ek;
|
||||||
|
|
|
@ -185,14 +185,15 @@ public class IntersectionTargetTypeTest {
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
//create default shared JavaCompiler - reused across multiple compilations
|
//create default shared JavaCompiler - reused across multiple compilations
|
||||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||||
|
|
||||||
for (CastInfo cInfo : allCastInfo()) {
|
for (CastInfo cInfo : allCastInfo()) {
|
||||||
for (ExpressionKind ek : ExpressionKind.values()) {
|
for (ExpressionKind ek : ExpressionKind.values()) {
|
||||||
new IntersectionTargetTypeTest(cInfo, ek).run(comp, fm);
|
new IntersectionTargetTypeTest(cInfo, ek).run(comp, fm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("Total check executed: " + checkCount);
|
||||||
}
|
}
|
||||||
System.out.println("Total check executed: " + checkCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<CastInfo> allCastInfo() {
|
static List<CastInfo> allCastInfo() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -250,13 +250,17 @@ public class SamConversionComboTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
for(Context ct : Context.values()) {
|
try {
|
||||||
for (FInterface fi : FInterface.values()) {
|
for(Context ct : Context.values()) {
|
||||||
for (MethodDef md: MethodDef.values()) {
|
for (FInterface fi : FInterface.values()) {
|
||||||
new SamConversionComboTest(fi, ct, md).test();
|
for (MethodDef md: MethodDef.values()) {
|
||||||
|
new SamConversionComboTest(fi, ct, md).test();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("total tests: " + count);
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
System.out.println("total tests: " + count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,6 +28,7 @@ import org.openjdk.tests.shapegen.*;
|
||||||
import com.sun.source.util.JavacTask;
|
import com.sun.source.util.JavacTask;
|
||||||
import com.sun.tools.javac.util.Pair;
|
import com.sun.tools.javac.util.Pair;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -41,6 +42,7 @@ import javax.tools.SimpleJavaFileObject;
|
||||||
import javax.tools.StandardJavaFileManager;
|
import javax.tools.StandardJavaFileManager;
|
||||||
import javax.tools.ToolProvider;
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
|
import org.testng.annotations.AfterSuite;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.testng.annotations.BeforeSuite;
|
import org.testng.annotations.BeforeSuite;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
|
@ -70,12 +72,19 @@ public class FDTest {
|
||||||
fm = comp.getStandardFileManager(null, null, null);
|
fm = comp.getStandardFileManager(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterSuite
|
||||||
|
static void teardown() throws IOException {
|
||||||
|
fm.close();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
|
for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
|
||||||
runTest(fdtest.fst, fdtest.snd, comp, fm);
|
runTest(fdtest.fst, fdtest.snd, comp, fm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dataProvider = "fdCases")
|
@Test(dataProvider = "fdCases")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -193,27 +193,30 @@ public class NativeHeaderTest {
|
||||||
void run() throws Exception {
|
void run() throws Exception {
|
||||||
javac = JavacTool.create();
|
javac = JavacTool.create();
|
||||||
fm = javac.getStandardFileManager(null, null, null);
|
fm = javac.getStandardFileManager(null, null, null);
|
||||||
|
try {
|
||||||
for (RunKind rk: RunKind.values()) {
|
for (RunKind rk: RunKind.values()) {
|
||||||
for (GenKind gk: GenKind.values()) {
|
for (GenKind gk: GenKind.values()) {
|
||||||
for (Method m: getClass().getDeclaredMethods()) {
|
for (Method m: getClass().getDeclaredMethods()) {
|
||||||
Annotation a = m.getAnnotation(Test.class);
|
Annotation a = m.getAnnotation(Test.class);
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
init(rk, gk, m.getName());
|
init(rk, gk, m.getName());
|
||||||
try {
|
try {
|
||||||
m.invoke(this, new Object[] { rk, gk });
|
m.invoke(this, new Object[] { rk, gk });
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
throw (cause instanceof Exception) ? ((Exception) cause) : e;
|
throw (cause instanceof Exception) ? ((Exception) cause) : e;
|
||||||
|
}
|
||||||
|
System.err.println();
|
||||||
}
|
}
|
||||||
System.err.println();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
|
||||||
|
if (errorCount > 0)
|
||||||
|
throw new Exception(errorCount + " errors found");
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
|
|
||||||
if (errorCount > 0)
|
|
||||||
throw new Exception(errorCount + " errors found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,6 +45,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.tools.JavaCompiler;
|
import javax.tools.JavaCompiler;
|
||||||
import javax.tools.JavaCompiler.CompilationTask;
|
import javax.tools.JavaCompiler.CompilationTask;
|
||||||
|
import javax.tools.StandardJavaFileManager;
|
||||||
import javax.tools.ToolProvider;
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,27 +74,31 @@ public class XPreferTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
final static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
final static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||||
|
final static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||||
final static File OUTPUT_DIR = new File("out");
|
final static File OUTPUT_DIR = new File("out");
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
|
try {
|
||||||
|
// Initialize test-directories
|
||||||
|
OUTPUT_DIR.mkdir();
|
||||||
|
for (Dir dir : Dir.values())
|
||||||
|
dir.file.mkdir();
|
||||||
|
|
||||||
// Initialize test-directories
|
int testCaseCounter = 0;
|
||||||
OUTPUT_DIR.mkdir();
|
|
||||||
for (Dir dir : Dir.values())
|
|
||||||
dir.file.mkdir();
|
|
||||||
|
|
||||||
int testCaseCounter = 0;
|
for (List<Dir> dirSubset : SubseqIter.subseqsOf(Dir.values())) {
|
||||||
|
|
||||||
for (List<Dir> dirSubset : SubseqIter.subseqsOf(Dir.values())) {
|
if (dirSubset.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (dirSubset.isEmpty())
|
for (ImplicitOption policy : ImplicitOption.values()) {
|
||||||
continue;
|
for (List<Dir> dirOrder : PermutationIterator.permutationsOf(dirSubset)) {
|
||||||
|
new TestCase(dirOrder, policy, testCaseCounter++).run();
|
||||||
for (ImplicitOption policy : ImplicitOption.values()) {
|
}
|
||||||
for (List<Dir> dirOrder : PermutationIterator.permutationsOf(dirSubset)) {
|
|
||||||
new TestCase(dirOrder, policy, testCaseCounter++).run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
fm.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,8 +239,8 @@ public class XPreferTest {
|
||||||
if(dir == Dir.SOURCE_PATH)
|
if(dir == Dir.SOURCE_PATH)
|
||||||
return src;
|
return src;
|
||||||
// ...otherwise compile into a ".class".
|
// ...otherwise compile into a ".class".
|
||||||
CompilationTask task = comp.getTask(null, null, null, null, null,
|
CompilationTask task = comp.getTask(null, fm, null, null, null,
|
||||||
comp.getStandardFileManager(null, null, null).getJavaFileObjects(src));
|
fm.getJavaFileObjects(src));
|
||||||
File dest = new File(dir.file, classId + ".class");
|
File dest = new File(dir.file, classId + ".class");
|
||||||
if(!task.call() || !dest.exists())
|
if(!task.call() || !dest.exists())
|
||||||
throw new RuntimeException("Compilation failure.");
|
throw new RuntimeException("Compilation failure.");
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue