This commit is contained in:
Lana Steuck 2016-02-11 16:06:11 -08:00
commit eb64b90d89
31 changed files with 361 additions and 279 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -217,11 +217,6 @@ public class Lint
*/
STATIC("static"),
/**
* Warn about proprietary API that may be removed in a future release.
*/
SUNAPI("sunapi", true),
/**
* Warn about issues relating to use of try blocks (i.e. try-with-resources)
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -83,7 +83,6 @@ public class Check {
private final JCDiagnostic.Factory diags;
private boolean warnOnSyntheticConflicts;
private boolean suppressAbortOnBadClassFile;
private boolean enableSunApiLintControl;
private final JavaFileManager fileManager;
private final Source source;
private final Profile profile;
@ -131,10 +130,8 @@ public class Check {
allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
allowPrivateSafeVarargs = source.allowPrivateSafeVarargs();
allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
complexInference = options.isSet("complexinference");
warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
enableSunApiLintControl = options.isSet("enableSunApiLintControl");
warnOnAccessToSensitiveMembers = options.isSet("warnOnAccessToSensitiveMembers");
Target target = Target.instance(context);
@ -144,14 +141,13 @@ public class Check {
boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI);
boolean enforceMandatoryWarnings = true;
deprecationHandler = new MandatoryWarningHandler(log, verboseDeprecated,
enforceMandatoryWarnings, "deprecated", LintCategory.DEPRECATION);
uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked,
enforceMandatoryWarnings, "unchecked", LintCategory.UNCHECKED);
sunApiHandler = new MandatoryWarningHandler(log, verboseSunApi,
sunApiHandler = new MandatoryWarningHandler(log, false,
enforceMandatoryWarnings, "sunapi", null);
deferredLintHandler = DeferredLintHandler.instance(context);
@ -177,10 +173,6 @@ public class Check {
*/
boolean allowDiamondWithAnonymousClassCreation;
/** Switch: -complexinference option set?
*/
boolean complexInference;
/** Character for synthetic names
*/
char syntheticNameChar;
@ -248,15 +240,6 @@ public class Check {
log.warning(LintCategory.VARARGS, pos, key, args);
}
/** Warn about using proprietary API.
* @param pos Position to be used for error reporting.
* @param msg A string describing the problem.
*/
public void warnSunApi(DiagnosticPosition pos, String msg, Object... args) {
if (!lint.isSuppressed(LintCategory.SUNAPI))
sunApiHandler.report(pos, msg, args);
}
public void warnStatic(DiagnosticPosition pos, String msg, Object... args) {
if (lint.isEnabled(LintCategory.STATIC))
log.warning(LintCategory.STATIC, pos, msg, args);
@ -3226,13 +3209,8 @@ public class Check {
void checkSunAPI(final DiagnosticPosition pos, final Symbol s) {
if ((s.flags() & PROPRIETARY) != 0) {
deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
public void report() {
if (enableSunApiLintControl)
warnSunApi(pos, "sun.proprietary", s);
else
log.mandatoryWarning(pos, "sun.proprietary", s);
}
deferredLintHandler.report(() -> {
log.mandatoryWarning(pos, "sun.proprietary", s);
});
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -94,7 +94,6 @@ public class Resolve {
public final boolean allowMethodHandles;
public final boolean allowFunctionalInterfaceMostSpecific;
public final boolean checkVarargsAccessAfterResolution;
private final boolean debugResolve;
private final boolean compactMethodDiags;
final EnumSet<VerboseResolutionMode> verboseResolutionMode;
@ -120,7 +119,6 @@ public class Resolve {
diags = JCDiagnostic.Factory.instance(context);
Source source = Source.instance(context);
Options options = Options.instance(context);
debugResolve = options.isSet("debugresolve");
compactMethodDiags = options.isSet(Option.XDIAGS, "compact") ||
options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics");
verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
@ -3897,8 +3895,6 @@ public class Resolve {
super(HIDDEN, sym, "access error");
this.env = env;
this.site = site;
if (debugResolve)
log.error("proc.messager", sym + " @ " + site + " is inaccessible.");
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
@ -55,8 +55,6 @@ import javax.tools.JavaFileObject.Kind;
import com.sun.tools.javac.code.Lint;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.file.FSInfo;
import com.sun.tools.javac.file.Locations;
import com.sun.tools.javac.main.Option;
import com.sun.tools.javac.main.OptionHelper;
import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
@ -88,6 +86,27 @@ public abstract class BaseFileManager implements JavaFileManager {
options = Options.instance(context);
classLoaderClass = options.get("procloader");
locations.update(log, Lint.instance(context), FSInfo.instance(context));
// Setting this option is an indication that close() should defer actually closing
// the file manager until after a specified period of inactivity.
// This is to accomodate clients which save references to Symbols created for use
// within doclets or annotation processors, and which then attempt to use those
// references after the tool exits, having closed any internally managed file manager.
// Ideally, such clients should run the tool via the javax.tools API, providing their
// own file manager, which can be closed by the client when all use of that file
// manager is complete.
// If the option has a numeric value, it will be interpreted as the duration,
// in seconds, of the period of inactivity to wait for, before the file manager
// is actually closed.
// See also deferredClose().
String s = options.get("fileManager.deferClose");
if (s != null) {
try {
deferredCloseTimeout = (int) (Float.parseFloat(s) * 1000);
} catch (NumberFormatException e) {
deferredCloseTimeout = 60 * 1000; // default: one minute, in millis
}
}
}
protected Locations createLocations() {
@ -116,6 +135,42 @@ public abstract class BaseFileManager implements JavaFileManager {
*/
public boolean autoClose;
/**
* Wait for a period of inactivity before calling close().
* The length of the period of inactivity is given by {@code deferredCloseTimeout}
*/
protected void deferredClose() {
Thread t = new Thread(getClass().getName() + " DeferredClose") {
@Override
public void run() {
try {
synchronized (BaseFileManager.this) {
long now = System.currentTimeMillis();
while (now < lastUsedTime + deferredCloseTimeout) {
BaseFileManager.this.wait(lastUsedTime + deferredCloseTimeout - now);
now = System.currentTimeMillis();
}
deferredCloseTimeout = 0;
close();
}
} catch (InterruptedException e) {
} catch (IOException e) {
}
}
};
t.setDaemon(true);
t.start();
}
synchronized void updateLastUsedTime() {
if (deferredCloseTimeout > 0) { // avoid updating the time unnecessarily
lastUsedTime = System.currentTimeMillis();
}
}
private long lastUsedTime = System.currentTimeMillis();
protected long deferredCloseTimeout = 0;
protected Source getSource() {
String sourceName = options.get(Option.SOURCE);
Source source = null;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -525,8 +525,16 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
*/
@Override @DefinedBy(Api.COMPILER)
public void close() throws IOException {
for (FileSystem fs: fileSystems.values())
if (deferredCloseTimeout > 0) {
deferredClose();
return;
}
for (FileSystem fs: fileSystems.values()) {
fs.close();
}
fileSystems.clear();
contentCache.clear();
}
@Override @DefinedBy(Api.COMPILER)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
@ -432,11 +432,13 @@ public abstract class PathFileObject implements JavaFileObject {
@Override @DefinedBy(Api.COMPILER)
public InputStream openInputStream() throws IOException {
fileManager.updateLastUsedTime();
return Files.newInputStream(path);
}
@Override @DefinedBy(Api.COMPILER)
public OutputStream openOutputStream() throws IOException {
fileManager.updateLastUsedTime();
fileManager.flushCache(this);
ensureParentDirectoriesExist();
return Files.newOutputStream(path);
@ -471,6 +473,7 @@ public abstract class PathFileObject implements JavaFileObject {
@Override @DefinedBy(Api.COMPILER)
public Writer openWriter() throws IOException {
fileManager.updateLastUsedTime();
fileManager.flushCache(this);
ensureParentDirectoriesExist();
return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -91,11 +91,6 @@ public class ClassReader {
*/
boolean verbose;
/** Switch: check class file for correct minor version, unrecognized
* attributes.
*/
boolean checkClassFile;
/** Switch: read constant pool and code sections. This switch is initially
* set to false but can be turned on from outside.
*/
@ -230,7 +225,6 @@ public class ClassReader {
Options options = Options.instance(context);
verbose = options.isSet(VERBOSE);
checkClassFile = options.isSet("-checkclassfile");
Source source = Source.instance(context);
allowSimplifiedVarargs = source.allowSimplifiedVarargs();
@ -1148,15 +1142,6 @@ public class ClassReader {
attributeReaders.put(r.name, r);
}
/** Report unrecognized attribute.
*/
void unrecognized(Name attrName) {
if (checkClassFile)
printCCF("ccf.unrecognized.attribute", attrName);
}
protected void readEnclosingMethodAttr(Symbol sym) {
// sym is a nested class with an "Enclosing Method" attribute
// remove sym from it's current owners scope and place it in
@ -1279,7 +1264,6 @@ public class ClassReader {
if (r != null && r.accepts(kind))
r.read(sym, attrLen);
else {
unrecognized(attrName);
bp = bp + attrLen;
}
}
@ -2315,8 +2299,7 @@ public class ClassReader {
int maxMinor = Version.MAX().minor;
if (majorVersion > maxMajor ||
majorVersion * 1000 + minorVersion <
Version.MIN().major * 1000 + Version.MIN().minor)
{
Version.MIN().major * 1000 + Version.MIN().minor) {
if (majorVersion == (maxMajor + 1))
log.warning("big.major.version",
currentClassFile,
@ -2329,13 +2312,7 @@ public class ClassReader {
Integer.toString(maxMajor),
Integer.toString(maxMinor));
}
else if (checkClassFile &&
majorVersion == maxMajor &&
minorVersion > maxMinor)
{
printCCF("found.later.version",
Integer.toString(minorVersion));
}
indexPool();
if (signatureBuffer.length < bp) {
int ns = Integer.highestOneBit(bp) << 1;
@ -2455,14 +2432,6 @@ public class ClassReader {
return flags & ~ACC_SUPER; // SUPER and SYNCHRONIZED bits overloaded
}
/** Output for "-checkclassfile" option.
* @param key The key to look up the correct internationalized string.
* @param arg An argument for substitution into the output string.
*/
private void printCCF(String key, Object arg) {
log.printLines(key, arg);
}
/**
* A subclass of JavaFileObject for the sourcefile attribute found in a classfile.
* The attribute is only the last component of the original filename, so is unlikely

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -373,7 +373,6 @@ public class JavaCompiler {
throw new Abort();
}
source = Source.instance(context);
Target target = Target.instance(context);
attr = Attr.instance(context);
chk = Check.instance(context);
gen = Gen.instance(context);
@ -393,7 +392,6 @@ public class JavaCompiler {
stubOutput = options.isSet("-stubs");
relax = options.isSet("-relax");
printFlat = options.isSet("-printflat");
attrParseOnly = options.isSet("-attrparseonly");
encoding = options.get(ENCODING);
lineDebugInfo = options.isUnset(G_CUSTOM) ||
options.isSet(G_CUSTOM, "lines");
@ -405,7 +403,8 @@ public class JavaCompiler {
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
if (attrParseOnly)
if (options.isSet("shouldStopPolicy") &&
CompileState.valueOf(options.get("shouldStopPolicy")) == CompileState.ATTR)
compilePolicy = CompilePolicy.ATTR_ONLY;
else
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
@ -452,10 +451,6 @@ public class JavaCompiler {
*/
public boolean stubOutput;
/** Generate attributed parse tree only.
*/
public boolean attrParseOnly;
/** Switch: relax some constraints for producing the jsr14 prototype.
*/
boolean relax;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -766,10 +766,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
// Run contributing processors that haven't run yet
psi.runContributingProcs(renv);
// Debugging
if (options.isSet("displayFilerState"))
filer.displayState();
}
/**

View File

@ -1,6 +1,6 @@
#
# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 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
@ -1284,24 +1284,6 @@ compiler.note.unchecked.filename.additional=\
compiler.note.unchecked.plural.additional=\
Some input files additionally use unchecked or unsafe operations.
# 0: file name
compiler.note.sunapi.filename=\
{0} uses internal proprietary API that may be removed in a future release.
compiler.note.sunapi.plural=\
Some input files use internal proprietary API that may be removed in a future release.
# The following string may appear after one of the above sunapi messages.
compiler.note.sunapi.recompile=\
Recompile with -Xlint:sunapi for details.
# 0: file name
compiler.note.sunapi.filename.additional=\
{0} uses additional internal proprietary API that may be removed in a future release.
compiler.note.sunapi.plural.additional=\
Some input files additionally use internal proprietary API that may be removed in a future release.
# Notes related to annotation processing
# Print a client-generated note; assumed to be localized, no translation required
@ -1375,13 +1357,6 @@ compiler.misc.verbose.sourcepath=\
compiler.misc.verbose.classpath=\
[search path for class files: {0}]
## extra output when using -checkclassfile (code/ClassReader)
compiler.misc.ccf.found.later.version=\
class file has later version than expected: {0}
compiler.misc.ccf.unrecognized.attribute=\
unrecognized attribute: {0}
## extra output when using -prompt (util/Log)
compiler.misc.resume.abort=\
R)esume, A)bort>

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 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
@ -208,9 +208,6 @@ javac.opt.Xlint.desc.serial=\
javac.opt.Xlint.desc.static=\
Warn about accessing a static member using an instance.
javac.opt.Xlint.desc.sunapi=\
Warn about proprietary API that may be removed in a future release.
javac.opt.Xlint.desc.try=\
Warn about issues relating to use of try blocks (i.e. try-with-resources).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -34,6 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.StringJoiner;
import com.sun.tools.sjavac.Transformer;
import com.sun.tools.sjavac.Util;
@ -225,10 +226,7 @@ public class Options {
}
String getResult() {
String result = "";
for (String s : args)
result += s + " ";
return result.trim();
return String.join(" ", args);
}
public void addAll(Collection<String> toAdd) {
@ -337,10 +335,11 @@ public class Options {
// Helper method to join a list of source locations separated by
// File.pathSeparator
private static String concatenateSourceLocations(List<SourceLocation> locs) {
String s = "";
for (SourceLocation loc : locs)
s += (s.isEmpty() ? "" : java.io.File.pathSeparator) + loc.getPath();
return s;
StringJoiner joiner = new StringJoiner(java.io.File.pathSeparator);
for (SourceLocation loc : locs) {
joiner.add(loc.getPath().toString());
}
return joiner.toString();
}
// OptionHelper that records the traversed options in this Options instance.

View File

@ -278,7 +278,7 @@ jtreg-tests: check-jtreg FRC
@mkdir -p $(JTREG_OUTPUT_DIR)
JT_JAVA=$(JT_JAVA) $(JTREG) \
-J-Xmx512m \
-vmoption:-Xmx1024m \
-vmoption:-Xmx768m \
-a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \
-r:$(JTREG_OUTPUT_DIR)/JTreport \
-w:$(JTREG_OUTPUT_DIR)/JTwork \

View File

@ -1,87 +0,0 @@
/*
* @test /nodynamiccopyright/
* @bug 6873845
* @summary refine access to symbol file
* @modules java.base/sun.misc
* jdk.compiler
*/
import java.io.*;
import java.util.*;
import sun.misc.*;
public class T6873845 {
public static void main(String... args) throws Exception {
new T6873845().run();
}
public void run() throws Exception {
String out = compile(Arrays.asList("-XDrawDiagnostics", "-X"));
if (out.contains("sunapi"))
throw new Exception("unexpected output for -X");
String warn1 = "T6873845.java:75:9: compiler.warn.sun.proprietary: sun.misc.Unsafe" + newline;
String warn2 = "T6873845.java:80:9: compiler.warn.sun.proprietary: sun.misc.Unsafe" + newline;
String note1 = "- compiler.note.sunapi.filename: T6873845.java" + newline;
String note2 = "- compiler.note.sunapi.recompile" + newline;
test(opts(),
warn1 + warn2 + "2 warnings" + newline);
test(opts("-XDenableSunApiLintControl"),
note1 + note2);
test(opts("-XDenableSunApiLintControl", "-XDsuppressNotes"),
"");
test(opts("-XDenableSunApiLintControl", "-Xlint:sunapi"),
warn1 + "1 warning" + newline);
test(opts("-XDenableSunApiLintControl", "-Xlint:all"),
warn1 + "1 warning" + newline);
test(opts("-XDenableSunApiLintControl", "-Xlint:all,-sunapi"),
note1 + note2);
}
List<String> opts(String... opts) {
return Arrays.asList(opts);
}
void test(List<String> opts, String expect) throws Exception {
List<String> args = new ArrayList<String>();
args.addAll(opts);
args.add("-d");
args.add(testClasses.getPath());
args.add(new File(testSrc, "T6873845.java").getPath());
compile(args); // to verify resource strings exist
args.add(0, "-XDrawDiagnostics");
String out = compile(args);
if (!out.equals(expect))
throw new Exception("unexpected output from compiler; expected: " + expect +
"\n found: " + out);
}
String compile(List<String> args) throws Exception{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
System.out.println("compile: " + args);
int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
pw.close();
String out = sw.toString();
System.out.println(out);
if (rc != 0)
throw new Exception("compilation failed unexpectedly");
return out;
}
void m1() {
Unsafe.getUnsafe();
}
@SuppressWarnings("sunapi")
void m2() {
Unsafe.getUnsafe();
}
private File testSrc = new File(System.getProperty("test.src", "."));
private File testClasses = new File(System.getProperty("test.classes", "."));
private String newline = System.getProperty("line.separator");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -182,7 +182,7 @@ public class CheckResourceKeys {
* have a significant recognizable substring to look for.
*/
private boolean isMandatoryWarningString(String s) {
String[] bases = { "deprecated", "unchecked", "varargs", "sunapi" };
String[] bases = { "deprecated", "unchecked", "varargs" };
String[] tails = { ".filename", ".filename.additional", ".plural", ".plural.additional", ".recompile" };
for (String b: bases) {
if (s.startsWith(b)) {
@ -229,7 +229,6 @@ public class CheckResourceKeys {
"compiler.err.signature.doesnt.match.supertype", // UNUSED
"compiler.err.type.var.more.than.once", // UNUSED
"compiler.err.type.var.more.than.once.in.result", // UNUSED
"compiler.misc.ccf.found.later.version", // UNUSED
"compiler.misc.non.denotable.type", // UNUSED
"compiler.misc.unnamed.package", // should be required, CR 6964147
"compiler.misc.verbose.retro", // UNUSED
@ -289,6 +288,7 @@ public class CheckResourceKeys {
// -XD option names
"process.packages",
"ignore.symbol.file",
"fileManager.deferClose",
// prefix/embedded strings
"compiler.",
"compiler.misc.",

View File

@ -49,8 +49,6 @@ compiler.misc.bad.runtime.invisible.param.annotations # bad class file
compiler.misc.bad.signature # bad class file
compiler.misc.bad.type.annotation.value
compiler.misc.base.membership # UNUSED
compiler.misc.ccf.found.later.version
compiler.misc.ccf.unrecognized.attribute
compiler.misc.class.file.not.found # ClassReader
compiler.misc.class.file.wrong.class
compiler.misc.fatal.err.cant.locate.ctor # Resolve, from Lower

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -21,9 +21,7 @@
* questions.
*/
// key: compiler.note.sunapi.filename
// key: compiler.note.sunapi.recompile
// options: -XDenableSunApiLintControl
// key: compiler.warn.sun.proprietary
class SunApiFilename {
sun.misc.Unsafe x;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -21,9 +21,7 @@
* questions.
*/
// key: compiler.note.sunapi.filename.additional
// key: compiler.warn.sun.proprietary
// options: -XDenableSunApiLintControl -Xlint:sunapi -Xmaxwarns 1
class SunApiFilenameAdditional {
sun.misc.Unsafe x1;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -21,9 +21,7 @@
* questions.
*/
// key: compiler.note.sunapi.plural
// key: compiler.note.sunapi.recompile
// options: -XDenableSunApiLintControl
// key: compiler.warn.sun.proprietary
class SunApiPlural {
sun.misc.Unsafe x;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -21,9 +21,7 @@
* questions.
*/
// key: compiler.note.sunapi.plural.additional
// key: compiler.warn.sun.proprietary
// options: -XDenableSunApiLintControl -Xlint:sunapi -Xmaxwarns 1
class SunApiPluralAdditional {
sun.misc.Unsafe x;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -26,7 +26,7 @@
* @bug 8003280
* @summary Add lambda tests
* conditional and varargs
* @compile -XDcomplexinference Conditional01.java
* @compile Conditional01.java
*/
import java.util.*;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -26,7 +26,7 @@
* @bug 8003280
* @summary Add lambda tests
* inference and conditionals
* @compile -XDcomplexinference Conditional02.java
* @compile Conditional02.java
*/
class Conditional02 {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -26,7 +26,7 @@
* @bug 8003280
* @summary Add lambda tests
* conditionals and boxing
* @compile -XDcomplexinference Conditional03.java
* @compile Conditional03.java
*/
class Conditional03 {

View File

@ -4,7 +4,7 @@
* @summary Add lambda tests
* complex case of cyclic type inference (lambda returned where inference var expected)
* @compile/fail/ref=TargetType27.out -XDrawDiagnostics TargetType27.java
* @compile/fail/ref=TargetType27.out -XDrawDiagnostics -XDcomplexinference TargetType27.java
* @compile/fail/ref=TargetType27.out -XDrawDiagnostics TargetType27.java
*/
class TargetType27 {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -26,7 +26,7 @@
* @bug 8003280
* @summary Add lambda tests
* spurious resolution diagnostics when diamond constructor contains poly expression
* @compile -XDcomplexinference TargetType34.java
* @compile TargetType34.java
*/
class TargetType34<X> {

View File

@ -1,32 +0,0 @@
/**
* @test /nodynamiccopyright/
* @bug 6594914
* @summary \\@SuppressWarnings("deprecation") does not not work for the type of a variable
* @modules java.base/sun.security.x509
* @compile/ref=T6594914b.out -XDenableSunApiLintControl -XDrawDiagnostics -Xlint:sunapi T6594914b.java
*/
class T6747671b {
sun.security.x509.X509CertInfo a1; //warn
@SuppressWarnings("sunapi")
sun.security.x509.X509CertInfo a2;
<X extends sun.security.x509.X509CertInfo>
sun.security.x509.X509CertInfo m1(sun.security.x509.X509CertInfo a)
throws sun.security.x509.CertException { return null; } //warn
@SuppressWarnings("sunapi")
<X extends sun.security.x509.X509CertInfo>
sun.security.x509.X509CertInfo m2(sun.security.x509.X509CertInfo a)
throws sun.security.x509.CertException { return null; }
void test() {
sun.security.x509.X509CertInfo a1; //warn
@SuppressWarnings("sunapi")
sun.security.x509.X509CertInfo a2;
}
}

View File

@ -0,0 +1,160 @@
/*
* Copyright (c) 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
* 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 8147801
* @summary java.nio.file.ClosedFileSystemException when using Javadoc API's in JDK9
* @modules jdk.javadoc/com.sun.tools.javadoc
* @library jarsrc
* @build lib.* p.*
* @run main T8147801
*/
import java.io.IOException;
import java.nio.file.ClosedFileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.RootDoc;
/*
* This test verifies the use of the hidden fileManager.deferClose
* option, to work around the limitation that javadoc objects
* (like RootDoc and related types) should cannot normally be used
* after javadoc exits, closing its file manager (if it opened it.)
*
* The test runs javadoc on a chain of classes, 1 in source form,
* and 2 in a jar file. javadoc/javac will "complete" classes found
* in source, but will eagerly "classes" in class form.
* The chain is p/Test.java -> lib/Lib1.class -> lib/Lib2.class.
* After javadoc exits, the classes are examined, to finally force
* the classes to be completed, possibly causing javac to try and access
* references into a .jar file system which has now been closed.
*
* The test runs two test cases -- one without the workaround option,
* to test the validity of the test case, and one with the workaround
* option, to test that it works as expected.
*/
public class T8147801 {
public static void main(String... args) throws Exception {
new T8147801().run();
}
void run() throws Exception {
initJar();
test(false);
test(true);
if (errors > 0) {
throw new Exception(errors + " errors occurred");
}
}
void test(boolean withOption) {
System.err.println("Testing " + (withOption ? "with" : "without") + " option");
try {
RootDoc root = getRootDoc(withOption);
for (ClassDoc cd: root.specifiedClasses()) {
dump("", cd);
}
if (!withOption) {
error("expected option did not occur");
}
} catch (ClosedFileSystemException e) {
if (withOption) {
error("Unexpected exception: " + e);
} else {
System.err.println("Exception received as expected: " + e);
}
}
System.err.println();
}
RootDoc getRootDoc(boolean withOption) {
List<String> opts = new ArrayList<>();
if (withOption)
opts.add("-XDfileManager.deferClose=10");
opts.add("-doclet");
opts.add(getClass().getName());
opts.add("-classpath");
opts.add(jarPath.toString());
opts.add(Paths.get(System.getProperty("test.src"), "p", "Test.java").toString());
System.err.println("javadoc opts: " + opts);
int rc = com.sun.tools.javadoc.Main.execute(
"javadoc",
// by specifying our own class loader, we get the same Class instance as this
getClass().getClassLoader(),
opts.toArray(new String[opts.size()]));
if (rc != 0) {
error("unexpected exit from javadoc or doclet: " + rc);
}
return cachedRoot;
}
void dump(String prefix, ClassDoc cd) {
System.err.println(prefix + "class: " + cd);
for (FieldDoc fd: cd.fields()) {
System.err.println(fd);
if (fd.type().asClassDoc() != null) {
dump(prefix + " ", fd.type().asClassDoc());
}
}
}
void initJar() throws IOException {
Path testClasses = Paths.get(System.getProperty("test.classes"));
jarPath = Paths.get("lib.jar");
try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(jarPath))) {
String[] classNames = {"Lib1.class", "Lib2.class"};
for (String cn : classNames) {
out.putNextEntry(new JarEntry("lib/" + cn));
Path libClass = testClasses.resolve("jarsrc").resolve("lib").resolve(cn);
out.write(Files.readAllBytes(libClass));
}
}
}
void error(String msg) {
System.err.println("Error: " + msg);
errors++;
}
Path jarPath;
int errors;
// Bad doclet caches the RootDoc for later use
static RootDoc cachedRoot;
public static boolean start(RootDoc root) {
cachedRoot = root;
return true;
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 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
* 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.
*/
package lib;
public class Lib1 {
public Lib2 lib2;
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 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
* 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.
*/
package lib;
public class Lib2 {
int i;
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 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
* 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.
*/
package p;
public class Test {
public lib.Lib1 lib1;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -65,7 +65,7 @@ public class JavacOptionPrep {
// - Sources provided without preceding option (SRC2)
// - An unrecognized option which is to be passed on to javac
String sjavacArgs = "-cp " + TestPath.CP1 + SEP + TestPath.CP2 +
" -d dest " +
" -d dest" +
" -h header" +
" -sourcepath " + TestPath.SOURCEPATH1 +
" -src " + TestPath.SRC1 +