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,7 +77,7 @@ public class RunCodingRules {
|
|||
}
|
||||
|
||||
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null)) {
|
||||
DiagnosticListener<JavaFileObject> noErrors = diagnostic -> {
|
||||
Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString());
|
||||
};
|
||||
|
@ -113,6 +113,7 @@ public class RunCodingRules {
|
|||
javaCompiler.getTask(null, fm, noErrors, options, null,
|
||||
fm.getJavaFileObjectsFromFiles(sources)).call();
|
||||
}
|
||||
}
|
||||
|
||||
Stream<Path> silentFilesWalk(Path dir) throws IllegalStateException {
|
||||
try {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -113,7 +113,7 @@ public class T6341866 {
|
|||
|
||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||
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
|
||||
File file = (implicitType != ImplicitType.NONE) ? a_java : b_java;
|
||||
|
@ -166,6 +166,7 @@ public class T6341866 {
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static void createProcessorServices(String name) throws IOException {
|
||||
processorServices.getParentFile().mkdirs();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -58,8 +58,7 @@ public class T6400872 {
|
|||
throws IOException {
|
||||
System.err.println("compile...");
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||
try {
|
||||
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> fileObjects =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
|
||||
|
||||
|
@ -78,8 +77,6 @@ public class T6400872 {
|
|||
compiler.getTask(null, fm, null, options, null, fileObjects);
|
||||
if (!task.call())
|
||||
throw new AssertionError("compilation failed");
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ abstract class Checker {
|
|||
};
|
||||
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(getFiles(testSrc, fileNames));
|
||||
task = tool.getTask(null, fm, dl, null, null, files);
|
||||
|
@ -74,6 +74,7 @@ abstract class Checker {
|
|||
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
|
||||
protected boolean check(Scope s, String ref) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -40,7 +40,7 @@ public class T6440583 {
|
|||
String testSrc = System.getProperty("test.src", ".");
|
||||
String testClasses = System.getProperty("test.classes", ".");
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
|
||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||
|
@ -65,6 +65,7 @@ public class T6440583 {
|
|||
if (!found)
|
||||
throw new AssertionError("no ErroneousTree nodes 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -54,7 +54,7 @@ public class Test {
|
|||
|
||||
void test(File test) throws Exception {
|
||||
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);
|
||||
|
||||
// parse test file into a tree, and write it out to a stringbuffer using Pretty
|
||||
|
@ -88,4 +88,5 @@ public class Test {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -49,9 +49,6 @@ public class T7003595 {
|
|||
|
||||
/** 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
|
||||
static int checkCount = 0;
|
||||
|
||||
|
@ -112,6 +109,8 @@ public class T7003595 {
|
|||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
// Create a single file manager and reuse it for each compile to save time.
|
||||
try (StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null)) {
|
||||
for (ClassKind ck1 : ClassKind.values()) {
|
||||
String cname1 = "C1";
|
||||
for (ClassKind ck2 : ClassKind.values()) {
|
||||
|
@ -120,7 +119,8 @@ public class T7003595 {
|
|||
for (ClassKind ck3 : ClassKind.values()) {
|
||||
if (!ck2.isAllowed(ck3)) continue;
|
||||
String cname3 = "C3";
|
||||
new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
|
||||
new T7003595(fm, new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,10 @@ public class T7003595 {
|
|||
|
||||
ClassKind[] cks;
|
||||
String[] cnames;
|
||||
StandardJavaFileManager fm;
|
||||
|
||||
T7003595(ClassKind[] cks, String[] cnames) {
|
||||
T7003595(StandardJavaFileManager fm, ClassKind[] cks, String[] cnames) {
|
||||
this.fm = fm;
|
||||
this.cks = cks;
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -100,7 +100,7 @@ public class TestCircularClassfile {
|
|||
|
||||
public static void main(String... args) throws Exception {
|
||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||
int count = 0;
|
||||
for (SourceKind sk1 : SourceKind.values()) {
|
||||
for (SourceKind sk2 : SourceKind.values()) {
|
||||
|
@ -112,6 +112,7 @@ public class TestCircularClassfile {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static String workDir = System.getProperty("user.dir");
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -96,11 +96,12 @@ public class T7142086 {
|
|||
void run(List<JavaFileObject> sources) throws Exception {
|
||||
DiagnosticChecker dc = new DiagnosticChecker();
|
||||
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,
|
||||
null, null, sources);
|
||||
ct.analyze();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -54,7 +54,7 @@ public class NoStringToLower {
|
|||
*/
|
||||
boolean run(String... args) throws Exception {
|
||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||
JavaFileManager fm = c.getStandardFileManager(null, null, null);
|
||||
try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||
JavaFileManager.Location javacLoc = findJavacLocation(fm);
|
||||
String[] pkgs = {
|
||||
"javax.annotation.processing",
|
||||
|
@ -80,6 +80,7 @@ public class NoStringToLower {
|
|||
|
||||
return (errors == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// depending on how the test is run, javac may be on bootclasspath or classpath
|
||||
JavaFileManager.Location findJavacLocation(JavaFileManager fm) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -71,10 +71,10 @@ 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...");
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> fileObjects =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(files));
|
||||
|
||||
|
@ -94,6 +94,7 @@ public class JarFromManifestFailure {
|
|||
if (!task.call())
|
||||
throw new AssertionError("compilation failed");
|
||||
}
|
||||
}
|
||||
|
||||
static void jar(File jar, Iterable<File> classPath, File base, File... files)
|
||||
throws IOException {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -116,7 +116,7 @@ public class TestCompileJARInClassPath {
|
|||
|
||||
javax.tools.JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||
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<>();
|
||||
files.add(clientJarFile);
|
||||
|
@ -130,3 +130,4 @@ public class TestCompileJARInClassPath {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,11 +44,12 @@ public class T6265400 {
|
|||
throw new NullPointerException(SILLY_BILLY);
|
||||
}
|
||||
};
|
||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
||||
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromStrings(Arrays.asList("badfile.java"));
|
||||
javac.getTask(null, fm, dl, null, null, files).call();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof NullPointerException
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,7 +44,7 @@ public class T6340549 {
|
|||
|
||||
try {
|
||||
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(".")));
|
||||
|
||||
for (JavaFileObject jfo : jfm.list(StandardLocation.CLASS_PATH,
|
||||
|
@ -53,6 +53,7 @@ public class T6340549 {
|
|||
throw new AssertionError("Found directory: " + jfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
dir.delete(); // cleanup
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -38,7 +38,7 @@ public class T6351767 {
|
|||
public static void main(String... args) throws Exception {
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
JavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
|
||||
try (JavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) {
|
||||
|
||||
// test null
|
||||
try {
|
||||
|
@ -83,7 +83,7 @@ public class T6351767 {
|
|||
}
|
||||
if (!found)
|
||||
error("expected file, java/lang/Object.class, not found");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -57,7 +57,7 @@ public class T6361619 extends AbstractProcessor {
|
|||
}
|
||||
};
|
||||
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||
Iterable<? extends JavaFileObject> f =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir,
|
||||
self + ".java")));
|
||||
|
@ -69,6 +69,7 @@ public class T6361619 extends AbstractProcessor {
|
|||
// should complete, without exceptions
|
||||
task.call();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) {
|
||||
return true;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class T6395974 {
|
|||
String testSrc = System.getProperty("test.src");
|
||||
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<?extends JavaFileObject> f =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self + ".java")));
|
||||
|
||||
|
@ -63,6 +63,7 @@ public class T6395974 {
|
|||
|
||||
task.call();
|
||||
}
|
||||
}
|
||||
|
||||
static class MyTaskListener implements TaskListener {
|
||||
public void started(TaskEvent e) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -42,7 +42,7 @@ public abstract class T6397044 {
|
|||
String srcDir = System.getProperty("test.src", ".");
|
||||
String self = T6397044.class.getName();
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files
|
||||
= fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcDir, self + ".java")));
|
||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||
|
@ -51,6 +51,7 @@ public abstract class T6397044 {
|
|||
for (CompilationUnitTree tree: trees)
|
||||
checker.check(tree);
|
||||
}
|
||||
}
|
||||
|
||||
public int x_public;
|
||||
protected int x_protected;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -40,7 +40,7 @@ public class T6397286 {
|
|||
String self = T6397286.class.getName();
|
||||
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||
|
||||
|
@ -67,6 +67,7 @@ public class T6397286 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TaskEventError extends Error {
|
||||
public TaskEventError(TaskEvent ev) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -51,7 +51,7 @@ public class T6403466 extends AbstractProcessor {
|
|||
public static void main(String[] args) throws IOException {
|
||||
JavacTool tool = JavacTool.create();
|
||||
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||
|
||||
|
@ -70,6 +70,7 @@ public class T6403466 extends AbstractProcessor {
|
|||
if (vtl.iter.hasNext() || vtl.errors)
|
||||
throw new AssertionError("comparison against golden file failed.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
|
||||
if (!rEnv.processingOver()) {
|
||||
|
|
|
@ -33,13 +33,13 @@ public class T6406771 extends AbstractProcessor {
|
|||
|
||||
// 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 testSrc = System.getProperty("test.src");
|
||||
String testClasses = System.getProperty("test.classes");
|
||||
|
||||
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();
|
||||
|
||||
List<String> opts = Arrays.asList("-d", ".", "-processorpath", testClasses, "-processor", self, "-proc:only");
|
||||
|
@ -49,6 +49,7 @@ public class T6406771 extends AbstractProcessor {
|
|||
if (!task.call())
|
||||
throw new AssertionError("failed");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean process(Set<? extends TypeElement> elems, RoundEnvironment rEnv) {
|
||||
final String LINE = "line" + ':'; // avoid matching this string
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,7 +37,7 @@ public class T6407066 {
|
|||
String testClasses = System.getProperty("test.classes", ".");
|
||||
|
||||
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>();
|
||||
path.add(new File("BadDirectory"));
|
||||
|
@ -54,3 +54,4 @@ public class T6407066 {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,7 +44,7 @@ public class T6410706 {
|
|||
String testClasses = System.getProperty("test.classes", ".");
|
||||
JavacTool tool = JavacTool.create();
|
||||
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)));
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6410706.class.getName()+".java")));
|
||||
|
@ -60,6 +60,7 @@ public class T6410706 {
|
|||
if (dl.notes != 2)
|
||||
throw new AssertionError(dl.notes + " notes given");
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -55,7 +55,7 @@ public class T6458823 {
|
|||
}
|
||||
DiagnosticCollector<JavaFileObject> diagColl =
|
||||
new DiagnosticCollector<JavaFileObject>();
|
||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||
List<String> options = new ArrayList<String>();
|
||||
options.add("-processor");
|
||||
options.add("MyProcessor");
|
||||
|
@ -85,3 +85,4 @@ public class T6458823 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -47,8 +47,8 @@ public class T6665791 {
|
|||
write(test_java, test);
|
||||
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager manager =
|
||||
compiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager manager =
|
||||
compiler.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> units = manager.getJavaFileObjects(test_java);
|
||||
final StringWriter sw = new StringWriter();
|
||||
JavacTask task = (JavacTask) compiler.getTask(sw, manager, null, null,
|
||||
|
@ -72,6 +72,7 @@ public class T6665791 {
|
|||
throw new Exception("unexpected output");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write(File file, String body) throws IOException {
|
||||
FileWriter out = new FileWriter(file);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -45,7 +45,7 @@ public class T6705935 {
|
|||
java_home = java_home.getParentFile();
|
||||
|
||||
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)));
|
||||
|
||||
for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
|
||||
|
@ -86,6 +86,7 @@ public class T6705935 {
|
|||
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) {
|
||||
List<T> list = new ArrayList<T>();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,8 +37,8 @@ public class T6900149 {
|
|||
DiagnosticCollector<JavaFileObject> diag =
|
||||
new DiagnosticCollector<JavaFileObject>();
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm =
|
||||
compiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm =
|
||||
compiler.getStandardFileManager(null, null, null)) {
|
||||
File emptyFile = createTempFile("Empty.java");
|
||||
File[] files = new File[] { emptyFile, emptyFile };
|
||||
CompilationTask task = compiler.getTask(null, fm, diag,
|
||||
|
@ -47,6 +47,7 @@ public class T6900149 {
|
|||
throw new AssertionError("compilation failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static File createTempFile(String path) throws IOException {
|
||||
File f = new File(path);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,7 +44,7 @@ public class T6956462 {
|
|||
if (compiler == null) {
|
||||
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>();
|
||||
files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
|
||||
final CompilationTask task = compiler.getTask(null, fm, null,
|
||||
|
@ -54,6 +54,7 @@ public class T6956462 {
|
|||
cu.accept(new MyVisitor(javacTask), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyVisitor extends SimpleTreeVisitor<Tree, Void> {
|
||||
private final Trees trees;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -96,7 +96,7 @@ public class T6956638 {
|
|||
List<String> compileOptions = Arrays.asList("-d", classesDir.getPath());
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
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);
|
||||
System.err.println("1- javac given java source JavaFileObjects " + sourceFileObjects);
|
||||
JavaCompiler.CompilationTask task = compiler.getTask(compilerOutputStream, fileManager, null, compileOptions, null, sourceFileObjects);
|
||||
|
@ -126,6 +126,7 @@ public class T6956638 {
|
|||
+ " expected: " + size(parsedTrees));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void error(Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -58,7 +58,7 @@ public class Bug {
|
|||
}
|
||||
};
|
||||
|
||||
StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null);
|
||||
try (StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null)) {
|
||||
|
||||
List<String> opts = new ArrayList<String>();
|
||||
opts.add("-proc:only");
|
||||
|
@ -83,3 +83,4 @@ public class Bug {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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.tools.Diagnostic;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
public class T7159016 {
|
||||
|
@ -58,13 +59,15 @@ public class T7159016 {
|
|||
w.close();
|
||||
}
|
||||
JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
|
||||
JavaCompiler.CompilationTask task = jc.getTask(null, null, null, null, null,
|
||||
jc.getStandardFileManager(null, null, null).getJavaFileObjects(src));
|
||||
try (StandardJavaFileManager fm = jc.getStandardFileManager(null, null, null)) {
|
||||
JavaCompiler.CompilationTask task = jc.getTask(null, fm, null, null, null,
|
||||
fm.getJavaFileObjects(src));
|
||||
task.setProcessors(Collections.singleton(new Proc()));
|
||||
if (!task.call()) {
|
||||
throw new Error("Test failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class Proc extends JavacTestingAbstractProcessor {
|
||||
int written;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -179,7 +179,7 @@ public class DetectMutableStaticFields {
|
|||
ConstantPoolException,
|
||||
InvalidDescriptor {
|
||||
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
JavaFileManager.Location location =
|
||||
StandardLocation.locationFor(resource.getPath());
|
||||
fm.setLocation(location, com.sun.tools.javac.util.List.of(
|
||||
|
@ -194,6 +194,7 @@ public class DetectMutableStaticFields {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> currentFieldsToIgnore;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -132,7 +132,7 @@ public class ParameterNamesAreNotCopiedToAnonymousInitTest {
|
|||
throws IOException {
|
||||
Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg);
|
||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> fos =
|
||||
fm.getJavaFileObjectsFromFiles(
|
||||
Arrays.asList(new File(System.getProperty("test.src"),
|
||||
|
@ -201,6 +201,7 @@ public class ParameterNamesAreNotCopiedToAnonymousInitTest {
|
|||
error(compilationFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
throw new AssertionError(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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -117,7 +117,7 @@ public class InterruptedExceptionTest {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (SuppressLevel suppress_decl : SuppressLevel.values()) {
|
||||
|
@ -134,6 +134,7 @@ public class InterruptedExceptionTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XlintOption xlint;
|
||||
SuppressLevel suppress_decl;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -161,6 +161,7 @@ public class UnusedResourcesTest {
|
|||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
try {
|
||||
for (XlintOption xlint : XlintOption.values()) {
|
||||
for (SuppressLevel suppressLevel : SuppressLevel.values()) {
|
||||
for (ResourceUsage usage1 : ResourceUsage.values()) {
|
||||
|
@ -176,6 +177,9 @@ public class UnusedResourcesTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Create a single file manager and reuse it for each compile to save time.
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -41,7 +41,7 @@ public class VerifyAnnotationsAttributed {
|
|||
File testSrc = new File(System.getProperty("test.src"));
|
||||
File testFile = new File(testSrc, args[0]);
|
||||
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,
|
||||
fm,
|
||||
null,
|
||||
|
@ -76,3 +76,4 @@ public class VerifyAnnotationsAttributed {
|
|||
}.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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -102,8 +102,7 @@ public class Helper {
|
|||
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
|
||||
if (isPkgInfoPresent(files)) {
|
||||
JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
|
||||
|
@ -125,6 +124,9 @@ public class Helper {
|
|||
ok = task.call();
|
||||
}
|
||||
return ok;
|
||||
} catch (IOException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -46,7 +46,7 @@ public class AnnotatedArrayOrder {
|
|||
public static void main(String[] args) throws Exception {
|
||||
PrintWriter out = new PrintWriter(System.out, true);
|
||||
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"));
|
||||
Iterable<? extends JavaFileObject> f =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java")));
|
||||
|
@ -57,7 +57,7 @@ public class AnnotatedArrayOrder {
|
|||
Scanner s = new Scanner();
|
||||
for (CompilationUnitTree t: trees)
|
||||
s.scan(t, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -48,7 +48,7 @@ public class ArrayCreationTree {
|
|||
public static void main(String[] args) throws Exception {
|
||||
PrintWriter out = new PrintWriter(System.out, true);
|
||||
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"));
|
||||
Iterable<? extends JavaFileObject> f =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayCreationTree.java")));
|
||||
|
@ -59,7 +59,7 @@ public class ArrayCreationTree {
|
|||
Scanner s = new Scanner();
|
||||
for (CompilationUnitTree t: trees)
|
||||
s.scan(t, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -47,7 +47,7 @@ public class ArrayPositionConsistency {
|
|||
public static void main(String[] args) throws Exception {
|
||||
PrintWriter out = new PrintWriter(System.out, true);
|
||||
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"));
|
||||
Iterable<? extends JavaFileObject> f =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayPositionConsistency.java")));
|
||||
|
@ -58,7 +58,7 @@ public class ArrayPositionConsistency {
|
|||
Scanner s = new Scanner();
|
||||
for (CompilationUnitTree t: trees)
|
||||
s.scan(t, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class Scanner extends TreeScanner<Void,Void> {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class CheckErrorsForSource7 {
|
|||
File testSrc = new File(System.getProperty("test.src"));
|
||||
File testFile = new File(testSrc, args[0]);
|
||||
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:
|
||||
JavacTask task = JavacTool.create().getTask(null,
|
||||
|
@ -145,6 +145,7 @@ public class CheckErrorsForSource7 {
|
|||
throw new IllegalStateException("Did not produce proper errors for: " + updated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final Set<String> EXPECTED_ERRORS = new HashSet<>(Arrays.asList(
|
||||
"compiler.err.type.annotations.not.supported.in.source",
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -46,7 +46,7 @@ public class T6420409 {
|
|||
|
||||
public static void main(String... args) throws IOException {
|
||||
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(CLASS_PATH, Arrays.asList(test_src));
|
||||
fm.setLocation(CLASS_OUTPUT, Arrays.asList(test_classes));
|
||||
|
@ -62,6 +62,7 @@ public class T6420409 {
|
|||
test(fm.getLocation(SOURCE_PATH), test_classes, SOURCE_PATH);
|
||||
test(fm.getLocation(CLASS_OUTPUT), test_classes, CLASS_OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
static void test(Iterable<? extends File> path, File file, Location location) {
|
||||
Iterator<? extends File> it = path.iterator();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -38,7 +38,7 @@ public class T6420464 {
|
|||
|
||||
public static void main(String... args) throws IOException {
|
||||
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));
|
||||
JavaFileObject f = mgr.getJavaFileForInput(StandardLocation.SOURCE_PATH,
|
||||
"T6420464",
|
||||
|
@ -50,3 +50,4 @@ public class T6420464 {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -39,7 +39,7 @@ public class T6431435 {
|
|||
String testSrc = System.getProperty("test.src", ".");
|
||||
String testClasses = System.getProperty("test.classes", ".");
|
||||
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.SOURCE_PATH, Arrays.asList(new File(testSrc)));
|
||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjectsFromFiles(Arrays.asList(
|
||||
|
@ -52,6 +52,7 @@ public class T6431435 {
|
|||
if (!ok)
|
||||
throw new AssertionError("Test failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean check(String name, Iterable<?> iter, int expect) {
|
||||
int found = 0;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -66,11 +66,12 @@ public class T7086261 {
|
|||
|
||||
void test() throws Throwable {
|
||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||
JavaFileManager jfm = javac.getStandardFileManager(null, null, null);
|
||||
try (JavaFileManager jfm = javac.getStandardFileManager(null, null, null)) {
|
||||
JavaCompiler.CompilationTask task =
|
||||
javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource()));
|
||||
task.call();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
new T7086261().test();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -83,7 +83,7 @@ public class Test {
|
|||
File testSrc = new File(System.getProperty("test.src"));
|
||||
File thisFile = new File(testSrc, getClass().getName() + ".java");
|
||||
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(".")));
|
||||
Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
|
||||
testAnnoProcessor(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
|
||||
|
@ -92,6 +92,7 @@ public class Test {
|
|||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm,
|
||||
Iterable<? extends JavaFileObject> files, PrintWriter out,
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -39,7 +39,7 @@ import static javax.tools.JavaFileObject.Kind.CLASS;
|
|||
public class Sibling {
|
||||
public static void main(String... args) throws IOException {
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||
JavaFileObject sibling =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java")))
|
||||
.iterator().next();
|
||||
|
@ -53,3 +53,4 @@ public class Sibling {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,7 +33,7 @@ import java.util.Arrays;
|
|||
import javax.tools.*;
|
||||
|
||||
public class T6258271 {
|
||||
public static void main(String... args) {
|
||||
public static void main(String... args) throws IOException {
|
||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
|
||||
public void report(Diagnostic<? extends JavaFileObject> message) {
|
||||
|
@ -43,9 +43,10 @@ public class T6258271 {
|
|||
System.out.println(message);
|
||||
}
|
||||
};
|
||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
||||
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java"));
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -29,11 +29,12 @@
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import javax.tools.*;
|
||||
|
||||
public class T6265137 {
|
||||
public static void main(String... args) {
|
||||
public static void main(String... args) throws IOException {
|
||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||
DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
|
||||
public void report(Diagnostic<? extends JavaFileObject> message) {
|
||||
|
@ -45,10 +46,11 @@ public class T6265137 {
|
|||
System.out.flush();
|
||||
}
|
||||
};
|
||||
StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null);
|
||||
try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) {
|
||||
String srcdir = System.getProperty("test.src");
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
|
||||
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.
|
||||
*
|
||||
* 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 {
|
||||
T6306137 self = new T6306137();
|
||||
try {
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -45,7 +45,7 @@ public class T6345974 {
|
|||
public static void main(String[] args) throws Exception {
|
||||
PrintWriter out = new PrintWriter(System.out, true);
|
||||
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"));
|
||||
Iterable<? extends JavaFileObject> f =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "T6345974.java")));
|
||||
|
@ -57,6 +57,7 @@ public class T6345974 {
|
|||
for (CompilationUnitTree t: trees)
|
||||
s.scan(t, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Scanner extends TreeScanner<Void,Void> {
|
||||
public Void visitPrimitiveType(PrimitiveTypeTree node, Void ignore) {
|
||||
|
|
|
@ -33,11 +33,11 @@ import com.sun.source.util.*;
|
|||
|
||||
public class T6357331
|
||||
{
|
||||
public static void main(String... args) {
|
||||
public static void main(String... args) throws IOException {
|
||||
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
|
||||
PrintWriter out = new PrintWriter(new StringWriter());
|
||||
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");
|
||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
|
||||
final JavacTask task = (JavacTask) (tool.getTask(out, fm, null, opts, null, files));
|
||||
|
@ -72,3 +72,4 @@ public class T6357331
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -44,7 +44,7 @@ import javax.tools.*;
|
|||
public class T6358786 {
|
||||
public static void main(String... args) throws IOException {
|
||||
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");
|
||||
File file = new File(srcdir, args[0]);
|
||||
JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
|
||||
|
@ -57,3 +57,4 @@ public class T6358786 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -36,7 +36,7 @@ import static javax.tools.JavaFileObject.Kind.*;
|
|||
public class T6358955 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
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());
|
||||
if (!dir.exists())
|
||||
|
@ -68,3 +68,4 @@ public class T6358955 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -38,7 +38,7 @@ public class T6392782 {
|
|||
public static void main(String... args) throws IOException {
|
||||
String testSrc = System.getProperty("test.src", ".");
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6392782.class.getName()+".java")));
|
||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||
|
@ -49,11 +49,12 @@ public class T6392782 {
|
|||
CountNodes nodeCounter = new CountNodes();
|
||||
// 359 nodes with the regular parser; 360 nodes with EndPosParser
|
||||
// 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();
|
||||
check(idCounter, 107, idCounter.scan(trees, null));
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(TreeScanner<?,?> scanner, int expect, int found) {
|
||||
if (found != expect)
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -65,18 +65,17 @@ public class T6397104 {
|
|||
void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)
|
||||
throws Exception
|
||||
{
|
||||
StandardJavaFileManager fm;
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
if (hasLocation) {
|
||||
for (Location location : StandardLocation.values()) {
|
||||
fm = tool.getStandardFileManager(null, null, null);
|
||||
fm.setLocation(location, Arrays.asList(new File(".")));
|
||||
test(fm, location, siblingFile, relName, expectedPath);
|
||||
}
|
||||
} else {
|
||||
fm = tool.getStandardFileManager(null, null, null);
|
||||
test(fm, CLASS_OUTPUT, siblingFile, relName, expectedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
T6397104 tester = new T6397104();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -28,13 +28,14 @@
|
|||
* @author Peter von der Ah\u00e9
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.tools.*;
|
||||
import static javax.tools.StandardLocation.*;
|
||||
|
||||
public class T6400205 {
|
||||
public static void main(String... args) {
|
||||
JavaFileManager fm =
|
||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
||||
public static void main(String... args) throws IOException {
|
||||
try (JavaFileManager fm =
|
||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||
try {
|
||||
fm.getClassLoader(null);
|
||||
throw new AssertionError("NullPointerException not thrown");
|
||||
|
@ -47,3 +48,4 @@ public class T6400205 {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -61,8 +61,8 @@ public class T6400207 {
|
|||
}
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
JavaFileManager fm =
|
||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
|
||||
try (JavaFileManager fm =
|
||||
ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||
JavaFileManager.Location bogusLocation = locationFor("bogus");
|
||||
JavaFileManager.Location knownLocation = CLASS_PATH;
|
||||
String packageName = "java.lang";
|
||||
|
@ -86,3 +86,4 @@ public class T6400207 {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -64,7 +64,7 @@ public class T6412669 extends AbstractProcessor {
|
|||
//System.err.println("toolsClasses: " + toolsClasses);
|
||||
|
||||
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));
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java")));
|
||||
|
@ -81,6 +81,7 @@ public class T6412669 extends AbstractProcessor {
|
|||
if (!out.contains("processing element"))
|
||||
throw new AssertionError("expected text not found in compilation output");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
Trees trees = Trees.instance(processingEnv);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -35,7 +35,7 @@ import javax.tools.*;
|
|||
public class T6419926 {
|
||||
public static void main(String[] argv) throws Exception {
|
||||
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() );
|
||||
mgr.setLocation(StandardLocation.CLASS_OUTPUT,
|
||||
Collections.singleton(new File(".")));
|
||||
|
@ -49,3 +49,4 @@ public class T6419926 {
|
|||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -134,7 +134,7 @@
|
|||
System.err.println("test task API: " + pcp);
|
||||
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
|
||||
if (pcp != null)
|
||||
fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
|
||||
|
@ -150,6 +150,7 @@
|
|||
checkCompilationOK(ok);
|
||||
checkOutput(out, expectWarnings);
|
||||
}
|
||||
}
|
||||
|
||||
//----- 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -39,7 +39,7 @@ public class T6431879 {
|
|||
String testSrc = System.getProperty("test.src", ".");
|
||||
String testClasses = System.getProperty("test.classes", ".");
|
||||
JavacTool tool = JavacTool.create();
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6431879.class.getName()+".java")));
|
||||
JavacTask task = tool.getTask(null, fm, null, null, null, files);
|
||||
|
@ -50,7 +50,7 @@ public class T6431879 {
|
|||
//System.err.println("scan " + unit);
|
||||
dependencyScanner.scan(unit, treeUtil);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -42,7 +42,7 @@ public class T6483788 {
|
|||
void run() throws Exception {
|
||||
File jar = createJar();
|
||||
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));
|
||||
JavaFileObject fo = fm.getJavaFileForInput(StandardLocation.CLASS_PATH, "dummy", JavaFileObject.Kind.CLASS);
|
||||
System.err.println("file: " + fo);
|
||||
|
@ -51,6 +51,7 @@ public class T6483788 {
|
|||
if (uri.toString().contains(" "))
|
||||
throw new Exception("unexpected space character found");
|
||||
}
|
||||
}
|
||||
|
||||
File createJar() throws IOException {
|
||||
byte[] dummy_data = new byte[10];
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -46,7 +46,8 @@ public class T6501502 {
|
|||
// we test a number of platform-independent paths.
|
||||
void run() throws Exception {
|
||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||
fm = c.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager sfm = c.getStandardFileManager(null, null, null)) {
|
||||
fm = sfm;
|
||||
System.err.println(System.getProperties());
|
||||
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
File testSrcDir = new File(System.getProperty("test.src"));
|
||||
|
@ -57,6 +58,7 @@ public class T6501502 {
|
|||
test(new File(testClassesDir, "T6501501.class"));
|
||||
test(new File("a b"));
|
||||
}
|
||||
}
|
||||
|
||||
void test(File f) throws Exception {
|
||||
System.err.println("test " + f);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -56,7 +56,8 @@ public class TestClientCodeWrapper extends JavacTestingAbstractProcessor {
|
|||
*/
|
||||
void run() throws Exception {
|
||||
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")) {
|
||||
test(m);
|
||||
|
@ -85,6 +86,7 @@ public class TestClientCodeWrapper extends JavacTestingAbstractProcessor {
|
|||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
/** Get a sorted set of the methods declared on a class. */
|
||||
Set<Method> getMethods(Class<?> clazz) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -52,8 +52,7 @@ public class TestDocComments {
|
|||
File file = new File(testSrc, "TestDocComments.java");
|
||||
|
||||
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);
|
||||
|
@ -70,6 +69,7 @@ public class TestDocComments {
|
|||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* class-CommentScanner.
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -50,7 +50,7 @@ public class TestGetElementReference {
|
|||
|
||||
public static void main(String... args) throws IOException {
|
||||
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<>();
|
||||
JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, Arrays.asList("-Xjcov"), null, fm.getJavaFileObjects(source));
|
||||
Trees trees = Trees.instance(ct);
|
||||
|
@ -78,6 +78,7 @@ public class TestGetElementReference {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static TreePath pathFor(final Trees trees, final CompilationUnitTree cut, final int pos) {
|
||||
final TreePath[] result = new TreePath[1];
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -29,6 +29,7 @@
|
|||
|
||||
import com.sun.source.tree.IdentifierTree;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -51,16 +52,16 @@ import javax.lang.model.SourceVersion;
|
|||
|
||||
@SupportedAnnotationTypes("*")
|
||||
public class TestGetScope extends AbstractProcessor {
|
||||
public static void main(String... args) {
|
||||
public static void main(String... args) throws IOException {
|
||||
new TestGetScope().run();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
public void run() throws IOException {
|
||||
File srcDir = new File(System.getProperty("test.src"));
|
||||
File thisFile = new File(srcDir, getClass().getName() + ".java");
|
||||
|
||||
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");
|
||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
|
||||
|
@ -70,6 +71,7 @@ public class TestGetScope extends AbstractProcessor {
|
|||
if (!ok)
|
||||
throw new Error("compilation failed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -41,8 +41,8 @@ import javax.tools.ToolProvider;
|
|||
|
||||
public class TestJavacTask {
|
||||
static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
static final StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||
static JavacTaskImpl getTask(File... file) {
|
||||
StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(file));
|
||||
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 {
|
||||
try {
|
||||
basicTest(args);
|
||||
checkKindError();
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class TestJavacTask_Lock {
|
|||
void run() throws Exception {
|
||||
comp = ToolProvider.getSystemJavaCompiler();
|
||||
fm = comp.getStandardFileManager(null, null, null);
|
||||
|
||||
try {
|
||||
for (MethodKind first: MethodKind.values()) {
|
||||
for (MethodKind second: MethodKind.values()) {
|
||||
test(first, second);
|
||||
|
@ -76,6 +76,9 @@ public class TestJavacTask_Lock {
|
|||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " errors found");
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -68,6 +68,7 @@ public class TestJavacTask_Multiple {
|
|||
void run() throws Exception {
|
||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
try {
|
||||
for (TestKind tk: TestKind.values()) {
|
||||
test(comp, fm, tk);
|
||||
}
|
||||
|
@ -77,7 +78,9 @@ public class TestJavacTask_Multiple {
|
|||
throw new Exception("Unexpected number of tests completed: " + count
|
||||
+ ", expected: " + expect);
|
||||
}
|
||||
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -45,7 +45,7 @@ public class TestJavacTask_ParseAttrGen {
|
|||
void run() throws Exception {
|
||||
comp = ToolProvider.getSystemJavaCompiler();
|
||||
fm = comp.getStandardFileManager(null, null, null);
|
||||
|
||||
try {
|
||||
final boolean[] booleanValues = { false, true };
|
||||
for (boolean pk: booleanValues) {
|
||||
for (boolean ak: booleanValues) {
|
||||
|
@ -54,6 +54,9 @@ public class TestJavacTask_ParseAttrGen {
|
|||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
void test(boolean pk, boolean ak, boolean gk) throws Exception {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class TestSearchPaths {
|
|||
void run() throws Exception {
|
||||
compiler = ToolProvider.getSystemJavaCompiler();
|
||||
fileManager = compiler.getStandardFileManager(null, null, null);
|
||||
|
||||
try {
|
||||
// basic output path
|
||||
testClassOutput();
|
||||
|
||||
|
@ -101,6 +101,9 @@ public class TestSearchPaths {
|
|||
if (errors > 0) {
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
} finally {
|
||||
fileManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
void testClassOutput() throws IOException {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -105,8 +105,8 @@ public class TestTreePath extends AbstractProcessor {
|
|||
|
||||
public void run() throws IOException {
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fileManager
|
||||
= compiler.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fileManager
|
||||
= compiler.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> tests
|
||||
= fileManager.getJavaFileObjects(writeTestFile());
|
||||
|
||||
|
@ -117,6 +117,7 @@ public class TestTreePath extends AbstractProcessor {
|
|||
tests);
|
||||
task.call();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
new TestTreePath().run();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TestTrees extends AbstractProcessor {
|
|||
}
|
||||
};
|
||||
|
||||
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
|
||||
Iterable<? extends JavaFileObject> files =
|
||||
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
|
||||
|
||||
|
@ -98,6 +98,7 @@ public class TestTrees extends AbstractProcessor {
|
|||
if (errors > 0)
|
||||
throw new AssertionError(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
void testElement(Trees trees, Element e) {
|
||||
trees.getClass();
|
||||
|
|
|
@ -73,7 +73,7 @@ public class CompileEvent {
|
|||
assertOutput(out.toString());
|
||||
|
||||
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);
|
||||
|
||||
//test events fired to listeners registered from plugins
|
||||
|
@ -86,6 +86,7 @@ public class CompileEvent {
|
|||
throw new AssertionError("Compilation failed unexpectedly.");
|
||||
assertOutput(out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void assertOutput(String found) {
|
||||
String lineSeparator = System.getProperty("line.separator");
|
||||
|
|
|
@ -44,7 +44,12 @@ public class EventsBalancedTest {
|
|||
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
|
||||
|
||||
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 {
|
||||
|
|
|
@ -203,7 +203,12 @@ public class TestSimpleAddRemove {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -104,7 +104,7 @@ public class IntersectionTypeParserTest {
|
|||
public static void main(String... args) throws Exception {
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (TypeKind t1 : TypeKind.values()) {
|
||||
|
@ -134,6 +134,7 @@ public class IntersectionTypeParserTest {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
CastKind ck;
|
||||
Type[] types;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -68,7 +68,7 @@ public class T7031108 extends JavacTestingAbstractProcessor {
|
|||
|
||||
void run() throws Exception {
|
||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||
|
||||
// step 1: compile test classes
|
||||
File cwd = new File(".");
|
||||
|
@ -103,6 +103,7 @@ public class T7031108 extends JavacTestingAbstractProcessor {
|
|||
throw new Exception("unexpected diags received");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void compile(JavaCompiler comp, JavaFileManager fm,
|
||||
DiagnosticListener<JavaFileObject> dl,
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -54,7 +54,7 @@ public class DefaultMethodFlags {
|
|||
|
||||
void checkDefaultMethodFlags() throws IOException {
|
||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||
Iterable<? extends JavaFileObject> fos =
|
||||
fm.getJavaFileObjectsFromFiles(
|
||||
Arrays.asList(new File(
|
||||
|
@ -80,6 +80,7 @@ public class DefaultMethodFlags {
|
|||
|
||||
task.analyze();
|
||||
}
|
||||
}
|
||||
|
||||
void checkDefaultInterface(TypeElement te) {
|
||||
System.err.println("Checking " + te.getSimpleName());
|
||||
|
|
|
@ -123,7 +123,7 @@ public class InterfaceMethodHidingTest {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (SignatureKind sk1 : SignatureKind.values()) {
|
||||
|
@ -146,6 +146,7 @@ public class InterfaceMethodHidingTest {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
MethodKind mk1, mk2, mk3;
|
||||
SignatureKind sk1, sk2, sk3;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -188,7 +188,7 @@ public class TestDefaultMethodsSyntax {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (EnclosingKind ek : EnclosingKind.values()) {
|
||||
|
@ -203,6 +203,7 @@ public class TestDefaultMethodsSyntax {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
VersionKind vk;
|
||||
EnclosingKind ek;
|
||||
|
|
|
@ -313,7 +313,7 @@ public class CheckResourceKeys {
|
|||
Set<String> getCodeStrings() throws IOException {
|
||||
Set<String> results = new TreeSet<String>();
|
||||
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
|
||||
JavaFileManager fm = c.getStandardFileManager(null, null, null);
|
||||
try (JavaFileManager fm = c.getStandardFileManager(null, null, null)) {
|
||||
JavaFileManager.Location javacLoc = findJavacLocation(fm);
|
||||
String[] pkgs = {
|
||||
"javax.annotation.processing",
|
||||
|
@ -335,6 +335,7 @@ public class CheckResourceKeys {
|
|||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
// depending on how the test is run, javac may be on bootclasspath or classpath
|
||||
JavaFileManager.Location findJavacLocation(JavaFileManager 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -109,6 +109,7 @@ public class DocLintTest {
|
|||
void run() throws Exception {
|
||||
javac = ToolProvider.getSystemJavaCompiler();
|
||||
fm = javac.getStandardFileManager(null, null, null);
|
||||
try {
|
||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
||||
file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
|
||||
@Override
|
||||
|
@ -147,6 +148,9 @@ public class DocLintTest {
|
|||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -66,7 +66,7 @@ public class DocTreePathScannerTest {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -83,6 +83,7 @@ public class DocTreePathScannerTest {
|
|||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
System.err.println("Error: " + 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -66,7 +66,7 @@ public class SimpleDocTreeVisitorTest {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -89,6 +89,7 @@ public class SimpleDocTreeVisitorTest {
|
|||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
}
|
||||
}
|
||||
|
||||
void error(String msg) {
|
||||
System.err.println("Error: " + 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.
|
||||
*
|
||||
* 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.JavaCompiler;
|
||||
import javax.tools.JavaCompiler.CompilationTask;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.StandardLocation;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
|
@ -75,8 +76,9 @@ public class T7068451 {
|
|||
System.err.println("FIRST compilation");
|
||||
System.err.println();
|
||||
|
||||
CompilationTask task = compiler.getTask(null, null, null, opts, null,
|
||||
compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
|
||||
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
|
||||
CompilationTask task = compiler.getTask(null, fm, null, opts, null,
|
||||
fm.getJavaFileObjects(input));
|
||||
task.setProcessors(Collections.singleton(new Proc("first")));
|
||||
check("compilation", task.call());
|
||||
|
||||
|
@ -88,8 +90,8 @@ public class T7068451 {
|
|||
System.err.println("SECOND compilation");
|
||||
System.err.println();
|
||||
|
||||
task = compiler.getTask(null, null, null, opts, null,
|
||||
compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
|
||||
task = compiler.getTask(null, fm, null, opts, null,
|
||||
fm.getJavaFileObjects(input));
|
||||
task.setProcessors(Collections.singleton(new Proc("second")));
|
||||
check("compilation", task.call());
|
||||
|
||||
|
@ -99,11 +101,12 @@ public class T7068451 {
|
|||
System.err.println("SECOND compilation, REPEATED");
|
||||
System.err.println();
|
||||
|
||||
task = compiler.getTask(null, null, null, opts, null,
|
||||
compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
|
||||
task = compiler.getTask(null, fm, null, opts, null,
|
||||
fm.getJavaFileObjects(input));
|
||||
task.setProcessors(Collections.singleton(new Proc("second")));
|
||||
check("compilation", task.call());
|
||||
}
|
||||
}
|
||||
|
||||
void check(String msg, boolean ok) {
|
||||
System.err.println(msg + ": " + (ok ? "ok" : "failed"));
|
||||
|
|
|
@ -76,7 +76,7 @@ public class LVTHarness {
|
|||
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
|
||||
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")));
|
||||
|
||||
|
@ -89,6 +89,9 @@ public class LVTHarness {
|
|||
if (nerrors > 0) {
|
||||
throw new AssertionError("Errors were found");
|
||||
}
|
||||
} 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -70,6 +70,7 @@ public class BridgeHarness {
|
|||
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
//set sourcepath
|
||||
fm.setLocation(SOURCE_PATH,
|
||||
Arrays.asList(new File(System.getProperty("test.src"), "tests")));
|
||||
|
@ -84,6 +85,9 @@ public class BridgeHarness {
|
|||
if (nerrors > 0) {
|
||||
throw new AssertionError("Errors were found");
|
||||
}
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
/* utility methods */
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -150,8 +150,7 @@ public class GenericConstructorAndDiamondTest {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (ConstructorKind constructorKind : ConstructorKind.values()) {
|
||||
for (TypeArgumentKind declArgKind : TypeArgumentKind.values()) {
|
||||
|
@ -169,6 +168,7 @@ public class GenericConstructorAndDiamondTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BoundKind boundKind;
|
||||
ConstructorKind constructorKind;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -78,7 +78,7 @@ public class ParserTest {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (TypeArgumentKind tak1 : TypeArgumentKind.values()) {
|
||||
|
@ -104,6 +104,7 @@ public class ParserTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TypeQualifierArity qualifierArity;
|
||||
TypeArgumentKind[] typeArgumentKinds;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -86,7 +86,7 @@ public class T7086601b {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 a2 : TypeKind.values()) {
|
||||
|
@ -99,6 +99,7 @@ public class T7086601b {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
TypeKind a1;
|
||||
TypeKind a2;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -105,7 +105,7 @@ public class BadLambdaExpr {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (ParameterKind pk : ParameterKind.values()) {
|
||||
|
@ -118,6 +118,7 @@ public class BadLambdaExpr {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
ParameterListKind plk;
|
||||
ParameterKind pk;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -114,7 +114,7 @@ public class TestSelfRef {
|
|||
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
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 (SiteKind sk : SiteKind.values()) {
|
||||
|
@ -131,6 +131,7 @@ public class TestSelfRef {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
EnclosingKind ek;
|
||||
SiteKind sk;
|
||||
|
|
|
@ -185,7 +185,7 @@ public class IntersectionTargetTypeTest {
|
|||
public static void main(String... args) throws Exception {
|
||||
//create default shared JavaCompiler - reused across multiple compilations
|
||||
JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
try (StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null)) {
|
||||
|
||||
for (CastInfo cInfo : allCastInfo()) {
|
||||
for (ExpressionKind ek : ExpressionKind.values()) {
|
||||
|
@ -194,6 +194,7 @@ public class IntersectionTargetTypeTest {
|
|||
}
|
||||
System.out.println("Total check executed: " + checkCount);
|
||||
}
|
||||
}
|
||||
|
||||
static List<CastInfo> allCastInfo() {
|
||||
ListBuffer<CastInfo> buf = new ListBuffer<>();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -250,6 +250,7 @@ public class SamConversionComboTest {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
for(Context ct : Context.values()) {
|
||||
for (FInterface fi : FInterface.values()) {
|
||||
for (MethodDef md: MethodDef.values()) {
|
||||
|
@ -258,5 +259,8 @@ public class SamConversionComboTest {
|
|||
}
|
||||
}
|
||||
System.out.println("total tests: " + count);
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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.tools.javac.util.Pair;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
|
@ -41,6 +42,7 @@ import javax.tools.SimpleJavaFileObject;
|
|||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
@ -70,12 +72,19 @@ public class FDTest {
|
|||
fm = comp.getStandardFileManager(null, null, null);
|
||||
}
|
||||
|
||||
@AfterSuite
|
||||
static void teardown() throws IOException {
|
||||
fm.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
init();
|
||||
|
||||
for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
|
||||
runTest(fdtest.fst, fdtest.snd, comp, fm);
|
||||
}
|
||||
|
||||
teardown();
|
||||
}
|
||||
|
||||
@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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -193,7 +193,7 @@ public class NativeHeaderTest {
|
|||
void run() throws Exception {
|
||||
javac = JavacTool.create();
|
||||
fm = javac.getStandardFileManager(null, null, null);
|
||||
|
||||
try {
|
||||
for (RunKind rk: RunKind.values()) {
|
||||
for (GenKind gk: GenKind.values()) {
|
||||
for (Method m: getClass().getDeclaredMethods()) {
|
||||
|
@ -214,6 +214,9 @@ public class NativeHeaderTest {
|
|||
System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
|
||||
if (errorCount > 0)
|
||||
throw new Exception(errorCount + " errors found");
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaCompiler.CompilationTask;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
|
||||
|
@ -73,10 +74,11 @@ public class XPreferTest {
|
|||
}
|
||||
|
||||
final static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
|
||||
final static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
|
||||
final static File OUTPUT_DIR = new File("out");
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
|
||||
try {
|
||||
// Initialize test-directories
|
||||
OUTPUT_DIR.mkdir();
|
||||
for (Dir dir : Dir.values())
|
||||
|
@ -95,6 +97,9 @@ public class XPreferTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestCase {
|
||||
|
@ -234,8 +239,8 @@ public class XPreferTest {
|
|||
if(dir == Dir.SOURCE_PATH)
|
||||
return src;
|
||||
// ...otherwise compile into a ".class".
|
||||
CompilationTask task = comp.getTask(null, null, null, null, null,
|
||||
comp.getStandardFileManager(null, null, null).getJavaFileObjects(src));
|
||||
CompilationTask task = comp.getTask(null, fm, null, null, null,
|
||||
fm.getJavaFileObjects(src));
|
||||
File dest = new File(dir.file, classId + ".class");
|
||||
if(!task.call() || !dest.exists())
|
||||
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