[javascript] Update Rhino library to 1.7.13

*   Convert pmd-javascript to a java8 module
*   Fixes #699
*   Fixes #2081
This commit is contained in:
Andreas Dangel 2021-04-29 14:59:13 +02:00
parent e7ebae1cea
commit cab260ed22
9 changed files with 46 additions and 17 deletions

View File

@ -16,7 +16,8 @@ This will create the zip files in the directory `pmd-dist/target`:
That's all !
**Note:** While Java 11 is required for building, running PMD only requires Java 7 (or Java 8 for Apex and the Designer).
**Note:** While Java 11 is required for building, running PMD only requires Java 7
(or Java 8 for Apex, JavaScript, Scala, Visualforce, and the Designer).
**Note:** With PMD 6.24.0, we are creating [Reproducible Builds](https://reproducible-builds.org/). Since we use
[Maven](https://maven.apache.org/guides/mini/guide-reproducible-builds.html) for building, the following

View File

@ -12,7 +12,8 @@ author: Tom Copeland, Xavier Le Vourch <xlv@users.sourceforge.net>
* JDK 11 or higher
{% include note.html content="While Java 11 is required for building, running PMD only requires Java 7 (or Java 8 for Apex, Scala, Visualforce, and the Designer)." %}
{% include note.html content="While Java 11 is required for building, running PMD only requires Java 7
(or Java 8 for Apex, JavaScript, Scala, Visualforce, and the Designer)." %}
Youll need to either check out the source code or download the latest source release. Assuming youve got the latest source release, unzip it to a directory:

View File

@ -11,7 +11,13 @@ sidebar: pmd_sidebar
### Requirements
* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1.7 or higher
* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html),
OpenJDK from [Azul](https://www.azul.com/downloads/zulu-community/)
or [AdoptOpenJDK](https://adoptopenjdk.net/) 1.7 or higher.
**Note:** For analyzing Apex, JavaScript, Scala or VisualForce or running the [Designer](pmd_userdocs_extending_designer_reference.html)
at least Java 8 is required.
* A zip archiver, e.g.:
* For Windows: [Winzip](http://winzip.com) or the free [7-zip](http://www.7-zip.org/)

View File

@ -14,8 +14,19 @@ This is a {{ site.pmd.release_type }} release.
### New and noteworthy
#### Javascript module now requires at least Java 8
The latest version of [Rhino](https://github.com/mozilla/rhino), the implementation of JavaScript we use
for parsing JavaScript code, requires at least Java 8. Therefore we decided to upgrade the pmd-javascript
module to Java 8 as well. This means, that from now on, a Java 8 or later runtime is required in order
to analyze JavaScript code. Note, that PMD core still stays the at Java 7.
### Fixed Issues
* pmd-javascript
* [#699](https://github.com/pmd/pmd/issues/699): \[javascript] Update Rhino library to 1.7.13
* [#2081](https://github.com/pmd/pmd/issues/2081): \[javascript] Failing with OutOfMemoryError parsing a Javascript file
### API Changes
### External Contributions

View File

@ -138,11 +138,6 @@
<artifactId>pmd-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-javascript</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-jsp</artifactId>
@ -249,6 +244,11 @@
<artifactId>pmd-apex</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-javascript</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-scala_2.13</artifactId>

View File

@ -25,10 +25,10 @@ public class BinaryDistributionIT extends AbstractBinaryDistributionTest {
private static final String SUPPORTED_LANGUAGES_PMD;
static {
// note: apex, visualforce, and scala require java8
// note: apex, javascript, visualforce, and scala require java8
if (PMDExecutor.isJava7Test()) {
SUPPORTED_LANGUAGES_CPD = "Supported languages: [cpp, cs, dart, ecmascript, fortran, go, groovy, java, jsp, kotlin, lua, matlab, modelica, objectivec, perl, php, plsql, python, ruby, swift, xml]";
SUPPORTED_LANGUAGES_PMD = "ecmascript, java, jsp, modelica, plsql, pom, vm, wsdl, xml, xsl";
SUPPORTED_LANGUAGES_CPD = "Supported languages: [cpp, cs, dart, fortran, go, groovy, java, jsp, kotlin, lua, matlab, modelica, objectivec, perl, php, plsql, python, ruby, swift, xml]";
SUPPORTED_LANGUAGES_PMD = "java, jsp, modelica, plsql, pom, vm, wsdl, xml, xsl";
} else {
SUPPORTED_LANGUAGES_CPD = "Supported languages: [apex, cpp, cs, dart, ecmascript, fortran, go, groovy, java, jsp, kotlin, lua, matlab, modelica, objectivec, perl, php, plsql, python, ruby, scala, swift, vf, xml]";
SUPPORTED_LANGUAGES_PMD = "apex, ecmascript, java, jsp, modelica, plsql, pom, scala, vf, vm, wsdl, xml, xsl";

View File

@ -11,6 +11,10 @@
<relativePath>../</relativePath>
</parent>
<properties>
<java.version>8</java.version>
</properties>
<build>
<resources>
<resource>
@ -78,6 +82,7 @@
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7.13</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>

View File

@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.ecmascript.ast;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.Reader;
@ -181,4 +182,13 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
ASTAssignment infix = rootNode.getFirstDescendantOfType(ASTAssignment.class);
assertEquals("^=", infix.getImage());
}
/**
* [javascript] Failing with OutOfMemoryError parsing a Javascript file #2081
*/
@Test(timeout = 5000L)
public void shouldNotFailWithOutOfMemory() {
ASTAstRoot rootNode = js.parse("(``\n);");
assertNotNull(rootNode);
}
}

View File

@ -687,11 +687,6 @@
<version>9.1.0.8</version>
<classifier>dom</classifier>
</dependency>
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7.7.2</version>
</dependency>
<dependency>
<groupId>net.java.dev.javacc</groupId>
<artifactId>javacc</artifactId>
@ -1066,7 +1061,6 @@
<module>pmd-groovy</module>
<module>pmd-lua</module>
<module>pmd-java</module>
<module>pmd-javascript</module>
<module>pmd-jsp</module>
<module>pmd-kotlin</module>
<module>pmd-matlab</module>
@ -1086,6 +1080,7 @@
<module>pmd-apex-jorje</module>
<module>pmd-apex</module>
<module>pmd-java8</module>
<module>pmd-javascript</module>
<module>pmd-doc</module>
<module>pmd-lang-test</module>
<module>pmd-scala</module> <!-- deprecated -->