├── .gitattributes
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE.txt
├── NOTICE-tools.txt
├── NOTICE.txt
├── README.md
├── RELEASE-NOTES.md
├── RELEASE-STEPS.md
├── build.gradle
├── checkstyle.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── man
└── rhino.1
├── resources
├── StrUtils.class
├── StrUtils.java
└── dx-29.0.3.jar
├── spotbugs-exclude.xml
├── src
├── META-INF
│ └── services
│ │ └── javax.script.ScriptEngineFactory
├── defpackage
│ └── StrUtils.java
└── org
│ └── mozilla
│ ├── classfile
│ ├── ByteCode.java
│ ├── ClassFileField.java
│ ├── ClassFileMethod.java
│ ├── ClassFileWriter.java
│ ├── ConstantEntry.java
│ ├── ConstantPool.java
│ ├── ExceptionTableEntry.java
│ ├── FieldOrMethodRef.java
│ ├── SuperBlock.java
│ └── TypeInfo.java
│ ├── javascript
│ ├── AbstractEcmaObjectOperations.java
│ ├── AccessorSlot.java
│ ├── Arguments.java
│ ├── ArrowFunction.java
│ ├── BaseFunction.java
│ ├── BoundFunction.java
│ ├── Callable.java
│ ├── ClassCache.java
│ ├── ClassShutter.java
│ ├── CodeGenerator.java
│ ├── CompilerEnvirons.java
│ ├── ConsString.java
│ ├── ConstProperties.java
│ ├── Constructable.java
│ ├── Context.java
│ ├── ContextAction.java
│ ├── ContextFactory.java
│ ├── ContextListener.java
│ ├── ContinuationPending.java
│ ├── DToA.java
│ ├── Decompiler.java
│ ├── DefaultErrorReporter.java
│ ├── DefiningClassLoader.java
│ ├── Delegator.java
│ ├── ES6Generator.java
│ ├── ES6Iterator.java
│ ├── EcmaError.java
│ ├── EmbeddedSlotMap.java
│ ├── EqualObjectGraphs.java
│ ├── ErrorReporter.java
│ ├── Evaluator.java
│ ├── EvaluatorException.java
│ ├── ExternalArrayData.java
│ ├── Function.java
│ ├── FunctionObject.java
│ ├── GeneratedClassLoader.java
│ ├── HashSlotMap.java
│ ├── Hashtable.java
│ ├── IRFactory.java
│ ├── Icode.java
│ ├── IdFunctionCall.java
│ ├── IdFunctionObject.java
│ ├── IdFunctionObjectES6.java
│ ├── IdScriptableObject.java
│ ├── ImplementationVersion.java
│ ├── ImporterTopLevel.java
│ ├── InterfaceAdapter.java
│ ├── InterpretedFunction.java
│ ├── Interpreter.java
│ ├── InterpreterData.java
│ ├── IteratorLikeIterable.java
│ ├── JavaAdapter.java
│ ├── JavaMembers.java
│ ├── JavaMembers_jdk11.java
│ ├── JavaScriptException.java
│ ├── JavaToJSONConverters.java
│ ├── Kit.java
│ ├── LambdaConstructor.java
│ ├── LambdaFunction.java
│ ├── LambdaSlot.java
│ ├── LazilyLoadedCtor.java
│ ├── LazyLoadSlot.java
│ ├── MemberBox.java
│ ├── NativeArray.java
│ ├── NativeArrayIterator.java
│ ├── NativeBigInt.java
│ ├── NativeBoolean.java
│ ├── NativeCall.java
│ ├── NativeCallSite.java
│ ├── NativeCollectionIterator.java
│ ├── NativeContinuation.java
│ ├── NativeDate.java
│ ├── NativeError.java
│ ├── NativeFunction.java
│ ├── NativeGenerator.java
│ ├── NativeGlobal.java
│ ├── NativeIterator.java
│ ├── NativeJSON.java
│ ├── NativeJavaArray.java
│ ├── NativeJavaClass.java
│ ├── NativeJavaConstructor.java
│ ├── NativeJavaList.java
│ ├── NativeJavaMap.java
│ ├── NativeJavaMethod.java
│ ├── NativeJavaObject.java
│ ├── NativeJavaPackage.java
│ ├── NativeJavaTopPackage.java
│ ├── NativeMap.java
│ ├── NativeMath.java
│ ├── NativeNumber.java
│ ├── NativeObject.java
│ ├── NativePromise.java
│ ├── NativeScript.java
│ ├── NativeSet.java
│ ├── NativeString.java
│ ├── NativeStringIterator.java
│ ├── NativeSymbol.java
│ ├── NativeWeakMap.java
│ ├── NativeWeakSet.java
│ ├── NativeWith.java
│ ├── Node.java
│ ├── NodeTransformer.java
│ ├── ObjArray.java
│ ├── ObjToIntMap.java
│ ├── Parser.java
│ ├── PolicySecurityController.java
│ ├── Ref.java
│ ├── RefCallable.java
│ ├── RegExpProxy.java
│ ├── RhinoException.java
│ ├── RhinoSecurityManager.java
│ ├── Script.java
│ ├── ScriptRuntime.java
│ ├── ScriptRuntimeES6.java
│ ├── ScriptStackElement.java
│ ├── Scriptable.java
│ ├── ScriptableObject.java
│ ├── SecureCaller.java
│ ├── SecurityController.java
│ ├── SecurityUtilities.java
│ ├── Slot.java
│ ├── SlotMap.java
│ ├── SlotMapContainer.java
│ ├── Sorting.java
│ ├── SpecialRef.java
│ ├── StackStyle.java
│ ├── Symbol.java
│ ├── SymbolKey.java
│ ├── SymbolScriptable.java
│ ├── Synchronizer.java
│ ├── ThreadSafeSlotMapContainer.java
│ ├── Token.java
│ ├── TokenStream.java
│ ├── TopLevel.java
│ ├── UintMap.java
│ ├── Undefined.java
│ ├── UnhandledRejectionTracker.java
│ ├── UniqueTag.java
│ ├── VMBridge.java
│ ├── WrapFactory.java
│ ├── WrappedException.java
│ ├── Wrapper.java
│ ├── annotations
│ │ ├── JSConstructor.java
│ │ ├── JSFunction.java
│ │ ├── JSGetter.java
│ │ ├── JSSetter.java
│ │ └── JSStaticFunction.java
│ ├── ast
│ │ ├── ArrayComprehension.java
│ │ ├── ArrayComprehensionLoop.java
│ │ ├── ArrayLiteral.java
│ │ ├── Assignment.java
│ │ ├── AstNode.java
│ │ ├── AstRoot.java
│ │ ├── BigIntLiteral.java
│ │ ├── Block.java
│ │ ├── BreakStatement.java
│ │ ├── CatchClause.java
│ │ ├── Comment.java
│ │ ├── ConditionalExpression.java
│ │ ├── ContinueStatement.java
│ │ ├── DestructuringForm.java
│ │ ├── DoLoop.java
│ │ ├── ElementGet.java
│ │ ├── EmptyExpression.java
│ │ ├── EmptyStatement.java
│ │ ├── ErrorCollector.java
│ │ ├── ErrorNode.java
│ │ ├── ExpressionStatement.java
│ │ ├── ForInLoop.java
│ │ ├── ForLoop.java
│ │ ├── FunctionCall.java
│ │ ├── FunctionNode.java
│ │ ├── GeneratorExpression.java
│ │ ├── GeneratorExpressionLoop.java
│ │ ├── IdeErrorReporter.java
│ │ ├── IfStatement.java
│ │ ├── InfixExpression.java
│ │ ├── Jump.java
│ │ ├── KeywordLiteral.java
│ │ ├── Label.java
│ │ ├── LabeledStatement.java
│ │ ├── LetNode.java
│ │ ├── Loop.java
│ │ ├── Name.java
│ │ ├── NewExpression.java
│ │ ├── NodeVisitor.java
│ │ ├── NumberLiteral.java
│ │ ├── ObjectLiteral.java
│ │ ├── ObjectProperty.java
│ │ ├── ParenthesizedExpression.java
│ │ ├── ParseProblem.java
│ │ ├── PropertyGet.java
│ │ ├── RegExpLiteral.java
│ │ ├── ReturnStatement.java
│ │ ├── Scope.java
│ │ ├── ScriptNode.java
│ │ ├── StringLiteral.java
│ │ ├── SwitchCase.java
│ │ ├── SwitchStatement.java
│ │ ├── Symbol.java
│ │ ├── TaggedTemplateLiteral.java
│ │ ├── TemplateCharacters.java
│ │ ├── TemplateLiteral.java
│ │ ├── ThrowStatement.java
│ │ ├── TryStatement.java
│ │ ├── UnaryExpression.java
│ │ ├── UpdateExpression.java
│ │ ├── VariableDeclaration.java
│ │ ├── VariableInitializer.java
│ │ ├── WhileLoop.java
│ │ ├── WithStatement.java
│ │ ├── XmlDotQuery.java
│ │ ├── XmlElemRef.java
│ │ ├── XmlExpression.java
│ │ ├── XmlFragment.java
│ │ ├── XmlLiteral.java
│ │ ├── XmlMemberGet.java
│ │ ├── XmlPropRef.java
│ │ ├── XmlRef.java
│ │ ├── XmlString.java
│ │ └── Yield.java
│ ├── commonjs
│ │ └── module
│ │ │ ├── ModuleScope.java
│ │ │ ├── ModuleScript.java
│ │ │ ├── ModuleScriptProvider.java
│ │ │ ├── Require.java
│ │ │ ├── RequireBuilder.java
│ │ │ ├── package.html
│ │ │ └── provider
│ │ │ ├── CachingModuleScriptProviderBase.java
│ │ │ ├── DefaultUrlConnectionExpiryCalculator.java
│ │ │ ├── ModuleSource.java
│ │ │ ├── ModuleSourceProvider.java
│ │ │ ├── ModuleSourceProviderBase.java
│ │ │ ├── MultiModuleScriptProvider.java
│ │ │ ├── ParsedContentType.java
│ │ │ ├── SoftCachingModuleScriptProvider.java
│ │ │ ├── StrongCachingModuleScriptProvider.java
│ │ │ ├── UrlConnectionExpiryCalculator.java
│ │ │ ├── UrlConnectionSecurityDomainProvider.java
│ │ │ ├── UrlModuleSourceProvider.java
│ │ │ └── package.html
│ ├── debug
│ │ ├── DebugFrame.java
│ │ ├── DebuggableObject.java
│ │ ├── DebuggableScript.java
│ │ └── Debugger.java
│ ├── engine
│ │ ├── BindingsObject.java
│ │ ├── Builtins.java
│ │ ├── RhinoCompiledScript.java
│ │ ├── RhinoInvocationHandler.java
│ │ ├── RhinoScriptEngine.java
│ │ └── RhinoScriptEngineFactory.java
│ ├── jdk18
│ │ └── VMBridge_jdk18.java
│ ├── json
│ │ └── JsonParser.java
│ ├── optimizer
│ │ ├── Block.java
│ │ ├── BodyCodegen.java
│ │ ├── ClassCompiler.java
│ │ ├── Codegen.java
│ │ ├── OptFunctionNode.java
│ │ ├── OptRuntime.java
│ │ ├── OptTransformer.java
│ │ └── Optimizer.java
│ ├── regexp
│ │ ├── NativeRegExp.java
│ │ ├── NativeRegExpCallable.java
│ │ ├── NativeRegExpCtor.java
│ │ ├── NativeRegExpInstantiator.java
│ │ ├── RegExpImpl.java
│ │ └── SubString.java
│ ├── resources
│ │ ├── Messages.properties
│ │ ├── Messages_en.properties
│ │ └── Messages_fr.properties
│ ├── serialize
│ │ ├── ScriptableInputStream.java
│ │ └── ScriptableOutputStream.java
│ ├── typedarrays
│ │ ├── ByteIo.java
│ │ ├── Conversions.java
│ │ ├── NativeArrayBuffer.java
│ │ ├── NativeArrayBufferView.java
│ │ ├── NativeDataView.java
│ │ ├── NativeFloat32Array.java
│ │ ├── NativeFloat64Array.java
│ │ ├── NativeInt16Array.java
│ │ ├── NativeInt32Array.java
│ │ ├── NativeInt8Array.java
│ │ ├── NativeTypedArrayIterator.java
│ │ ├── NativeTypedArrayView.java
│ │ ├── NativeUint16Array.java
│ │ ├── NativeUint32Array.java
│ │ ├── NativeUint8Array.java
│ │ └── NativeUint8ClampedArray.java
│ ├── v8dtoa
│ │ ├── CachedPowers.java
│ │ ├── DiyFp.java
│ │ ├── DoubleConversion.java
│ │ ├── DoubleHelper.java
│ │ ├── FastDtoa.java
│ │ └── FastDtoaBuilder.java
│ └── xml
│ │ ├── XMLLib.java
│ │ └── XMLObject.java
│ └── mycode
│ └── Main.java
├── tools
└── ci
│ └── linux
│ ├── release.sh
│ └── test.sh
├── toolsrc
└── org
│ └── mozilla
│ └── javascript
│ └── tools
│ ├── SourceReader.java
│ ├── ToolErrorReporter.java
│ ├── debugger
│ ├── Dim.java
│ ├── GuiCallback.java
│ ├── Main.java
│ ├── ScopeProvider.java
│ ├── SourceProvider.java
│ ├── SwingGui.java
│ ├── test.js
│ └── treetable
│ │ ├── AbstractCellEditor.java
│ │ ├── JTreeTable.java
│ │ ├── TreeTableModel.java
│ │ └── TreeTableModelAdapter.java
│ ├── jsc
│ └── Main.java
│ ├── resources
│ └── Messages.properties
│ └── shell
│ ├── ConsoleTextArea.java
│ ├── Environment.java
│ ├── Global.java
│ ├── JSConsole.java
│ ├── JavaPolicySecurity.java
│ ├── Main.java
│ ├── QuitAction.java
│ ├── SecurityProxy.java
│ ├── ShellConsole.java
│ ├── ShellContextFactory.java
│ ├── ShellLine.java
│ └── Timers.java
└── xmlimplsrc
└── org
└── mozilla
└── javascript
└── xmlimpl
├── Namespace.java
├── QName.java
├── XML.java
├── XMLCtor.java
├── XMLLibImpl.java
├── XMLList.java
├── XMLName.java
├── XMLObjectImpl.java
├── XMLWithScope.java
├── XmlNode.java
└── XmlProcessor.java
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set default behavior, in case users don't have core.autocrlf set.
2 | * text=auto
3 |
4 | .classpath text
5 | .project text
6 | *.html text
7 | *.htm text
8 | *.java text
9 | *.js text
10 | *.jsp text
11 | *.php text
12 | *.properties text
13 | *.sh text
14 | *.xml text
15 | *.md text
16 | *.bat text
17 | *.gradle text
18 | *.pl text
19 | *.mk text
20 | *.tests text
21 | *.doctest text
22 | /man/*.1 text
23 | /gradlew text
24 |
25 | *.bmp binary
26 | *.gif binary
27 | *.jar binary
28 | *.jpg binary
29 | *.jpeg binary
30 | *.png binary
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # os specific
2 | .DS_Store
3 |
4 | # build directories
5 | build/
6 | lib/
7 | buildGradle
8 |
9 | # artifacts
10 | *.zip
11 |
12 | *.iml
13 | .idea/
14 | out/
15 | target/
16 | .gradle
17 |
18 |
19 | *~
20 |
21 | # eclipse
22 | .classpath
23 | .project
24 | test262
25 | bin/
26 | .settings/
27 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Community Participation Guidelines
2 |
3 | This repository is governed by Mozilla's code of conduct and etiquette guidelines.
4 | For more details, please read the
5 | [Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).
6 |
7 | ## How to Report
8 | For more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.
9 |
10 |
16 |
--------------------------------------------------------------------------------
/NOTICE-tools.txt:
--------------------------------------------------------------------------------
1 | Rhino is licensed subject to the terms of the Mozilla Public License, v. 2.0.
2 | See "LICENSE.txt" for the text of the license.
3 |
4 | The files in toolsrc/org/mozilla/javascript/tools/debugger/treetable (runtime
5 | package org.mozilla.javascript.tools.debugger.treetable) are available under
6 | the following license:
7 |
8 | ----
9 |
10 | Copyright 1997, 1998 Sun Microsystems, Inc. All Rights Reserved.
11 |
12 | Redistribution and use in source and binary forms, with or without
13 | modification, are permitted provided that the following conditions
14 | are met:
15 | - Redistributions of source code must retain the above copyright
16 | notice, this list of conditions and the following disclaimer.
17 |
18 | - Redistributions in binary form must reproduce the above copyright
19 | notice, this list of conditions and the following disclaimer in the
20 | documentation and/or other materials provided with the distribution.
21 |
22 | - Neither the name of Sun Microsystems nor the names of its
23 | contributors may be used to endorse or promote products derived
24 | from this software without specific prior written permission.
25 |
26 |
27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
28 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
29 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
31 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 |
--------------------------------------------------------------------------------
/NOTICE.txt:
--------------------------------------------------------------------------------
1 | Rhino is licensed subject to the terms of the Mozilla Public License, v. 2.0.
2 | See "License.txt" for the text of the license.
3 |
4 | Rhino contains the following additional software:
5 |
6 | ----
7 |
8 | Portions of the floating-point conversion code, and portions of the test suite
9 | come from the Google V8 JavaScript engine and are subject to the following:
10 |
11 | Copyright 2010-2015 the V8 project authors. All rights reserved.
12 | Redistribution and use in source and binary forms, with or without
13 | modification, are permitted provided that the following conditions are
14 | met:
15 |
16 | * Redistributions of source code must retain the above copyright
17 | notice, this list of conditions and the following disclaimer.
18 | * Redistributions in binary form must reproduce the above
19 | copyright notice, this list of conditions and the following
20 | disclaimer in the documentation and/or other materials provided
21 | with the distribution.
22 | * Neither the name of Google Inc. nor the names of its
23 | contributors may be used to endorse or promote products derived
24 | from this software without specific prior written permission.
25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/RELEASE-STEPS.md:
--------------------------------------------------------------------------------
1 | # Rhino Release Process
2 |
3 | ## Prepare the repository
4 |
5 | Update the version in gradle.properties to the new release version.
6 |
7 | Update RELEASE_NOTES.md to include at least a summary of the major features
8 | of the release. (This is historical, but many find it helpful to have a single
9 | file in the repo that lists the major changes.)
10 |
11 | Update README.md to add a row to the table of releases that points to the
12 | GitHub release that we'll create in the next step (just follow the pattern
13 | that's there).
14 |
15 | Now might be a good time to run "./gradlew publishToMavenLocal" and use the
16 | published JARs as a sanity check.
17 |
18 | ## Update Compatibility Table
19 |
20 | The offial Kangax "compat table" now supports Rhino, but it's convenient
21 | to have our own that shows progress across all releases. Here's how to
22 | update it:
23 |
24 | git clone -b gh-pages https://github.com/gbrail/node-compat-table.git
25 | cd node-compat-table
26 |
27 | Now, edit "rhinoall.sh" to include the new release -- it includes a series
28 | of lines that fetch old releases, and use your local build of the new one.
29 | Then, update the table:
30 |
31 | ./rhinoall.sh
32 |
33 | The resulting "index.html" can be copied into "docs/compat/engines.html" in
34 | this repo.
35 |
36 | ## Push the Release to GitHub
37 |
38 | At this point, the current contents of your directory correspond to the
39 | new release. Prepare a pull request containing the changes, submit it,
40 | and merge it -- the result will be that the head of the "master" branch
41 | will build your new release.
42 |
43 | Update to that branch and create a tag for the release, where XX is a number
44 | like "1_7_14":
45 |
46 | git pull origin master
47 | git tag Rhino_XX_Release
48 | git push origin Rhino_XX_Release
49 |
50 | Now, on the Rhino "Releases" tab in GitHub, create a release that corresponds
51 | to the new tag. Include the following:
52 |
53 | * A cut and paste of the part of RELEASE_NOTES.md added for the release
54 | * The three JARs created by "./gradlew.jar"
55 | * The ZIP file created by "./gradlew distZip"
56 | * A ZIP of the source will be included automatically by GitHub
57 |
58 | ## Push the release to Maven Central
59 |
60 | The "Publish to Maven Central" action on GitHub Actions will automatically
61 | build the release, sign the JARs, and push it to oss.sonatype.org in the
62 | "org.mozilla" area. Log in to oss.sonatype.org, verify that all the checks
63 | that happen there were successful, and "close" the release. It will appear
64 | on Maven Central a few hours later.
65 |
66 | ## Update Homebrew
67 |
68 | The Homebrew team for Mac does not necessarily pick up Rhino releases
69 | automatically. It may be necessary to submit a PR to the "homebrew/homebrew"
70 | repo in GitHub for a change to the file "Library/Formula/rhino.rb".
71 |
72 | ## Prepare for Next Release
73 |
74 | Now it's time to move to the next "SNAPSHOT" release. Update gradle.properties,
75 | create a PR, and push the new PR. Now development can proceeed anew!
76 |
77 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | rootProject.name=rhino
2 | group=org.mozilla
3 | version=1.7.14
4 | buildDir=buildGradle
5 | mavenSnapshotRepo=https://oss.sonatype.org/content/repositories/snapshots
6 | mavenReleaseRepo=https://oss.sonatype.org/service/local/staging/deploy/maven2/
7 | org.gradle.caching=true
8 | org.gradle.parallel=true
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/autox-community/Autojs_Rhino_Dex/245911092fae9bef524fb1ab48e0f20720e39414/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/autox-community/Autojs_Rhino_Dex/245911092fae9bef524fb1ab48e0f20720e39414/gradlew
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/resources/StrUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/autox-community/Autojs_Rhino_Dex/245911092fae9bef524fb1ab48e0f20720e39414/resources/StrUtils.class
--------------------------------------------------------------------------------
/resources/StrUtils.java:
--------------------------------------------------------------------------------
1 | package defpackage;
2 |
3 | public class StrUtils {
4 | public static String d(String data) {
5 | int l = data.length() / 2;
6 | byte[] b = new byte[l];
7 | for (int i = 0; i < l; i++) {
8 | b[i] = Integer.valueOf(data.substring(i * 2, (i * 2) + 2), 16).byteValue();
9 | }
10 | for (int i2 = 0; i2 < b.length; i2++) {
11 | b[i2] = (byte) (b[i2] - 1);
12 | }
13 | return new String(b);
14 | }
15 | }
--------------------------------------------------------------------------------
/resources/dx-29.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/autox-community/Autojs_Rhino_Dex/245911092fae9bef524fb1ab48e0f20720e39414/resources/dx-29.0.3.jar
--------------------------------------------------------------------------------
/src/META-INF/services/javax.script.ScriptEngineFactory:
--------------------------------------------------------------------------------
1 | org.mozilla.javascript.engine.RhinoScriptEngineFactory
2 |
--------------------------------------------------------------------------------
/src/defpackage/StrUtils.java:
--------------------------------------------------------------------------------
1 | package defpackage;
2 |
3 | import org.mozilla.classfile.ByteCode;
4 | import org.mozilla.classfile.ClassFileWriter;
5 |
6 | import static org.mozilla.mycode.Main._isNoEncryptString;
7 |
8 | public class StrUtils {
9 |
10 | /**
11 | * 字符串加密
12 | */
13 | public static String e(String data) {
14 | byte[] b = data.getBytes();
15 | for (int i = 0; i < b.length; i++) {
16 | b[i] = (byte) (b[i] + 1);
17 | }
18 | StringBuilder hex = new StringBuilder();
19 | for (int i2 = 0; i2 < b.length; i2++) {
20 | hex.append(String.format("%02X", Byte.valueOf(b[i2])));
21 | }
22 | return hex.toString();
23 | }
24 |
25 | /**
26 | * 字符串解密
27 | */
28 | public static String d(String data) {
29 | int l = data.length() / 2;
30 | byte[] b = new byte[l];
31 | for (int i = 0; i < l; i++) {
32 | b[i] = Integer.valueOf(data.substring(i * 2, (i * 2) + 2), 16).byteValue();
33 | }
34 | for (int i2 = 0; i2 < b.length; i2++) {
35 | b[i2] = (byte) (b[i2] - 1);
36 | }
37 | return new String(b);
38 | }
39 |
40 | /**
41 | * 加密,把一个字符串在原有的基础上 加一个数值
42 | */
43 | public static String e2(String data) {
44 | //把字符串转为字节数组
45 | byte[] b = data.getBytes();
46 | //遍历
47 | for (int i = 0; i < b.length; i++) {
48 | b[i] += 3;//在原有的基础上 加一个数值
49 | }
50 | return new String(b);
51 | }
52 |
53 | /**
54 | * 解密:把一个加密后的字符串在原有基础上 减一个数
55 | *
56 | * @param data 加密后的字符串
57 | * @return 返回解密后的新字符串
58 | */
59 | public static String d2(String data) {
60 | //把字符串转为字节数组
61 | byte[] b = data.getBytes();
62 | //遍历
63 | for (int i = 0; i < b.length; i++) {
64 | b[i] -= 3;//在原有的基础上 减一个数
65 | }
66 | return new String(b);
67 | }
68 |
69 | /**
70 | * 字符串加密
71 | */
72 | public static void strE(ClassFileWriter cfw, String content) {
73 | // 禁用加密
74 | if (_isNoEncryptString) {
75 | cfw.addPush(content);
76 | return;
77 | }
78 | if (content.isEmpty()) {
79 | //为空 则 不调用 解密..
80 | cfw.addPush(content);
81 | } else {
82 | cfw.addPush(StrUtils.e(content));
83 | cfw.addInvoke(ByteCode.INVOKESTATIC, "defpackage.StrUtils", "d", "(Ljava/lang/String;)" +
84 | "Ljava/lang/String;");
85 | }
86 | }
87 | }
--------------------------------------------------------------------------------
/src/org/mozilla/classfile/ClassFileField.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.classfile;
8 |
9 | final class ClassFileField
10 | {
11 | ClassFileField(short nameIndex, short typeIndex, short flags)
12 | {
13 | itsNameIndex = nameIndex;
14 | itsTypeIndex = typeIndex;
15 | itsFlags = flags;
16 | itsHasAttributes = false;
17 | }
18 |
19 | void setAttributes(short attr1, short attr2, short attr3, int index)
20 | {
21 | itsHasAttributes = true;
22 | itsAttr1 = attr1;
23 | itsAttr2 = attr2;
24 | itsAttr3 = attr3;
25 | itsIndex = index;
26 | }
27 |
28 | int write(byte[] data, int offset)
29 | {
30 | offset = ClassFileWriter.putInt16(itsFlags, data, offset);
31 | offset = ClassFileWriter.putInt16(itsNameIndex, data, offset);
32 | offset = ClassFileWriter.putInt16(itsTypeIndex, data, offset);
33 | if (!itsHasAttributes) {
34 | // write 0 attributes
35 | offset = ClassFileWriter.putInt16(0, data, offset);
36 | } else {
37 | offset = ClassFileWriter.putInt16(1, data, offset);
38 | offset = ClassFileWriter.putInt16(itsAttr1, data, offset);
39 | offset = ClassFileWriter.putInt16(itsAttr2, data, offset);
40 | offset = ClassFileWriter.putInt16(itsAttr3, data, offset);
41 | offset = ClassFileWriter.putInt16(itsIndex, data, offset);
42 | }
43 | return offset;
44 | }
45 |
46 | int getWriteSize()
47 | {
48 | int size = 2 * 3;
49 | if (!itsHasAttributes) {
50 | size += 2;
51 | } else {
52 | size += 2 + 2 * 4;
53 | }
54 | return size;
55 | }
56 |
57 | private short itsNameIndex;
58 | private short itsTypeIndex;
59 | private short itsFlags;
60 | private boolean itsHasAttributes;
61 | private short itsAttr1, itsAttr2, itsAttr3;
62 | private int itsIndex;
63 | }
--------------------------------------------------------------------------------
/src/org/mozilla/classfile/ClassFileMethod.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.classfile;
8 |
9 | final class ClassFileMethod
10 | {
11 | ClassFileMethod(String name, short nameIndex, String type, short typeIndex,
12 | short flags)
13 | {
14 | itsName = name;
15 | itsNameIndex = nameIndex;
16 | itsType = type;
17 | itsTypeIndex = typeIndex;
18 | itsFlags = flags;
19 | }
20 |
21 | void setCodeAttribute(byte codeAttribute[])
22 | {
23 | itsCodeAttribute = codeAttribute;
24 | }
25 |
26 | int write(byte[] data, int offset)
27 | {
28 | offset = ClassFileWriter.putInt16(itsFlags, data, offset);
29 | offset = ClassFileWriter.putInt16(itsNameIndex, data, offset);
30 | offset = ClassFileWriter.putInt16(itsTypeIndex, data, offset);
31 | // Code attribute only
32 | offset = ClassFileWriter.putInt16(1, data, offset);
33 | System.arraycopy(itsCodeAttribute, 0, data, offset,
34 | itsCodeAttribute.length);
35 | offset += itsCodeAttribute.length;
36 | return offset;
37 | }
38 |
39 | int getWriteSize()
40 | {
41 | return 2 * 4 + itsCodeAttribute.length;
42 | }
43 |
44 | String getName()
45 | {
46 | return itsName;
47 | }
48 |
49 | String getType()
50 | {
51 | return itsType;
52 | }
53 |
54 | short getFlags()
55 | {
56 | return itsFlags;
57 | }
58 |
59 | private String itsName;
60 | private String itsType;
61 | private short itsNameIndex;
62 | private short itsTypeIndex;
63 | private short itsFlags;
64 | private byte[] itsCodeAttribute;
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/org/mozilla/classfile/ConstantEntry.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.classfile;
8 |
9 | final class ConstantEntry {
10 | private int type;
11 | private int intval;
12 | private long longval;
13 | private String str1;
14 | private String str2;
15 | private int hashcode;
16 |
17 | ConstantEntry(int type, int intval, String str1, String str2) {
18 | this.type = type;
19 | this.intval = intval;
20 | this.str1 = str1;
21 | this.str2 = str2;
22 | hashcode = type ^ intval + str1.hashCode() * str2.hashCode();
23 | }
24 |
25 | @Override
26 | public int hashCode() {
27 | return hashcode;
28 | }
29 |
30 | @Override
31 | public boolean equals(Object obj) {
32 | if (!(obj instanceof ConstantEntry)) {
33 | return false;
34 | }
35 | ConstantEntry entry = (ConstantEntry) obj;
36 | if (type != entry.type) {
37 | return false;
38 | }
39 | switch (type) {
40 | case ConstantPool.CONSTANT_Integer:
41 | case ConstantPool.CONSTANT_Float:
42 | return intval == entry.intval;
43 | case ConstantPool.CONSTANT_Long:
44 | case ConstantPool.CONSTANT_Double:
45 | return longval == entry.longval;
46 | case ConstantPool.CONSTANT_NameAndType:
47 | return str1.equals(entry.str1) && str2.equals(entry.str2);
48 | case ConstantPool.CONSTANT_InvokeDynamic:
49 | return intval == entry.intval
50 | && str1.equals(entry.str1)
51 | && str2.equals(entry.str2);
52 | default:
53 | throw new RuntimeException("unsupported constant type");
54 |
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/org/mozilla/classfile/ExceptionTableEntry.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.classfile;
8 |
9 | final class ExceptionTableEntry
10 | {
11 | ExceptionTableEntry(int startLabel, int endLabel,
12 | int handlerLabel, short catchType)
13 | {
14 | itsStartLabel = startLabel;
15 | itsEndLabel = endLabel;
16 | itsHandlerLabel = handlerLabel;
17 | itsCatchType = catchType;
18 | }
19 |
20 | int itsStartLabel;
21 | int itsEndLabel;
22 | int itsHandlerLabel;
23 | short itsCatchType;
24 | }
25 |
--------------------------------------------------------------------------------
/src/org/mozilla/classfile/FieldOrMethodRef.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.classfile;
8 |
9 | final class FieldOrMethodRef
10 | {
11 | FieldOrMethodRef(String className, String name, String type)
12 | {
13 | this.className = className;
14 | this.name = name;
15 | this.type = type;
16 | }
17 |
18 | public String getClassName()
19 | {
20 | return className;
21 | }
22 |
23 | public String getName()
24 | {
25 | return name;
26 | }
27 |
28 | public String getType()
29 | {
30 | return type;
31 | }
32 |
33 | @Override
34 | public boolean equals(Object obj)
35 | {
36 | if (!(obj instanceof FieldOrMethodRef)) { return false; }
37 | FieldOrMethodRef x = (FieldOrMethodRef)obj;
38 | return className.equals(x.className)
39 | && name.equals(x.name)
40 | && type.equals(x.type);
41 | }
42 |
43 | @Override
44 | public int hashCode()
45 | {
46 | if (hashCode == -1) {
47 | int h1 = className.hashCode();
48 | int h2 = name.hashCode();
49 | int h3 = type.hashCode();
50 | hashCode = h1 ^ h2 ^ h3;
51 | }
52 | return hashCode;
53 | }
54 |
55 | private String className;
56 | private String name;
57 | private String type;
58 | private int hashCode = -1;
59 | }
60 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/Callable.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.javascript;
8 |
9 | /**
10 | * Generic notion of callable object that can execute some script-related code
11 | * upon request with specified values for script scope and this objects.
12 | */
13 | public interface Callable
14 | {
15 | /**
16 | * Perform the call.
17 | *
18 | * @param cx the current Context for this thread
19 | * @param scope the scope to use to resolve properties.
20 | * @param thisObj the JavaScript this object
21 | * @param args the array of arguments
22 | * @return the result of the call
23 | */
24 | public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args);
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/ClassShutter.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | // API class
8 |
9 | package org.mozilla.javascript;
10 |
11 | /**
12 | Embeddings that wish to filter Java classes that are visible to scripts
13 | through the LiveConnect, should implement this interface.
14 |
15 | @see Context#setClassShutter(ClassShutter)
16 | @since 1.5 Release 4
17 | @author Norris Boyd
18 | */
19 |
20 | public interface ClassShutter {
21 |
22 | /**
23 | * Return true iff the Java class with the given name should be exposed
24 | * to scripts.
25 | *
26 | * An embedding may filter which Java classes are exposed through
27 | * LiveConnect to JavaScript scripts.
28 | *
29 | * Due to the fact that there is no package reflection in Java,
30 | * this method will also be called with package names. There
31 | * is no way for Rhino to tell if "Packages.a.b" is a package name
32 | * or a class that doesn't exist. What Rhino does is attempt
33 | * to load each segment of "Packages.a.b.c": It first attempts to
34 | * load class "a", then attempts to load class "a.b", then
35 | * finally attempts to load class "a.b.c". On a Rhino installation
36 | * without any ClassShutter set, and without any of the
37 | * above classes, the expression "Packages.a.b.c" will result in
38 | * a [JavaPackage a.b.c] and not an error.
39 | *
40 | * With ClassShutter supplied, Rhino will first call
41 | * visibleToScripts before attempting to look up the class name. If
42 | * visibleToScripts returns false, the class name lookup is not
43 | * performed and subsequent Rhino execution assumes the class is
44 | * not present. So for "java.lang.System.out.println" the lookup
45 | * of "java.lang.System" is skipped and thus Rhino assumes that
46 | * "java.lang.System" doesn't exist. So then for "java.lang.System.out",
47 | * Rhino attempts to load the class "java.lang.System.out" because
48 | * it assumes that "java.lang.System" is a package name.
49 | *
50 | * @param fullClassName the full name of the class (including the package
51 | * name, with '.' as a delimiter). For example the
52 | * standard string class is "java.lang.String"
53 | * @return whether or not to reveal this class to scripts
54 | */
55 | public boolean visibleToScripts(String fullClassName);
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/Constructable.java:
--------------------------------------------------------------------------------
1 | package org.mozilla.javascript;
2 |
3 | /** An interface that can be used to implement a constructor function as a lambda. */
4 | public interface Constructable {
5 |
6 | /**
7 | * Call the function as a constructor.
8 | *
9 | *
This method is invoked by the runtime in order to satisfy a use of the JavaScript
10 | * new operator. This method is expected to create a new object and return it.
11 | *
12 | * @param cx the current Context for this thread
13 | * @param scope an enclosing scope of the caller except when the function is called from a
14 | * closure.
15 | * @param args the array of arguments
16 | * @return the allocated object
17 | */
18 | Scriptable construct(Context cx, Scriptable scope, Object[] args);
19 | }
20 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/ContextAction.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | // API class
8 |
9 | package org.mozilla.javascript;
10 |
11 | /**
12 | * Interface to represent arbitrary action that requires to have Context
13 | * object associated with the current thread for its execution.
14 | * @param T the type of the return value of action execution
15 | */
16 | public interface ContextAction
17 | {
18 | /**
19 | * Execute action using the supplied Context instance.
20 | * When Rhino runtime calls the method, cx will be associated
21 | * with the current thread as active context.
22 | *
23 | * @see ContextFactory#call(ContextAction)
24 | */
25 | public T run(Context cx);
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/ContextListener.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | // API class
8 |
9 | package org.mozilla.javascript;
10 |
11 | /**
12 | * @deprecated Embeddings that wish to customize newly created
13 | * {@link Context} instances should implement
14 | * {@link ContextFactory.Listener}.
15 | */
16 | @Deprecated
17 | public interface ContextListener extends ContextFactory.Listener
18 | {
19 |
20 | /**
21 | * @deprecated Rhino runtime never calls the method.
22 | */
23 | @Deprecated
24 | public void contextEntered(Context cx);
25 |
26 | /**
27 | * @deprecated Rhino runtime never calls the method.
28 | */
29 | @Deprecated
30 | public void contextExited(Context cx);
31 | }
32 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/DefiningClassLoader.java:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 |
5 | package org.mozilla.javascript;
6 |
7 | /**
8 | * Load generated classes.
9 | *
10 | * @author Norris Boyd
11 | */
12 | public class DefiningClassLoader extends ClassLoader
13 | implements GeneratedClassLoader
14 | {
15 | public DefiningClassLoader() {
16 | this.parentLoader = getClass().getClassLoader();
17 | }
18 |
19 | public DefiningClassLoader(ClassLoader parentLoader) {
20 | this.parentLoader = parentLoader;
21 | }
22 |
23 | @Override
24 | public Class> defineClass(String name, byte[] data) {
25 | // Use our own protection domain for the generated classes.
26 | // TODO: we might want to use a separate protection domain for classes
27 | // compiled from scripts, based on where the script was loaded from.
28 | return super.defineClass(name, data, 0, data.length,
29 | SecurityUtilities.getProtectionDomain(getClass()));
30 | }
31 |
32 | @Override
33 | public void linkClass(Class> cl) {
34 | resolveClass(cl);
35 | }
36 |
37 | @Override
38 | public Class> loadClass(String name, boolean resolve)
39 | throws ClassNotFoundException
40 | {
41 | Class> cl = findLoadedClass(name);
42 | if (cl == null) {
43 | if (parentLoader != null) {
44 | cl = parentLoader.loadClass(name);
45 | } else {
46 | cl = findSystemClass(name);
47 | }
48 | }
49 | if (resolve) {
50 | resolveClass(cl);
51 | }
52 | return cl;
53 | }
54 |
55 | private final ClassLoader parentLoader;
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/ErrorReporter.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | // API class
8 |
9 | package org.mozilla.javascript;
10 |
11 | /**
12 | * This is interface defines a protocol for the reporting of
13 | * errors during JavaScript translation or execution.
14 | *
15 | * @author Norris Boyd
16 | */
17 |
18 | public interface ErrorReporter {
19 |
20 | /**
21 | * Report a warning.
22 | *
23 | * The implementing class may choose to ignore the warning
24 | * if it desires.
25 | *
26 | * @param message a String describing the warning
27 | * @param sourceName a String describing the JavaScript source
28 | * where the warning occured; typically a filename or URL
29 | * @param line the line number associated with the warning
30 | * @param lineSource the text of the line (may be null)
31 | * @param lineOffset the offset into lineSource where problem was detected
32 | */
33 | void warning(String message, String sourceName, int line,
34 | String lineSource, int lineOffset);
35 |
36 | /**
37 | * Report an error.
38 | *
39 | * The implementing class is free to throw an exception if
40 | * it desires.
41 | *
42 | * If execution has not yet begun, the JavaScript engine is
43 | * free to find additional errors rather than terminating
44 | * the translation. It will not execute a script that had
45 | * errors, however.
46 | *
47 | * @param message a String describing the error
48 | * @param sourceName a String describing the JavaScript source
49 | * where the error occured; typically a filename or URL
50 | * @param line the line number associated with the error
51 | * @param lineSource the text of the line (may be null)
52 | * @param lineOffset the offset into lineSource where problem was detected
53 | */
54 | void error(String message, String sourceName, int line,
55 | String lineSource, int lineOffset);
56 |
57 | /**
58 | * Creates an EvaluatorException that may be thrown.
59 | *
60 | * runtimeErrors, unlike errors, will always terminate the
61 | * current script.
62 | *
63 | * @param message a String describing the error
64 | * @param sourceName a String describing the JavaScript source
65 | * where the error occured; typically a filename or URL
66 | * @param line the line number associated with the error
67 | * @param lineSource the text of the line (may be null)
68 | * @param lineOffset the offset into lineSource where problem was detected
69 | * @return an EvaluatorException that will be thrown.
70 | */
71 | EvaluatorException runtimeError(String message, String sourceName,
72 | int line, String lineSource,
73 | int lineOffset);
74 | }
75 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/EvaluatorException.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 |
8 | package org.mozilla.javascript;
9 |
10 | /**
11 | * The class of exceptions thrown by the JavaScript engine.
12 | */
13 | public class EvaluatorException extends RhinoException
14 | {
15 | private static final long serialVersionUID = -8743165779676009808L;
16 |
17 | public EvaluatorException(String detail)
18 | {
19 | super(detail);
20 | }
21 |
22 | /**
23 | * Create an exception with the specified detail message.
24 | *
25 | * Errors internal to the JavaScript engine will simply throw a
26 | * RuntimeException.
27 | *
28 | * @param detail the error message
29 | * @param sourceName the name of the source reponsible for the error
30 | * @param lineNumber the line number of the source
31 | */
32 | public EvaluatorException(String detail, String sourceName,
33 | int lineNumber)
34 | {
35 | this(detail, sourceName, lineNumber, null, 0);
36 | }
37 |
38 | /**
39 | * Create an exception with the specified detail message.
40 | *
41 | * Errors internal to the JavaScript engine will simply throw a
42 | * RuntimeException.
43 | *
44 | * @param detail the error message
45 | * @param sourceName the name of the source responsible for the error
46 | * @param lineNumber the line number of the source
47 | * @param columnNumber the columnNumber of the source (may be zero if
48 | * unknown)
49 | * @param lineSource the source of the line containing the error (may be
50 | * null if unknown)
51 | */
52 | public EvaluatorException(String detail, String sourceName, int lineNumber,
53 | String lineSource, int columnNumber)
54 | {
55 | super(detail);
56 | recordErrorOrigin(sourceName, lineNumber, lineSource, columnNumber);
57 | }
58 |
59 | /**
60 | * @deprecated Use {@link RhinoException#sourceName()} from the super class.
61 | */
62 | @Deprecated
63 | public String getSourceName()
64 | {
65 | return sourceName();
66 | }
67 |
68 | /**
69 | * @deprecated Use {@link RhinoException#lineNumber()} from the super class.
70 | */
71 | @Deprecated
72 | public int getLineNumber()
73 | {
74 | return lineNumber();
75 | }
76 |
77 | /**
78 | * @deprecated Use {@link RhinoException#columnNumber()} from the super class.
79 | */
80 | @Deprecated
81 | public int getColumnNumber()
82 | {
83 | return columnNumber();
84 | }
85 |
86 | /**
87 | * @deprecated Use {@link RhinoException#lineSource()} from the super class.
88 | */
89 | @Deprecated
90 | public String getLineSource()
91 | {
92 | return lineSource();
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/ExternalArrayData.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.javascript;
8 |
9 | /**
10 | * Implement this interface in order to allow external data to be attached to a ScriptableObject.
11 | */
12 |
13 | public interface ExternalArrayData
14 | {
15 | /**
16 | * Return the element at the specified index. The result must be a type that is valid in JavaScript:
17 | * Number, String, or Scriptable. This method will not be called unless "index" is in
18 | * range.
19 | */
20 | Object getArrayElement(int index);
21 |
22 | /**
23 | * Set the element at the specified index. This method will not be called unless "index" is in
24 | * range. The method must check that "value" is a valid type, and convert it if necessary.
25 | */
26 | void setArrayElement(int index, Object value);
27 |
28 | /**
29 | * Return the length of the array.
30 | */
31 | int getArrayLength();
32 | }
33 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/Function.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | // API class
8 |
9 | package org.mozilla.javascript;
10 |
11 | /**
12 | * This is interface that all functions in JavaScript must implement. The interface provides for
13 | * calling functions and constructors.
14 | *
15 | * @see org.mozilla.javascript.Scriptable
16 | * @author Norris Boyd
17 | */
18 | public interface Function extends Scriptable, Callable, Constructable {
19 | /**
20 | * Call the function.
21 | *
22 | *
Note that the array of arguments is not guaranteed to have length greater than 0.
23 | *
24 | * @param cx the current Context for this thread
25 | * @param scope the scope to execute the function relative to. This is set to the value returned
26 | * by getParentScope() except when the function is called from a closure.
27 | * @param thisObj the JavaScript this object
28 | * @param args the array of arguments
29 | * @return the result of the call
30 | */
31 | @Override
32 | Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args);
33 |
34 | /**
35 | * Call the function as a constructor.
36 | *
37 | *
This method is invoked by the runtime in order to satisfy a use of the JavaScript
38 | * new operator. This method is expected to create a new object and return it.
39 | *
40 | * @param cx the current Context for this thread
41 | * @param scope an enclosing scope of the caller except when the function is called from a
42 | * closure.
43 | * @param args the array of arguments
44 | * @return the allocated object
45 | */
46 | @Override
47 | Scriptable construct(Context cx, Scriptable scope, Object[] args);
48 | }
49 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/GeneratedClassLoader.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | // API class
8 |
9 | package org.mozilla.javascript;
10 |
11 | /**
12 | * Interface to define classes from generated byte code.
13 | */
14 | public interface GeneratedClassLoader {
15 |
16 | /**
17 | * Define a new Java class.
18 | * Classes created via this method should have the same class loader.
19 | *
20 | * @param name fully qualified class name
21 | * @param data class byte code
22 | * @return new class object
23 | */
24 | public Class> defineClass(String name, byte[] data);
25 |
26 | /**
27 | * Link the given class.
28 | *
29 | * @param cl Class instance returned from the previous call to
30 | * {@link #defineClass(String, byte[])}
31 | * @see java.lang.ClassLoader
32 | */
33 | public void linkClass(Class> cl);
34 | }
35 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/IdFunctionCall.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.javascript;
8 |
9 | /**
10 | * Master for id-based functions that knows their properties and how to
11 | * execute them.
12 | */
13 | public interface IdFunctionCall
14 | {
15 | /**
16 | * 'thisObj' will be null if invoked as constructor, in which case
17 | * instance of Scriptable should be returned
18 | */
19 | public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope,
20 | Scriptable thisObj, Object[] args);
21 |
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/IdFunctionObjectES6.java:
--------------------------------------------------------------------------------
1 | package org.mozilla.javascript;
2 |
3 | public class IdFunctionObjectES6 extends IdFunctionObject{
4 |
5 | private static final long serialVersionUID = -8023088662589035261L;
6 |
7 | public IdFunctionObjectES6(IdFunctionCall idcall, Object tag, int id, String name, int arity, Scriptable scope) {
8 | super(idcall, tag, id, name, arity, scope);
9 | }
10 |
11 | private static final int Id_length = 1, Id_name = 3;
12 | private boolean myLength = true;
13 | private boolean myName = true;
14 |
15 | @Override
16 | protected int findInstanceIdInfo(String s) {
17 | if (s.equals("length")) return instanceIdInfo(READONLY | DONTENUM, Id_length);
18 | else if (s.equals("name")) return instanceIdInfo(READONLY | DONTENUM, Id_name);
19 | return super.findInstanceIdInfo(s);
20 | }
21 |
22 | @Override
23 | protected Object getInstanceIdValue(int id) {
24 | if (id == Id_length && !myLength) {
25 | return NOT_FOUND;
26 | } else if (id == Id_name && !myName) {
27 | return NOT_FOUND;
28 | }
29 | return super.getInstanceIdValue(id);
30 | }
31 |
32 | @Override
33 | protected void setInstanceIdValue(int id, Object value) {
34 | if (id == Id_length && value == NOT_FOUND) {
35 | this.myLength = false;
36 | return;
37 | } else if (id == Id_name && value == NOT_FOUND) {
38 | this.myName = false;
39 | return;
40 | }
41 | super.setInstanceIdValue(id, value);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/ImplementationVersion.java:
--------------------------------------------------------------------------------
1 | package org.mozilla.javascript;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.net.URL;
6 | import java.util.Enumeration;
7 | import java.util.jar.Attributes;
8 | import java.util.jar.Manifest;
9 |
10 | /**
11 | * This class is a singleton that just exists to serve up the implementation version. This should
12 | * encourage that it's safely but lazily loaded just once per VM.
13 | */
14 | public class ImplementationVersion {
15 |
16 | private String versionString;
17 |
18 | private static final ImplementationVersion version = new ImplementationVersion();
19 |
20 | public static String get() {
21 | return version.versionString;
22 | }
23 |
24 | private ImplementationVersion() {
25 | Enumeration urls;
26 | try {
27 | urls =
28 | ImplementationVersion.class
29 | .getClassLoader()
30 | .getResources("META-INF/MANIFEST.MF");
31 | } catch (IOException ioe) {
32 | return;
33 | }
34 |
35 | // There will be many manifests in the world -- enumerate all of them until we find the
36 | // right one.
37 | while (urls.hasMoreElements()) {
38 | URL metaUrl = urls.nextElement();
39 | try (InputStream is = metaUrl.openStream()) {
40 | Manifest mf = new Manifest(is);
41 | Attributes attrs = mf.getMainAttributes();
42 | if ("Mozilla Rhino".equals(attrs.getValue("Implementation-Title"))) {
43 | StringBuilder buf = new StringBuilder(23);
44 | buf.append("Rhino ").append(attrs.getValue("Implementation-Version"));
45 | String builtDate = attrs.getValue("Built-Date");
46 | if (builtDate != null) {
47 | builtDate = builtDate.replaceAll("-", " ");
48 | buf.append(' ').append(builtDate);
49 | }
50 | versionString = buf.toString();
51 | return;
52 | }
53 | } catch (IOException e) {
54 | // Ignore this unlikely event
55 | }
56 | }
57 | // We are probably in a IDE
58 | versionString = "Rhino Snapshot";
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/LambdaFunction.java:
--------------------------------------------------------------------------------
1 | /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 | *
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 |
7 | package org.mozilla.javascript;
8 |
9 | /**
10 | * This class implements a single JavaScript function that has the prototype of the built-in
11 | * Function class, and which is implemented using a single function that can easily be implemented
12 | * using a lambda expression.
13 | */
14 | public class LambdaFunction extends BaseFunction {
15 |
16 | private static final long serialVersionUID = -8388132362854748293L;
17 |
18 | // The target is expected to be a lambda -- lambdas should not be serialized.
19 | private final transient Callable target;
20 | private final String name;
21 | private final int length;
22 |
23 | /**
24 | * Create a new function. The new object will have the Function prototype and no parent. The
25 | * caller is responsible for binding this object to the appropriate scope.
26 | *
27 | * @param scope scope of the calling context
28 | * @param name name of the function
29 | * @param length the arity of the function
30 | * @param target an object that implements the function in Java. Since Callable is a
31 | * single-function interface this will typically be implemented as a lambda.
32 | */
33 | public LambdaFunction(Scriptable scope, String name, int length, Callable target) {
34 | this.target = target;
35 | this.name = name;
36 | this.length = length;
37 | ScriptRuntime.setFunctionProtoAndParent(this, scope);
38 | setupDefaultPrototype();
39 | }
40 |
41 | /** Create a new built-in function, with no name, and no default prototype. */
42 | public LambdaFunction(Scriptable scope, int length, Callable target) {
43 | this.target = target;
44 | this.length = length;
45 | this.name = "";
46 | ScriptRuntime.setFunctionProtoAndParent(this, scope);
47 | }
48 |
49 | @Override
50 | public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
51 | return target.call(cx, scope, thisObj, args);
52 | }
53 |
54 | @Override
55 | public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
56 | throw ScriptRuntime.typeErrorById("msg.no.new", getFunctionName());
57 | }
58 |
59 | @Override
60 | public int getLength() {
61 | return length;
62 | }
63 |
64 | @Override
65 | public int getArity() {
66 | return length;
67 | }
68 |
69 | @Override
70 | public String getFunctionName() {
71 | return name;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/org/mozilla/javascript/LambdaSlot.java:
--------------------------------------------------------------------------------
1 | package org.mozilla.javascript;
2 |
3 | import java.util.function.Consumer;
4 | import java.util.function.Supplier;
5 |
6 | /**
7 | * This is a specialization of property access using some lambda functions. It behaves exactly like
8 | * any other slot that has only a value, but instead of getting the value directly, it comes from
9 | * calling the functions. This makes it different from GetterSlot, which lets the user see directly
10 | * that there is a getter or a setter function involved. This makes this class useful for
11 | * implementing properties that behave like any other JavaScript property but which are implemented
12 | * using some native functionality without using reflection.
13 | */
14 | public class LambdaSlot extends Slot {
15 | private static final long serialVersionUID = -3046681698806493052L;
16 |
17 | LambdaSlot(Slot oldSlot) {
18 | super(oldSlot);
19 | }
20 |
21 | transient Supplier