mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
Merge
This commit is contained in:
commit
340be2d06f
59 changed files with 418 additions and 395 deletions
|
@ -164,6 +164,11 @@ public class Lint
|
||||||
*/
|
*/
|
||||||
FINALLY("finally"),
|
FINALLY("finally"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about issues relating to use of command line options
|
||||||
|
*/
|
||||||
|
OPTIONS("options"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about issues regarding method overrides.
|
* Warn about issues regarding method overrides.
|
||||||
*/
|
*/
|
||||||
|
@ -181,25 +186,15 @@ public class Lint
|
||||||
*/
|
*/
|
||||||
PROCESSING("processing"),
|
PROCESSING("processing"),
|
||||||
|
|
||||||
/**
|
|
||||||
* Warn about Serializable classes that do not provide a serial version ID.
|
|
||||||
*/
|
|
||||||
SERIAL("serial"),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Warn about unchecked operations on raw types.
|
|
||||||
*/
|
|
||||||
UNCHECKED("unchecked"),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about unchecked operations on raw types.
|
* Warn about unchecked operations on raw types.
|
||||||
*/
|
*/
|
||||||
RAW("rawtypes"),
|
RAW("rawtypes"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about proprietary API that may be removed in a future release.
|
* Warn about Serializable classes that do not provide a serial version ID.
|
||||||
*/
|
*/
|
||||||
SUNAPI("sunapi", true),
|
SERIAL("serial"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about issues relating to use of statics
|
* Warn about issues relating to use of statics
|
||||||
|
@ -207,14 +202,24 @@ public class Lint
|
||||||
STATIC("static"),
|
STATIC("static"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about potentially unsafe vararg methods
|
* Warn about proprietary API that may be removed in a future release.
|
||||||
*/
|
*/
|
||||||
VARARGS("varargs"),
|
SUNAPI("sunapi", true),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about issues relating to use of try blocks (i.e. try-with-resources)
|
* Warn about issues relating to use of try blocks (i.e. try-with-resources)
|
||||||
*/
|
*/
|
||||||
TRY("try");
|
TRY("try"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about unchecked operations on raw types.
|
||||||
|
*/
|
||||||
|
UNCHECKED("unchecked"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about potentially unsafe vararg methods
|
||||||
|
*/
|
||||||
|
VARARGS("varargs");
|
||||||
|
|
||||||
LintCategory(String option) {
|
LintCategory(String option) {
|
||||||
this(option, false);
|
this(option, false);
|
||||||
|
|
|
@ -528,7 +528,7 @@ public class Scope {
|
||||||
}
|
}
|
||||||
public Entry next() {
|
public Entry next() {
|
||||||
Entry e = super.shadowed;
|
Entry e = super.shadowed;
|
||||||
while (isBogus())
|
while (e.isBogus())
|
||||||
e = e.shadowed;
|
e = e.shadowed;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,9 +174,6 @@ public enum Source {
|
||||||
public boolean allowUnderscoresInLiterals() {
|
public boolean allowUnderscoresInLiterals() {
|
||||||
return compareTo(JDK1_7) >= 0;
|
return compareTo(JDK1_7) >= 0;
|
||||||
}
|
}
|
||||||
public boolean allowExoticIdentifiers() {
|
|
||||||
return compareTo(JDK1_7) >= 0;
|
|
||||||
}
|
|
||||||
public boolean allowStringsInSwitch() {
|
public boolean allowStringsInSwitch() {
|
||||||
return compareTo(JDK1_7) >= 0;
|
return compareTo(JDK1_7) >= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2772,6 +2772,8 @@ public class Types {
|
||||||
public Type glb(Type t, Type s) {
|
public Type glb(Type t, Type s) {
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return t;
|
return t;
|
||||||
|
else if (t.isPrimitive() || s.isPrimitive())
|
||||||
|
return syms.errType;
|
||||||
else if (isSubtypeNoCapture(t, s))
|
else if (isSubtypeNoCapture(t, s))
|
||||||
return t;
|
return t;
|
||||||
else if (isSubtypeNoCapture(s, t))
|
else if (isSubtypeNoCapture(s, t))
|
||||||
|
@ -2927,6 +2929,15 @@ public class Types {
|
||||||
return reader.enterClass(syms.boxedName[t.tag]);
|
return reader.enterClass(syms.boxedName[t.tag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the boxed type if 't' is primitive, otherwise return 't' itself.
|
||||||
|
*/
|
||||||
|
public Type boxedTypeOrType(Type t) {
|
||||||
|
return t.isPrimitive() ?
|
||||||
|
boxedClass(t).type :
|
||||||
|
t;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the primitive type corresponding to a boxed type.
|
* Return the primitive type corresponding to a boxed type.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -305,7 +305,8 @@ public class Infer {
|
||||||
uv.hibounds = hibounds.toList();
|
uv.hibounds = hibounds.toList();
|
||||||
}
|
}
|
||||||
Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
|
Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
|
||||||
if (!types.isSubtype(qtype1, to)) {
|
if (!types.isSubtype(qtype1,
|
||||||
|
qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
|
||||||
throw unambiguousNoInstanceException
|
throw unambiguousNoInstanceException
|
||||||
.setMessage("infer.no.conforming.instance.exists",
|
.setMessage("infer.no.conforming.instance.exists",
|
||||||
that.tvars, that.qtype, to);
|
that.tvars, that.qtype, to);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package com.sun.tools.javac.file;
|
package com.sun.tools.javac.file;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -110,6 +111,20 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
protected boolean mmappedIO;
|
protected boolean mmappedIO;
|
||||||
protected boolean ignoreSymbolFile;
|
protected boolean ignoreSymbolFile;
|
||||||
|
|
||||||
|
protected enum SortFiles implements Comparator<File> {
|
||||||
|
FORWARD {
|
||||||
|
public int compare(File f1, File f2) {
|
||||||
|
return f1.getName().compareTo(f2.getName());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
REVERSE {
|
||||||
|
public int compare(File f1, File f2) {
|
||||||
|
return -f1.getName().compareTo(f2.getName());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
protected SortFiles sortFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a Context.Factory to create a JavacFileManager.
|
* Register a Context.Factory to create a JavacFileManager.
|
||||||
*/
|
*/
|
||||||
|
@ -152,6 +167,16 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
|
|
||||||
mmappedIO = options.isSet("mmappedIO");
|
mmappedIO = options.isSet("mmappedIO");
|
||||||
ignoreSymbolFile = options.isSet("ignore.symbol.file");
|
ignoreSymbolFile = options.isSet("ignore.symbol.file");
|
||||||
|
|
||||||
|
String sf = options.get("sortFiles");
|
||||||
|
if (sf != null) {
|
||||||
|
sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDefaultBootClassPath() {
|
||||||
|
return paths.isDefaultBootClassPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavaFileObject getFileForInput(String name) {
|
public JavaFileObject getFileForInput(String name) {
|
||||||
|
@ -293,6 +318,9 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||||
if (files == null)
|
if (files == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (sortFiles != null)
|
||||||
|
Arrays.sort(files, sortFiles);
|
||||||
|
|
||||||
for (File f: files) {
|
for (File f: files) {
|
||||||
String fname = f.getName();
|
String fname = f.getName();
|
||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
|
|
|
@ -114,6 +114,11 @@ public class Paths {
|
||||||
*/
|
*/
|
||||||
private File bootClassPathRtJar = null;
|
private File bootClassPathRtJar = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is bootclasspath the default?
|
||||||
|
*/
|
||||||
|
private boolean isDefaultBootClassPath;
|
||||||
|
|
||||||
Path getPathForLocation(Location location) {
|
Path getPathForLocation(Location location) {
|
||||||
Path path = pathsForLocation.get(location);
|
Path path = pathsForLocation.get(location);
|
||||||
if (path == null)
|
if (path == null)
|
||||||
|
@ -129,7 +134,7 @@ public class Paths {
|
||||||
if (location == CLASS_PATH)
|
if (location == CLASS_PATH)
|
||||||
p = computeUserClassPath();
|
p = computeUserClassPath();
|
||||||
else if (location == PLATFORM_CLASS_PATH)
|
else if (location == PLATFORM_CLASS_PATH)
|
||||||
p = computeBootClassPath();
|
p = computeBootClassPath(); // sets isDefaultBootClassPath
|
||||||
else if (location == ANNOTATION_PROCESSOR_PATH)
|
else if (location == ANNOTATION_PROCESSOR_PATH)
|
||||||
p = computeAnnotationProcessorPath();
|
p = computeAnnotationProcessorPath();
|
||||||
else if (location == SOURCE_PATH)
|
else if (location == SOURCE_PATH)
|
||||||
|
@ -138,6 +143,8 @@ public class Paths {
|
||||||
// no defaults for other paths
|
// no defaults for other paths
|
||||||
p = null;
|
p = null;
|
||||||
} else {
|
} else {
|
||||||
|
if (location == PLATFORM_CLASS_PATH)
|
||||||
|
isDefaultBootClassPath = false;
|
||||||
p = new Path();
|
p = new Path();
|
||||||
for (File f: path)
|
for (File f: path)
|
||||||
p.addFile(f, warn); // TODO: is use of warn appropriate?
|
p.addFile(f, warn); // TODO: is use of warn appropriate?
|
||||||
|
@ -145,6 +152,11 @@ public class Paths {
|
||||||
pathsForLocation.put(location, p);
|
pathsForLocation.put(location, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDefaultBootClassPath() {
|
||||||
|
lazy();
|
||||||
|
return isDefaultBootClassPath;
|
||||||
|
}
|
||||||
|
|
||||||
protected void lazy() {
|
protected void lazy() {
|
||||||
if (!inited) {
|
if (!inited) {
|
||||||
warn = lint.isEnabled(Lint.LintCategory.PATH);
|
warn = lint.isEnabled(Lint.LintCategory.PATH);
|
||||||
|
@ -262,9 +274,10 @@ public class Paths {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path addFiles(String files, boolean warn) {
|
public Path addFiles(String files, boolean warn) {
|
||||||
if (files != null)
|
if (files != null) {
|
||||||
for (File file : getPathEntries(files, emptyPathDefault))
|
for (File file : getPathEntries(files, emptyPathDefault))
|
||||||
addFile(file, warn);
|
addFile(file, warn);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,18 +347,23 @@ public class Paths {
|
||||||
|
|
||||||
private Path computeBootClassPath() {
|
private Path computeBootClassPath() {
|
||||||
bootClassPathRtJar = null;
|
bootClassPathRtJar = null;
|
||||||
String optionValue;
|
|
||||||
Path path = new Path();
|
Path path = new Path();
|
||||||
|
|
||||||
path.addFiles(options.get(XBOOTCLASSPATH_PREPEND));
|
String bootclasspathOpt = options.get(BOOTCLASSPATH);
|
||||||
|
String endorseddirsOpt = options.get(ENDORSEDDIRS);
|
||||||
|
String extdirsOpt = options.get(EXTDIRS);
|
||||||
|
String xbootclasspathPrependOpt = options.get(XBOOTCLASSPATH_PREPEND);
|
||||||
|
String xbootclasspathAppendOpt = options.get(XBOOTCLASSPATH_APPEND);
|
||||||
|
|
||||||
if ((optionValue = options.get(ENDORSEDDIRS)) != null)
|
path.addFiles(xbootclasspathPrependOpt);
|
||||||
path.addDirectories(optionValue);
|
|
||||||
|
if (endorseddirsOpt != null)
|
||||||
|
path.addDirectories(endorseddirsOpt);
|
||||||
else
|
else
|
||||||
path.addDirectories(System.getProperty("java.endorsed.dirs"), false);
|
path.addDirectories(System.getProperty("java.endorsed.dirs"), false);
|
||||||
|
|
||||||
if ((optionValue = options.get(BOOTCLASSPATH)) != null) {
|
if (bootclasspathOpt != null) {
|
||||||
path.addFiles(optionValue);
|
path.addFiles(bootclasspathOpt);
|
||||||
} else {
|
} else {
|
||||||
// Standard system classes for this compiler's release.
|
// Standard system classes for this compiler's release.
|
||||||
String files = System.getProperty("sun.boot.class.path");
|
String files = System.getProperty("sun.boot.class.path");
|
||||||
|
@ -357,16 +375,21 @@ public class Paths {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path.addFiles(options.get(XBOOTCLASSPATH_APPEND));
|
path.addFiles(xbootclasspathAppendOpt);
|
||||||
|
|
||||||
// Strictly speaking, standard extensions are not bootstrap
|
// Strictly speaking, standard extensions are not bootstrap
|
||||||
// classes, but we treat them identically, so we'll pretend
|
// classes, but we treat them identically, so we'll pretend
|
||||||
// that they are.
|
// that they are.
|
||||||
if ((optionValue = options.get(EXTDIRS)) != null)
|
if (extdirsOpt != null)
|
||||||
path.addDirectories(optionValue);
|
path.addDirectories(extdirsOpt);
|
||||||
else
|
else
|
||||||
path.addDirectories(System.getProperty("java.ext.dirs"), false);
|
path.addDirectories(System.getProperty("java.ext.dirs"), false);
|
||||||
|
|
||||||
|
isDefaultBootClassPath =
|
||||||
|
(xbootclasspathPrependOpt == null) &&
|
||||||
|
(bootclasspathOpt == null) &&
|
||||||
|
(xbootclasspathAppendOpt == null);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2615,7 +2615,6 @@ public class ClassReader implements Completer {
|
||||||
String binaryName = fileManager.inferBinaryName(currentLoc, fo);
|
String binaryName = fileManager.inferBinaryName(currentLoc, fo);
|
||||||
String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
|
String simpleName = binaryName.substring(binaryName.lastIndexOf(".") + 1);
|
||||||
if (SourceVersion.isIdentifier(simpleName) ||
|
if (SourceVersion.isIdentifier(simpleName) ||
|
||||||
fo.getKind() == JavaFileObject.Kind.CLASS ||
|
|
||||||
simpleName.equals("package-info"))
|
simpleName.equals("package-info"))
|
||||||
includeClassFile(p, fo);
|
includeClassFile(p, fo);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -51,6 +51,7 @@ import com.sun.source.util.TaskListener;
|
||||||
import com.sun.tools.javac.file.JavacFileManager;
|
import com.sun.tools.javac.file.JavacFileManager;
|
||||||
import com.sun.tools.javac.util.*;
|
import com.sun.tools.javac.util.*;
|
||||||
import com.sun.tools.javac.code.*;
|
import com.sun.tools.javac.code.*;
|
||||||
|
import com.sun.tools.javac.code.Lint.LintCategory;
|
||||||
import com.sun.tools.javac.code.Symbol.*;
|
import com.sun.tools.javac.code.Symbol.*;
|
||||||
import com.sun.tools.javac.tree.*;
|
import com.sun.tools.javac.tree.*;
|
||||||
import com.sun.tools.javac.tree.JCTree.*;
|
import com.sun.tools.javac.tree.JCTree.*;
|
||||||
|
@ -370,6 +371,15 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
processPcks = options.isSet("process.packages");
|
processPcks = options.isSet("process.packages");
|
||||||
werror = options.isSet(WERROR);
|
werror = options.isSet(WERROR);
|
||||||
|
|
||||||
|
if (source.compareTo(Source.DEFAULT) < 0) {
|
||||||
|
if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) {
|
||||||
|
if (fileManager instanceof BaseFileManager) {
|
||||||
|
if (((BaseFileManager) fileManager).isDefaultBootClassPath())
|
||||||
|
log.warning(LintCategory.OPTIONS, "source.no.bootclasspath", source.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
|
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
|
||||||
|
|
||||||
if (attrParseOnly)
|
if (attrParseOnly)
|
||||||
|
@ -783,6 +793,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
hasBeenUsed = true;
|
hasBeenUsed = true;
|
||||||
|
|
||||||
start_msec = now();
|
start_msec = now();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
initProcessAnnotations(processors);
|
initProcessAnnotations(processors);
|
||||||
|
|
||||||
|
@ -797,7 +808,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
elapsed_msec = delegateCompiler.elapsed_msec;
|
elapsed_msec = delegateCompiler.elapsed_msec;
|
||||||
} catch (Abort ex) {
|
} catch (Abort ex) {
|
||||||
if (devVerbose)
|
if (devVerbose)
|
||||||
ex.printStackTrace();
|
ex.printStackTrace(System.err);
|
||||||
} finally {
|
} finally {
|
||||||
if (procEnvImpl != null)
|
if (procEnvImpl != null)
|
||||||
procEnvImpl.close();
|
procEnvImpl.close();
|
||||||
|
@ -841,7 +852,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
}
|
}
|
||||||
} catch (Abort ex) {
|
} catch (Abort ex) {
|
||||||
if (devVerbose)
|
if (devVerbose)
|
||||||
ex.printStackTrace();
|
ex.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
|
|
|
@ -420,7 +420,7 @@ public class Main {
|
||||||
processors);
|
processors);
|
||||||
|
|
||||||
if (log.expectDiagKeys != null) {
|
if (log.expectDiagKeys != null) {
|
||||||
if (log.expectDiagKeys.size() == 0) {
|
if (log.expectDiagKeys.isEmpty()) {
|
||||||
Log.printLines(log.noticeWriter, "all expected diagnostics found");
|
Log.printLines(log.noticeWriter, "all expected diagnostics found");
|
||||||
return EXIT_OK;
|
return EXIT_OK;
|
||||||
} else {
|
} else {
|
||||||
|
@ -506,7 +506,7 @@ public class Main {
|
||||||
void apMessage(AnnotationProcessingError ex) {
|
void apMessage(AnnotationProcessingError ex) {
|
||||||
Log.printLines(out,
|
Log.printLines(out,
|
||||||
getLocalizedString("msg.proc.annotation.uncaught.exception"));
|
getLocalizedString("msg.proc.annotation.uncaught.exception"));
|
||||||
ex.getCause().printStackTrace();
|
ex.getCause().printStackTrace(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Display the location and checksum of a class. */
|
/** Display the location and checksum of a class. */
|
||||||
|
@ -563,6 +563,7 @@ public class Main {
|
||||||
public static void useRawMessages(boolean enable) {
|
public static void useRawMessages(boolean enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
messages = new JavacMessages(javacBundleName) {
|
messages = new JavacMessages(javacBundleName) {
|
||||||
|
@Override
|
||||||
public String getLocalizedString(String key, Object... args) {
|
public String getLocalizedString(String key, Object... args) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,11 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
|
||||||
return getClassLoader(lb.toArray(new URL[lb.size()]));
|
return getClassLoader(lb.toArray(new URL[lb.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDefaultBootClassPath() {
|
||||||
|
return searchPaths.isDefaultBootClassPath();
|
||||||
|
}
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Location handling">
|
// <editor-fold defaultstate="collapsed" desc="Location handling">
|
||||||
|
|
||||||
public boolean hasLocation(Location location) {
|
public boolean hasLocation(Location location) {
|
||||||
|
|
|
@ -66,10 +66,6 @@ public class Scanner implements Lexer {
|
||||||
*/
|
*/
|
||||||
private boolean allowUnderscoresInLiterals;
|
private boolean allowUnderscoresInLiterals;
|
||||||
|
|
||||||
/** Allow exotic identifiers.
|
|
||||||
*/
|
|
||||||
private boolean allowExoticIdentifiers;
|
|
||||||
|
|
||||||
/** The source language setting.
|
/** The source language setting.
|
||||||
*/
|
*/
|
||||||
private Source source;
|
private Source source;
|
||||||
|
@ -143,7 +139,6 @@ public class Scanner implements Lexer {
|
||||||
allowBinaryLiterals = source.allowBinaryLiterals();
|
allowBinaryLiterals = source.allowBinaryLiterals();
|
||||||
allowHexFloats = source.allowHexFloats();
|
allowHexFloats = source.allowHexFloats();
|
||||||
allowUnderscoresInLiterals = source.allowBinaryLiterals();
|
allowUnderscoresInLiterals = source.allowBinaryLiterals();
|
||||||
allowExoticIdentifiers = source.allowExoticIdentifiers(); // for invokedynamic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean hexFloatsWork = hexFloatsWork();
|
private static final boolean hexFloatsWork = hexFloatsWork();
|
||||||
|
@ -295,7 +290,7 @@ public class Scanner implements Lexer {
|
||||||
|
|
||||||
/** Read next character in character or string literal and copy into sbuf.
|
/** Read next character in character or string literal and copy into sbuf.
|
||||||
*/
|
*/
|
||||||
private void scanLitChar(boolean forBytecodeName) {
|
private void scanLitChar() {
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
if (buf[bp+1] == '\\' && unicodeConversionBp != bp) {
|
if (buf[bp+1] == '\\' && unicodeConversionBp != bp) {
|
||||||
bp++;
|
bp++;
|
||||||
|
@ -335,18 +330,6 @@ public class Scanner implements Lexer {
|
||||||
putChar('\"'); scanChar(); break;
|
putChar('\"'); scanChar(); break;
|
||||||
case '\\':
|
case '\\':
|
||||||
putChar('\\'); scanChar(); break;
|
putChar('\\'); scanChar(); break;
|
||||||
case '|': case ',': case '?': case '%':
|
|
||||||
case '^': case '_': case '{': case '}':
|
|
||||||
case '!': case '-': case '=':
|
|
||||||
if (forBytecodeName) {
|
|
||||||
// Accept escape sequences for dangerous bytecode chars.
|
|
||||||
// This is illegal in normal Java string or character literals.
|
|
||||||
// Note that the escape sequence itself is passed through.
|
|
||||||
putChar('\\'); putChar(ch); scanChar();
|
|
||||||
} else {
|
|
||||||
lexError(bp, "illegal.esc.char");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
lexError(bp, "illegal.esc.char");
|
lexError(bp, "illegal.esc.char");
|
||||||
}
|
}
|
||||||
|
@ -355,24 +338,6 @@ public class Scanner implements Lexer {
|
||||||
putChar(ch); scanChar();
|
putChar(ch); scanChar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void scanLitChar() {
|
|
||||||
scanLitChar(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Read next character in an exotic name #"foo"
|
|
||||||
*/
|
|
||||||
private void scanBytecodeNameChar() {
|
|
||||||
switch (ch) {
|
|
||||||
// reject any "dangerous" char which is illegal somewhere in the JVM spec
|
|
||||||
// cf. http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm
|
|
||||||
case '/': case '.': case ';': // illegal everywhere
|
|
||||||
case '<': case '>': // illegal in methods, dangerous in classes
|
|
||||||
case '[': // illegal in classes
|
|
||||||
lexError(bp, "illegal.bytecode.ident.char", String.valueOf((int)ch));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
scanLitChar(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scanDigits(int digitRadix) {
|
private void scanDigits(int digitRadix) {
|
||||||
char saveCh;
|
char saveCh;
|
||||||
|
@ -970,30 +935,6 @@ public class Scanner implements Lexer {
|
||||||
lexError(pos, "unclosed.str.lit");
|
lexError(pos, "unclosed.str.lit");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case '#':
|
|
||||||
scanChar();
|
|
||||||
if (ch == '\"') {
|
|
||||||
if (!allowExoticIdentifiers) {
|
|
||||||
lexError("unsupported.exotic.id", source.name);
|
|
||||||
allowExoticIdentifiers = true;
|
|
||||||
}
|
|
||||||
scanChar();
|
|
||||||
if (ch == '\"')
|
|
||||||
lexError(pos, "empty.bytecode.ident");
|
|
||||||
while (ch != '\"' && ch != CR && ch != LF && bp < buflen) {
|
|
||||||
scanBytecodeNameChar();
|
|
||||||
}
|
|
||||||
if (ch == '\"') {
|
|
||||||
name = names.fromChars(sbuf, 0, sp);
|
|
||||||
token = IDENTIFIER; // even if #"int" or #"do"
|
|
||||||
scanChar();
|
|
||||||
} else {
|
|
||||||
lexError(pos, "unclosed.bytecode.ident");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lexError("illegal.char", String.valueOf((int)'#'));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
if (isSpecial(ch)) {
|
if (isSpecial(ch)) {
|
||||||
scanOperator();
|
scanOperator();
|
||||||
|
|
|
@ -153,8 +153,6 @@ compiler.err.duplicate.default.label=\
|
||||||
|
|
||||||
compiler.err.else.without.if=\
|
compiler.err.else.without.if=\
|
||||||
''else'' without ''if''
|
''else'' without ''if''
|
||||||
compiler.err.empty.bytecode.ident=\
|
|
||||||
empty bytecode identifier
|
|
||||||
compiler.err.empty.char.lit=\
|
compiler.err.empty.char.lit=\
|
||||||
empty character literal
|
empty character literal
|
||||||
compiler.err.encl.class.required=\
|
compiler.err.encl.class.required=\
|
||||||
|
@ -201,8 +199,6 @@ compiler.err.generic.throwable=\
|
||||||
|
|
||||||
compiler.err.icls.cant.have.static.decl=\
|
compiler.err.icls.cant.have.static.decl=\
|
||||||
inner classes cannot have static declarations
|
inner classes cannot have static declarations
|
||||||
compiler.err.illegal.bytecode.ident.char=\
|
|
||||||
illegal bytecode identifier character: \\{0}
|
|
||||||
compiler.err.illegal.char=\
|
compiler.err.illegal.char=\
|
||||||
illegal character: \\{0}
|
illegal character: \\{0}
|
||||||
compiler.err.illegal.char.for.encoding=\
|
compiler.err.illegal.char.for.encoding=\
|
||||||
|
@ -472,8 +468,6 @@ compiler.err.type.var.more.than.once.in.result=\
|
||||||
compiler.err.types.incompatible.diff.ret=\
|
compiler.err.types.incompatible.diff.ret=\
|
||||||
types {0} and {1} are incompatible; both define {2}, but with unrelated return types
|
types {0} and {1} are incompatible; both define {2}, but with unrelated return types
|
||||||
|
|
||||||
compiler.err.unclosed.bytecode.ident=\
|
|
||||||
unclosed bytecode identifier
|
|
||||||
compiler.err.unclosed.char.lit=\
|
compiler.err.unclosed.char.lit=\
|
||||||
unclosed character literal
|
unclosed character literal
|
||||||
compiler.err.unclosed.comment=\
|
compiler.err.unclosed.comment=\
|
||||||
|
@ -770,6 +764,9 @@ compiler.warn.big.major.version=\
|
||||||
compiler.warn.static.not.qualified.by.type=\
|
compiler.warn.static.not.qualified.by.type=\
|
||||||
static {0} should be qualified by type name, {1}, instead of by an expression
|
static {0} should be qualified by type name, {1}, instead of by an expression
|
||||||
|
|
||||||
|
compiler.warn.source.no.bootclasspath=\
|
||||||
|
bootstrap class path not set in conjunction with -source {0}
|
||||||
|
|
||||||
# Warnings related to annotation processing
|
# Warnings related to annotation processing
|
||||||
compiler.warn.proc.package.does.not.exist=\
|
compiler.warn.proc.package.does.not.exist=\
|
||||||
package {0} does not exist
|
package {0} does not exist
|
||||||
|
@ -1269,10 +1266,6 @@ compiler.err.unsupported.underscore.lit=\
|
||||||
underscores in literals are not supported in -source {0}\n\
|
underscores in literals are not supported in -source {0}\n\
|
||||||
(use -source 7 or higher to enable underscores in literals)
|
(use -source 7 or higher to enable underscores in literals)
|
||||||
|
|
||||||
compiler.err.unsupported.exotic.id=\
|
|
||||||
exotic identifiers #"___" are not supported in -source {0}\n\
|
|
||||||
(use -source 7 or higher to enable exotic identifiers)
|
|
||||||
|
|
||||||
compiler.err.try.with.resources.not.supported.in.source=\
|
compiler.err.try.with.resources.not.supported.in.source=\
|
||||||
try-with-resources is not supported in -source {0}\n\
|
try-with-resources is not supported in -source {0}\n\
|
||||||
(use -source 7 or higher to enable try-with-resources)
|
(use -source 7 or higher to enable try-with-resources)
|
||||||
|
|
|
@ -59,7 +59,7 @@ import javax.tools.JavaFileObject.Kind;
|
||||||
* There are no references here to file-system specific objects such as
|
* There are no references here to file-system specific objects such as
|
||||||
* java.io.File or java.nio.file.Path.
|
* java.io.File or java.nio.file.Path.
|
||||||
*/
|
*/
|
||||||
public class BaseFileManager {
|
public abstract class BaseFileManager {
|
||||||
protected BaseFileManager(Charset charset) {
|
protected BaseFileManager(Charset charset) {
|
||||||
this.charset = charset;
|
this.charset = charset;
|
||||||
byteBufferCache = new ByteBufferCache();
|
byteBufferCache = new ByteBufferCache();
|
||||||
|
@ -163,6 +163,9 @@ public class BaseFileManager {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract boolean isDefaultBootClassPath();
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Encoding">
|
// <editor-fold defaultstate="collapsed" desc="Encoding">
|
||||||
|
|
|
@ -62,6 +62,7 @@ class JavadocClassReader extends ClassReader {
|
||||||
private JavadocClassReader(Context context) {
|
private JavadocClassReader(Context context) {
|
||||||
super(context, true);
|
super(context, true);
|
||||||
docenv = DocEnv.instance(context);
|
docenv = DocEnv.instance(context);
|
||||||
|
preferSource = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class T6341866 {
|
||||||
processorServices.delete();
|
processorServices.delete();
|
||||||
|
|
||||||
List<String> opts = new ArrayList<String>();
|
List<String> opts = new ArrayList<String>();
|
||||||
opts.addAll(Arrays.asList("-d", ".", "-sourcepath", testSrc, "-classpath", testClasses, "-source", "1.6"));
|
opts.addAll(Arrays.asList("-d", ".", "-sourcepath", testSrc, "-classpath", testClasses, "-source", "1.6", "-Xlint:-options"));
|
||||||
if (implicitType.opt != null)
|
if (implicitType.opt != null)
|
||||||
opts.add(implicitType.opt);
|
opts.add(implicitType.opt);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* @bug 4249112 4785453
|
* @bug 4249112 4785453
|
||||||
* @summary Verify that implicit member modifiers are set correctly.
|
* @summary Verify that implicit member modifiers are set correctly.
|
||||||
*
|
*
|
||||||
* @compile/ref=MemberModifiers.out -source 1.4 -target 1.4.2 -XDdumpmodifiers=cfm MemberModifiers.java
|
* @compile/ref=MemberModifiers.out -source 1.4 -target 1.4.2 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Currently, we check only that members of final classes are not final.
|
// Currently, we check only that members of final classes are not final.
|
||||||
|
|
|
@ -21,11 +21,14 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.unsupported.exotic.id
|
/*
|
||||||
// options: -source 6
|
* @test
|
||||||
|
* @bug 6900037
|
||||||
|
* @summary javac should warn if earlier -source is used and bootclasspath not set
|
||||||
|
* @compile T6900037.java
|
||||||
|
* @compile -source 1.6 T6900037.java
|
||||||
|
* @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java
|
||||||
|
* @compile -Werror -source 1.6 -Xlint:-options T6900037.java
|
||||||
|
*/
|
||||||
|
|
||||||
class UnsupportedExoticID {
|
class T6900037 { }
|
||||||
void m() {
|
|
||||||
Object #"Hello!" = null;
|
|
||||||
}
|
|
||||||
}
|
|
4
langtools/test/tools/javac/T6900037.out
Normal file
4
langtools/test/tools/javac/T6900037.out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- compiler.warn.source.no.bootclasspath: 1.6
|
||||||
|
- compiler.err.warnings.and.werror
|
||||||
|
1 error
|
||||||
|
1 warning
|
|
@ -3,8 +3,8 @@
|
||||||
* @bug 6911256 6964740
|
* @bug 6911256 6964740
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @summary Test error messages for an unadorned try
|
* @summary Test error messages for an unadorned try
|
||||||
* @compile/fail/ref=PlainTry6.out -XDrawDiagnostics -source 6 PlainTry.java
|
* @compile/fail/ref=PlainTry6.out -XDrawDiagnostics -source 6 -Xlint:-options PlainTry.java
|
||||||
* @compile/fail/ref=PlainTry.out -XDrawDiagnostics PlainTry.java
|
* @compile/fail/ref=PlainTry.out -XDrawDiagnostics PlainTry.java
|
||||||
*/
|
*/
|
||||||
public class PlainTry {
|
public class PlainTry {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) {
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
* @summary Please add annotation <at>Deprecated to supplant the javadoc tag
|
* @summary Please add annotation <at>Deprecated to supplant the javadoc tag
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile -source 1.4 -Xlint:dep-ann -Werror Dep.java
|
* @compile -source 1.4 -Xlint:-options -Xlint:dep-ann -Werror Dep.java
|
||||||
* @compile/fail -Xlint:dep-ann -Werror Dep.java
|
* @compile/fail -Xlint:dep-ann -Werror Dep.java
|
||||||
* @compile -Xlint:dep-ann Dep.java
|
* @compile -Xlint:dep-ann Dep.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.annotations.not.supported.in.source
|
// key: compiler.err.annotations.not.supported.in.source
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
class AnnotationsNotSupported { }
|
class AnnotationsNotSupported { }
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.warn.assert.as.identifier
|
// key: compiler.warn.assert.as.identifier
|
||||||
// options: -source 1.3
|
// options: -source 1.3 -Xlint:-options
|
||||||
|
|
||||||
class AssertAsIdentifier {
|
class AssertAsIdentifier {
|
||||||
int assert;
|
int assert;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.diamond.not.supported.in.source
|
// key: compiler.err.diamond.not.supported.in.source
|
||||||
// options: -source 6
|
// options: -source 6 -Xlint:-options
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.warn.enum.as.identifier
|
// key: compiler.warn.enum.as.identifier
|
||||||
// options: -source 1.3
|
// options: -source 1.3 -Xlint:-options
|
||||||
|
|
||||||
class EnumAsIdentifier {
|
class EnumAsIdentifier {
|
||||||
int enum;
|
int enum;
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.enums.not.supported.in.source
|
// key: compiler.err.enums.not.supported.in.source
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
enum EnumsNotSupported { A, B, C }
|
enum EnumsNotSupported { A, B, C }
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.expected2
|
// key: compiler.err.expected2
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
int Expected2;
|
int Expected2;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.foreach.not.supported.in.source
|
// key: compiler.err.foreach.not.supported.in.source
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
class ForeachNotSupported {
|
class ForeachNotSupported {
|
||||||
void m(String[] args) {
|
void m(String[] args) {
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.generics.not.supported.in.source
|
// key: compiler.err.generics.not.supported.in.source
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
class GenericsNotSupported<T> { }
|
class GenericsNotSupported<T> { }
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.multicatch.not.supported.in.source
|
// key: compiler.err.multicatch.not.supported.in.source
|
||||||
// options: -source 1.6
|
// options: -source 1.6 -Xlint:-options
|
||||||
|
|
||||||
class MulticatchNotSupported {
|
class MulticatchNotSupported {
|
||||||
class E1 extends Exception { }
|
class E1 extends Exception { }
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.neither.conditional.subtype
|
// key: compiler.err.neither.conditional.subtype
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
class X {
|
class X {
|
||||||
Object m(boolean b) {
|
Object m(boolean b) {
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.illegal.bytecode.ident.char
|
// key: compiler.warn.source.no.bootclasspath
|
||||||
|
// options: -source 6
|
||||||
|
|
||||||
class IllegalBytecodeIdentChar {
|
class SourceNoBootclasspath { }
|
||||||
int #"abc/def" = 3;
|
|
||||||
}
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.static.import.not.supported.in.source
|
// key: compiler.err.static.import.not.supported.in.source
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
import static java.util.regex.Pattern.*;
|
import static java.util.regex.Pattern.*;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.string.switch.not.supported.in.source
|
// key: compiler.err.string.switch.not.supported.in.source
|
||||||
// options: -source 6
|
// options: -source 6 -Xlint:-options
|
||||||
|
|
||||||
class StringSwitchNotSupported {
|
class StringSwitchNotSupported {
|
||||||
int m(String s) {
|
int m(String s) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.try.with.resources.not.supported.in.source
|
// key: compiler.err.try.with.resources.not.supported.in.source
|
||||||
// options: -source 1.6
|
// options: -source 1.6 -Xlint:-options
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.try.without.catch.or.finally
|
// key: compiler.err.try.without.catch.or.finally
|
||||||
// options: -source 1.6
|
// options: -source 1.6 -Xlint:-options
|
||||||
|
|
||||||
class TryWithoutCatchOrFinally {
|
class TryWithoutCatchOrFinally {
|
||||||
void m() {
|
void m() {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.unsupported.binary.lit
|
// key: compiler.err.unsupported.binary.lit
|
||||||
// options: -source 6
|
// options: -source 6 -Xlint:-options
|
||||||
|
|
||||||
class UnsupportedBinaryLiteral {
|
class UnsupportedBinaryLiteral {
|
||||||
int i = 0b01000010;
|
int i = 0b01000010;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.unsupported.fp.lit
|
// key: compiler.err.unsupported.fp.lit
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
class UnsupportedFpLit {
|
class UnsupportedFpLit {
|
||||||
float f = 0xCafe.BabeP1;
|
float f = 0xCafe.BabeP1;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.unsupported.underscore.lit
|
// key: compiler.err.unsupported.underscore.lit
|
||||||
// options: -source 6
|
// options: -source 6 -Xlint:-options
|
||||||
|
|
||||||
class UnsupportedUnderscoreLiteral {
|
class UnsupportedUnderscoreLiteral {
|
||||||
int i = 123_456_789;
|
int i = 123_456_789;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.varargs.not.supported.in.source
|
// key: compiler.err.varargs.not.supported.in.source
|
||||||
// options: -source 1.4
|
// options: -source 1.4 -Xlint:-options
|
||||||
|
|
||||||
class VarargsNotSupported {
|
class VarargsNotSupported {
|
||||||
void m(String... args) { }
|
void m(String... args) { }
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
* @bug 6384542
|
* @bug 6384542
|
||||||
* @summary crash: test/tools/javac/versions/check.sh
|
* @summary crash: test/tools/javac/versions/check.sh
|
||||||
* @author Peter von der Ah\u00e9
|
* @author Peter von der Ah\u00e9
|
||||||
* @compile/fail -source 1.4 T6384542.java
|
* @compile/fail -source 1.4 -Xlint:-options T6384542.java
|
||||||
* @compile/fail/ref=T6384542.out -source 1.4 -XDrawDiagnostics T6384542.java
|
* @compile/fail/ref=T6384542.out -source 1.4 -Xlint:-options -XDrawDiagnostics T6384542.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static java.lang.Math.sin;
|
import static java.lang.Math.sin;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* @author Peter von der Ah\u00e9
|
* @author Peter von der Ah\u00e9
|
||||||
* @compile/fail -source 5 T6384542a.java
|
* @compile/fail -source 5 T6384542a.java
|
||||||
* @compile -source 1.4 T6384542a.java
|
* @compile -source 1.4 T6384542a.java
|
||||||
* @compile/fail/ref=T6384542a_5.out -source 5 -XDrawDiagnostics T6384542a.java
|
* @compile/fail/ref=T6384542a_5.out -source 5 -Xlint:-options -XDrawDiagnostics T6384542a.java
|
||||||
* @compile/ref=T6384542a_1_4.out -source 1.4 -XDrawDiagnostics T6384542a.java
|
* @compile/ref=T6384542a_1_4.out -source 1.4 -Xlint:-options -XDrawDiagnostics T6384542a.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class T6384542a {
|
public class T6384542a {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.*;
|
||||||
|
|
||||||
class T6638712a {
|
class T6638712a {
|
||||||
|
|
||||||
<T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) {}
|
<T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) { return null; }
|
||||||
|
|
||||||
public void test(List<Comparator<?>> x) {
|
public void test(List<Comparator<?>> x) {
|
||||||
Comparator<String> c3 = compound(x);
|
Comparator<String> c3 = compound(x);
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 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 6995200
|
||||||
|
*
|
||||||
|
* @summary JDK 7 compiler crashes when type-variable is inferred from expected primitive type
|
||||||
|
* @author mcimadamore
|
||||||
|
* @compile T6995200.java
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class T6995200 {
|
||||||
|
static <T> T getValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
<X> void test() {
|
||||||
|
byte v1 = getValue();
|
||||||
|
short v2 = getValue();
|
||||||
|
int v3 = getValue();
|
||||||
|
long v4 = getValue();
|
||||||
|
float v5 = getValue();
|
||||||
|
double v6 = getValue();
|
||||||
|
String v7 = getValue();
|
||||||
|
String[] v8 = getValue();
|
||||||
|
List<String> v9 = getValue();
|
||||||
|
List<String>[] v10 = getValue();
|
||||||
|
List<? extends String> v11 = getValue();
|
||||||
|
List<? extends String>[] v12 = getValue();
|
||||||
|
List<? super String> v13 = getValue();
|
||||||
|
List<? super String>[] v14 = getValue();
|
||||||
|
List<?> v15 = getValue();
|
||||||
|
List<?>[] v16 = getValue();
|
||||||
|
X v17 = getValue();
|
||||||
|
X[] v18 = getValue();
|
||||||
|
List<X> v19 = getValue();
|
||||||
|
List<X>[] v20 = getValue();
|
||||||
|
List<? extends X> v21 = getValue();
|
||||||
|
List<? extends X>[] v22 = getValue();
|
||||||
|
List<? super X> v23 = getValue();
|
||||||
|
List<? super X>[] v24 = getValue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
* @test /nodynamiccopyright/
|
* @test /nodynamiccopyright/
|
||||||
* @bug 6860965
|
* @bug 6860965
|
||||||
* @summary Project Coin: binary literals
|
* @summary Project Coin: binary literals
|
||||||
* @compile/fail/ref=BadBinaryLiterals.6.out -XDrawDiagnostics -source 6 BadBinaryLiterals.java
|
* @compile/fail/ref=BadBinaryLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadBinaryLiterals.java
|
||||||
* @compile/fail/ref=BadBinaryLiterals.7.out -XDrawDiagnostics BadBinaryLiterals.java
|
* @compile/fail/ref=BadBinaryLiterals.7.out -XDrawDiagnostics BadBinaryLiterals.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @compile/fail/ref=BadUnderscoreLiterals.7.out -XDrawDiagnostics BadUnderscoreLiterals.java
|
* @compile/fail/ref=BadUnderscoreLiterals.7.out -XDrawDiagnostics BadUnderscoreLiterals.java
|
||||||
*
|
*
|
||||||
* @compile/fail -source 6 BadUnderscoreLiterals.java
|
* @compile/fail -source 6 BadUnderscoreLiterals.java
|
||||||
* @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 BadUnderscoreLiterals.java
|
* @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadUnderscoreLiterals.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BadUnderscoreLiterals {
|
public class BadUnderscoreLiterals {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class InvokeDyn {
|
||||||
ojunk = InvokeDynamic.greet(x, "mundus", 456);
|
ojunk = InvokeDynamic.greet(x, "mundus", 456);
|
||||||
ojunk = InvokeDynamic.greet(x, "kosmos", 789);
|
ojunk = InvokeDynamic.greet(x, "kosmos", 789);
|
||||||
ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14);
|
ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14);
|
||||||
InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null);
|
//InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null);
|
||||||
ijunk = (int) InvokeDynamic.invoke("goodbye");
|
ijunk = (int) InvokeDynamic.invoke("goodbye");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -53,7 +53,7 @@ public class InvokeDynTrans {
|
||||||
InvokeDynamic.greet(x, "mundus", 456);
|
InvokeDynamic.greet(x, "mundus", 456);
|
||||||
InvokeDynamic.greet(x, "kosmos", 789);
|
InvokeDynamic.greet(x, "kosmos", 789);
|
||||||
InvokeDynamic.<String>cogitate(10.11121, 3.14);
|
InvokeDynamic.<String>cogitate(10.11121, 3.14);
|
||||||
InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
|
//InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
|
||||||
InvokeDynamic.<int>invoke("goodbye");
|
InvokeDynamic.<int>invoke("goodbye");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
InvokeDynTrans.java:55:39: compiler.warn.type.parameter.on.polymorphic.signature
|
InvokeDynTrans.java:55:39: compiler.warn.type.parameter.on.polymorphic.signature
|
||||||
InvokeDynTrans.java:56:91: compiler.warn.type.parameter.on.polymorphic.signature
|
|
||||||
InvokeDynTrans.java:57:34: compiler.warn.type.parameter.on.polymorphic.signature
|
InvokeDynTrans.java:57:34: compiler.warn.type.parameter.on.polymorphic.signature
|
||||||
- compiler.err.warnings.and.werror
|
- compiler.err.warnings.and.werror
|
||||||
1 error
|
1 error
|
||||||
3 warnings
|
2 warnings
|
||||||
|
|
|
@ -27,15 +27,15 @@
|
||||||
* @summary Test that warnings about source versions are output as expected.
|
* @summary Test that warnings about source versions are output as expected.
|
||||||
* @author Joseph D. Darcy
|
* @author Joseph D. Darcy
|
||||||
* @compile TestSourceVersionWarnings.java
|
* @compile TestSourceVersionWarnings.java
|
||||||
* @compile/ref=gold_0.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -source 1.5 HelloWorld.java
|
* @compile/ref=gold_0.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -source 1.5 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_sv_warn_0_2.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_0 -source 1.2 HelloWorld.java
|
* @compile/ref=gold_sv_warn_0_2.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_0 -source 1.2 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.2 HelloWorld.java
|
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.2 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_sv_warn_2_3.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.3 HelloWorld.java
|
* @compile/ref=gold_sv_warn_2_3.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_2 -source 1.3 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.5 HelloWorld.java
|
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.5 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_sv_warn_5_6.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 HelloWorld.java
|
* @compile/ref=gold_sv_warn_5_6.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 HelloWorld.java
|
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options HelloWorld.java
|
||||||
* @compile/ref=gold_unsp_warn.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Aunsupported HelloWorld.java
|
* @compile/ref=gold_unsp_warn.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java
|
||||||
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 HelloWorld.java
|
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 HelloWorld.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2008, 2010, 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 6746458
|
|
||||||
* @summary Verify correct lexing of quoted identifiers.
|
|
||||||
* @author jrose
|
|
||||||
* @ignore 6877225 test fails on Windows:
|
|
||||||
* QuotedIdent.java:81: error while writing QuotedIdent.*86: PATH\QuotedIdent$*86.class
|
|
||||||
* (The filename, directory name, or volume label syntax is incorrect)
|
|
||||||
*
|
|
||||||
* @library ..
|
|
||||||
* @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java
|
|
||||||
* @run main quid.QuotedIdent
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Standalone testing:
|
|
||||||
* <code>
|
|
||||||
* $ cd $MY_REPO_DIR/langtools
|
|
||||||
* $ (cd make; make)
|
|
||||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent.java
|
|
||||||
* $ java -version # should print 1.6 or later
|
|
||||||
* $ java -cp dist quid.QuotedIdent
|
|
||||||
* </code>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package quid;
|
|
||||||
|
|
||||||
public class QuotedIdent {
|
|
||||||
static void check(int testid, String have, String expect)
|
|
||||||
throws RuntimeException {
|
|
||||||
if ((have == null && have != expect) ||
|
|
||||||
(have != null && !have.equals(expect))) {
|
|
||||||
String msg =
|
|
||||||
"TEST " + testid + ": HAVE \"" +
|
|
||||||
have + "\" EXPECT \"" + expect + "\"";
|
|
||||||
System.out.println("StringConversion: " + msg);
|
|
||||||
throw new RuntimeException(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// negative tests:
|
|
||||||
//static class #"" { } //BAD empty ident name
|
|
||||||
//static class #"<foo>" { } //BAD bad char in ident name
|
|
||||||
/*static class /*(//BAD ident name interrupted by newline) #"jump:
|
|
||||||
" { } /* uncomment previous line to attempt class w/ bad name */
|
|
||||||
|
|
||||||
static class #"int" extends Number {
|
|
||||||
final int #"int";
|
|
||||||
#"int"(int #"int") {
|
|
||||||
this.#"int" = #"int";
|
|
||||||
}
|
|
||||||
static #"int" valueOf(int #"int") {
|
|
||||||
return new #"int"(#"int");
|
|
||||||
}
|
|
||||||
public int intValue() { return #"int"; }
|
|
||||||
public long longValue() { return #"int"; }
|
|
||||||
public float floatValue() { return #"int"; }
|
|
||||||
public double doubleValue() { return #"int"; }
|
|
||||||
public String toString() { return String.valueOf(#"int"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class #"*86" {
|
|
||||||
String #"555-1212"() { return "[*86.555-1212]"; }
|
|
||||||
}
|
|
||||||
static#"*86"#"MAKE-*86"() { // note close spacing
|
|
||||||
return new QuotedIdent().new#"*86"();
|
|
||||||
}
|
|
||||||
|
|
||||||
static String bar() { return "[bar]"; }
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
String s;
|
|
||||||
|
|
||||||
String #"sticky \' wicket" = "wicked ' stick";
|
|
||||||
s = #"sticky ' wicket";
|
|
||||||
check(11, s, "wicked \' stick");
|
|
||||||
check(12, #"s", s);
|
|
||||||
check(13, #"\163", s);
|
|
||||||
|
|
||||||
s = #"QuotedIdent".bar();
|
|
||||||
check(21, s, "[bar]");
|
|
||||||
|
|
||||||
s = #"int".valueOf(123).toString();
|
|
||||||
check(22, s, "123");
|
|
||||||
|
|
||||||
s = #"MAKE-*86"().#"555-1212"();
|
|
||||||
check(23, s, "[*86.555-1212]");
|
|
||||||
|
|
||||||
class#"{{{inmost}}}" { }
|
|
||||||
s = new#"{{{inmost}}}"().getClass().getName();
|
|
||||||
if (!s.endsWith("{{{inmost}}}"))
|
|
||||||
check(24, s, "should end with \"{{{inmost}}}\"");
|
|
||||||
|
|
||||||
s = #"Yog-Shoggoth".#"(nameless ululation)";
|
|
||||||
check(25, s, "Tekeli-li!");
|
|
||||||
|
|
||||||
s = #"int".class.getName();
|
|
||||||
check(31, s, QuotedIdent.class.getName()+"$int");
|
|
||||||
|
|
||||||
Class<?> x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
|
|
||||||
if (x86 != #"*86".class)
|
|
||||||
check(32, "reflected "+x86, "static "+#"*86".class);
|
|
||||||
|
|
||||||
s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
|
|
||||||
check(31, s, "[*86.555-1212]");
|
|
||||||
|
|
||||||
System.out.println("OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface #"Yog-Shoggoth" {
|
|
||||||
final String #"(nameless ululation)" = "Tekeli-li!";
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2008, 2010, 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 6746458
|
|
||||||
* @summary Verify correct separate compilation of classes with extended identifiers.
|
|
||||||
* @author jrose
|
|
||||||
* @ignore 6877225 test fails on Windows:
|
|
||||||
* QuotedIdent.java:81: error while writing QuotedIdent.*86: PATH\QuotedIdent$*86.class
|
|
||||||
* (The filename, directory name, or volume label syntax is incorrect)
|
|
||||||
*
|
|
||||||
* @library ..
|
|
||||||
* @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java
|
|
||||||
* @run main quid.QuotedIdent2
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Standalone testing:
|
|
||||||
* <code>
|
|
||||||
* $ cd $MY_REPO_DIR/langtools
|
|
||||||
* $ (cd make; make)
|
|
||||||
* $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent.java
|
|
||||||
* $ ./dist/bootstrap/bin/javac -d dist -cp dist test/tools/javac/quid/QuotedIdent2.java
|
|
||||||
* $ java -version # should print 1.6 or later
|
|
||||||
* $ java -cp dist QuotedIdent2
|
|
||||||
* </code>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package quid;
|
|
||||||
|
|
||||||
import quid.QuotedIdent.*;
|
|
||||||
import quid.QuotedIdent.#"*86";
|
|
||||||
import static quid.QuotedIdent.#"MAKE-*86";
|
|
||||||
|
|
||||||
public class QuotedIdent2 {
|
|
||||||
static void check(int testid, String have, String expect)
|
|
||||||
throws RuntimeException {
|
|
||||||
QuotedIdent.check(testid, have, expect);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
String s;
|
|
||||||
|
|
||||||
s = #"int".valueOf(123).toString();
|
|
||||||
check(22, s, "123");
|
|
||||||
|
|
||||||
s = #"MAKE-*86"().#"555-1212"();
|
|
||||||
check(23, s, "[*86.555-1212]");
|
|
||||||
|
|
||||||
s = #"Yog-Shoggoth".#"(nameless ululation)";
|
|
||||||
check(25, s, "Tekeli-li!");
|
|
||||||
|
|
||||||
s = QuotedIdent.#"int".class.getName();
|
|
||||||
check(31, s, QuotedIdent.class.getName()+"$int");
|
|
||||||
|
|
||||||
Class<?> x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
|
|
||||||
if (x86 != #"*86".class)
|
|
||||||
check(32, "reflected "+x86, "static "+#"*86".class);
|
|
||||||
|
|
||||||
s = (String) x86.getDeclaredMethod("555-1212").invoke(QuotedIdent.#"MAKE-*86"());
|
|
||||||
check(31, s, "[*86.555-1212]");
|
|
||||||
|
|
||||||
System.out.println("OK");
|
|
||||||
}
|
|
||||||
}
|
|
9
langtools/test/tools/javac/quid/T6999438.java
Normal file
9
langtools/test/tools/javac/quid/T6999438.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/* @test /nodynamiccopyright/
|
||||||
|
* @bug 6999438
|
||||||
|
* @summary remove support for exotic identifiers from JDK 7
|
||||||
|
* @compile/fail/ref=T6999438.out -XDrawDiagnostics -source 7 T6999438.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
int #"not supported";
|
||||||
|
}
|
6
langtools/test/tools/javac/quid/T6999438.out
Normal file
6
langtools/test/tools/javac/quid/T6999438.out
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
T6999438.java:8:9: compiler.err.illegal.char: 35
|
||||||
|
T6999438.java:8:10: compiler.err.illegal.start.of.type
|
||||||
|
T6999438.java:8:25: compiler.err.expected: token.identifier
|
||||||
|
T6999438.java:8:26: compiler.err.expected: ';'
|
||||||
|
T6999438.java:9:2: compiler.err.premature.eof
|
||||||
|
5 errors
|
|
@ -27,7 +27,7 @@
|
||||||
* @summary fixed-arity warning given too often
|
* @summary fixed-arity warning given too often
|
||||||
* @author gafter
|
* @author gafter
|
||||||
*
|
*
|
||||||
* @compile -Werror -source 1.4 Warn1.java
|
* @compile -Werror -source 1.4 -Xlint:-options Warn1.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package varargs.warning.warn1;
|
package varargs.warning.warn1;
|
||||||
|
|
134
langtools/test/tools/javadoc/6942366/T6942366.java
Normal file
134
langtools/test/tools/javadoc/6942366/T6942366.java
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 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 6942366
|
||||||
|
* @summary javadoc no longer inherits doc from sourcepath
|
||||||
|
* @build p.Base Test
|
||||||
|
* @run main T6942366
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class T6942366 {
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
|
new T6942366().run();
|
||||||
|
}
|
||||||
|
|
||||||
|
File testSrc;
|
||||||
|
File testClasses;
|
||||||
|
int count;
|
||||||
|
int errors;
|
||||||
|
|
||||||
|
void run() throws Exception {
|
||||||
|
testSrc = new File(System.getProperty("test.src"));
|
||||||
|
testClasses = new File(System.getProperty("test.classes"));
|
||||||
|
|
||||||
|
test(true, false);
|
||||||
|
test(false, true);
|
||||||
|
test(true, true);
|
||||||
|
|
||||||
|
if (errors > 0)
|
||||||
|
throw new Exception(errors + " errors found");
|
||||||
|
}
|
||||||
|
|
||||||
|
void test(boolean useSourcePath, boolean useClassPath) throws Exception {
|
||||||
|
System.out.println("test " + (++count) + " sp:" + useSourcePath + " cp:" + useClassPath);
|
||||||
|
File testDir = new File("test" + count);
|
||||||
|
testDir.mkdirs();
|
||||||
|
|
||||||
|
List<String> args = new ArrayList<String>();
|
||||||
|
//args.add("-verbose");
|
||||||
|
args.add("-d");
|
||||||
|
args.add(testDir.getPath());
|
||||||
|
if (useSourcePath) {
|
||||||
|
args.add("-sourcepath");
|
||||||
|
args.add(testSrc.getPath());
|
||||||
|
}
|
||||||
|
if (useClassPath) {
|
||||||
|
args.add("-classpath");
|
||||||
|
args.add(testClasses.getPath());
|
||||||
|
} else {
|
||||||
|
// override classpath to avoid stuff jtreg might have put on papth
|
||||||
|
args.add("-classpath");
|
||||||
|
args.add(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
// use a very simple bootclasspath to avoid stuff jtreg might have put on path
|
||||||
|
File javaHome = new File(System.getProperty("java.home"));
|
||||||
|
File rt_jar = new File(javaHome, "lib/rt.jar");
|
||||||
|
if (!rt_jar.exists())
|
||||||
|
throw new Exception("rt.jar not found");
|
||||||
|
args.add("-bootclasspath");
|
||||||
|
args.add(rt_jar.getPath());
|
||||||
|
|
||||||
|
args.add(new File(testSrc, "Test.java").getPath());
|
||||||
|
System.out.println("javadoc: " + args);
|
||||||
|
|
||||||
|
int rc = com.sun.tools.javadoc.Main.execute(args.toArray(new String[args.size()]));
|
||||||
|
if (rc != 0)
|
||||||
|
throw new Exception("unexpected exit from javadoc, rc=" + rc);
|
||||||
|
|
||||||
|
if (useSourcePath && useClassPath) {
|
||||||
|
long srcLastMod = new File(testSrc, "Test.java").lastModified();
|
||||||
|
long classLastMod = new File(testClasses, "Test.class").lastModified();
|
||||||
|
System.out.println("Test.java last modified: " + new Date(srcLastMod));
|
||||||
|
System.out.println("Test.class last modified: " + new Date(classLastMod));
|
||||||
|
System.out.println((srcLastMod > classLastMod ? "source" : "class") + " is newer");
|
||||||
|
}
|
||||||
|
|
||||||
|
String s = "javadoc-for-Base.m";
|
||||||
|
boolean expect = useSourcePath;
|
||||||
|
boolean found = contains(new File(testDir, "Test.html"), s);
|
||||||
|
if (found) {
|
||||||
|
if (expect)
|
||||||
|
System.out.println("javadoc content \"" + s + "\" found, as expected");
|
||||||
|
else
|
||||||
|
error("javadoc content \"" + s + "\" found unexpectedly");
|
||||||
|
} else {
|
||||||
|
if (expect)
|
||||||
|
error("javadoc content \"" + s + "\" not found");
|
||||||
|
else
|
||||||
|
System.out.println("javadoc content \"" + s + "\" not found, as expected");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean contains(File f, String s) throws Exception {
|
||||||
|
byte[] buf = new byte[(int) f.length()];
|
||||||
|
try (DataInputStream in = new DataInputStream(new FileInputStream(f))) {
|
||||||
|
in.readFully(buf);
|
||||||
|
}
|
||||||
|
return new String(buf).contains(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(String msg) {
|
||||||
|
System.out.println("Error: " + msg);
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.empty.bytecode.ident
|
public class Test extends p.Base {
|
||||||
|
// overrides Base.m
|
||||||
class EmptyBytecodeIdent {
|
public void m() { }
|
||||||
int #"" = 3;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// key: compiler.err.unclosed.bytecode.ident
|
package p;
|
||||||
|
|
||||||
class UnclosedBytecodeIdent {
|
public class Base {
|
||||||
int #"abc
|
/** javadoc-for-Base.m. */
|
||||||
|
public void m() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class T6729471
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
|
File testClasses = new File(System.getProperty("test.classes"));
|
||||||
|
|
||||||
// simple class
|
// simple class
|
||||||
verify("java.util.Map",
|
verify("java.util.Map",
|
||||||
"public abstract boolean containsKey(java.lang.Object)");
|
"public abstract boolean containsKey(java.lang.Object)");
|
||||||
|
@ -48,11 +50,11 @@ public class T6729471
|
||||||
"public abstract K getKey()");
|
"public abstract K getKey()");
|
||||||
|
|
||||||
// file name
|
// file name
|
||||||
verify("../classes/tools/javap/T6729471.class",
|
verify(new File(testClasses, "T6729471.class").getPath(),
|
||||||
"public static void main(java.lang.String...)");
|
"public static void main(java.lang.String...)");
|
||||||
|
|
||||||
// file url
|
// file url
|
||||||
verify("file:../classes/tools/javap/T6729471.class",
|
verify(new File(testClasses, "T6729471.class").toURI().toString(),
|
||||||
"public static void main(java.lang.String...)");
|
"public static void main(java.lang.String...)");
|
||||||
|
|
||||||
// jar url: rt.jar
|
// jar url: rt.jar
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue