diff --git a/deprecatedsrc/org/mozilla/javascript/xml/impl/xmlbeans/XML.java b/deprecatedsrc/org/mozilla/javascript/xml/impl/xmlbeans/XML.java index c8818a56d7..90b6140389 100644 --- a/deprecatedsrc/org/mozilla/javascript/xml/impl/xmlbeans/XML.java +++ b/deprecatedsrc/org/mozilla/javascript/xml/impl/xmlbeans/XML.java @@ -59,7 +59,7 @@ class XML extends XMLObjectImpl final static class XScriptAnnotation extends XmlBookmark implements Serializable { private static final long serialVersionUID = 1L; - + javax.xml.namespace.QName _name; XML _xScriptXML; @@ -721,7 +721,7 @@ private XmlCursor copy (XmlCursor cursToCopy) { cursToCopy.toNextToken(); } - + cursToCopy.copyXml(copyCurs); if (!cursToCopy.toNextSibling()) // If element skip element. { diff --git a/examples/File.java b/examples/File.java index 3af0b2793e..986d99c15e 100644 --- a/examples/File.java +++ b/examples/File.java @@ -73,7 +73,7 @@ public class File extends ScriptableObject { /** - * + * */ private static final long serialVersionUID = 2549960399774237828L; /** diff --git a/examples/Matrix.java b/examples/Matrix.java index d2e2dd8375..c60844e0bf 100644 --- a/examples/Matrix.java +++ b/examples/Matrix.java @@ -54,7 +54,7 @@ * js> defineClass("Matrix") * js> var m = new Matrix(2); // A constructor call, see "Matrix(int dimension)" * js> m // Object.toString will call "Matrix.getClassName()" - * [object Matrix] + * [object Matrix] * js> m[0][0] = 3; * 3 * js> uneval(m[0]); // an array was created automatically! diff --git a/src/org/mozilla/javascript/Arguments.java b/src/org/mozilla/javascript/Arguments.java index 5e3d008e9b..fa60372db6 100644 --- a/src/org/mozilla/javascript/Arguments.java +++ b/src/org/mozilla/javascript/Arguments.java @@ -94,7 +94,7 @@ private Object arg(int index) { } // the following helper methods assume that 0 < index < args.length - + private void putIntoActivation(int index, Object value) { String argName = activation.function.getParamOrVarName(index); activation.put(argName, activation, value); @@ -108,7 +108,7 @@ private Object getFromActivation(int index) { private void replaceArg(int index, Object value) { if (sharedWithActivation(index)) { putIntoActivation(index, value); - } + } synchronized (this) { if (args == activation.originalArgs) { args = args.clone(); @@ -180,7 +180,7 @@ public void put(int index, Scriptable start, Object value) if (arg(index) == NOT_FOUND) { super.put(index, start, value); } else { - replaceArg(index, value); + replaceArg(index, value); } } @@ -189,7 +189,7 @@ public void delete(int index) { if (0 <= index && index < args.length) { removeArg(index); - } + } super.delete(index); } @@ -315,7 +315,7 @@ Object[] getIds(boolean getAll) } if (!getAll) { // avoid adding args which were redefined to non-enumerable for (int i = 0; i < present.length; i++) { - if (!present[i] && super.has(i, this)) { + if (!present[i] && super.has(i, this)) { present[i] = true; extraCount--; } @@ -348,7 +348,7 @@ protected ScriptableObject getOwnPropertyDescriptor(Context cx, Object id) { Object value = arg(index); if (value == NOT_FOUND) { return super.getOwnPropertyDescriptor(cx, id); - } + } if (sharedWithActivation(index)) { value = getFromActivation(index); } @@ -401,7 +401,7 @@ public void defineOwnProperty(Context cx, Object id, ScriptableObject desc) { private NativeCall activation; - private BaseFunction objectCtor; + private BaseFunction objectCtor; // Initially args holds activation.getOriginalArgs(), but any modification // of its elements triggers creation of a copy. If its element holds NOT_FOUND, diff --git a/src/org/mozilla/javascript/BaseFunction.java b/src/org/mozilla/javascript/BaseFunction.java index e642763b21..cd87a8cb4b 100644 --- a/src/org/mozilla/javascript/BaseFunction.java +++ b/src/org/mozilla/javascript/BaseFunction.java @@ -56,7 +56,7 @@ public class BaseFunction extends IdScriptableObject implements Function static void init(Scriptable scope, boolean sealed) { BaseFunction obj = new BaseFunction(); - // Function.prototype attributes: see ECMA 15.3.3.1 + // Function.prototype attributes: see ECMA 15.3.3.1 obj.prototypePropertyAttributes = DONTENUM | READONLY | PERMANENT; obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); } @@ -74,9 +74,9 @@ public BaseFunction(Scriptable scope, Scriptable prototype) public String getClassName() { return "Function"; } - + /** - * Gets the value returned by calling the typeof operator on this object. + * Gets the value returned by calling the typeof operator on this object. * @see org.mozilla.javascript.ScriptableObject#getTypeOf() * @return "function" or "undefined" if {@link #avoidObjectDetection()} returns true */ @@ -250,7 +250,7 @@ protected void initPrototypeId(int id) static boolean isApply(IdFunctionObject f) { return f.hasTag(FUNCTION_TAG) && f.methodId() == Id_apply; } - + static boolean isApplyOrCall(IdFunctionObject f) { if(f.hasTag(FUNCTION_TAG)) { switch(f.methodId()) { @@ -550,7 +550,7 @@ private static Object jsConstructor(Context cx, Scriptable scope, Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", - filename, linep[0]); + filename, linep[0]); } // Compile with explicit interpreter instance to force interpreter @@ -599,7 +599,7 @@ protected int findPrototypeId(String s) private Object prototypeProperty; // For function object instances, attributes are - // {configurable:false, enumerable:false}; + // {configurable:false, enumerable:false}; // see ECMA 15.3.5.2 private int prototypePropertyAttributes = PERMANENT|DONTENUM; } diff --git a/src/org/mozilla/javascript/ClassCache.java b/src/org/mozilla/javascript/ClassCache.java index 1ef86b4aec..1260dd3c93 100644 --- a/src/org/mozilla/javascript/ClassCache.java +++ b/src/org/mozilla/javascript/ClassCache.java @@ -60,7 +60,7 @@ public class ClassCache implements Serializable private transient HashMap> classAdapterCache; private transient HashMap,Object> interfaceAdapterCache; private int generatedClassSerial; - private Scriptable associatedScope; + private Scriptable associatedScope; /** * Search for ClassCache object in the given scope. @@ -155,7 +155,7 @@ public synchronized void setCachingEnabled(boolean enabled) clearCaches(); cachingIsEnabled = enabled; } - + /** * @return a map from classes to associated JavaMembers objects */ @@ -165,7 +165,7 @@ Map,JavaMembers> getClassCacheMap() { } return classTable; } - + Map> getInterfaceAdapterCacheMap() { if (classAdapterCache == null) { @@ -173,7 +173,7 @@ Map> getInterfaceAdapterCacheMap() } return classAdapterCache; } - + /** * @deprecated * The method always returns false. @@ -208,8 +208,8 @@ public final synchronized int newClassSerialNumber() Object getInterfaceAdapter(Class cl) { - return interfaceAdapterCache == null - ? null + return interfaceAdapterCache == null + ? null : interfaceAdapterCache.get(cl); } @@ -222,7 +222,7 @@ synchronized void cacheInterfaceAdapter(Class cl, Object iadapter) interfaceAdapterCache.put(cl, iadapter); } } - + Scriptable getAssociatedScope() { return associatedScope; } diff --git a/src/org/mozilla/javascript/CompilerEnvirons.java b/src/org/mozilla/javascript/CompilerEnvirons.java index d9be273fe4..a558e0a065 100644 --- a/src/org/mozilla/javascript/CompilerEnvirons.java +++ b/src/org/mozilla/javascript/CompilerEnvirons.java @@ -84,7 +84,7 @@ public void initFromContext(Context cx) generatingSource = cx.isGeneratingSource(); activationNames = cx.activationNames; - + // Observer code generation in compiled code : generateObserverCount = cx.generateObserverCount; } diff --git a/src/org/mozilla/javascript/Context.java b/src/org/mozilla/javascript/Context.java index 28dcee82f2..ab5faf657c 100644 --- a/src/org/mozilla/javascript/Context.java +++ b/src/org/mozilla/javascript/Context.java @@ -324,14 +324,14 @@ public class Context public static final Object[] emptyArgs = ScriptRuntime.emptyArgs; /** - * Creates a new Context. The context will be associated with the {@link + * Creates a new Context. The context will be associated with the {@link * ContextFactory#getGlobal() global context factory}. * * Note that the Context must be associated with a thread before * it can be used to execute a script. - * @deprecated this constructor is deprecated because it creates a - * dependency on a static singleton context factory. Use - * {@link ContextFactory#enter()} or + * @deprecated this constructor is deprecated because it creates a + * dependency on a static singleton context factory. Use + * {@link ContextFactory#enter()} or * {@link ContextFactory#call(ContextAction)} instead. If you subclass * this class, consider using {@link #Context(ContextFactory)} constructor * instead in the subclasses' constructors. @@ -340,13 +340,13 @@ public Context() { this(ContextFactory.getGlobal()); } - + /** * Creates a new context. Provided as a preferred super constructor for * subclasses in place of the deprecated default public constructor. * @param factory the context factory associated with this context (most * likely, the one that created the context). Can not be null. The context - * features are inherited from the factory, and the context will also + * features are inherited from the factory, and the context will also * otherwise use its factory's services. * @throws IllegalArgumentException if factory parameter is null. */ @@ -1144,11 +1144,11 @@ public final Object evaluateReader(Scriptable scope, Reader in, return null; } } - + /** * Execute script that may pause execution by capturing a continuation. * Caller must be prepared to catch a ContinuationPending exception - * and resume execution by calling + * and resume execution by calling * {@link #resumeContinuation(Object, Scriptable, Object)}. * @param script The script to execute. Script must have been compiled * with interpreted mode (optimization level -1) @@ -1171,11 +1171,11 @@ public Object executeScriptWithContinuations(Script script, return callFunctionWithContinuations((InterpretedFunction) script, scope, ScriptRuntime.emptyArgs); } - + /** * Call function that may pause execution by capturing a continuation. * Caller must be prepared to catch a ContinuationPending exception - * and resume execution by calling + * and resume execution by calling * {@link #resumeContinuation(Object, Scriptable, Object)}. * @param function The function to call. The function must have been * compiled with interpreted mode (optimization level -1) @@ -1203,10 +1203,10 @@ public Object callFunctionWithContinuations(Callable function, isContinuationsTopCall = true; return ScriptRuntime.doTopCall(function, this, scope, scope, args); } - + /** * Capture a continuation from the current execution. The execution must - * have been started via a call to + * have been started via a call to * {@link #executeScriptWithContinuations(Script, Scriptable)} or * {@link #callFunctionWithContinuations(Callable, Scriptable, Object[])}. * This implies that the code calling @@ -1221,7 +1221,7 @@ public ContinuationPending captureContinuation() { return new ContinuationPending( Interpreter.captureContinuation(this)); } - + /** * Restarts execution of the JavaScript suspended at the call * to {@link #captureContinuation()}. Execution of the code will resume @@ -1230,7 +1230,7 @@ public ContinuationPending captureContinuation() { * Execution of the script will either conclude normally and the * result returned, another continuation will be captured and * thrown, or the script will terminate abnormally and throw an exception. - * @param continuation The value returned by + * @param continuation The value returned by * {@link ContinuationPending#getContinuation()} * @param functionResult This value will appear to the code being resumed * as the result of the function that captured the continuation @@ -1336,7 +1336,7 @@ public final Script compileReader(Reader in, String sourceName, * * @param source the source string * @param sourceName a string describing the source, such as a filename - * @param lineno the starting line number for reporting errors. Use + * @param lineno the starting line number for reporting errors. Use * 0 if the line number is unknown. * @param securityDomain an arbitrary object that specifies security * information about the origin or owner of the script. For @@ -1984,17 +1984,17 @@ public synchronized final void setClassShutter(ClassShutter shutter) classShutter = shutter; hasClassShutter = true; } - + final synchronized ClassShutter getClassShutter() { return classShutter; } - + public interface ClassShutterSetter { public void setClassShutter(ClassShutter shutter); public ClassShutter getClassShutter(); } - + public final synchronized ClassShutterSetter getClassShutterSetter() { if (hasClassShutter) return null; @@ -2197,10 +2197,10 @@ public boolean hasFeature(int featureIndex) * Returns an object which specifies an E4X implementation to use within * this Context. Note that the XMLLib.Factory interface should * be considered experimental. - * + * * The default implementation uses the implementation provided by this * Context's {@link ContextFactory}. - * + * * @return An XMLLib.Factory. Should not return null if * {@link #FEATURE_E4X} is enabled. See {@link #hasFeature}. */ diff --git a/src/org/mozilla/javascript/ContextFactory.java b/src/org/mozilla/javascript/ContextFactory.java index 00e5273cd5..aa2874f39c 100644 --- a/src/org/mozilla/javascript/ContextFactory.java +++ b/src/org/mozilla/javascript/ContextFactory.java @@ -211,12 +211,12 @@ public synchronized static void initGlobal(ContextFactory factory) hasCustomGlobal = true; global = factory; } - + public interface GlobalSetter { public void setContextFactoryGlobal(ContextFactory factory); public ContextFactory getContextFactoryGlobal(); } - + public synchronized static GlobalSetter getGlobalSetter() { if (hasCustomGlobal) { throw new IllegalStateException(); @@ -232,7 +232,7 @@ public ContextFactory getContextFactoryGlobal() { } return new GlobalSetterImpl(); } - + /** * Create new {@link Context} instance to be associated with the current * thread. @@ -334,10 +334,10 @@ private boolean isDom3Present() { * {@link org.mozilla.javascript.xml.XMLLib.Factory XMLLib.Factory} * to be used by the Context instances produced by this * factory. See {@link Context#getE4xImplementationFactory} for details. - * + * * May return null, in which case E4X functionality is not supported in * Rhino. - * + * * The default implementation now prefers the DOM3 E4X implementation. */ protected org.mozilla.javascript.xml.XMLLib.Factory @@ -536,16 +536,16 @@ public final Object call(ContextAction action) } /** - * Get a context associated with the current thread, creating one if need - * be. The Context stores the execution state of the JavaScript engine, so - * it is required that the context be entered before execution may begin. - * Once a thread has entered a Context, then getCurrentContext() may be + * Get a context associated with the current thread, creating one if need + * be. The Context stores the execution state of the JavaScript engine, so + * it is required that the context be entered before execution may begin. + * Once a thread has entered a Context, then getCurrentContext() may be * called to find the context that is associated with the current thread. *

- * Calling enterContext() will return either the Context - * currently associated with the thread, or will create a new context and - * associate it with the current thread. Each call to - * enterContext() must have a matching call to + * Calling enterContext() will return either the Context + * currently associated with the thread, or will create a new context and + * associate it with the current thread. Each call to + * enterContext() must have a matching call to * {@link Context#exit()}. *

      *      Context cx = contextFactory.enterContext();
@@ -556,8 +556,8 @@ public final Object call(ContextAction action)
      *          Context.exit();
      *      }
      * 
- * Instead of using enterContext(), exit() pair consider - * using {@link #call(ContextAction)} which guarantees proper association + * Instead of using enterContext(), exit() pair consider + * using {@link #call(ContextAction)} which guarantees proper association * of Context instances with the current thread. * With this method the above example becomes: *
@@ -578,7 +578,7 @@ public Context enterContext()
     {
         return enterContext(null);
     }
-    
+
     /**
      * @deprecated use {@link #enterContext()} instead
      * @return a Context associated with the current thread
@@ -597,7 +597,7 @@ public final void exit()
     }
 
     /**
-     * Get a Context associated with the current thread, using the given 
+     * Get a Context associated with the current thread, using the given
      * Context if need be.
      * 

* The same as enterContext() except that cx diff --git a/src/org/mozilla/javascript/ContinuationPending.java b/src/org/mozilla/javascript/ContinuationPending.java index deff4f6bcf..18239e4049 100644 --- a/src/org/mozilla/javascript/ContinuationPending.java +++ b/src/org/mozilla/javascript/ContinuationPending.java @@ -39,7 +39,7 @@ package org.mozilla.javascript; /** - * Exception thrown by + * Exception thrown by * {@link org.mozilla.javascript.Context#executeScriptWithContinuations(Script, Scriptable)} * and {@link org.mozilla.javascript.Context#callFunctionWithContinuations(Callable, Scriptable, Object[])} * when execution encounters a continuation captured by @@ -52,7 +52,7 @@ public class ContinuationPending extends RuntimeException { private static final long serialVersionUID = 4956008116771118856L; private NativeContinuation continuationState; private Object applicationState; - + /** * Construct a ContinuationPending exception. Internal call only; * users of the API should get continuations created on their behalf by @@ -63,24 +63,24 @@ public class ContinuationPending extends RuntimeException { ContinuationPending(NativeContinuation continuationState) { this.continuationState = continuationState; } - + /** * Get continuation object. The only - * use for this object is to be passed to + * use for this object is to be passed to * {@link org.mozilla.javascript.Context#resumeContinuation(Object, Scriptable, Object)}. * @return continuation object */ public Object getContinuation() { return continuationState; } - + /** * @return internal continuation state */ NativeContinuation getContinuationState() { return continuationState; } - + /** * Store an arbitrary object that applications can use to associate * their state with the continuation. diff --git a/src/org/mozilla/javascript/DToA.java b/src/org/mozilla/javascript/DToA.java index ad2a68a96c..b2feacbc51 100644 --- a/src/org/mozilla/javascript/DToA.java +++ b/src/org/mozilla/javascript/DToA.java @@ -793,7 +793,7 @@ else if ((j1 = -k) != 0) { } else if (d < 0.5 - eps) { - stripTrailingZeroes(buf); + stripTrailingZeroes(buf); // while(*--s == '0') ; // s++; return k + 1; @@ -1151,7 +1151,7 @@ else if (i < 4) { return k + 1; } - private static void + private static void stripTrailingZeroes(StringBuffer buf) { // while(*--s == '0') ; diff --git a/src/org/mozilla/javascript/Decompiler.java b/src/org/mozilla/javascript/Decompiler.java index ee453a3d52..afb78b5302 100644 --- a/src/org/mozilla/javascript/Decompiler.java +++ b/src/org/mozilla/javascript/Decompiler.java @@ -753,11 +753,11 @@ else if (nextToken == Token.NAME) { case Token.CONST: result.append("const "); break; - + case Token.YIELD: result.append("yield "); break; - + case Token.NOT: result.append('!'); break; diff --git a/src/org/mozilla/javascript/DefaultErrorReporter.java b/src/org/mozilla/javascript/DefaultErrorReporter.java index c7d93d4845..f6a0d5c9b0 100644 --- a/src/org/mozilla/javascript/DefaultErrorReporter.java +++ b/src/org/mozilla/javascript/DefaultErrorReporter.java @@ -86,7 +86,7 @@ public void error(String message, String sourceURI, int line, error = TYPE_ERROR_NAME; message = message.substring(prefix.length()); } - throw ScriptRuntime.constructError(error, message, sourceURI, + throw ScriptRuntime.constructError(error, message, sourceURI, line, lineText, lineOffset); } if (chainedReporter != null) { diff --git a/src/org/mozilla/javascript/DefiningClassLoader.java b/src/org/mozilla/javascript/DefiningClassLoader.java index 9723d9c618..a42c9b04db 100644 --- a/src/org/mozilla/javascript/DefiningClassLoader.java +++ b/src/org/mozilla/javascript/DefiningClassLoader.java @@ -59,7 +59,7 @@ public Class defineClass(String name, byte[] data) { // Use our own protection domain for the generated classes. // TODO: we might want to use a separate protection domain for classes // compiled from scripts, based on where the script was loaded from. - return super.defineClass(name, data, 0, data.length, + return super.defineClass(name, data, 0, data.length, SecurityUtilities.getProtectionDomain(getClass())); } diff --git a/src/org/mozilla/javascript/IRFactory.java b/src/org/mozilla/javascript/IRFactory.java index c97e37a713..5cb85ed271 100644 --- a/src/org/mozilla/javascript/IRFactory.java +++ b/src/org/mozilla/javascript/IRFactory.java @@ -613,7 +613,7 @@ private Node transformIf(IfStatement n) { decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node ifTrue = transform(n.getThenPart()); - Node ifFalse = null; + Node ifFalse = null; if (n.getElsePart() != null) { decompiler.addToken(Token.RC); decompiler.addToken(Token.ELSE); @@ -2231,7 +2231,7 @@ void decompilePropertyGet(PropertyGet node) { decompiler.addToken(Token.DOT); decompile(node.getProperty()); } - + // only used for destructuring forms void decompileElementGet(ElementGet node) { decompile(node.getTarget()); diff --git a/src/org/mozilla/javascript/IdScriptableObject.java b/src/org/mozilla/javascript/IdScriptableObject.java index 4a6f2d8fb3..c883366fb6 100644 --- a/src/org/mozilla/javascript/IdScriptableObject.java +++ b/src/org/mozilla/javascript/IdScriptableObject.java @@ -778,7 +778,7 @@ private ScriptableObject getBuiltInDescriptor(String name) { value = getInstanceIdValue(id); attr = (info >>> 16); return buildDataDescriptor(scope, value, attr); - } + } if (prototypeValues != null) { int id = prototypeValues.findId(name); if (id != 0) { diff --git a/src/org/mozilla/javascript/InterpretedFunction.java b/src/org/mozilla/javascript/InterpretedFunction.java index c26890b1f9..e1e2d6dad3 100644 --- a/src/org/mozilla/javascript/InterpretedFunction.java +++ b/src/org/mozilla/javascript/InterpretedFunction.java @@ -147,10 +147,10 @@ public String getFunctionName() /** * Calls the function. - * @param cx the current context + * @param cx the current context * @param scope the scope used for the call * @param thisObj the value of "this" - * @param args function arguments. Must not be null. You can use + * @param args function arguments. Must not be null. You can use * {@link ScriptRuntime#emptyArgs} to pass empty arguments. * @return the result of the function call. */ @@ -178,7 +178,7 @@ public Object exec(Context cx, Scriptable scope) return Interpreter.interpret( this, cx, scope, scope, ScriptRuntime.emptyArgs); } - + public boolean isScript() { return idata.itsFunctionType == 0; } diff --git a/src/org/mozilla/javascript/Interpreter.java b/src/org/mozilla/javascript/Interpreter.java index 594db80895..0dadab25f6 100644 --- a/src/org/mozilla/javascript/Interpreter.java +++ b/src/org/mozilla/javascript/Interpreter.java @@ -1677,7 +1677,7 @@ private static Object interpretLoop(Context cx, CallFrame frame, } } - // Bug 447697 -- make best effort to keep __noSuchMethod__ within this + // Bug 447697 -- make best effort to keep __noSuchMethod__ within this // interpreter loop invocation if (fun instanceof NoSuchMethodShim) { // get the shim and the actual method @@ -1698,7 +1698,7 @@ private static Object interpretLoop(Context cx, CallFrame frame, cx.lastInterpreterFrame = frame; frame.savedCallOp = op; frame.savedStackTop = stackTop; - stack[stackTop] = fun.call(cx, calleeScope, funThisObj, + stack[stackTop] = fun.call(cx, calleeScope, funThisObj, getArgsArray(stack, sDbl, stackTop + 2, indexReg)); continue Loop; @@ -2406,7 +2406,7 @@ private static CallFrame initFrameForNoSuchMethod(Context cx, argsArray = new Object[2]; argsArray[0] = noSuchMethodShim.methodName; argsArray[1] = cx.newArray(calleeScope, elements); - + // exactly the same as if it's a regular InterpretedFunction CallFrame callParentFrame = frame; CallFrame calleeFrame = new CallFrame(); @@ -2414,7 +2414,7 @@ private static CallFrame initFrameForNoSuchMethod(Context cx, callParentFrame = frame.parentFrame; exitFrame(cx, frame, null); } - // init the frame with the underlying method with the + // init the frame with the underlying method with the // adjusted args array and shim's function initFrame(cx, calleeScope, funThisObj, argsArray, null, 0, 2, ifun, callParentFrame, calleeFrame); @@ -2424,7 +2424,7 @@ private static CallFrame initFrameForNoSuchMethod(Context cx, } return calleeFrame; } - + private static boolean shallowEquals(Object[] stack, double[] sDbl, int stackTop) { @@ -2913,7 +2913,7 @@ private static void setCallResult(CallFrame frame, } frame.savedCallOp = 0; } - + public static NativeContinuation captureContinuation(Context cx) { if (cx.lastInterpreterFrame == null || !(cx.lastInterpreterFrame instanceof CallFrame)) @@ -2953,11 +2953,11 @@ private static NativeContinuation captureContinuation(Context cx, CallFrame fram outermost = x; x = x.parentFrame; } - + if (requireContinuationsTopFrame) { while (outermost.parentFrame != null) outermost = outermost.parentFrame; - + if (!outermost.isContinuationsTopFrame) { throw new IllegalStateException("Cannot capture continuation " + "from JavaScript code not called directly by " + @@ -2965,7 +2965,7 @@ private static NativeContinuation captureContinuation(Context cx, CallFrame fram "callFunctionWithContinuations"); } } - + c.initImplementation(frame); return c; } diff --git a/src/org/mozilla/javascript/JavaAdapter.java b/src/org/mozilla/javascript/JavaAdapter.java index cd10f63547..f1a335a629 100644 --- a/src/org/mozilla/javascript/JavaAdapter.java +++ b/src/org/mozilla/javascript/JavaAdapter.java @@ -475,13 +475,13 @@ static Method[] getOverridableMethods(Class clazz) } return list.toArray(new Method[list.size()]); } - - private static void appendOverridableMethods(Class c, + + private static void appendOverridableMethods(Class c, ArrayList list, HashSet skip) { Method[] methods = c.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { - String methodKey = methods[i].getName() + + String methodKey = methods[i].getName() + getMethodSignature(methods[i], methods[i].getParameterTypes()); if (skip.contains(methodKey)) @@ -522,7 +522,7 @@ static Class loadAdapterClass(String className, byte[] classBytes) else { staticDomain = null; } - GeneratedClassLoader loader = SecurityController.createLoader(null, + GeneratedClassLoader loader = SecurityController.createLoader(null, staticDomain); Class result = loader.defineClass(className, classBytes); loader.linkClass(result); diff --git a/src/org/mozilla/javascript/JavaMembers.java b/src/org/mozilla/javascript/JavaMembers.java index 5379902dc4..90ae129225 100644 --- a/src/org/mozilla/javascript/JavaMembers.java +++ b/src/org/mozilla/javascript/JavaMembers.java @@ -322,12 +322,12 @@ private Object getExplicitFunction(Scriptable scope, String name, /** * Retrieves mapping of methods to accessible methods for a class. - * In case the class is not public, retrieves methods with same - * signature as its public methods from public superclasses and - * interfaces (if they exist). Basically upcasts every method to the + * In case the class is not public, retrieves methods with same + * signature as its public methods from public superclasses and + * interfaces (if they exist). Basically upcasts every method to the * nearest accessible method. */ - private static Method[] discoverAccessibleMethods(Class clazz, + private static Method[] discoverAccessibleMethods(Class clazz, boolean includeProtected, boolean includePrivate) { @@ -335,8 +335,8 @@ private static Method[] discoverAccessibleMethods(Class clazz, discoverAccessibleMethods(clazz, map, includeProtected, includePrivate); return map.values().toArray(new Method[map.size()]); } - - private static void discoverAccessibleMethods(Class clazz, + + private static void discoverAccessibleMethods(Class clazz, Map map, boolean includeProtected, boolean includePrivate) { @@ -349,7 +349,7 @@ private static void discoverAccessibleMethods(Class clazz, for (int i = 0; i < methods.length; i++) { Method method = methods[i]; int mods = method.getModifiers(); - + if (Modifier.isPublic(mods) || Modifier.isProtected(mods) || includePrivate) @@ -370,7 +370,7 @@ private static void discoverAccessibleMethods(Class clazz, Method[] methods = clazz.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; - MethodSignature sig + MethodSignature sig = new MethodSignature(method); if (!map.containsKey(sig)) map.put(sig, method); @@ -416,18 +416,18 @@ private static final class MethodSignature { private final String name; private final Class[] args; - + private MethodSignature(String name, Class[] args) { this.name = name; this.args = args; } - + MethodSignature(Method method) { this(method.getName(), method.getParameterTypes()); } - + @Override public boolean equals(Object o) { @@ -438,14 +438,14 @@ public boolean equals(Object o) } return false; } - + @Override public int hashCode() { return name.hashCode() ^ args.length; } } - + private void reflect(Scriptable scope, boolean includeProtected) { // We reflect methods first, because we want overloaded field/method @@ -578,7 +578,7 @@ private void reflect(Scriptable scope, boolean includeProtected) boolean memberIsGetMethod = name.startsWith("get"); boolean memberIsSetMethod = name.startsWith("set"); boolean memberIsIsMethod = name.startsWith("is"); - if (memberIsGetMethod || memberIsIsMethod + if (memberIsGetMethod || memberIsIsMethod || memberIsSetMethod) { // Double check name component. String nameComponent @@ -636,14 +636,14 @@ private void reflect(Scriptable scope, boolean includeProtected) if (member instanceof NativeJavaMethod) { NativeJavaMethod njmSet = (NativeJavaMethod)member; if (getter != null) { - // We have a getter. Now, do we have a matching + // We have a getter. Now, do we have a matching // setter? Class type = getter.method().getReturnType(); setter = extractSetMethod(type, njmSet.methods, isStatic); } else { // No getter, find any set method - setter = extractSetMethod(njmSet.methods, + setter = extractSetMethod(njmSet.methods, isStatic); } if (njmSet.methods.length > 1) { diff --git a/src/org/mozilla/javascript/LazilyLoadedCtor.java b/src/org/mozilla/javascript/LazilyLoadedCtor.java index caf11afa56..a1d72c98ef 100644 --- a/src/org/mozilla/javascript/LazilyLoadedCtor.java +++ b/src/org/mozilla/javascript/LazilyLoadedCtor.java @@ -50,7 +50,7 @@ */ public final class LazilyLoadedCtor implements java.io.Serializable { private static final long serialVersionUID = 1L; - + private static final int STATE_BEFORE_INIT = 0; private static final int STATE_INITIALIZING = 1; private static final int STATE_WITH_VALUE = 2; @@ -63,7 +63,7 @@ public final class LazilyLoadedCtor implements java.io.Serializable { private Object initializedValue; private int state; - public LazilyLoadedCtor(ScriptableObject scope, String propertyName, + public LazilyLoadedCtor(ScriptableObject scope, String propertyName, String className, boolean sealed) { this(scope, propertyName, className, sealed, false); @@ -129,7 +129,7 @@ public Object run() return buildValue0(); } } - + private Object buildValue0() { Class cl = cast(Kit.classOrNull(className)); @@ -160,7 +160,7 @@ private Object buildValue0() } return Scriptable.NOT_FOUND; } - + @SuppressWarnings({"unchecked"}) private Class cast(Class cl) { return (Class)cl; diff --git a/src/org/mozilla/javascript/MemberBox.java b/src/org/mozilla/javascript/MemberBox.java index 8a50fe88b3..34411e1978 100644 --- a/src/org/mozilla/javascript/MemberBox.java +++ b/src/org/mozilla/javascript/MemberBox.java @@ -178,9 +178,9 @@ Object invoke(Object target, Object[] args) do { e = ((InvocationTargetException) e).getTargetException(); } while ((e instanceof InvocationTargetException)); - if (e instanceof ContinuationPending) + if (e instanceof ContinuationPending) throw (ContinuationPending) e; - throw Context.throwAsScriptRuntimeEx(e); + throw Context.throwAsScriptRuntimeEx(e); } catch (Exception ex) { throw Context.throwAsScriptRuntimeEx(ex); } diff --git a/src/org/mozilla/javascript/NativeArray.java b/src/org/mozilla/javascript/NativeArray.java index 2f2f92ff64..99c9567800 100644 --- a/src/org/mozilla/javascript/NativeArray.java +++ b/src/org/mozilla/javascript/NativeArray.java @@ -79,7 +79,7 @@ static void init(Scriptable scope, boolean sealed) NativeArray obj = new NativeArray(0); obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); } - + static int getMaximumInitialCapacity() { return maximumInitialCapacity; } @@ -157,7 +157,7 @@ protected void setInstanceIdValue(int id, Object value) } super.setInstanceIdValue(id, value); } - + @Override protected void fillConstructorProperties(IdFunctionObject ctor) { @@ -281,7 +281,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, case ConstructorId_isArray: return args.length > 0 && (args[0] instanceof NativeArray); - + case Id_constructor: { boolean inNewExpr = (thisObj == null); if (!inNewExpr) { @@ -290,53 +290,53 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, } return jsConstructor(cx, scope, args); } - + case Id_toString: return toStringHelper(cx, scope, thisObj, cx.hasFeature(Context.FEATURE_TO_STRING_AS_SOURCE), false); - + case Id_toLocaleString: return toStringHelper(cx, scope, thisObj, false, true); - + case Id_toSource: return toStringHelper(cx, scope, thisObj, true, false); - + case Id_join: return js_join(cx, thisObj, args); - + case Id_reverse: return js_reverse(cx, thisObj, args); - + case Id_sort: return js_sort(cx, scope, thisObj, args); - + case Id_push: return js_push(cx, thisObj, args); - + case Id_pop: return js_pop(cx, thisObj, args); - + case Id_shift: return js_shift(cx, thisObj, args); - + case Id_unshift: return js_unshift(cx, thisObj, args); - + case Id_splice: return js_splice(cx, scope, thisObj, args); - + case Id_concat: return js_concat(cx, scope, thisObj, args); - + case Id_slice: return js_slice(cx, thisObj, args); - + case Id_indexOf: return indexOfHelper(cx, thisObj, args, false); - + case Id_lastIndexOf: return indexOfHelper(cx, thisObj, args, true); - + case Id_every: case Id_filter: case Id_forEach: @@ -617,7 +617,7 @@ public long getLength() { public long jsGet_length() { return getLength(); } - + /** * Change the value of the internal flag that determines whether all * storage is handed by a dense backing array rather than an associative @@ -1531,7 +1531,7 @@ else if (start < 0) /** * Implements the methods "every", "filter", "forEach", "map", and "some". */ - private Object iterativeMethod(Context cx, int id, Scriptable scope, + private Object iterativeMethod(Context cx, int id, Scriptable scope, Scriptable thisObj, Object[] args) { Object callbackArg = args.length > 0 ? args[0] : Undefined.instance; @@ -1900,7 +1900,7 @@ protected int findPrototypeId(String s) // #/generated# return id; } - + private static final int Id_constructor = 1, Id_toString = 2, @@ -1929,7 +1929,7 @@ protected int findPrototypeId(String s) MAX_PROTOTYPE_ID = 23; // #/string_id_map# - + private static final int ConstructorId_join = -Id_join, ConstructorId_reverse = -Id_reverse, diff --git a/src/org/mozilla/javascript/NativeDate.java b/src/org/mozilla/javascript/NativeDate.java index 43dedd2784..cbdd03aa2a 100644 --- a/src/org/mozilla/javascript/NativeDate.java +++ b/src/org/mozilla/javascript/NativeDate.java @@ -26,7 +26,7 @@ * Norris Boyd * Mike McCabe * Ilya Frank - * + * * * Alternatively, the contents of this file may be used under the terms of * the GNU General Public License Version 2 or later (the "GPL"), in which @@ -224,12 +224,12 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, } Object toISO = o.get(toISOString, o); if (toISO == NOT_FOUND) { - throw ScriptRuntime.typeError2("msg.function.not.found.in", + throw ScriptRuntime.typeError2("msg.function.not.found.in", toISOString, ScriptRuntime.toString(o)); } if ( !(toISO instanceof Callable) ) { - throw ScriptRuntime.typeError3("msg.isnt.function.in", + throw ScriptRuntime.typeError3("msg.isnt.function.in", toISOString, ScriptRuntime.toString(o), ScriptRuntime.toString(toISO)); @@ -237,9 +237,9 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Object result = ((Callable) toISO).call(cx, scope, o, ScriptRuntime.emptyArgs); if ( !ScriptRuntime.isPrimitive(result) ) { - throw ScriptRuntime.typeError1("msg.toisostring.must.return.primitive", + throw ScriptRuntime.typeError1("msg.toisostring.must.return.primitive", ScriptRuntime.toString(result)); - } + } return result; } diff --git a/src/org/mozilla/javascript/NativeError.java b/src/org/mozilla/javascript/NativeError.java index 44d28b55ee..373d5117dc 100644 --- a/src/org/mozilla/javascript/NativeError.java +++ b/src/org/mozilla/javascript/NativeError.java @@ -98,7 +98,7 @@ public String getClassName() @Override public String toString() { - // According to spec, Error.prototype.toString() may return undefined. + // According to spec, Error.prototype.toString() may return undefined. Object toString = js_toString(this); return toString instanceof String ? (String) toString : super.toString(); } @@ -168,7 +168,7 @@ public Object getStack() { public void setStack(Object value) { if (stackProvider != null) { stackProvider = null; - delete("stack"); + delete("stack"); } put("stack", this, value); } diff --git a/src/org/mozilla/javascript/NativeFunction.java b/src/org/mozilla/javascript/NativeFunction.java index ffa6a86bc1..3c335ffed8 100644 --- a/src/org/mozilla/javascript/NativeFunction.java +++ b/src/org/mozilla/javascript/NativeFunction.java @@ -163,8 +163,8 @@ public Object resumeGenerator(Context cx, Scriptable scope, */ protected boolean getParamOrVarConst(int index) { - // By default return false to preserve compatibility with existing - // classes subclassing this class, which are mostly generated by jsc + // By default return false to preserve compatibility with existing + // classes subclassing this class, which are mostly generated by jsc // from earlier Rhino versions. See Bugzilla #396117. return false; } diff --git a/src/org/mozilla/javascript/NativeGlobal.java b/src/org/mozilla/javascript/NativeGlobal.java index 7f403f38c3..01e85df56d 100644 --- a/src/org/mozilla/javascript/NativeGlobal.java +++ b/src/org/mozilla/javascript/NativeGlobal.java @@ -147,7 +147,7 @@ public static void init(Context cx, Scriptable scope, boolean sealed) { */ for (int i = 0; i < errorMethods.length; i++) { String name = errorMethods[i]; - ScriptableObject errorProto = + ScriptableObject errorProto = (ScriptableObject) ScriptRuntime.newObject(cx, scope, "Error", ScriptRuntime.emptyArgs); errorProto.put("name", errorProto, name); diff --git a/src/org/mozilla/javascript/NativeIterator.java b/src/org/mozilla/javascript/NativeIterator.java index 1e72be7989..0858104c3e 100644 --- a/src/org/mozilla/javascript/NativeIterator.java +++ b/src/org/mozilla/javascript/NativeIterator.java @@ -33,7 +33,7 @@ import java.util.Iterator; /** - * This class implements iterator objects. See + * This class implements iterator objects. See * http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Iterators * * @author Norris Boyd @@ -41,7 +41,7 @@ public final class NativeIterator extends IdScriptableObject { private static final long serialVersionUID = -4136968203581667681L; private static final Object ITERATOR_TAG = "Iterator"; - + static void init(ScriptableObject scope, boolean sealed) { // Iterator NativeIterator iterator = new NativeIterator(); @@ -62,13 +62,13 @@ static void init(ScriptableObject scope, boolean sealed) { // scope is replaced or deleted. scope.associateValue(ITERATOR_TAG, obj); } - + /** * Only for constructing the prototype object. */ private NativeIterator() { } - + private NativeIterator(Object objectIterator) { this.objectIterator = objectIterator; } @@ -85,10 +85,10 @@ public static Object getStopIterationObject(Scriptable scope) { Scriptable top = ScriptableObject.getTopLevelScope(scope); return ScriptableObject.getTopScopeValue(top, ITERATOR_TAG); } - + private static final String STOP_ITERATION = "StopIteration"; public static final String ITERATOR_PROPERTY_NAME = "__iterator__"; - + static class StopIteration extends NativeObject { private static final long serialVersionUID = 2485151085722377663L; @@ -132,50 +132,50 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, return super.execIdCall(f, cx, scope, thisObj, args); } int id = f.methodId(); - + if (id == Id_constructor) { return jsConstructor(cx, scope, thisObj, args); } if (!(thisObj instanceof NativeIterator)) throw incompatibleCallError(f); - + NativeIterator iterator = (NativeIterator) thisObj; - + switch (id) { - case Id_next: + case Id_next: return iterator.next(cx, scope); case Id___iterator__: /// XXX: what about argument? SpiderMonkey apparently ignores it return thisObj; - default: + default: throw new IllegalArgumentException(String.valueOf(id)); } } - + /* The JavaScript constructor */ - private static Object jsConstructor(Context cx, Scriptable scope, + private static Object jsConstructor(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { - if (args.length == 0 || args[0] == null || + if (args.length == 0 || args[0] == null || args[0] == Undefined.instance) { Object argument = args.length == 0 ? Undefined.instance : args[0]; - throw ScriptRuntime.typeError1("msg.no.properties", + throw ScriptRuntime.typeError1("msg.no.properties", ScriptRuntime.toString(argument)); } Scriptable obj = ScriptRuntime.toObject(scope, args[0]); boolean keyOnly = args.length > 1 && ScriptRuntime.toBoolean(args[1]); if (thisObj != null) { // Called as a function. Convert to iterator if possible. - + // For objects that implement java.lang.Iterable or // java.util.Iterator, have JavaScript Iterator call the underlying // iteration methods - Iterator iterator = + Iterator iterator = VMBridge.instance.getJavaIterator(cx, scope, obj); if (iterator != null) { scope = ScriptableObject.getTopLevelScope(scope); @@ -183,15 +183,15 @@ private static Object jsConstructor(Context cx, Scriptable scope, new WrappedJavaIterator(iterator, scope), WrappedJavaIterator.class); } - + // Otherwise, just call the runtime routine - Scriptable jsIterator = ScriptRuntime.toIterator(cx, scope, obj, + Scriptable jsIterator = ScriptRuntime.toIterator(cx, scope, obj, keyOnly); if (jsIterator != null) { return jsIterator; } } - + // Otherwise, just set up to iterate over the properties of the object. // Do not call __iterator__ method. Object objectIterator = ScriptRuntime.enumInit(obj, cx, @@ -199,12 +199,12 @@ private static Object jsConstructor(Context cx, Scriptable scope, : ScriptRuntime.ENUMERATE_ARRAY_NO_ITERATOR); ScriptRuntime.setEnumNumbers(objectIterator, true); NativeIterator result = new NativeIterator(objectIterator); - result.setPrototype(ScriptableObject.getClassPrototype(scope, + result.setPrototype(ScriptableObject.getClassPrototype(scope, result.getClassName())); result.setParentScope(scope); return result; } - + private Object next(Context cx, Scriptable scope) { Boolean b = ScriptRuntime.enumNext(this.objectIterator); if (!b.booleanValue()) { @@ -214,7 +214,7 @@ private Object next(Context cx, Scriptable scope) { } return ScriptRuntime.enumId(this.objectIterator, cx); } - + static public class WrappedJavaIterator { WrappedJavaIterator(Iterator iterator, Scriptable scope) { @@ -238,7 +238,7 @@ public Object __iterator__(boolean b) { private Iterator iterator; private Scriptable scope; } - + // #string_id_map# @Override diff --git a/src/org/mozilla/javascript/NativeJSON.java b/src/org/mozilla/javascript/NativeJSON.java index 441fefefdf..aa3dec6172 100644 --- a/src/org/mozilla/javascript/NativeJSON.java +++ b/src/org/mozilla/javascript/NativeJSON.java @@ -144,7 +144,7 @@ private static Object parse(Context cx, Scriptable scope, String jtext) { return new JsonParser(cx, scope).parseValue(jtext); } catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); - } + } } public static Object parse(Context cx, Scriptable scope, String jtext, @@ -179,18 +179,18 @@ private static Object walk(Context cx, Scriptable scope, Callable reviver, } } } else { - Object[] keys = val.getIds(); + Object[] keys = val.getIds(); for (Object p : keys) { Object newElement = walk(cx, scope, reviver, val, p); if (newElement == Undefined.instance) { - if (p instanceof Number) + if (p instanceof Number) val.delete(((Number) p).intValue()); - else + else val.delete((String) p); } else { - if (p instanceof Number) + if (p instanceof Number) val.put(((Number) p).intValue(), val, newElement); - else + else val.put((String) p, val, newElement); } } @@ -251,7 +251,7 @@ public static Object stringify(Context cx, Scriptable scope, Object value, if (v instanceof String || v instanceof Number) { propertyList.add(v); } else if (v instanceof NativeString || v instanceof NativeNumber) { - propertyList.add(ScriptRuntime.toString(v)); + propertyList.add(ScriptRuntime.toString(v)); } } } @@ -316,7 +316,7 @@ private static Object str(Object key, Scriptable holder, value = ScriptRuntime.toNumber(value); } else if (value instanceof NativeString) { value = ScriptRuntime.toString(value); - } else if (value instanceof NativeBoolean) { + } else if (value instanceof NativeBoolean) { value = ((NativeBoolean) value).getDefaultValue(ScriptRuntime.BooleanClass); } diff --git a/src/org/mozilla/javascript/NativeJavaClass.java b/src/org/mozilla/javascript/NativeJavaClass.java index c88572c27c..dc3f8f664e 100644 --- a/src/org/mozilla/javascript/NativeJavaClass.java +++ b/src/org/mozilla/javascript/NativeJavaClass.java @@ -114,7 +114,7 @@ public Object get(String name, Scriptable start) { if (members.has(name, true)) { return members.get(this, name, javaObject, true); } - + Context cx = Context.getContext(); Scriptable scope = ScriptableObject.getTopLevelScope(start); WrapFactory wrapFactory = cx.getWrapFactory(); @@ -123,7 +123,7 @@ public Object get(String name, Scriptable start) { return wrapFactory.wrap(cx, scope, javaObject, ScriptRuntime.ClassClass); } - + // experimental: look for nested classes by appending $name to // current class' name. Class nestedClass = findNestedClass(getClassObject(), name); @@ -133,7 +133,7 @@ public Object get(String name, Scriptable start) { nestedValue.setParentScope(this); return nestedValue; } - + throw members.reportMemberNotFound(name); } @@ -230,16 +230,16 @@ static Scriptable constructSpecific(Context cx, Scriptable scope, { Scriptable topLevel = ScriptableObject.getTopLevelScope(scope); Class[] argTypes = ctor.argTypes; - + if (ctor.vararg) { // marshall the explicit parameter Object[] newArgs = new Object[argTypes.length]; for (int i = 0; i < argTypes.length-1; i++) { newArgs[i] = Context.jsToJava(args[i], argTypes[i]); } - + Object varArgs; - + // Handle special situation where a single variable parameter // is given and it is a Java or ECMA array. if (args.length == argTypes.length && @@ -248,21 +248,21 @@ static Scriptable constructSpecific(Context cx, Scriptable scope, args[args.length-1] instanceof NativeJavaArray)) { // convert the ECMA array into a native array - varArgs = Context.jsToJava(args[args.length-1], + varArgs = Context.jsToJava(args[args.length-1], argTypes[argTypes.length - 1]); - } else { + } else { // marshall the variable parameter Class componentType = argTypes[argTypes.length - 1]. getComponentType(); - varArgs = Array.newInstance(componentType, - args.length - argTypes.length + 1); + varArgs = Array.newInstance(componentType, + args.length - argTypes.length + 1); for (int i=0; i < Array.getLength(varArgs); i++) { Object value = Context.jsToJava(args[argTypes.length-1 + i], componentType); Array.set(varArgs, i, value); } } - + // add varargs newArgs[argTypes.length-1] = varArgs; // replace the original args with the new one @@ -280,7 +280,7 @@ static Scriptable constructSpecific(Context cx, Scriptable scope, } } } - + Object instance = ctor.newInstance(args); // we need to force this to be wrapped, because construct _has_ // to return a scriptable diff --git a/src/org/mozilla/javascript/NativeJavaMethod.java b/src/org/mozilla/javascript/NativeJavaMethod.java index 5b09d8c9bb..0be9043b10 100644 --- a/src/org/mozilla/javascript/NativeJavaMethod.java +++ b/src/org/mozilla/javascript/NativeJavaMethod.java @@ -168,16 +168,16 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, MemberBox meth = methods[index]; Class[] argTypes = meth.argTypes; - + if (meth.vararg) { // marshall the explicit parameters Object[] newArgs = new Object[argTypes.length]; for (int i = 0; i < argTypes.length-1; i++) { newArgs[i] = Context.jsToJava(args[i], argTypes[i]); } - + Object varArgs; - + // Handle special situation where a single variable parameter // is given and it is a Java or ECMA array or is null. if (args.length == argTypes.length && @@ -186,26 +186,26 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, args[args.length-1] instanceof NativeJavaArray)) { // convert the ECMA array into a native array - varArgs = Context.jsToJava(args[args.length-1], + varArgs = Context.jsToJava(args[args.length-1], argTypes[argTypes.length - 1]); - } else { + } else { // marshall the variable parameters Class componentType = argTypes[argTypes.length - 1]. getComponentType(); - varArgs = Array.newInstance(componentType, - args.length - argTypes.length + 1); + varArgs = Array.newInstance(componentType, + args.length - argTypes.length + 1); for (int i = 0; i < Array.getLength(varArgs); i++) { - Object value = Context.jsToJava(args[argTypes.length-1 + i], + Object value = Context.jsToJava(args[argTypes.length-1 + i], componentType); Array.set(varArgs, i, value); } } - + // add varargs newArgs[argTypes.length-1] = varArgs; // replace the original args with the new one args = newArgs; - } else { + } else { // First, we marshall the args. Object[] origArgs = args; for (int i = 0; i < args.length; i++) { @@ -284,7 +284,7 @@ static int findFunction(Context cx, MemberBox member = methodsOrCtors[0]; Class[] argTypes = member.argTypes; int alength = argTypes.length; - + if (member.vararg) { alength--; if ( alength > args.length) { @@ -478,7 +478,7 @@ static int findFunction(Context cx, * Returns one of PREFERENCE_EQUAL, PREFERENCE_FIRST_ARG, * PREFERENCE_SECOND_ARG, or PREFERENCE_AMBIGUOUS. */ - private static int preferSignature(Object[] args, + private static int preferSignature(Object[] args, Class[] sig1, boolean vararg1, Class[] sig2, diff --git a/src/org/mozilla/javascript/NativeJavaObject.java b/src/org/mozilla/javascript/NativeJavaObject.java index b32af95ca3..acdfbc39da 100644 --- a/src/org/mozilla/javascript/NativeJavaObject.java +++ b/src/org/mozilla/javascript/NativeJavaObject.java @@ -87,7 +87,7 @@ protected void initMembers() { } else { dynamicType = staticType; } - members = JavaMembers.lookupClass(parent, dynamicType, staticType, + members = JavaMembers.lookupClass(parent, dynamicType, staticType, isAdapter); fieldAndMethods = members.getFieldAndMethodsObjects(this, javaObject, false); @@ -603,7 +603,7 @@ else if (type == ScriptRuntime.StringClass) { break; case JSTYPE_JAVA_OBJECT: - case JSTYPE_JAVA_ARRAY: + case JSTYPE_JAVA_ARRAY: if (value instanceof Wrapper) { value = ((Wrapper)value).unwrap(); } @@ -613,7 +613,7 @@ else if (type == ScriptRuntime.StringClass) { } return coerceToNumber(type, value); } - else { + else { if (type == ScriptRuntime.StringClass) { return value.toString(); } @@ -838,7 +838,7 @@ else if (value instanceof Scriptable) { else { Method meth; try { - meth = value.getClass().getMethod("doubleValue", + meth = value.getClass().getMethod("doubleValue", (Class [])null); } catch (NoSuchMethodException e) { @@ -849,7 +849,7 @@ else if (value instanceof Scriptable) { } if (meth != null) { try { - return ((Number)meth.invoke(value, + return ((Number)meth.invoke(value, (Object [])null)).doubleValue(); } catch (IllegalAccessException e) { diff --git a/src/org/mozilla/javascript/NativeNumber.java b/src/org/mozilla/javascript/NativeNumber.java index 3f0b8e7dc1..a5f8e02aba 100644 --- a/src/org/mozilla/javascript/NativeNumber.java +++ b/src/org/mozilla/javascript/NativeNumber.java @@ -161,7 +161,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, return num_to(value, args, DToA.DTOSTR_FIXED, DToA.DTOSTR_FIXED, -20, 0); - case Id_toExponential: { + case Id_toExponential: { // Handle special values before range check if(Double.isNaN(value)) { return "NaN"; diff --git a/src/org/mozilla/javascript/NativeObject.java b/src/org/mozilla/javascript/NativeObject.java index 76e79be8bb..49566f5b72 100644 --- a/src/org/mozilla/javascript/NativeObject.java +++ b/src/org/mozilla/javascript/NativeObject.java @@ -269,7 +269,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, if (args.length < 1 || !(thisObj instanceof ScriptableObject)) return Undefined.instance; - + ScriptableObject so = (ScriptableObject)thisObj; String name = ScriptRuntime.toStringIdOrIndex(cx, args[0]); int index = (name != null ? 0 @@ -391,7 +391,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, for (Object name: obj.getAllIds()) { Object configurable = obj.getOwnPropertyDescriptor(cx, name).get("configurable"); - if (Boolean.TRUE.equals(configurable)) + if (Boolean.TRUE.equals(configurable)) return false; } @@ -406,7 +406,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, for (Object name: obj.getAllIds()) { ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); - if (Boolean.TRUE.equals(desc.get("configurable"))) + if (Boolean.TRUE.equals(desc.get("configurable"))) return false; if (isDataDescriptor(desc) && Boolean.TRUE.equals(desc.get("writable"))) return false; @@ -423,7 +423,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, ScriptableObject desc = obj.getOwnPropertyDescriptor(cx, name); if (Boolean.TRUE.equals(desc.get("configurable"))) { desc.put("configurable", desc, false); - obj.defineOwnProperty(cx, name, desc); + obj.defineOwnProperty(cx, name, desc); } } obj.preventExtensions(); diff --git a/src/org/mozilla/javascript/NativeString.java b/src/org/mozilla/javascript/NativeString.java index ad03f4055e..0eeccd04e8 100644 --- a/src/org/mozilla/javascript/NativeString.java +++ b/src/org/mozilla/javascript/NativeString.java @@ -243,7 +243,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, id = -id; continue again; } - + case ConstructorId_fromCharCode: { int N = args.length; if (N < 1) @@ -254,7 +254,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, } return sb.toString(); } - + case Id_constructor: { String s = (args.length >= 1) ? ScriptRuntime.toString(args[0]) : ""; @@ -265,17 +265,17 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, // String(val) converts val to a string value. return s; } - + case Id_toString: case Id_valueOf: // ECMA 15.5.4.2: 'the toString function is not generic. return realThis(thisObj, f).string; - + case Id_toSource: { String s = realThis(thisObj, f).string; return "(new String(\""+ScriptRuntime.escapeString(s)+"\"))"; } - + case Id_charAt: case Id_charCodeAt: { // See ECMA 15.5.4.[4,5] @@ -289,90 +289,90 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, if (id == Id_charAt) return String.valueOf(c); else return ScriptRuntime.wrapInt(c); } - + case Id_indexOf: return ScriptRuntime.wrapInt(js_indexOf( ScriptRuntime.toString(thisObj), args)); - + case Id_lastIndexOf: return ScriptRuntime.wrapInt(js_lastIndexOf( ScriptRuntime.toString(thisObj), args)); - + case Id_split: return ScriptRuntime.checkRegExpProxy(cx). js_split(cx, scope, ScriptRuntime.toString(thisObj), args); - + case Id_substring: return js_substring(cx, ScriptRuntime.toString(thisObj), args); - + case Id_toLowerCase: // See ECMA 15.5.4.11 return ScriptRuntime.toString(thisObj).toLowerCase( ScriptRuntime.ROOT_LOCALE); - + case Id_toUpperCase: // See ECMA 15.5.4.12 return ScriptRuntime.toString(thisObj).toUpperCase( ScriptRuntime.ROOT_LOCALE); - + case Id_substr: return js_substr(ScriptRuntime.toString(thisObj), args); - + case Id_concat: return js_concat(ScriptRuntime.toString(thisObj), args); - + case Id_slice: return js_slice(ScriptRuntime.toString(thisObj), args); - + case Id_bold: return tagify(thisObj, "b", null, null); - + case Id_italics: return tagify(thisObj, "i", null, null); - + case Id_fixed: return tagify(thisObj, "tt", null, null); - + case Id_strike: return tagify(thisObj, "strike", null, null); - + case Id_small: return tagify(thisObj, "small", null, null); - + case Id_big: return tagify(thisObj, "big", null, null); - + case Id_blink: return tagify(thisObj, "blink", null, null); - + case Id_sup: return tagify(thisObj, "sup", null, null); - + case Id_sub: return tagify(thisObj, "sub", null, null); - + case Id_fontsize: return tagify(thisObj, "font", "size", args); - + case Id_fontcolor: return tagify(thisObj, "font", "color", args); - + case Id_link: return tagify(thisObj, "a", "href", args); - + case Id_anchor: return tagify(thisObj, "a", "name", args); - + case Id_equals: case Id_equalsIgnoreCase: { String s1 = ScriptRuntime.toString(thisObj); String s2 = ScriptRuntime.toString(args, 0); return ScriptRuntime.wrapBoolean( - (id == Id_equals) ? s1.equals(s2) + (id == Id_equals) ? s1.equals(s2) : s1.equalsIgnoreCase(s2)); } - + case Id_match: case Id_search: case Id_replace: @@ -399,7 +399,7 @@ public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, collator.setStrength(Collator.IDENTICAL); collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); return ScriptRuntime.wrapNumber(collator.compare( - ScriptRuntime.toString(thisObj), + ScriptRuntime.toString(thisObj), ScriptRuntime.toString(args, 0))); } case Id_toLocaleLowerCase: @@ -778,7 +778,7 @@ protected int findPrototypeId(String s) // #/string_id_map# - private static final int + private static final int ConstructorId_charAt = -Id_charAt, ConstructorId_charCodeAt = -Id_charCodeAt, ConstructorId_indexOf = -Id_indexOf, diff --git a/src/org/mozilla/javascript/NativeWith.java b/src/org/mozilla/javascript/NativeWith.java index 080e9c44e5..cfaa49dcfd 100644 --- a/src/org/mozilla/javascript/NativeWith.java +++ b/src/org/mozilla/javascript/NativeWith.java @@ -48,7 +48,7 @@ * for operations on its parent. */ public class NativeWith implements Scriptable, IdFunctionCall, Serializable { - + private static final long serialVersionUID = 1L; static void init(Scriptable scope, boolean sealed) diff --git a/src/org/mozilla/javascript/Node.java b/src/org/mozilla/javascript/Node.java index 6544621eed..2d5414f126 100644 --- a/src/org/mozilla/javascript/Node.java +++ b/src/org/mozilla/javascript/Node.java @@ -95,7 +95,7 @@ public class Node implements Iterable DESTRUCTURING_NAMES = 22, DESTRUCTURING_PARAMS = 23, JSDOC_PROP = 24, - EXPRESSION_CLOSURE_PROP = 25, // JS 1.8 expression closure pseudo-return + EXPRESSION_CLOSURE_PROP = 25, // JS 1.8 expression closure pseudo-return DESTRUCTURING_SHORTHAND = 26, // JS 1.8 destructuring shorthand LAST_PROP = 26; diff --git a/src/org/mozilla/javascript/NodeTransformer.java b/src/org/mozilla/javascript/NodeTransformer.java index 9e42a00209..2ad6ce1754 100644 --- a/src/org/mozilla/javascript/NodeTransformer.java +++ b/src/org/mozilla/javascript/NodeTransformer.java @@ -139,7 +139,7 @@ private void transformCompilationUnit_r(final ScriptNode tree, let.addChildToBack(oldNode); } } - + switch (type) { case Token.LABEL: @@ -233,7 +233,7 @@ private void transformCompilationUnit_r(final ScriptNode tree, returnNode = new Node(Token.RETURN_RESULT); unwindBlock.addChildToBack(returnNode); // transform return expression - transformCompilationUnit_r(tree, store, scope, + transformCompilationUnit_r(tree, store, scope, createScopeObjects, inStrictMode); } @@ -353,7 +353,7 @@ private void transformCompilationUnit_r(final ScriptNode tree, case Token.TYPEOF: case Token.IFNE: { /* We want to suppress warnings for undefined property o.p - * for the following constructs: typeof o.p, if (o.p), + * for the following constructs: typeof o.p, if (o.p), * if (!o.p), if (o.p == undefined), if (undefined == o.p) */ Node child = node.getFirstChild(); @@ -432,7 +432,7 @@ else if (last.getType() == Token.NAME && } } - transformCompilationUnit_r(tree, node, + transformCompilationUnit_r(tree, node, node instanceof Scope ? (Scope)node : scope, createScopeObjects, inStrictMode); } @@ -443,8 +443,8 @@ protected void visitNew(Node node, ScriptNode tree) { protected void visitCall(Node node, ScriptNode tree) { } - - protected Node visitLet(boolean createWith, Node parent, Node previous, + + protected Node visitLet(boolean createWith, Node parent, Node previous, Node scopeNode) { Node vars = scopeNode.getFirstChild(); diff --git a/src/org/mozilla/javascript/Parser.java b/src/org/mozilla/javascript/Parser.java index 65694c8018..9f3ec46eb2 100644 --- a/src/org/mozilla/javascript/Parser.java +++ b/src/org/mozilla/javascript/Parser.java @@ -240,7 +240,7 @@ String lookupMessage(String messageId, String messageArg) { ? ScriptRuntime.getMessage0(messageId) : ScriptRuntime.getMessage1(messageId, messageArg); } - + void reportError(String messageId) { reportError(messageId, null); } @@ -541,7 +541,7 @@ private AstRoot parse() throws IOException int baseLineno = ts.lineno; // line number where source starts int end = pos; // in case source is empty - + boolean inDirectivePrologue = true; boolean savedStrictMode = inUseStrictDirective; // TODO: eval code should get strict mode from invoking code @@ -628,11 +628,11 @@ private AstNode parseFunctionBody() ++nestingOfFunction; int pos = ts.tokenBeg; Block pn = new Block(pos); // starts at LC position - + boolean inDirectivePrologue = true; boolean savedStrictMode = inUseStrictDirective; // Don't set 'inUseStrictDirective' to false: inherit strict mode. - + pn.setLineno(ts.lineno); try { bodyLoop: for (;;) { @@ -676,7 +676,7 @@ private AstNode parseFunctionBody() pn.setLength(end - pos); return pn; } - + private String getDirective(AstNode n) { if (n instanceof ExpressionStatement) { AstNode e = ((ExpressionStatement) n).getExpression(); @@ -781,7 +781,7 @@ private FunctionNode function(int type) if (inUseStrictDirective) { String id = name.getIdentifier(); if ("eval".equals(id)|| "arguments".equals(id)) { - reportError("msg.bad.id.strict", id); + reportError("msg.bad.id.strict", id); } } if (!matchToken(Token.LP)) { @@ -1896,7 +1896,7 @@ private VariableDeclaration variables(int declType, int pos) String id = ts.getString(); if ("eval".equals(id) || "arguments".equals(ts.getString())) { - reportError("msg.bad.id.strict", id); + reportError("msg.bad.id.strict", id); } } defineSymbol(declType, ts.getString(), inForInit); @@ -2438,7 +2438,7 @@ private List argumentList() } finally { inForInit = wasInForInit; } - + mustMatchToken(Token.RP, "msg.no.paren.arg"); return result; } @@ -2834,7 +2834,7 @@ private AstNode primaryExpr() s, ts.getNumber()); } - + case Token.STRING: return createStringLiteral(); @@ -3156,7 +3156,7 @@ && peekToken() == Token.NAME reportError("msg.bad.prop"); break; } - + if (this.inUseStrictDirective) { if (propertyNames.contains(propertyName)) { addError("msg.dup.obj.lit.prop.strict", propertyName); @@ -3167,7 +3167,7 @@ && peekToken() == Token.NAME // Eat any dangling jsdoc in the property. getAndResetJsDoc(); jsdoc = null; - + if (matchToken(Token.COMMA)) { afterComma = ts.tokenEnd; } else { @@ -3766,7 +3766,7 @@ void markDestructuring(AstNode node) { } // throw a failed-assertion with some helpful debugging info - private RuntimeException codeBug() + private RuntimeException codeBug() throws RuntimeException { throw Kit.codeBug("ts.cursor=" + ts.cursor diff --git a/src/org/mozilla/javascript/PolicySecurityController.java b/src/org/mozilla/javascript/PolicySecurityController.java index 49cb1248da..d23e30c57d 100644 --- a/src/org/mozilla/javascript/PolicySecurityController.java +++ b/src/org/mozilla/javascript/PolicySecurityController.java @@ -52,11 +52,11 @@ /** * A security controller relying on Java {@link Policy} in effect. When you use * this security controller, your securityDomain objects must be instances of - * {@link CodeSource} representing the location from where you load your + * {@link CodeSource} representing the location from where you load your * scripts. Any Java policy "grant" statements matching the URL and certificate - * in code sources will apply to the scripts. If you specify any certificates + * in code sources will apply to the scripts. If you specify any certificates * within your {@link CodeSource} objects, it is your responsibility to verify - * (or not) that the script source files are signed in whatever + * (or not) that the script source files are signed in whatever * implementation-specific way you're using. * @author Attila Szegedi */ @@ -71,7 +71,7 @@ public class PolicySecurityController extends SecurityController private static final Map>> callers = new WeakHashMap>>(); - + @Override public Class getStaticSecurityDomainClassInternal() { return CodeSource.class; @@ -81,7 +81,7 @@ private static class Loader extends SecureClassLoader implements GeneratedClassLoader { private final CodeSource codeSource; - + Loader(ClassLoader parent, CodeSource codeSource) { super(parent); @@ -92,15 +92,15 @@ public Class defineClass(String name, byte[] data) { return defineClass(name, data, 0, data.length, codeSource); } - + public void linkClass(Class cl) { resolveClass(cl); } } - + @Override - public GeneratedClassLoader createClassLoader(final ClassLoader parent, + public GeneratedClassLoader createClassLoader(final ClassLoader parent, final Object securityDomain) { return (Loader)AccessController.doPrivileged( @@ -122,11 +122,11 @@ public Object getDynamicSecurityDomain(Object securityDomain) } @Override - public Object callWithDomain(final Object securityDomain, final Context cx, - Callable callable, Scriptable scope, Scriptable thisObj, + public Object callWithDomain(final Object securityDomain, final Context cx, + Callable callable, Scriptable scope, Scriptable thisObj, Object[] args) { - // Run in doPrivileged as we might be checked for "getClassLoader" + // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { @@ -155,17 +155,17 @@ public Object run() { { try { - // Run in doPrivileged as we'll be checked for + // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { - Loader loader = new Loader(classLoader, + Loader loader = new Loader(classLoader, codeSource); Class c = loader.defineClass( - SecureCaller.class.getName() + "Impl", + SecureCaller.class.getName() + "Impl", secureCallerImplBytecode); return c.newInstance(); } @@ -180,32 +180,32 @@ public Object run() throws Exception } return caller.call(callable, cx, scope, thisObj, args); } - + public abstract static class SecureCaller { - public abstract Object call(Callable callable, Context cx, Scriptable scope, + public abstract Object call(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args); } - - + + private static byte[] loadBytecode() { String secureCallerClassName = SecureCaller.class.getName(); ClassFileWriter cfw = new ClassFileWriter( - secureCallerClassName + "Impl", secureCallerClassName, + secureCallerClassName + "Impl", secureCallerClassName, ""); cfw.startMethod("", "()V", ClassFileWriter.ACC_PUBLIC); cfw.addALoad(0); - cfw.addInvoke(ByteCode.INVOKESPECIAL, secureCallerClassName, + cfw.addInvoke(ByteCode.INVOKESPECIAL, secureCallerClassName, "", "()V"); cfw.add(ByteCode.RETURN); cfw.stopMethod((short)1); - String callableCallSig = + String callableCallSig = "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "Lorg/mozilla/javascript/Scriptable;" + "[Ljava/lang/Object;)Ljava/lang/Object;"; - + cfw.startMethod("call", "(Lorg/mozilla/javascript/Callable;" + callableCallSig, (short)(ClassFileWriter.ACC_PUBLIC @@ -213,8 +213,8 @@ private static byte[] loadBytecode() for(int i = 1; i < 6; ++i) { cfw.addALoad(i); } - cfw.addInvoke(ByteCode.INVOKEINTERFACE, - "org/mozilla/javascript/Callable", "call", + cfw.addInvoke(ByteCode.INVOKEINTERFACE, + "org/mozilla/javascript/Callable", "call", "(" + callableCallSig); cfw.add(ByteCode.ARETURN); cfw.stopMethod((short)6); diff --git a/src/org/mozilla/javascript/RhinoException.java b/src/org/mozilla/javascript/RhinoException.java index c92b5ebb48..b311a38fea 100644 --- a/src/org/mozilla/javascript/RhinoException.java +++ b/src/org/mozilla/javascript/RhinoException.java @@ -333,7 +333,7 @@ public void printStackTrace(PrintStream s) } /** - * Returns true if subclasses of RhinoException + * Returns true if subclasses of RhinoException * use the Mozilla/Firefox style of rendering script stacks * (functionName()@fileName:lineNumber) * instead of Rhino's own Java-inspired format diff --git a/src/org/mozilla/javascript/RhinoSecurityManager.java b/src/org/mozilla/javascript/RhinoSecurityManager.java index a51f678db7..1d39037470 100644 --- a/src/org/mozilla/javascript/RhinoSecurityManager.java +++ b/src/org/mozilla/javascript/RhinoSecurityManager.java @@ -1,18 +1,18 @@ package org.mozilla.javascript; /** - * A java.lang.SecurityManager subclass that provides access to - * the current top-most script class on the execution stack. This can be used - * to get the class loader or protection domain of the script that triggered - * the current action. It is required for JavaAdapters to have the same - * ProtectionDomain as the script code that created them. + * A java.lang.SecurityManager subclass that provides access to + * the current top-most script class on the execution stack. This can be used + * to get the class loader or protection domain of the script that triggered + * the current action. It is required for JavaAdapters to have the same + * ProtectionDomain as the script code that created them. * Embeddings that implement their own SecurityManager can use this as base class. */ public class RhinoSecurityManager extends SecurityManager { /** * Get the class of the top-most stack element representing a script. - * @return The class of the top-most script in the current stack, + * @return The class of the top-most script in the current stack, * or null if no script is currently running */ protected Class getCurrentScriptClass() { diff --git a/src/org/mozilla/javascript/ScriptRuntime.java b/src/org/mozilla/javascript/ScriptRuntime.java index bc1121994e..91ed49d942 100644 --- a/src/org/mozilla/javascript/ScriptRuntime.java +++ b/src/org/mozilla/javascript/ScriptRuntime.java @@ -186,7 +186,7 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, // Locale object used to request locale-neutral operations. public static Locale ROOT_LOCALE = new Locale(""); - + private static final Object LIBRARY_SCOPE_KEY = "LIBRARY_SCOPE"; public static boolean isRhinoRuntimeType(Class cl) @@ -230,9 +230,9 @@ public static ScriptableObject initStandardObjects(Context cx, NativeArray.init(scope, sealed); if (cx.getOptimizationLevel() > 0) { // When optimizing, attempt to fulfill all requests for new Array(N) - // with a higher threshold before switching to a sparse + // with a higher threshold before switching to a sparse // representation - NativeArray.setMaximumInitialCapacity(200000); + NativeArray.setMaximumInitialCapacity(200000); } NativeString.init(scope, sealed); NativeBoolean.init(scope, sealed); @@ -244,10 +244,10 @@ public static ScriptableObject initStandardObjects(Context cx, NativeWith.init(scope, sealed); NativeCall.init(scope, sealed); NativeScript.init(scope, sealed); - + NativeIterator.init(scope, sealed); // Also initializes NativeGenerator - boolean withXml = cx.hasFeature(Context.FEATURE_E4X) && + boolean withXml = cx.hasFeature(Context.FEATURE_E4X) && cx.getE4xImplementationFactory() != null; for (int i = 0; i != lazilyNames.length; i += 2) { @@ -1509,7 +1509,7 @@ public static Object getObjectProp(Object obj, String property, } return getObjectProp(sobj, property, cx); } - + public static Object getObjectProp(Scriptable obj, String property, Context cx) { @@ -1525,7 +1525,7 @@ public static Object getObjectProp(Scriptable obj, String property, return result; } - + public static Object getObjectPropNoWarn(Object obj, String property, Context cx) { @@ -1539,7 +1539,7 @@ public static Object getObjectPropNoWarn(Object obj, String property, } return result; } - + /* * A cheaper and less general version of the above for well-known argument * types. @@ -1983,22 +1983,22 @@ private static class IdEnumeration implements Serializable int index; ObjToIntMap used; Object currentId; - int enumType; /* one of ENUM_INIT_KEYS, ENUM_INIT_VALUES, + int enumType; /* one of ENUM_INIT_KEYS, ENUM_INIT_VALUES, ENUM_INIT_ARRAY */ - + // if true, integer ids will be returned as numbers rather than strings - boolean enumNumbers; - + boolean enumNumbers; + Scriptable iterator; } - - public static Scriptable toIterator(Context cx, Scriptable scope, + + public static Scriptable toIterator(Context cx, Scriptable scope, Scriptable obj, boolean keyOnly) { - if (ScriptableObject.hasProperty(obj, + if (ScriptableObject.hasProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME)) { - Object v = ScriptableObject.getProperty(obj, + Object v = ScriptableObject.getProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME); if (!(v instanceof Callable)) { throw typeError0("msg.invalid.iterator"); @@ -2052,10 +2052,10 @@ public static Object enumInit(Object value, Context cx, int enumType) // or "for (a.i in a)" would wrongly enumerate i in a as well enumChangeObject(x); } - + return x; } - + public static void setEnumNumbers(Object enumObj, boolean enumNumbers) { ((IdEnumeration)enumObj).enumNumbers = enumNumbers; } @@ -2070,7 +2070,7 @@ public static Boolean enumNext(Object enumObj) Callable f = (Callable) v; Context cx = Context.getContext(); try { - x.currentId = f.call(cx, x.iterator.getParentScope(), + x.currentId = f.call(cx, x.iterator.getParentScope(), x.iterator, emptyArgs); return Boolean.TRUE; } catch (JavaScriptException e) { @@ -2283,7 +2283,7 @@ public static Callable getPropFunctionAndThis(Object obj, Scriptable thisObj = toObjectOrNull(cx, obj, scope); return getPropFunctionAndThisHelper(obj, property, cx, thisObj); } - + private static Callable getPropFunctionAndThisHelper(Object obj, String property, Context cx, Scriptable thisObj) { @@ -2467,7 +2467,7 @@ public static Object applyOrCall(boolean isApply, Object[] callArgs; if (isApply) { // Follow Ecma 15.3.4.3 - callArgs = L <= 1 ? ScriptRuntime.emptyArgs : + callArgs = L <= 1 ? ScriptRuntime.emptyArgs : getApplyArguments(cx, args[1]); } else { // Follow Ecma 15.3.4.4 @@ -2548,7 +2548,7 @@ public static Object evalSpecial(Context cx, Scriptable scope, Evaluator evaluator = Context.createInterpreter(); if (evaluator == null) { throw new JavaScriptException("Interpreter not present", - filename, lineNumber); + filename, lineNumber); } // Compile with explicit interpreter instance to force interpreter @@ -2800,7 +2800,7 @@ public static Object refIncrDecr(Ref ref, Context cx, int incrDecrMask) public static Object toPrimitive(Object val) { return toPrimitive(val, null); } - + public static Object toPrimitive(Object val, Class typeHint) { if (!(val instanceof Scriptable)) { @@ -2896,9 +2896,9 @@ public static boolean eq(Object x, Object y) return x == y; } } - + public static boolean isPrimitive(Object obj) { - return obj == null || obj == Undefined.instance || + return obj == null || obj == Undefined.instance || (obj instanceof Number) || (obj instanceof String) || (obj instanceof Boolean); } @@ -3102,13 +3102,13 @@ public static ScriptableObject getGlobal(Context cx) { Constructor globalClassCtor = globalClass.getConstructor(parm); Object[] arg = { cx }; return (ScriptableObject) globalClassCtor.newInstance(arg); - } + } catch (RuntimeException e) { throw e; - } + } catch (Exception e) { // fall through... - } + } } return new ImporterTopLevel(cx); } @@ -3179,11 +3179,11 @@ static Scriptable checkDynamicScope(Scriptable possibleDynamicScope, } } } - + public static void addInstructionCount(Context cx, int instructionsToAdd) { cx.instructionCount += instructionsToAdd; - if (cx.instructionCount > cx.instructionThreshold) + if (cx.instructionCount > cx.instructionThreshold) { cx.observeInstructionCount(cx.instructionCount); cx.instructionCount = 0; @@ -3357,7 +3357,7 @@ public static Scriptable newCatchScope(Throwable t, Object wrap = cx.getWrapFactory().wrap(cx, scope, re, null); ScriptableObject.defineProperty( errorObject, "rhinoException", wrap, - ScriptableObject.PERMANENT | ScriptableObject.READONLY); + ScriptableObject.PERMANENT | ScriptableObject.READONLY); } obj = errorObject; } @@ -3366,7 +3366,7 @@ public static Scriptable newCatchScope(Throwable t, // See ECMA 12.4 catchScopeObject.defineProperty( exceptionName, obj, ScriptableObject.PERMANENT); - + if (isVisible(cx, t)) { // Add special Rhino object __exception__ defined in the catch // scope that can be used to retrieve the Java exception associated @@ -3381,7 +3381,7 @@ public static Scriptable newCatchScope(Throwable t, } return catchScopeObject; } - + private static boolean isVisible(Context cx, Object obj) { ClassShutter shutter = cx.getClassShutter(); return shutter == null || @@ -3521,7 +3521,7 @@ public static Scriptable newArrayLiteral(Object[] objects, } return cx.newArray(scope, sparse); } - + Scriptable array = cx.newArray(scope, length); int skip = 0; @@ -3584,7 +3584,7 @@ public static Scriptable newObjectLiteral(Object[] propertyIds, outArgs[0] = id; outArgs[1] = value; fun.call(cx, scope, object, outArgs); - } + } } else { int index = ((Integer)id).intValue(); ScriptableObject.putProperty(object, index, value); @@ -3662,15 +3662,15 @@ public static String getMessage4( Object[] arguments = {arg1, arg2, arg3, arg4}; return getMessage(messageId, arguments); } - + /** * This is an interface defining a message provider. Create your * own implementation to override the default error message provider. - * + * * @author Mike Harm */ public interface MessageProvider { - + /** * Returns a textual message identified by the given messageId, * parameterized by the given arguments. @@ -3727,7 +3727,7 @@ public static EcmaError constructError(String error, String message) String filename = Context.getSourcePositionFromStack(linep); return constructError(error, message, filename, linep[0], null, 0); } - + public static EcmaError constructError(String error, String message, int lineNumberDelta) @@ -4023,13 +4023,13 @@ private static RuntimeException errorWithClassName(String msg, Object val) } /** - * Equivalent to executing "new Error(message)" from JavaScript. + * Equivalent to executing "new Error(message)" from JavaScript. * @param cx the current context * @param scope the current scope * @param message the message * @return a JavaScriptException you should throw */ - public static JavaScriptException throwError(Context cx, Scriptable scope, + public static JavaScriptException throwError(Context cx, Scriptable scope, String message) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); @@ -4040,5 +4040,5 @@ public static JavaScriptException throwError(Context cx, Scriptable scope, public static final Object[] emptyArgs = new Object[0]; public static final String[] emptyStrings = new String[0]; - + } diff --git a/src/org/mozilla/javascript/ScriptableObject.java b/src/org/mozilla/javascript/ScriptableObject.java index 9980663db3..b702bfaa61 100644 --- a/src/org/mozilla/javascript/ScriptableObject.java +++ b/src/org/mozilla/javascript/ScriptableObject.java @@ -234,8 +234,8 @@ final void checkNotReadonly() ScriptableObject getPropertyDescriptor(Context cx, Scriptable scope) { return buildDataDescriptor( - scope, - (value == null ? Undefined.instance : value), + scope, + (value == null ? Undefined.instance : value), attributes); } @@ -373,7 +373,7 @@ public ScriptableObject(Scriptable scope, Scriptable prototype) parentScopeObject = scope; prototypeObject = prototype; } - + /** * Gets the value that will be returned by calling the typeof operator on this object. * @return default is "object" unless {@link #avoidObjectDetection()} is true in which @@ -710,7 +710,7 @@ private void setGetterOrSetter(String name, int index, Callable getterOrSetter, if (gslot == null) return; } - + if (!force) { gslot.checkNotReadonly(); } @@ -725,14 +725,14 @@ private void setGetterOrSetter(String name, int index, Callable getterOrSetter, /** * Get the getter or setter for a given property. Used by __lookupGetter__ * and __lookupSetter__. - * + * * @param name Name of the object. If nonnull, index must be 0. * @param index Index of the object. If nonzero, name must be null. * @param isSetter If true, return the setter, otherwise return the getter. * @exception IllegalArgumentException if both name and index are nonnull * and nonzero respectively. - * @return Null if the property does not exist. Otherwise returns either - * the getter or the setter for the property, depending on + * @return Null if the property does not exist. Otherwise returns either + * the getter or the setter for the property, depending on * the value of isSetter (may be undefined if unset). */ public Object getGetterOrSetter(String name, int index, boolean isSetter) @@ -860,7 +860,7 @@ public Object getDefaultValue(Class typeHint) { return getDefaultValue(this, typeHint); } - + public static Object getDefaultValue(Scriptable object, Class typeHint) { Context cx = null; @@ -959,7 +959,7 @@ public boolean hasInstance(Scriptable instance) { return ScriptRuntime.jsDelegatesTo(instance, this); } - + /** * Emulate the SpiderMonkey (and Firefox) feature of allowing * custom objects to avoid detection by normal "object detection" @@ -1048,7 +1048,7 @@ protected Object equivalentValues(Object value) * considered to define the body of the constructor. Only one * method of this name may be defined. You may use the varargs forms * for constructors documented in {@link FunctionObject#FunctionObject(String, Member, Scriptable)} - * + * * If no method is found that can serve as constructor, a Java * constructor will be selected to serve as the JavaScript * constructor in the following manner. If the class has only one @@ -1231,7 +1231,7 @@ static BaseFunction buildClassCtor( { Class superScriptable = extendsScriptable(superClass); - String name = ScriptableObject.defineClass(scope, + String name = ScriptableObject.defineClass(scope, superScriptable, sealed, mapInheritance); if (name != null) { superProto = ScriptableObject.getClassPrototype(scope, name); @@ -1258,7 +1258,7 @@ static BaseFunction buildClassCtor( } if (ctorMember == null) { ctorMember = FunctionObject.findSingleMethod(methods, ctorName); - } + } if (ctorMember == null) { if (ctors.length == 1) { ctorMember = ctors[0]; @@ -2016,8 +2016,8 @@ public void preventExtensions() { /** * Seal this object. * - * It is an error to add properties to or delete properties from - * a sealed object. It is possible to change the value of an + * It is an error to add properties to or delete properties from + * a sealed object. It is possible to change the value of an * existing property. Once an object is sealed it may not be unsealed. * * @since 1.4R3 @@ -2087,7 +2087,7 @@ public static Object getProperty(Scriptable obj, String name) } /** - * Gets an indexed property from an object or any object in its prototype + * Gets an indexed property from an object or any object in its prototype * chain and coerces it to the requested Java type. *

* Searches the prototype chain for a property with integral index @@ -2100,8 +2100,8 @@ public static Object getProperty(Scriptable obj, String name) * @param type the required Java type of the result * @return the value of a property with name name found in * obj or any object in its prototype chain, or - * null if not found. Note that it does not return - * {@link Scriptable#NOT_FOUND} as it can ordinarily not be + * null if not found. Note that it does not return + * {@link Scriptable#NOT_FOUND} as it can ordinarily not be * converted to most of the types. * @since 1.7R3 */ @@ -2152,8 +2152,8 @@ public static Object getProperty(Scriptable obj, int index) * @param type the required Java type of the result * @return the value of a property with name name found in * obj or any object in its prototype chain, or - * null if not found. Note that it does not return - * {@link Scriptable#NOT_FOUND} as it can ordinarily not be + * null if not found. Note that it does not return + * {@link Scriptable#NOT_FOUND} as it can ordinarily not be * converted to most of the types. * @since 1.7R3 */ @@ -2276,7 +2276,7 @@ public static void putConstProperty(Scriptable obj, String name, Object value) * to {@link Scriptable#put(int, Scriptable, Object)} on the prototype * passing obj as the start argument. This allows * the prototype to veto the property setting in case the prototype defines - * the property with [[ReadOnly]] attribute. If the property is not found, + * the property with [[ReadOnly]] attribute. If the property is not found, * it is added in obj. * @param obj a JavaScript object * @param index a property index @@ -2808,7 +2808,7 @@ Object[] getIds(boolean getAll) { if (s == null) return a; int c = 0; - Slot slot = firstAdded; + Slot slot = firstAdded; while (slot != null && slot.wasDeleted) { // as long as we're traversing the order-added linked list, // remove deleted slots @@ -2857,7 +2857,7 @@ private synchronized void writeObject(ObjectOutputStream out) out.writeInt(0); } else { out.writeInt(slots.length); - Slot slot = firstAdded; + Slot slot = firstAdded; while (slot != null && slot.wasDeleted) { // as long as we're traversing the order-added linked list, // remove deleted slots @@ -2884,7 +2884,7 @@ private void readObject(ObjectInputStream in) int tableSize = in.readInt(); if (tableSize != 0) { - // If tableSize is not a power of 2 find the closest + // If tableSize is not a power of 2 find the closest // power of 2 >= the original size. if ((tableSize & (tableSize - 1)) != 0) { if (tableSize > 1 << 30) diff --git a/src/org/mozilla/javascript/SecureCaller.java b/src/org/mozilla/javascript/SecureCaller.java index 3a25290519..0f38b6eb11 100644 --- a/src/org/mozilla/javascript/SecureCaller.java +++ b/src/org/mozilla/javascript/SecureCaller.java @@ -55,27 +55,27 @@ public abstract class SecureCaller { private static final byte[] secureCallerImplBytecode = loadBytecode(); - + // We're storing a CodeSource -> (ClassLoader -> SecureRenderer), since we // need to have one renderer per class loader. We're using weak hash maps // and soft references all the way, since we don't want to interfere with // cleanup of either CodeSource or ClassLoader objects. - private static final Map>> + private static final Map>> callers = new WeakHashMap>>(); - - public abstract Object call(Callable callable, Context cx, + + public abstract Object call(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args); - + /** - * Call the specified callable using a protection domain belonging to the - * specified code source. + * Call the specified callable using a protection domain belonging to the + * specified code source. */ - static Object callSecurely(final CodeSource codeSource, Callable callable, + static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); - // Run in doPrivileged as we might be checked for "getClassLoader" + // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { @@ -105,7 +105,7 @@ public Object run() { if (caller == null) { try { - // Run in doPrivileged as we'll be checked for + // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction() @@ -118,11 +118,11 @@ public Object run() throws Exception effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; - } - SecureClassLoaderImpl secCl = + } + SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class c = secCl.defineAndLinkClass( - SecureCaller.class.getName() + "Impl", + SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); } @@ -137,14 +137,14 @@ public Object run() throws Exception } return caller.call(callable, cx, scope, thisObj, args); } - + private static class SecureClassLoaderImpl extends SecureClassLoader { SecureClassLoaderImpl(ClassLoader parent) { super(parent); } - + Class defineAndLinkClass(String name, byte[] bytes, CodeSource cs) { Class cl = defineClass(name, bytes, 0, bytes.length, cs); @@ -152,7 +152,7 @@ Class defineAndLinkClass(String name, byte[] bytes, CodeSource cs) return cl; } } - + private static byte[] loadBytecode() { return (byte[])AccessController.doPrivileged(new PrivilegedAction() @@ -163,7 +163,7 @@ public Object run() } }); } - + private static byte[] loadBytecodePrivileged() { URL url = SecureCaller.class.getResource("SecureCallerImpl.clazz"); diff --git a/src/org/mozilla/javascript/SecurityController.java b/src/org/mozilla/javascript/SecurityController.java index bd625d90c5..8d51a619c5 100644 --- a/src/org/mozilla/javascript/SecurityController.java +++ b/src/org/mozilla/javascript/SecurityController.java @@ -150,9 +150,9 @@ public static GeneratedClassLoader createLoader( public static Class getStaticSecurityDomainClass() { SecurityController sc = Context.getContext().getSecurityController(); - return sc == null ? null : sc.getStaticSecurityDomainClassInternal(); + return sc == null ? null : sc.getStaticSecurityDomainClassInternal(); } - + public Class getStaticSecurityDomainClassInternal() { return null; diff --git a/src/org/mozilla/javascript/TokenStream.java b/src/org/mozilla/javascript/TokenStream.java index 93caf3f511..ae748c6d86 100644 --- a/src/org/mozilla/javascript/TokenStream.java +++ b/src/org/mozilla/javascript/TokenStream.java @@ -295,7 +295,7 @@ private static int stringToKeyword(String name) } final String getSourceString() { return sourceString; } - + final int getLineno() { return lineno; } final String getString() { return string; } @@ -1264,7 +1264,7 @@ private void addToString(int c) stringBuffer[N] = (char)c; stringBufferTop = N + 1; } - + private boolean canUngetChar() { return ungetCursor == 0 || ungetBuffer[ungetCursor - 1] != '\n'; } diff --git a/src/org/mozilla/javascript/ast/AstRoot.java b/src/org/mozilla/javascript/ast/AstRoot.java index 2cfa35b8a6..327e046f7b 100644 --- a/src/org/mozilla/javascript/ast/AstRoot.java +++ b/src/org/mozilla/javascript/ast/AstRoot.java @@ -107,11 +107,11 @@ public void addComment(Comment comment) { comments.add(comment); comment.setParent(this); } - + public void setInStrictMode(boolean inStrictMode) { this.inStrictMode = inStrictMode; } - + public boolean isInStrictMode() { return inStrictMode; } diff --git a/src/org/mozilla/javascript/ast/DestructuringForm.java b/src/org/mozilla/javascript/ast/DestructuringForm.java index 1a94fabfcd..d99f5f7785 100644 --- a/src/org/mozilla/javascript/ast/DestructuringForm.java +++ b/src/org/mozilla/javascript/ast/DestructuringForm.java @@ -51,7 +51,7 @@ public interface DestructuringForm { * target of a destructuring assignment. */ void setIsDestructuring(boolean destructuring); - + /** * Returns true if this node is in a destructuring position: * a function parameter, the target of a variable initializer, the diff --git a/src/org/mozilla/javascript/ast/ErrorCollector.java b/src/org/mozilla/javascript/ast/ErrorCollector.java index 52ce13a47d..b34bfff70c 100644 --- a/src/org/mozilla/javascript/ast/ErrorCollector.java +++ b/src/org/mozilla/javascript/ast/ErrorCollector.java @@ -89,7 +89,7 @@ public void error(String message, String sourceName, int line, /** * @inheritDoc */ - public void error(String message, String sourceName, + public void error(String message, String sourceName, int fileOffset, int length) { errors.add(new ParseProblem(ParseProblem.Type.Error, diff --git a/src/org/mozilla/javascript/ast/FunctionCall.java b/src/org/mozilla/javascript/ast/FunctionCall.java index 22ebb9fbf2..bdb3c3c2d4 100644 --- a/src/org/mozilla/javascript/ast/FunctionCall.java +++ b/src/org/mozilla/javascript/ast/FunctionCall.java @@ -51,7 +51,7 @@ public class FunctionCall extends AstNode { protected static final List NO_ARGS = Collections.unmodifiableList(new ArrayList()); - + protected AstNode target; protected List arguments; protected int lp = -1; diff --git a/src/org/mozilla/javascript/ast/IdeErrorReporter.java b/src/org/mozilla/javascript/ast/IdeErrorReporter.java index dfb0464831..3acfa45dbe 100644 --- a/src/org/mozilla/javascript/ast/IdeErrorReporter.java +++ b/src/org/mozilla/javascript/ast/IdeErrorReporter.java @@ -76,7 +76,7 @@ public interface IdeErrorReporter extends ErrorReporter { * @param length the length of the region contributing to the warning */ void warning(String message, String sourceName, int offset, int length); - + /** * Report an error.

* diff --git a/src/org/mozilla/javascript/ast/ScriptNode.java b/src/org/mozilla/javascript/ast/ScriptNode.java index 86b7a21bfe..b1330fdc6b 100644 --- a/src/org/mozilla/javascript/ast/ScriptNode.java +++ b/src/org/mozilla/javascript/ast/ScriptNode.java @@ -162,7 +162,7 @@ public void setEncodedSource(String encodedSource) { * {@link AstNode#toSource} method, although it's not guaranteed to produce * exactly the same results as {@code Object.toSource} with respect to * formatting, parenthesization and other details. - * + * * @return the encoded source, or {@code null} if it was not recorded. */ public String getEncodedSource() { diff --git a/src/org/mozilla/javascript/ast/Symbol.java b/src/org/mozilla/javascript/ast/Symbol.java index 3ca5c9c710..9658aa07b7 100644 --- a/src/org/mozilla/javascript/ast/Symbol.java +++ b/src/org/mozilla/javascript/ast/Symbol.java @@ -49,7 +49,7 @@ */ public class Symbol { - // One of Token.FUNCTION, Token.LP (for parameters), Token.VAR, + // One of Token.FUNCTION, Token.LP (for parameters), Token.VAR, // Token.LET, or Token.CONST private int declType; private int index = -1; diff --git a/src/org/mozilla/javascript/commonjs/module/ModuleScript.java b/src/org/mozilla/javascript/commonjs/module/ModuleScript.java index 32a3b3a21a..6da88ba127 100644 --- a/src/org/mozilla/javascript/commonjs/module/ModuleScript.java +++ b/src/org/mozilla/javascript/commonjs/module/ModuleScript.java @@ -6,7 +6,7 @@ import org.mozilla.javascript.Script; /** - * Represents a compiled CommonJS module script. The {@link Require} functions + * Represents a compiled CommonJS module script. The {@link Require} functions * use them and obtain them through a {@link ModuleScriptProvider}. Instances * are immutable. * @author Attila Szegedi @@ -15,7 +15,7 @@ public class ModuleScript implements Serializable { private static final long serialVersionUID = 1L; - + private final Script script; private final URI uri; private final URI base; @@ -31,7 +31,7 @@ public ModuleScript(Script script, URI uri, URI base) { this.uri = uri; this.base = base; } - + /** * Returns the script object representing the code of the module. * @return the script object representing the code of the module. diff --git a/src/org/mozilla/javascript/commonjs/module/ModuleScriptProvider.java b/src/org/mozilla/javascript/commonjs/module/ModuleScriptProvider.java index 14cc90bdfc..fbb9970aa0 100644 --- a/src/org/mozilla/javascript/commonjs/module/ModuleScriptProvider.java +++ b/src/org/mozilla/javascript/commonjs/module/ModuleScriptProvider.java @@ -8,16 +8,16 @@ /** * Should be implemented by Rhino embeddings to allow the require() function to * obtain {@link ModuleScript} objects. We provide two default implementations, - * but you can of course roll your own if they don't suit your needs. + * but you can of course roll your own if they don't suit your needs. * @author Attila Szegedi * @version $Id: ModuleScriptProvider.java,v 1.4 2011/04/07 20:26:11 hannes%helma.at Exp $ */ public interface ModuleScriptProvider { /** - * Returns a module script. It should attempt to load the module script if - * it is not already available to it, or return an already loaded module - * script instance if it is available to it. + * Returns a module script. It should attempt to load the module script if + * it is not already available to it, or return an already loaded module + * script instance if it is available to it. * @param cx current context. Can be used to compile module scripts. * @param moduleId the ID of the module. An implementation must only accept * an absolute ID, starting with a term. @@ -28,9 +28,9 @@ public interface ModuleScriptProvider * the require() function is sandboxed, it will be null, otherwise it will * be a JavaScript Array object. It is up to the provider implementation * whether and how it wants to honor the contents of the array. - * @return a module script representing the compiled code of the module. + * @return a module script representing the compiled code of the module. * Null should be returned if the script could not found. - * @throws Exception if there was an unrecoverable problem obtaining the + * @throws Exception if there was an unrecoverable problem obtaining the * script * @throws IllegalArgumentException if the module ID is syntactically not a * valid absolute module identifier. diff --git a/src/org/mozilla/javascript/commonjs/module/Require.java b/src/org/mozilla/javascript/commonjs/module/Require.java index efd898b25c..631e69619d 100644 --- a/src/org/mozilla/javascript/commonjs/module/Require.java +++ b/src/org/mozilla/javascript/commonjs/module/Require.java @@ -15,21 +15,21 @@ import org.mozilla.javascript.ScriptableObject; /** - * Implements the require() function as defined by + * Implements the require() function as defined by * Common JS modules. *

Thread safety

* You will ordinarily create one instance of require() for every top-level - * scope. This ordinarily means one instance per program execution, except if - * you use shared top-level scopes and installing most objects into them. - * Module loading is thread safe, so using a single require() in a shared + * scope. This ordinarily means one instance per program execution, except if + * you use shared top-level scopes and installing most objects into them. + * Module loading is thread safe, so using a single require() in a shared * top-level scope is also safe. *

Creation

- * If you need to create many otherwise identical require() functions for - * different scopes, you might want to use {@link RequireBuilder} for + * If you need to create many otherwise identical require() functions for + * different scopes, you might want to use {@link RequireBuilder} for * convenience. *

Making it available

- * In order to make the require() function available to your JavaScript - * program, you need to invoke either {@link #install(Scriptable)} or + * In order to make the require() function available to your JavaScript + * program, you need to invoke either {@link #install(Scriptable)} or * {@link #requireMain(Context, String)}. * @author Attila Szegedi * @version $Id: Require.java,v 1.4 2011/04/07 20:26:11 hannes%helma.at Exp $ @@ -48,34 +48,34 @@ public class Require extends BaseFunction private Scriptable mainExports; // Modules that completed loading; visible to all threads - private final Map exportedModuleInterfaces = + private final Map exportedModuleInterfaces = new ConcurrentHashMap(); private final Object loadLock = new Object(); // Modules currently being loaded on the thread. Used to resolve circular // dependencies while loading. - private static final ThreadLocal> + private static final ThreadLocal> loadingModuleInterfaces = new ThreadLocal>(); /** * Creates a new instance of the require() function. Upon constructing it, - * you will either want to install it in the global (or some other) scope + * you will either want to install it in the global (or some other) scope * using {@link #install(Scriptable)}, or alternatively, you can load the - * program's main module using {@link #requireMain(Context, String)} and + * program's main module using {@link #requireMain(Context, String)} and * then act on the main module's exports. * @param cx the current context - * @param nativeScope a scope that provides the standard native JavaScript + * @param nativeScope a scope that provides the standard native JavaScript * objects. * @param moduleScriptProvider a provider for module scripts - * @param preExec an optional script that is executed in every module's + * @param preExec an optional script that is executed in every module's * scope before its module script is run. - * @param postExec an optional script that is executed in every module's + * @param postExec an optional script that is executed in every module's * scope after its module script is run. - * @param sandboxed if set to true, the require function will be sandboxed. - * This means that it doesn't have the "paths" property, and also that the - * modules it loads don't export the "module.uri" property. + * @param sandboxed if set to true, the require function will be sandboxed. + * This means that it doesn't have the "paths" property, and also that the + * modules it loads don't export the "module.uri" property. */ - public Require(Context cx, Scriptable nativeScope, - ModuleScriptProvider moduleScriptProvider, Script preExec, + public Require(Context cx, Scriptable nativeScope, + ModuleScriptProvider moduleScriptProvider, Script preExec, Script postExec, boolean sandboxed) { this.moduleScriptProvider = moduleScriptProvider; this.nativeScope = nativeScope; @@ -91,7 +91,7 @@ public Require(Context cx, Scriptable nativeScope, paths = null; } } - + /** * Calling this method establishes a module as being the main module of the * program to which this require() instance belongs. The module will be @@ -102,12 +102,12 @@ public Require(Context cx, Scriptable nativeScope, * that the main module will execute in its own scope and not in the global * scope. Since all other modules see the global scope, executing the main * module in the global scope would open it for tampering by other modules. - * @param cx the current context + * @param cx the current context * @param mainModuleId the ID of the main module * @return the "exports" property of the main module * @throws IllegalStateException if the main module is already loaded when - * required, or if this require() instance already has a different main - * module set. + * required, or if this require() instance already has a different main + * module set. */ public Scriptable requireMain(Context cx, String mainModuleId) { if(this.mainModuleId != null) { @@ -161,7 +161,7 @@ public Scriptable requireMain(Context cx, String mainModuleId) { } /** - * Binds this instance of require() into the specified scope under the + * Binds this instance of require() into the specified scope under the * property name "require". * @param scope the scope where the require() function is to be installed. */ @@ -173,7 +173,7 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if(args == null || args.length < 1) { - throw ScriptRuntime.throwError(cx, scope, + throw ScriptRuntime.throwError(cx, scope, "require() needs one argument"); } @@ -215,7 +215,7 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, } public Scriptable construct(Context cx, Scriptable scope, Object[] args) { - throw ScriptRuntime.throwError(cx, scope, + throw ScriptRuntime.throwError(cx, scope, "require() can not be invoked as a constructor"); } @@ -231,9 +231,9 @@ private Scriptable getExportedModuleInterface(Context cx, String id, } return exports; } - // Check if it is currently being loaded on the current thread + // Check if it is currently being loaded on the current thread // (supporting circular dependencies). - Map threadLoadingModules = + Map threadLoadingModules = loadingModuleInterfaces.get(); if(threadLoadingModules != null) { exports = threadLoadingModules.get(id); @@ -241,16 +241,16 @@ private Scriptable getExportedModuleInterface(Context cx, String id, return exports; } } - // The requested module is neither already loaded, nor is it being - // loaded on the current thread. End of fast path. We must synchronize - // now, as we have to guarantee that at most one thread can load - // modules at any one time. Otherwise, two threads could end up - // attempting to load two circularly dependent modules in opposite - // order, which would lead to either unacceptable non-determinism or + // The requested module is neither already loaded, nor is it being + // loaded on the current thread. End of fast path. We must synchronize + // now, as we have to guarantee that at most one thread can load + // modules at any one time. Otherwise, two threads could end up + // attempting to load two circularly dependent modules in opposite + // order, which would lead to either unacceptable non-determinism or // deadlock, depending on whether we underprotected or overprotected it // with locks. synchronized(loadLock) { - // Recheck if it is already loaded - other thread might've + // Recheck if it is already loaded - other thread might've // completed loading it just as we entered the synchronized block. exports = exportedModuleInterfaces.get(id); if(exports != null) { @@ -269,13 +269,13 @@ private Scriptable getExportedModuleInterface(Context cx, String id, threadLoadingModules = new HashMap(); loadingModuleInterfaces.set(threadLoadingModules); } - // Must make the module exports available immediately on the - // current thread, to satisfy the CommonJS Modules/1.1 requirement + // Must make the module exports available immediately on the + // current thread, to satisfy the CommonJS Modules/1.1 requirement // that "If there is a dependency cycle, the foreign module may not // have finished executing at the time it is required by one of its - // transitive dependencies; in this case, the object returned by - // "require" must contain at least the exports that the foreign - // module has prepared before the call to require that led to the + // transitive dependencies; in this case, the object returned by + // "require" must contain at least the exports that the foreign + // module has prepared before the call to require that led to the // current module's execution." threadLoadingModules.put(id, exports); try { @@ -295,9 +295,9 @@ private Scriptable getExportedModuleInterface(Context cx, String id, } finally { if(outermostLocked) { - // Make loaded modules visible to other threads only after + // Make loaded modules visible to other threads only after // the topmost triggering load has completed. This strategy - // (compared to the one where we'd make each module + // (compared to the one where we'd make each module // globally available as soon as it loads) prevents other // threads from observing a partially loaded circular // dependency of a module that completed loading. @@ -321,9 +321,9 @@ private Scriptable executeModuleScript(Context cx, String id, defineReadOnlyProperty(moduleObject, "uri", uri.toString()); } final Scriptable executionScope = new ModuleScope(nativeScope, uri, base); - // Set this so it can access the global JS environment objects. - // This means we're currently using the "MGN" approach (ModuleScript - // with Global Natives) as specified here: + // Set this so it can access the global JS environment objects. + // This means we're currently using the "MGN" approach (ModuleScript + // with Global Natives) as specified here: // executionScope.put("exports", executionScope, exports); executionScope.put("module", executionScope, moduleObject); @@ -338,8 +338,8 @@ private Scriptable executeModuleScript(Context cx, String id, return ScriptRuntime.toObject(nativeScope, ScriptableObject.getProperty(moduleObject, "exports")); } - - private static void executeOptionalScript(Script script, Context cx, + + private static void executeOptionalScript(Script script, Context cx, Scriptable executionScope) { if(script != null) { @@ -347,10 +347,10 @@ private static void executeOptionalScript(Script script, Context cx, } } - private static void defineReadOnlyProperty(ScriptableObject obj, + private static void defineReadOnlyProperty(ScriptableObject obj, String name, Object value) { ScriptableObject.putProperty(obj, name, value); - obj.setAttributes(name, ScriptableObject.READONLY | + obj.setAttributes(name, ScriptableObject.READONLY | ScriptableObject.PERMANENT); } diff --git a/src/org/mozilla/javascript/commonjs/module/RequireBuilder.java b/src/org/mozilla/javascript/commonjs/module/RequireBuilder.java index 9c64f65227..c93f82d43b 100644 --- a/src/org/mozilla/javascript/commonjs/module/RequireBuilder.java +++ b/src/org/mozilla/javascript/commonjs/module/RequireBuilder.java @@ -11,7 +11,7 @@ * instances of {@link Require} that are identical except for their top-level * scope and current {@link Context}. Also useful if you prefer configuring it * using named setters instead of passing many parameters in a constructor. - * Every setter returns "this", so you can easily chain their invocations for + * Every setter returns "this", so you can easily chain their invocations for * additional convenience. * @author Attila Szegedi * @version $Id: RequireBuilder.java,v 1.4 2011/04/07 20:26:11 hannes%helma.at Exp $ @@ -24,12 +24,12 @@ public class RequireBuilder implements Serializable private ModuleScriptProvider moduleScriptProvider; private Script preExec; private Script postExec; - + /** * Sets the {@link ModuleScriptProvider} for the {@link Require} instances * that this builder builds. - * @param moduleScriptProvider the module script provider for the - * {@link Require} instances that this builder builds. + * @param moduleScriptProvider the module script provider for the + * {@link Require} instances that this builder builds. * @return this, so you can chain ("fluidize") setter invocations */ public RequireBuilder setModuleScriptProvider( @@ -38,7 +38,7 @@ public RequireBuilder setModuleScriptProvider( this.moduleScriptProvider = moduleScriptProvider; return this; } - + /** * Sets the script that should execute in every module's scope after the * module's own script has executed. @@ -60,12 +60,12 @@ public RequireBuilder setPreExec(Script preExec) { this.preExec = preExec; return this; } - + /** - * Sets whether the created require() instances will be sandboxed. + * Sets whether the created require() instances will be sandboxed. * See {@link Require#Require(Context, Scriptable, ModuleScriptProvider, * Script, Script, boolean)} for explanation. - * @param sandboxed true if the created require() instances will be + * @param sandboxed true if the created require() instances will be * sandboxed. * @return this, so you can chain ("fluidize") setter invocations */ @@ -73,18 +73,18 @@ public RequireBuilder setSandboxed(boolean sandboxed) { this.sandboxed = sandboxed; return this; } - + /** * Creates a new require() function. You are still responsible for invoking - * either {@link Require#install(Scriptable)} or - * {@link Require#requireMain(Context, String)} to effectively make it - * available to its JavaScript program. + * either {@link Require#install(Scriptable)} or + * {@link Require#requireMain(Context, String)} to effectively make it + * available to its JavaScript program. * @param cx the current context * @param globalScope the global scope containing the JS standard natives. * @return a new Require instance. */ public Require createRequire(Context cx, Scriptable globalScope) { - return new Require(cx, globalScope, moduleScriptProvider, preExec, + return new Require(cx, globalScope, moduleScriptProvider, preExec, postExec, sandboxed); } } \ No newline at end of file diff --git a/src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java b/src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java index f678a69a9d..206b115947 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/CachingModuleScriptProviderBase.java @@ -10,21 +10,21 @@ import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; /** - * Abstract base class that implements caching of loaded module scripts. It - * uses a {@link ModuleSourceProvider} to obtain the source text of the - * scripts. It supports a cache revalidation mechanism based on validator + * Abstract base class that implements caching of loaded module scripts. It + * uses a {@link ModuleSourceProvider} to obtain the source text of the + * scripts. It supports a cache revalidation mechanism based on validator * objects returned from the {@link ModuleSourceProvider}. Instances of this - * class and its subclasses are thread safe (and written to perform decently + * class and its subclasses are thread safe (and written to perform decently * under concurrent access). * @author Attila Szegedi * @version $Id: CachingModuleScriptProviderBase.java,v 1.3 2011/04/07 20:26:12 hannes%helma.at Exp $ */ -public abstract class CachingModuleScriptProviderBase +public abstract class CachingModuleScriptProviderBase implements ModuleScriptProvider, Serializable { private static final long serialVersionUID = 1L; - private static final int loadConcurrencyLevel = + private static final int loadConcurrencyLevel = Runtime.getRuntime().availableProcessors() * 8; private static final int loadLockShift; private static final int loadLockMask; @@ -45,7 +45,7 @@ public abstract class CachingModuleScriptProviderBase loadLocks[i] = new Object(); } } - + private final ModuleSourceProvider moduleSourceProvider; /** @@ -57,7 +57,7 @@ protected CachingModuleScriptProviderBase( this.moduleSourceProvider = moduleSourceProvider; } - public ModuleScript getModuleScript(Context cx, String moduleId, + public ModuleScript getModuleScript(Context cx, String moduleId, URI moduleUri, Scriptable paths) throws Exception { final CachedModuleScript cachedModule1 = getLoadedModule(moduleId); @@ -97,17 +97,17 @@ public ModuleScript getModuleScript(Context cx, String moduleId, } /** - * Store a loaded module script for later retrieval using + * Store a loaded module script for later retrieval using * {@link #getLoadedModule(String)}. * @param moduleId the ID of the module * @param moduleScript the module script * @param validator the validator for the module's source text entity */ - protected abstract void putLoadedModule(String moduleId, + protected abstract void putLoadedModule(String moduleId, ModuleScript moduleScript, Object validator); /** - * Retrieves an already loaded moduleScript stored using + * Retrieves an already loaded moduleScript stored using * {@link #putLoadedModule(String, ModuleScript, Object)}. * @param moduleId the ID of the module * @return a cached module script, or null if the module is not loaded. @@ -122,18 +122,18 @@ protected abstract void putLoadedModule(String moduleId, public static class CachedModuleScript { private final ModuleScript moduleScript; private final Object validator; - + /** * Creates a new cached module script. * @param moduleScript the module script itself - * @param validator a validator for the moduleScript's source text + * @param validator a validator for the moduleScript's source text * entity. */ public CachedModuleScript(ModuleScript moduleScript, Object validator) { this.moduleScript = moduleScript; this.validator = validator; } - + /** * Returns the module script. * @return the module script. @@ -141,7 +141,7 @@ public CachedModuleScript(ModuleScript moduleScript, Object validator) { ModuleScript getModule() { return moduleScript; } - + /** * Returns the validator for the module script's source text entity. * @return the validator for the module script's source text entity. @@ -150,15 +150,15 @@ Object getValidator() { return validator; } } - + private static Object getValidator(CachedModuleScript cachedModule) { return cachedModule == null ? null : cachedModule.getValidator(); } - + private static boolean equal(Object o1, Object o2) { return o1 == null ? o2 == null : o1.equals(o2); } - + /** * Returns the internal concurrency level utilized by caches in this JVM. * @return the internal concurrency level utilized by caches in this JVM. diff --git a/src/org/mozilla/javascript/commonjs/module/provider/DefaultUrlConnectionExpiryCalculator.java b/src/org/mozilla/javascript/commonjs/module/provider/DefaultUrlConnectionExpiryCalculator.java index b35e6cab05..0bda11aee6 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/DefaultUrlConnectionExpiryCalculator.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/DefaultUrlConnectionExpiryCalculator.java @@ -6,27 +6,27 @@ /** * The default heuristic for calculating cache expiry of URL-based resources. * It is simply configured with a default relative expiry, and each invocation - * of {@link #calculateExpiry(URLConnection)} returns - * {@link System#currentTimeMillis()} incremented with the relative expiry. + * of {@link #calculateExpiry(URLConnection)} returns + * {@link System#currentTimeMillis()} incremented with the relative expiry. * @author Attila Szegedi * @version $Id: DefaultUrlConnectionExpiryCalculator.java,v 1.3 2011/04/07 20:26:12 hannes%helma.at Exp $ */ -public class DefaultUrlConnectionExpiryCalculator +public class DefaultUrlConnectionExpiryCalculator implements UrlConnectionExpiryCalculator, Serializable { private static final long serialVersionUID = 1L; private final long relativeExpiry; - + /** * Creates a new default expiry calculator with one minute relative expiry. */ public DefaultUrlConnectionExpiryCalculator() { this(60000L); } - + /** - * Creates a new default expiry calculator with the specified relative + * Creates a new default expiry calculator with the specified relative * expiry. * @param relativeExpiry the fixed relative expiry, in milliseconds. */ @@ -36,7 +36,7 @@ public DefaultUrlConnectionExpiryCalculator(long relativeExpiry) { } this.relativeExpiry = relativeExpiry; } - + public long calculateExpiry(URLConnection urlConnection) { return System.currentTimeMillis() + relativeExpiry; } diff --git a/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProvider.java b/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProvider.java index ede89a0929..8a60b0e2f7 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProvider.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProvider.java @@ -8,7 +8,7 @@ /** * Implemented by objects that can provide the source text for the script. The - * design of the interface supports cache revalidation. + * design of the interface supports cache revalidation. * @author Attila Szegedi * @version $Id: ModuleSourceProvider.java,v 1.3 2011/04/07 20:26:12 hannes%helma.at Exp $ */ @@ -19,23 +19,23 @@ public interface ModuleSourceProvider * Object)} and {@link #loadSource(URI, Object)} that signifies that the * cached representation is still valid according to the passed validator. */ - public static final ModuleSource NOT_MODIFIED = new ModuleSource(null, + public static final ModuleSource NOT_MODIFIED = new ModuleSource(null, null, null, null, null); - + /** - * Returns the script source of the requested module. More specifically, it + * Returns the script source of the requested module. More specifically, it * resolves the module ID to a resource. If it can not resolve it, null is - * returned. If the caller passes a non-null validator, and the source - * provider recognizes it, and the validator applies to the same resource - * that the provider would use to load the source, and the validator - * validates the current cached representation of the resource (using - * whatever semantics for validation that this source provider implements), - * then {@link #NOT_MODIFIED} should be returned. Otherwise, it should - * return a {@link ModuleSource} object with the actual source text of the - * module, preferrably a validator for it, and a security domain, where - * applicable. + * returned. If the caller passes a non-null validator, and the source + * provider recognizes it, and the validator applies to the same resource + * that the provider would use to load the source, and the validator + * validates the current cached representation of the resource (using + * whatever semantics for validation that this source provider implements), + * then {@link #NOT_MODIFIED} should be returned. Otherwise, it should + * return a {@link ModuleSource} object with the actual source text of the + * module, preferrably a validator for it, and a security domain, where + * applicable. * @param moduleId the ID of the module. An implementation must only accept - * an absolute ID, starting with a term. + * an absolute ID, starting with a term. * @param paths the value of the require() function's "paths" attribute. If * the require() function is sandboxed, it will be null, otherwise it will * be a JavaScript Array object. It is up to the provider implementation @@ -45,7 +45,7 @@ public interface ModuleSourceProvider * returned earlier as part of a {@link ModuleSource}. It can be used to * validate the existing cached module and avoid reloading it. * @return a script representing the code of the module. Null should be - * returned if the script is not found. {@link #NOT_MODIFIED} should be + * returned if the script is not found. {@link #NOT_MODIFIED} should be * returned if the passed validator validates the current representation of * the module (the currently cached module script). * @throws IOException if there was an I/O problem reading the script diff --git a/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java b/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java index 42a8f3303c..48ee7846b3 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/ModuleSourceProviderBase.java @@ -12,13 +12,13 @@ import org.mozilla.javascript.ScriptableObject; /** - * A base implementation for all module script providers that actually load + * A base implementation for all module script providers that actually load * module scripts. Performs validation of identifiers, allows loading from - * preferred locations (attempted before require.paths), from require.paths - * itself, and from fallback locations (attempted after require.paths). Note - * that while this base class strives to be as generic as possible, it does + * preferred locations (attempted before require.paths), from require.paths + * itself, and from fallback locations (attempted after require.paths). Note + * that while this base class strives to be as generic as possible, it does * have loading from an URI built into its design, for the simple reason that - * the require.paths is defined in terms of URIs. + * the require.paths is defined in terms of URIs. * @author Attila Szegedi * @version $Id: ModuleSourceProviderBase.java,v 1.3 2011/04/07 20:26:12 hannes%helma.at Exp $ */ @@ -33,7 +33,7 @@ public ModuleSource loadSource(String moduleId, Scriptable paths, if(!entityNeedsRevalidation(validator)) { return NOT_MODIFIED; } - + ModuleSource moduleSource = loadFromPrivilegedLocations( moduleId, validator); if(moduleSource != null) { @@ -60,7 +60,7 @@ private ModuleSource loadFromPathArray(String moduleId, final long llength = ScriptRuntime.toUint32( ScriptableObject.getProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. - int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : + int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)llength; for(int i = 0; i < ilength; ++i) { @@ -89,21 +89,21 @@ private static String ensureTrailingSlash(String path) { } /** - * Override to determine whether according to the validator, the cached - * module script needs revalidation. A validator can carry expiry + * Override to determine whether according to the validator, the cached + * module script needs revalidation. A validator can carry expiry * information. If the cached representation is not expired, it doesn' * t need revalidation, otherwise it does. When no cache revalidation is - * required, the external resource will not be contacted at all, so some - * level of expiry (staleness tolerance) can greatly enhance performance. - * The default implementation always returns true so it will always require + * required, the external resource will not be contacted at all, so some + * level of expiry (staleness tolerance) can greatly enhance performance. + * The default implementation always returns true so it will always require * revalidation. * @param validator the validator - * @return returns true if the cached module needs revalidation. + * @return returns true if the cached module needs revalidation. */ protected boolean entityNeedsRevalidation(Object validator) { return true; } - + /** * Override in a subclass to load a module script from a logical URI. The * URI is absolute but does not have a file name extension such as ".js". @@ -112,10 +112,10 @@ protected boolean entityNeedsRevalidation(Object validator) { * @param uri the URI of the script, without file name extension. * @param base the base URI the uri was resolved from. * @param validator a validator that can be used to revalidate an existing - * cached source at the URI. Can be null if there is no cached source + * cached source at the URI. Can be null if there is no cached source * available. - * @return the loaded module script, or null if it can't be found, or - * {@link ModuleSourceProvider#NOT_MODIFIED} if it revalidated the existing + * @return the loaded module script, or null if it can't be found, or + * {@link ModuleSourceProvider#NOT_MODIFIED} if it revalidated the existing * cached source against the URI. * @throws IOException if the module script was found, but an I/O exception * prevented it from being loaded. @@ -125,8 +125,8 @@ protected abstract ModuleSource loadFromUri(URI uri, URI base, Object validator) throws IOException, URISyntaxException; /** - * Override to obtain a module source from privileged locations. This will - * be called before source is attempted to be obtained from URIs specified + * Override to obtain a module source from privileged locations. This will + * be called before source is attempted to be obtained from URIs specified * in require.paths. * @param moduleId the ID of the module * @param validator a validator that can be used to validate an existing @@ -146,8 +146,8 @@ protected ModuleSource loadFromPrivilegedLocations( } /** - * Override to obtain a module source from fallback locations. This will - * be called after source is attempted to be obtained from URIs specified + * Override to obtain a module source from fallback locations. This will + * be called after source is attempted to be obtained from URIs specified * in require.paths. * @param moduleId the ID of the module * @param validator a validator that can be used to validate an existing diff --git a/src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java b/src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java index 413d8ef746..2f357ecb30 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/MultiModuleScriptProvider.java @@ -17,9 +17,9 @@ public class MultiModuleScriptProvider implements ModuleScriptProvider { private final ModuleScriptProvider[] providers; - + /** - * Creates a new multiplexing module script provider tht gathers the + * Creates a new multiplexing module script provider tht gathers the * specified providers * @param providers the providers to multiplex. */ @@ -30,7 +30,7 @@ public MultiModuleScriptProvider(Iterable provid } this.providers = l.toArray(new ModuleScriptProvider[l.size()]); } - + public ModuleScript getModuleScript(Context cx, String moduleId, URI uri, Scriptable paths) throws Exception { for (ModuleScriptProvider provider : providers) { diff --git a/src/org/mozilla/javascript/commonjs/module/provider/ParsedContentType.java b/src/org/mozilla/javascript/commonjs/module/provider/ParsedContentType.java index de3ab8286c..33f16b60b5 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/ParsedContentType.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/ParsedContentType.java @@ -15,10 +15,10 @@ public final class ParsedContentType implements Serializable private final String contentType; private final String encoding; - + /** * Creates a new parsed content type. - * @param mimeType the full MIME type; typically the value of the + * @param mimeType the full MIME type; typically the value of the * "Content-Type" header of some MIME-compliant message. Can be null. */ public ParsedContentType(String mimeType) { @@ -49,7 +49,7 @@ public ParsedContentType(String mimeType) { this.contentType = contentType; this.encoding = encoding; } - + /** * Returns the content type (without charset declaration) of the MIME type. * @return the content type (without charset declaration) of the MIME type. @@ -58,7 +58,7 @@ public ParsedContentType(String mimeType) { public String getContentType() { return contentType; } - + /** * Returns the character encoding of the MIME type. * @return the character encoding of the MIME type. Can be null when it is diff --git a/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java b/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java index 4b6c12ee60..d372c28902 100644 --- a/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java +++ b/src/org/mozilla/javascript/commonjs/module/provider/SoftCachingModuleScriptProvider.java @@ -18,23 +18,23 @@ /** * A module script provider that uses a module source provider to load modules - * and caches the loaded modules. It softly references the loaded modules' + * and caches the loaded modules. It softly references the loaded modules' * Rhino {@link Script} objects, thus a module once loaded can become eligible * for garbage collection if it is otherwise unused under memory pressure. - * Instances of this class are thread safe. + * Instances of this class are thread safe. * @author Attila Szegedi * @version $Id: SoftCachingModuleScriptProvider.java,v 1.3 2011/04/07 20:26:12 hannes%helma.at Exp $ */ -public class SoftCachingModuleScriptProvider extends CachingModuleScriptProviderBase +public class SoftCachingModuleScriptProvider extends CachingModuleScriptProviderBase { private static final long serialVersionUID = 1L; - private transient ReferenceQueue