This commit is contained in:
Lana Steuck 2016-01-07 15:13:50 -08:00
commit cdd5f5f4f5
31 changed files with 41 additions and 288 deletions

View File

@ -145,7 +145,7 @@ public enum SourceVersion {
* The version recognized by the Java Platform, Standard Edition
* 9.
*
* @since 1.9
* @since 9
*/
RELEASE_9;

View File

@ -57,7 +57,7 @@ import javax.annotation.processing.SupportedSourceVersion;
* @see AbstractAnnotationValueVisitor6
* @see AbstractAnnotationValueVisitor7
* @see AbstractAnnotationValueVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public abstract class AbstractAnnotationValueVisitor9<R, P> extends AbstractAnnotationValueVisitor8<R, P> {

View File

@ -61,7 +61,7 @@ import static javax.lang.model.SourceVersion.*;
* @see AbstractElementVisitor6
* @see AbstractElementVisitor7
* @see AbstractElementVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public abstract class AbstractElementVisitor9<R, P> extends AbstractElementVisitor8<R, P> {

View File

@ -61,7 +61,7 @@ import static javax.lang.model.SourceVersion.*;
* @see AbstractTypeVisitor6
* @see AbstractTypeVisitor7
* @see AbstractTypeVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public abstract class AbstractTypeVisitor9<R, P> extends AbstractTypeVisitor8<R, P> {

View File

@ -74,7 +74,7 @@ import javax.lang.model.SourceVersion;
* @see ElementKindVisitor6
* @see ElementKindVisitor7
* @see ElementKindVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public class ElementKindVisitor9<R, P> extends ElementKindVisitor8<R, P> {

View File

@ -87,7 +87,7 @@ import static javax.lang.model.SourceVersion.*;
* @see ElementScanner6
* @see ElementScanner7
* @see ElementScanner8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public class ElementScanner9<R, P> extends ElementScanner8<R, P> {

View File

@ -64,7 +64,7 @@ import static javax.lang.model.SourceVersion.*;
* @see SimpleAnnotationValueVisitor6
* @see SimpleAnnotationValueVisitor7
* @see SimpleAnnotationValueVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public class SimpleAnnotationValueVisitor9<R, P> extends SimpleAnnotationValueVisitor8<R, P> {

View File

@ -69,7 +69,7 @@ import static javax.lang.model.SourceVersion.*;
* @see SimpleElementVisitor6
* @see SimpleElementVisitor7
* @see SimpleElementVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public class SimpleElementVisitor9<R, P> extends SimpleElementVisitor8<R, P> {

View File

@ -72,7 +72,7 @@ import static javax.lang.model.SourceVersion.*;
* @see TypeKindVisitor6
* @see TypeKindVisitor7
* @see TypeKindVisitor8
* @since 1.9
* @since 9
*/
@SupportedSourceVersion(RELEASE_9)
public class TypeKindVisitor9<R, P> extends TypeKindVisitor8<R, P> {

View File

@ -32,7 +32,7 @@ import java.util.Iterator;
/**
* Package-private utility methods to convert between files and paths.
*
* @since 1.9
* @since 9
*/
class FileManagerUtils {
private FileManagerUtils() { }

View File

@ -187,7 +187,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
* a directory or if this file manager does not support any of the
* given paths.
*
* @since 1.9
* @since 9
*/
default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
Iterable<? extends Path> paths) {
@ -226,7 +226,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
* @throws NullPointerException if the given array contains null
* elements
*
* @since 1.9
* @since 9
*/
default Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
return getJavaFileObjectsFromPaths(Arrays.asList(paths));
@ -295,7 +295,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
* @throws IOException if {@code location} is an output location and
* {@code paths} does not represent an existing directory
*
* @since 1.9
* @since 9
*/
default void setLocationFromPaths(Location location, Iterable<? extends Path> paths)
throws IOException {
@ -324,7 +324,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
* associated search path
*
* @see #setLocationFromPaths
* @since 1.9
* @since 9
*/
default Iterable<? extends Path> getLocationAsPaths(Location location) {
return asPaths(getLocation(location));
@ -345,7 +345,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
* @throws IllegalArgumentException if the file object does not have an underlying path
* @throws UnsupportedOperationException if the operation is not supported by this file manager
*
* @since 1.9
* @since 9
*/
default Path asPath(FileObject file) {
throw new UnsupportedOperationException();

View File

@ -49,7 +49,7 @@ public interface DocCommentTree extends DocTree {
* before any block tags, including the first sentence.
* @return body of a documentation comment first sentence inclusive
*
* @since 1.9
* @since 9
*/
default List<? extends DocTree> getFullBody() {
ArrayList<DocTree> bodyList = new ArrayList<>();

View File

@ -33,7 +33,7 @@ import java.util.List;
* <p>
* {&#064;index keyword optional description} <br>
*
* @since 1.9
* @since 9
*/
@jdk.Exported
public interface IndexTree extends InlineTagTree {

View File

@ -59,7 +59,7 @@ public interface CompilationUnitTree extends Tree {
* Returns the package tree associated with this compilation unit,
* or {@code null} if there is no package declaration.
* @return the package tree
* @since 1.9
* @since 9
*/
PackageTree getPackage();

View File

@ -33,7 +33,7 @@ import java.util.List;
* @jls sections 7.3, and 7.4
*
* @author Paul Govereau
* @since 1.9
* @since 9
*/
@jdk.Exported
public interface PackageTree extends Tree {

View File

@ -212,7 +212,7 @@ public interface Tree {
/**
* Used for instances of {@link PackageTree}.
* @since 1.9
* @since 9
*/
PACKAGE(PackageTree.class),

View File

@ -73,7 +73,7 @@ public abstract class DocTrees extends Trees {
* Returns {@code null} if none has been specified.
* @return the break iterator
*
* @since 1.9
* @since 9
*/
public abstract BreakIterator getBreakIterator();
@ -91,7 +91,7 @@ public abstract class DocTrees extends Trees {
* @param e an element whose documentation is required
* @return the doc comment tree
*
* @since 1.9
* @since 9
*/
public abstract DocCommentTree getDocCommentTree(Element e);
@ -105,7 +105,7 @@ public abstract class DocTrees extends Trees {
* @param fileObject the content container
* @return the doc comment tree
*
* @since 1.9
* @since 9
*/
public abstract DocCommentTree getDocCommentTree(FileObject fileObject);
@ -122,7 +122,7 @@ public abstract class DocTrees extends Trees {
* @return the doc comment tree
* @throws java.io.IOException if an exception occurs
*
* @since 1.9
* @since 9
*/
public abstract DocCommentTree getDocCommentTree(Element e, String relativePath) throws IOException;
@ -141,7 +141,7 @@ public abstract class DocTrees extends Trees {
* @param list the DocTree list to interrogate
* @return the first sentence
*
* @since 1.9
* @since 9
*/
public abstract List<DocTree> getFirstSentence(List<? extends DocTree> list);
@ -173,7 +173,7 @@ public abstract class DocTrees extends Trees {
* @param breakiterator a break iterator or {@code null} to specify the default
* sentence breaker
*
* @since 1.9
* @since 9
*/
public abstract void setBreakIterator(BreakIterator breakiterator);
}

View File

@ -74,7 +74,7 @@ public final class TaskEvent
* This event is not sent when using {@link JavacTask#parse()},
* {@link JavacTask#analyze()} or {@link JavacTask#generate()}.
*
* @since 1.9
* @since 9
*/
COMPILATION,
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2016, 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,6 @@ public class CleanProperties implements Transformer {
public boolean transform(CompilationService sjavac,
Map<String,Set<URI>> pkgSrcs,
Set<URI> visibleSrcs,
Map<URI,Set<String>> visibleClasses,
Map<String,Set<String>> oldPackageDependencies,
URI destRoot,
Map<String,Set<URI>> packageArtifacts,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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
@ -80,7 +80,6 @@ public class CompileJavaPackages implements Transformer {
public boolean transform(final CompilationService sjavac,
Map<String,Set<URI>> pkgSrcs,
final Set<URI> visibleSources,
final Map<URI,Set<String>> visibleClasses,
Map<String,Set<String>> oldPackageDependents,
URI destRoot,
final Map<String,Set<URI>> packageArtifacts,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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
@ -74,7 +74,6 @@ public class CompileProperties implements Transformer {
public boolean transform(CompilationService compilationService,
Map<String,Set<URI>> pkgSrcs,
Set<URI> visibleSrcs,
Map<URI,Set<String>> visibleClasses,
Map<String,Set<String>> oldPackageDependents,
URI destRoot,
Map<String,Set<URI>> packageArtifacts,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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,7 +61,6 @@ public class CopyFile implements Transformer {
public boolean transform(CompilationService compilationService,
Map<String,Set<URI>> pkgSrcs,
Set<URI> visibleSrcs,
Map<URI,Set<String>> visibleClasses,
Map<String,Set<String>> oldPackageDependents,
URI destRoot,
Map<String,Set<URI>> packageArtifacts,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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
@ -120,13 +120,6 @@ public class JavacState {
// ones that -sourcepath is allowed to see.
Set<URI> visibleSrcs;
// Visible classes for linking. These are the only
// ones that -classpath is allowed to see.
// It maps from a classpath root to the set of visible classes for that root.
// If the set is empty, then all classes are visible for that root.
// It can also map from a jar file to the set of visible classes for that jar file.
Map<URI,Set<String>> visibleClasses;
// Setup transform that always exist.
private CompileJavaPackages compileJavaPackages = new CompileJavaPackages();
@ -213,16 +206,6 @@ public class JavacState {
}
}
/**
* Specify which classes are visible to the compiler through -classpath.
*/
public void setVisibleClasses(Map<String,Source> vs) {
visibleSrcs = new HashSet<>();
for (String s : vs.keySet()) {
Source src = vs.get(s);
visibleSrcs.add(src.file().toURI());
}
}
/**
* Returns true if this is an incremental build.
*/
@ -820,7 +803,6 @@ public class JavacState {
boolean r = t.transform(sjavac,
srcs,
visibleSrcs,
visibleClasses,
prev.dependents(),
outputDir.toURI(),
packageArtifacts,
@ -954,8 +936,7 @@ public class JavacState {
}
}
// Read in the file and create another set of filenames with full paths.
try {
BufferedReader in = new BufferedReader(new FileReader(makefileSourceList));
try(BufferedReader in = new BufferedReader(new FileReader(makefileSourceList))) {
for (;;) {
String l = in.readLine();
if (l==null) break;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2016, 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,6 @@ public interface Transformer {
boolean transform(CompilationService sjavac,
Map<String,Set<URI>> pkgSrcs,
Set<URI> visibleSources,
Map<URI,Set<String>> visibleClasses,
Map<String,Set<String>> oldPackageDependencies,
URI destRoot,
Map<String,Set<URI>> packageArtifacts,

View File

@ -9,6 +9,6 @@
* @compile/fail/ref=WarnImport.out -XDrawDiagnostics -Werror -Xlint:none WarnImport.java
*/
import sun.misc.VM;
import sun.security.x509.X509CertInfo;
public class WarnImport {}

View File

@ -1,4 +1,4 @@
WarnImport.java:12:16: compiler.warn.sun.proprietary: sun.misc.VM
WarnImport.java:12:25: compiler.warn.sun.proprietary: sun.security.x509.X509CertInfo
- compiler.err.warnings.and.werror
1 error
1 warning

View File

@ -3,7 +3,7 @@
* @bug 6380059
* @summary Emit warnings for proprietary packages in the boot class path
* @author Peter von der Ah\u00e9
* @modules java.base/sun.misc
* @modules java.base/sun.security.x509
* @compile WarnMethod.java
* @compile/fail/ref=WarnMethod.out -XDrawDiagnostics -Werror WarnMethod.java
* @compile/fail/ref=WarnMethod.out -XDrawDiagnostics -Werror -nowarn WarnMethod.java
@ -12,6 +12,6 @@
public class WarnMethod {
public static void main(String... args) {
System.out.println(sun.misc.VM.getFinalRefCount());
System.out.println(sun.security.x509.OIDMap.getOID(""));
}
}

View File

@ -1,4 +1,4 @@
WarnMethod.java:15:36: compiler.warn.sun.proprietary: sun.misc.VM
WarnMethod.java:15:45: compiler.warn.sun.proprietary: sun.security.x509.OIDMap
- compiler.err.warnings.and.werror
1 error
1 warning

View File

@ -9,6 +9,6 @@
* @compile/fail/ref=WarnStaticImport.out -XDrawDiagnostics -Werror -Xlint:none WarnStaticImport.java
*/
import static sun.misc.VM.getFinalRefCount;
import static sun.security.x509.OIDMap.getOID;
public class WarnStaticImport {}

View File

@ -1,4 +1,4 @@
WarnStaticImport.java:12:23: compiler.warn.sun.proprietary: sun.misc.VM
WarnStaticImport.java:12:32: compiler.warn.sun.proprietary: sun.security.x509.OIDMap
- compiler.err.warnings.and.werror
1 error
1 warning

View File

@ -1,223 +0,0 @@
/*
* Copyright (c) 2011, 2015, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 7021650
* @summary Fix Context issues
* @library /tools/javac/lib
* @modules jdk.compiler/com.sun.tools.javac.comp
* jdk.compiler/com.sun.tools.javac.file
* jdk.compiler/com.sun.tools.javac.main
* jdk.compiler/com.sun.tools.javac.processing
* jdk.compiler/com.sun.tools.javac.util
* @build JavacTestingAbstractProcessor T7021650
* @run main T7021650
*/
import java.io.*;
import java.net.*;
import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.Main;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.util.Context;
public class T7021650 extends JavacTestingAbstractProcessor {
public static void main(String... args) throws Exception {
new T7021650().run();
}
static File testSrc = new File(System.getProperty("test.src"));
static final int MAX_ROUNDS = 3;
/**
* Perform a compilation with custom factories registered in the context,
* and verify that corresponding objects are created in each round.
*/
void run() throws Exception {
Counter myDemoCounter = new Counter();
Counter myAttrCounter = new Counter();
Context context = new Context();
// Use a custom file manager which creates classloaders for annotation
// processors with a sensible delegation parent, so that all instances
// of test classes come from the same class loader. This is important
// because the test performs class checks on the instances of classes
// found in the context for each round or processing.
context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
public JavaFileManager make(Context c) {
return new JavacFileManager(c, true, null) {
@Override
protected ClassLoader getClassLoader(URL[] urls) {
return new URLClassLoader(urls, T7021650.class.getClassLoader());
}
};
}
});
MyDemo.preRegister(context, myDemoCounter);
MyAttr.preRegister(context, myAttrCounter);
String[] args = {
"-d", ".",
"-processor", T7021650.class.getName(),
"-XprintRounds",
new File(testSrc, T7021650.class.getName() + ".java").getPath()
};
compile(context, args);
// the services should only be created once in the current scheme:
checkEqual("demoCounter", myDemoCounter.count, 1);
checkEqual("myAttrCounter", myAttrCounter.count, 1);
}
void compile(Context context, String... args) throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Main m = new Main("javac", pw);
Main.Result res = m.compile(args, context);
pw.close();
String out = sw.toString();
if (!out.isEmpty())
System.err.println(out);
if (!res.isOK())
throw new Exception("compilation failed unexpectedly: result=" + res);
}
void checkEqual(String label, int found, int expect) throws Exception {
if (found != expect)
throw new Exception("unexpected value for " + label
+ ": expected " + expect
+ ": found " + found);
}
//---------------
/*
* A custom class unknown to javac but nonetheless registered in the context.
*/
static class Demo {
Demo(Context c) {
c.put(Demo.class, this);
}
static Demo instance(Context context) {
return context.get(Demo.class);
}
}
static class MyDemo extends Demo {
static void preRegister(Context context, final Counter counter) {
context.put(Demo.class, new Context.Factory<Demo>() {
public Demo make(Context c) {
counter.count++;
return new MyDemo(c);
}
});
}
MyDemo(Context c) {
super(c);
}
}
/**
* A custom version of a standard javac component.
*/
static class MyAttr extends Attr {
static void preRegister(Context context, final Counter counter) {
context.put(attrKey, new Context.Factory<Attr>() {
public Attr make(Context c) {
counter.count++;
return new MyAttr(c);
}
});
}
MyAttr(Context c) {
super(c);
}
}
static class Counter {
int count;
}
//---------------
int round = 0;
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
round++;
Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
// verify items in context as expected
check("Demo", Demo.instance(context), MyDemo.class);
check("Attr", Attr.instance(context), MyAttr.class);
// For a few rounds, generate new source files, so that we can check whether
// values in the context are correctly handled in subsequent processing rounds
if (round <= MAX_ROUNDS) {
String pkg = "p";
String currClass = "Gen" + round;
String curr = pkg + "." + currClass;
String next = (pkg + ".Gen" + (round + 1));
StringBuilder text = new StringBuilder();
text.append("package ").append(pkg).append(";\n");
text.append("public class ").append(currClass).append(" {\n");
if (round < MAX_ROUNDS)
text.append(" ").append(next).append(" x;\n");
text.append("}\n");
try {
JavaFileObject fo = filer.createSourceFile(curr);
Writer out = fo.openWriter();
try {
out.write(text.toString());
} finally {
out.close();
}
} catch (IOException e) {
throw new Error(e);
}
}
return true;
}
void check(String label, Object o, Class<?> clazz) {
if (o == null)
throw new IllegalStateException(label + ": no item found");
if (!clazz.isAssignableFrom(o.getClass()))
throw new IllegalStateException(label + ": unexpected class: " + o.getClass());
}
}