提交 25f094b1 编写于 作者: L lagergren

8023550: -d option was broken for any dir but '.'. Fixed Java warnings.

Reviewed-by: jlaskey, sundar
上级 1e5a0a50
......@@ -27,7 +27,6 @@ package jdk.nashorn.internal.tools.nasgen;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.CONSTRUCTOR_SUFFIX;
......
......@@ -27,7 +27,6 @@ package jdk.nashorn.internal.tools.nasgen;
import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.DUP;
import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.NEW;
......
......@@ -121,7 +121,6 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
* to change the value. If your override returns a value less than 1, the code will break.
* @return the maximum number of method handles in the chain.
*/
@SuppressWarnings("static-method")
protected int getMaxChainLength() {
return 8;
}
......
......@@ -133,7 +133,7 @@ public class DefaultBootstrapper {
* @param type the method signature at the call site
* @return a new {@link MonomorphicCallSite} linked with the default dynamic linker.
*/
public static CallSite publicBootstrap(@SuppressWarnings("unused") MethodHandles.Lookup caller, String name, MethodType type) {
public static CallSite publicBootstrap(MethodHandles.Lookup caller, String name, MethodType type) {
return bootstrapInternal(MethodHandles.publicLookup(), name, type);
}
......
......@@ -97,6 +97,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.beans.GuardedInvocationComponent.ValidationType;
import jdk.internal.dynalink.linker.GuardedInvocation;
......
......@@ -148,6 +148,7 @@ class OverloadedDynamicMethod extends DynamicMethod {
}
}
@SuppressWarnings("fallthrough")
@Override
public MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
final MethodType callSiteType = callSiteDescriptor.getMethodType();
......
......@@ -124,6 +124,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
}
// load engine.js and return content as a char[]
@SuppressWarnings("resource")
private static char[] loadEngineJSSource() {
final String script = "resources/engine.js";
try {
......@@ -212,9 +213,8 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
// just create normal SimpleBindings.
// We use same 'global' for all Bindings.
return new SimpleBindings();
} else {
return createGlobalMirror(null);
}
return createGlobalMirror(null);
}
// Compilable methods
......
......@@ -414,30 +414,34 @@ enum CompilationPhase {
compiler.getCodeInstaller().verify(bytecode);
}
// should code be dumped to disk - only valid in compile_only
// mode?
// should code be dumped to disk - only valid in compile_only mode?
if (env._dest_dir != null && env._compile_only) {
final String fileName = className.replace('.', File.separatorChar) + ".class";
final int index = fileName.lastIndexOf(File.separatorChar);
final int index = fileName.lastIndexOf(File.separatorChar);
final File dir;
if (index != -1) {
final File dir = new File(fileName.substring(0, index));
try {
if (!dir.exists() && !dir.mkdirs()) {
throw new IOException(dir.toString());
}
final File file = new File(env._dest_dir, fileName);
try (final FileOutputStream fos = new FileOutputStream(file)) {
fos.write(bytecode);
}
} catch (final IOException e) {
Compiler.LOG.warning("Skipping class dump for ",
className,
": ",
ECMAErrors.getMessage(
"io.error.cant.write",
dir.toString()));
dir = new File(env._dest_dir, fileName.substring(0, index));
} else {
dir = new File(env._dest_dir);
}
try {
if (!dir.exists() && !dir.mkdirs()) {
throw new IOException(dir.toString());
}
final File file = new File(env._dest_dir, fileName);
try (final FileOutputStream fos = new FileOutputStream(file)) {
fos.write(bytecode);
}
Compiler.LOG.info("Wrote class to '" + file.getAbsolutePath() + '\'');
} catch (final IOException e) {
Compiler.LOG.warning("Skipping class dump for ",
className,
": ",
ECMAErrors.getMessage(
"io.error.cant.write",
dir.toString()));
}
}
}
......
......@@ -40,6 +40,7 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
import jdk.nashorn.internal.objects.annotations.Attribute;
import jdk.nashorn.internal.objects.annotations.Constructor;
......@@ -632,6 +633,7 @@ public final class NativeArray extends ScriptObject {
return new NativeArray(list.toArray());
}
@SuppressWarnings("null")
private static void concatToList(final ArrayList<Object> list, final Object obj) {
final boolean isScriptArray = isArray(obj);
final boolean isScriptObject = isScriptArray || obj instanceof ScriptObject;
......
......@@ -65,10 +65,9 @@ public final class NativeRegExp extends ScriptObject {
private RegExp regexp;
// Reference to global object needed to support static RegExp properties
private Global globalObject;
private final Global globalObject;
// initialized by nasgen
@SuppressWarnings("unused")
private static PropertyMap $nasgenmap$;
static PropertyMap getInitialMap() {
......
......@@ -894,7 +894,6 @@ public final class Context {
return script;
}
@SuppressWarnings("static-method")
private ScriptLoader createNewLoader() {
return AccessController.doPrivileged(
new PrivilegedAction<ScriptLoader>() {
......
......@@ -44,6 +44,7 @@ final class DebuggerSupport {
* Hook to force the loading of the DebuggerValueDesc class so that it is
* available to external debuggers.
*/
@SuppressWarnings("unused")
DebuggerValueDesc forceLoad = new DebuggerValueDesc(null, false, null, null);
}
......@@ -111,9 +112,8 @@ final class DebuggerSupport {
if (value instanceof ScriptObject && !(value instanceof ScriptFunction)) {
final ScriptObject object = (ScriptObject)value;
return new DebuggerValueDesc(name, !object.isEmpty(), value, objectAsString(object, all, duplicates));
} else {
return new DebuggerValueDesc(name, false, value, valueAsString(value));
}
return new DebuggerValueDesc(name, false, value, valueAsString(value));
}
/**
......@@ -199,7 +199,7 @@ final class DebuggerSupport {
final String valueAsString = descs[i].valueAsString;
sb.append(descs[i].key);
sb.append(": ");
sb.append(descs[i].valueAsString);
sb.append(valueAsString);
}
}
......@@ -239,9 +239,8 @@ final class DebuggerSupport {
case FUNCTION:
if (value instanceof ScriptFunction) {
return ((ScriptFunction)value).toSource();
} else {
return value.toString();
}
return value.toString();
default:
return value.toString();
......
......@@ -52,6 +52,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.linker.GuardedInvocation;
import jdk.internal.dynalink.linker.LinkRequest;
......@@ -1149,12 +1150,12 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
if (newProto == null || newProto instanceof ScriptObject) {
// check for circularity
ScriptObject proto = (ScriptObject)newProto;
while (proto != null) {
if (proto == this) {
ScriptObject p = (ScriptObject)newProto;
while (p != null) {
if (p == this) {
throw typeError("circular.__proto__.set", ScriptRuntime.safeToString(this));
}
proto = proto.getProto();
p = p.getProto();
}
setProto((ScriptObject)newProto);
} else {
......@@ -2017,6 +2018,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
* @param request the link request
* @return GuardedInvocation to be invoked at call site.
*/
@SuppressWarnings("null")
public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
final FindProperty find = findProperty(NO_SUCH_PROPERTY_NAME, true);
......
......@@ -39,7 +39,6 @@ import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType;
import jdk.nashorn.internal.runtime.regexp.joni.constants.OPCode;
import jdk.nashorn.internal.runtime.regexp.joni.constants.OPSize;
import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo;
import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType;
final class ArrayCompiler extends Compiler {
private int[] code;
......@@ -345,6 +344,7 @@ final class ArrayCompiler extends Compiler {
private static final int QUANTIFIER_EXPAND_LIMIT_SIZE = 50; // was 50
@SuppressWarnings("unused")
private static boolean cknOn(int ckn) {
return ckn > 0;
}
......@@ -879,6 +879,7 @@ final class ArrayCompiler extends Compiler {
}
}
@SuppressWarnings("unused")
private void addStateCheckNum(int num) {
addInt(num);
}
......@@ -887,6 +888,7 @@ final class ArrayCompiler extends Compiler {
addInt(addr);
}
@SuppressWarnings("unused")
private void addAbsAddr(int addr) {
addInt(addr);
}
......
......@@ -29,6 +29,7 @@ public final class BitSet {
final int[] bits = new int[BITSET_SIZE];
private static final int BITS_TO_STRING_WRAP = 4;
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append("BitSet");
......
......@@ -96,6 +96,7 @@ class ByteCodeMachine extends StackMachine {
}
}
@Override
protected final int matchAt(int range, int sstart, int sprev) {
this.range = range;
this.sstart = sstart;
......@@ -731,8 +732,6 @@ class ByteCodeMachine extends StackMachine {
// STRING_CMP
while(n-- > 0) if (chars[pstart++] != chars[s++]) {opFail(); return;}
int len;
// beyond string check
if (sprev < range) {
while (sprev + 1 < s) sprev++;
......@@ -768,7 +767,6 @@ class ByteCodeMachine extends StackMachine {
if (!stringCmpIC(regex.caseFoldFlag, pstart, this, n, end)) {opFail(); return;}
s = value;
int len;
// if (sprev < chars.length)
while (sprev + 1 < s) sprev++;
}
......@@ -796,8 +794,6 @@ class ByteCodeMachine extends StackMachine {
s = swork;
int len;
// beyond string check
if (sprev < range) {
while (sprev + 1 < s) sprev++;
......@@ -829,7 +825,6 @@ class ByteCodeMachine extends StackMachine {
if (!stringCmpIC(regex.caseFoldFlag, pstart, this, n, end)) continue loop; // STRING_CMP_VALUE_IC
s = value;
int len;
// if (sprev < chars.length)
while (sprev + 1 < s) sprev++;
......@@ -902,7 +897,6 @@ class ByteCodeMachine extends StackMachine {
sprev = s;
if (backrefMatchAtNestedLevel(ic != 0, regex.caseFoldFlag, level, tlen, ip)) { // (s) and (end) implicit
int len;
while (sprev + 1 < s) sprev++;
ip += tlen; // * SIZE_MEMNUM
} else {
......
......@@ -58,6 +58,7 @@ public final class CodeRangeBuffer implements Cloneable {
used = orig.used;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("CodeRange");
......
......@@ -139,6 +139,7 @@ class Lexer extends ScannerSupport {
}
}
@SuppressWarnings("fallthrough")
/* \M-, \C-, \c, or \... */
private int fetchEscapedValue() {
if (!left()) {
......
......@@ -297,8 +297,6 @@ class Parser extends Lexer {
throw new SyntaxException(ERR_END_PATTERN_IN_GROUP);
}
boolean listCapture = false;
fetch();
switch(c) {
case ':': /* (?:...) grouping only */
......
......@@ -32,6 +32,7 @@ public final class Region {
this.end = new int[num];
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Region: \n");
......
......@@ -21,9 +21,6 @@ package jdk.nashorn.internal.runtime.regexp.joni;
import jdk.nashorn.internal.runtime.regexp.joni.encoding.IntHolder;
import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages;
import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException;
import jdk.nashorn.internal.runtime.regexp.joni.exception.SyntaxException;
import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException;
abstract class ScannerSupport extends IntHolder implements ErrorMessages {
......
......@@ -28,14 +28,17 @@ public abstract class SearchAlgorithm {
public static final SearchAlgorithm NONE = new SearchAlgorithm() {
@Override
public final String getName() {
return "NONE";
}
@Override
public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) {
return textP;
}
@Override
public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) {
return textP;
}
......@@ -44,10 +47,12 @@ public abstract class SearchAlgorithm {
public static final SearchAlgorithm SLOW = new SearchAlgorithm() {
@Override
public final String getName() {
return "EXACT";
}
@Override
public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) {
char[] target = regex.exact;
int targetP = regex.exactP;
......@@ -78,6 +83,7 @@ public abstract class SearchAlgorithm {
return -1;
}
@Override
public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) {
char[] target = regex.exact;
int targetP = regex.exactP;
......@@ -114,10 +120,12 @@ public abstract class SearchAlgorithm {
this.caseFoldFlag = regex.caseFoldFlag;
}
@Override
public final String getName() {
return "EXACT_IC";
}
@Override
public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) {
char[] target = regex.exact;
int targetP = regex.exactP;
......@@ -136,6 +144,7 @@ public abstract class SearchAlgorithm {
return -1;
}
@Override
public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) {
char[] target = regex.exact;
int targetP = regex.exactP;
......@@ -163,14 +172,16 @@ public abstract class SearchAlgorithm {
}
return true;
}
};
}
public static final SearchAlgorithm BM = new SearchAlgorithm() {
@Override
public final String getName() {
return "EXACT_BM";
}
@Override
public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) {
char[] target = regex.exact;
int targetP = regex.exactP;
......@@ -212,6 +223,7 @@ public abstract class SearchAlgorithm {
private static final int BM_BACKWARD_SEARCH_LENGTH_THRESHOLD = 100;
@Override
public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) {
char[] target = regex.exact;
int targetP = regex.exactP;
......@@ -263,10 +275,12 @@ public abstract class SearchAlgorithm {
public static final SearchAlgorithm MAP = new SearchAlgorithm() {
@Override
public final String getName() {
return "MAP";
}
@Override
public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) {
byte[] map = regex.map;
int s = textP;
......@@ -278,6 +292,7 @@ public abstract class SearchAlgorithm {
return -1;
}
@Override
public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) {
byte[] map = regex.map;
int s = textStart;
......
......@@ -458,7 +458,7 @@ abstract class StackMachine extends Matcher implements StackType {
isNull = 0;
break;
} else if (endp != s) {
isNull = -1;; /* empty, but position changed */
isNull = -1; /* empty, but position changed */
}
}
k++;
......
......@@ -24,6 +24,7 @@ package jdk.nashorn.internal.runtime.regexp.joni;
*/
public interface WarnCallback {
WarnCallback DEFAULT = new WarnCallback() {
@Override
public void warn(String message) {
System.err.println(message);
}
......
......@@ -19,7 +19,6 @@
*/
package jdk.nashorn.internal.runtime.regexp.joni.ast;
import jdk.nashorn.internal.runtime.regexp.joni.Config;
import jdk.nashorn.internal.runtime.regexp.joni.Option;
import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType;
......
......@@ -35,7 +35,7 @@ public abstract class Node implements NodeType {
}
protected void setChild(Node tgt){} // default definition
protected Node getChild(){return null;}; // default definition
protected Node getChild(){return null;} // default definition
public void swap(Node with) {
Node tmp;
......@@ -74,6 +74,7 @@ public abstract class Node implements NodeType {
return getName() + ":0x" + Integer.toHexString(System.identityHashCode(this));
}
@Override
public final String toString() {
StringBuilder s = new StringBuilder();
s.append("<" + getAddressName() + " (" + (parent == null ? "NULL" : parent.getAddressName()) + ")>");
......
......@@ -223,6 +223,7 @@ public final class QuantifierNode extends StateNode {
other.target = null; // remove target from reduced quantifier
}
@SuppressWarnings("fallthrough")
public int setQuantifier(Node tgt, boolean group, ScanEnvironment env, char[] chars, int p, int end) {
if (lower == 1 && upper == 1) return 1;
......
......@@ -19,8 +19,6 @@
*/
package jdk.nashorn.internal.runtime.regexp.joni.exception;
import jdk.nashorn.internal.runtime.regexp.joni.Config;
public interface ErrorMessages {
/* from jcodings */
......
......@@ -32,13 +32,9 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.stage.Stage;
import javax.script.Invocable;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
......@@ -180,6 +176,7 @@ public class FXShell extends Application {
*
* @return Last evaluation result (discarded.)
*/
@SuppressWarnings("resource")
private Object load(String path) {
try {
FileInputStream file = new FileInputStream(path);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册