Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8256506: Create a standalone version of Nashorn for Java 15+ #3

Closed
wants to merge 29 commits into from

Conversation

szegedi
Copy link
Collaborator

@szegedi szegedi commented Nov 15, 2020

This is a PR with what are the minimal necessary changes required to publish the initial standalone Nashorn, version 15.0.0.

Emphasis on minimal necessary changes: the directory layout is the one as extracted from the JDK, and the build script is still based on Ant. This is therefore much less pretty than it could be, although it should be reasonable.

Main things to be aware of:

  • jdk.nashorn.* packages have all been renamed to org.openjdk.nashorn.*
  • jdk.scripting.nashorn module is renamed to org.openjdk.nashorn
  • jdk.scripting.nashorn.shell module is renamed to org.openjdk.nashorn.shell
  • Standalone Nashorn has a dependency on ASM 7.3.1. This version was chosen as it is the same version it relied on in OpenJDK 14.
  • Standalone Nashorn for now keeps embedding its private version of the Joni library for regular expressions, but I plan to switch to external Joni in a later update.
  • This release has no equivalent to jjs. We also won't release the shell module binary initially but plan it for a subsequent minor release.

Building

To build, use JDK 15 and Ant 1.9 or later with the following commands:

cd make/nashorn
ant artifacts

This will produce Nashorn artifacts ready for signing and release into Maven in build/nashorn/artifacts directory.

Other interesting targets: jar and test.

Using

If you want to try the code version in this PR with your existing Java app that uses Nashorn, make sure you put the directories containing Nashorn and ASM on the module path, e.g. if you're in the root directory of the project after the build, these can be found in build/nashorn/dist and build/nashorn/dependencies directories, so a command line like

java --module-path build/nashorn/dist:build/nashorn/dependencies ...

should work.

Launching shell

It is possible to launch the shell in a way that gives you an approximation of jjs too, although this is currently considered unsupported as we didn't work out the kinks with it. This is why the command line for that looks a bit hairy, with additional module exports added so it can use the JDK-internal copy of jline:

java \
  --add-exports jdk.internal.le/jdk.internal.org.jline.keymap=org.openjdk.nashorn.shell \
  --add-exports jdk.internal.le/jdk.internal.org.jline.reader=org.openjdk.nashorn.shell \
  --add-exports jdk.internal.le/jdk.internal.org.jline.reader.impl.completer=org.openjdk.nashorn.shell \
  --module-path build/nashorn/dist:build/nashorn/dependencies \
  --module org.openjdk.nashorn.shell/org.openjdk.nashorn.tools.jjs.Main

Note that you will first need to run ant jar in order to create the build/nashorn/dist/jjs.jar as ant artifacts presently doesn't build the shell module.


Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed

Issue

  • JDK-8256506: Create a standalone version of Nashorn for Java 15+

Reviewers

Download

$ git fetch https://git.openjdk.java.net/nashorn pull/3/head:pull/3
$ git checkout pull/3

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 15, 2020

👋 Welcome back attila! A progress list of the required criteria for merging this PR into main will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@ansell
Copy link

ansell commented Nov 15, 2020

The ant artifacts command is failing for me with the following (redacted) message during the get-deps stage:

get-deps:
[ivy:resolve] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy/ ::
[ivy:resolve] :: loading settings :: url = jar:file:/usr/local/Cellar/ant/1.10.9/libexec/lib/ivy-2.5.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[ivy:resolve] /Users/path/to/nashorn/make/nashorn/ivy-core.xml (No such file or directory) in file:/Users/path/to/nashorn/make/nashorn/ivy-core.xml

BUILD FAILED
/Users/path/to/nashorn/make/nashorn/build.xml:179: syntax errors in ivy file: java.text.ParseException: /Users/path/to/nashorn/make/nashorn/ivy-core.xml (No such file or directory) in file:/Users/path/to/nashorn/make/nashorn/ivy-core.xml
	at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parse(XmlModuleDescriptorParser.java:293)
	at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescriptor(XmlModuleDescriptorParser.java:123)
	at org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser.parseDescriptor(AbstractModuleDescriptorParser.java:50)
	at org.apache.ivy.core.resolve.ResolveEngine.resolve(ResolveEngine.java:196)
	at org.apache.ivy.Ivy.resolve(Ivy.java:507)
	at org.apache.ivy.ant.IvyResolve.doExecute(IvyResolve.java:328)
	at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:259)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
	at org.apache.tools.ant.Main.runBuild(Main.java:827)
	at org.apache.tools.ant.Main.startAnt(Main.java:223)
	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Caused by: java.io.FileNotFoundException: /Users/path/to/nashorn/make/nashorn/ivy-core.xml (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
	at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
	at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:189)
	at org.apache.ivy.util.url.BasicURLHandler.openStream(BasicURLHandler.java:211)
	at org.apache.ivy.util.url.URLHandlerDispatcher.openStream(URLHandlerDispatcher.java:137)
	at org.apache.ivy.util.url.URLHandlerDispatcher.openStream(URLHandlerDispatcher.java:129)
	at org.apache.ivy.util.XMLHelper.parse(XMLHelper.java:122)
	at org.apache.ivy.util.XMLHelper.parse(XMLHelper.java:116)
	at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parse(XmlModuleDescriptorParser.java:272)
	... 22 more

Total time: 5 seconds

The Java-15 version I am using is:

$ java -version
openjdk version "15" 2020-09-15
OpenJDK Runtime Environment AdoptOpenJDK (build 15+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15+36, mixed mode, sharing)

@szegedi
Copy link
Collaborator Author

szegedi commented Nov 15, 2020

Hi Peter, thanks for catching this! Yes, I forgot to add Ivy-related files to Git; it of course worked locally 😳. I fixed it up, can you give it another try? Thanks!

@ansell
Copy link

ansell commented Nov 15, 2020

Very understandable issue with the ivy build files.

This time it failed later in the process due to an issue with asm-test.jar and a class file in the default package:

.......
[ivy:retrieve] :: retrieving :: org.openjdk.nashorn#nashorn-core [sync]
[ivy:retrieve] 	confs: [default]
[ivy:retrieve] 	13 artifacts copied, 0 already retrieved (1991kB/18ms)

compile-nashorn:
    [javac] Compiling 593 source files to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn
    [javac] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:157: warning: [module] module not found: org.openjdk.nashorn.shell
    [javac]         org.openjdk.nashorn.shell;
    [javac]                            ^
    [javac] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:159: warning: [module] module not found: org.openjdk.nashorn.shell
    [javac]         org.openjdk.nashorn.shell;
    [javac]                            ^
    [javac] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:161: warning: [module] module not found: org.openjdk.nashorn.shell
    [javac]         org.openjdk.nashorn.shell;
    [javac]                            ^
    [javac] 3 warnings
    [javac] Creating empty /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/api/tree/package-info.class
    [javac] Creating empty /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/internal/objects/package-info.class
    [javac] Creating empty /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/api/scripting/package-info.class
     [copy] Copying 1 file to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/api/scripting/resources
     [copy] Copying 14 files to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/internal/runtime/resources
     [copy] Copying 1 file to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/tools/resources
     [copy] Copying 1 file to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/internal/codegen

build-nasgen:

init:

prepare:
    [mkdir] Created dir: /Users/path/to/nashorn/build/nashorn/nasgen/classes
    [mkdir] Created dir: /Users/path/to/nashorn/build/nashorn/nasgen/dist
    [mkdir] Created dir: /Users/path/to/nashorn/build/nashorn/nasgen/dist/lib

compile:
    [javac] Compiling 12 source files to /Users/path/to/nashorn/build/nashorn/nasgen/classes

jar:
      [jar] Building jar: /Users/path/to/nashorn/build/nashorn/nasgen/dist/nasgen.jar

run-nasgen:
     [java] Error occurred during initialization of boot layer
     [java] java.lang.module.FindException: Unable to derive module descriptor for /Users/path/to/nashorn/build/nashorn/dependencies/asm-test.jar
     [java] Caused by: java.lang.module.InvalidModuleDescriptorException: DefaultPackage.class found in top-level directory (unnamed package not allowed in module)

BUILD FAILED
/Users/path/to/nashorn/make/nashorn/build-nasgen.xml:35: Java returned: 1

@szegedi
Copy link
Collaborator Author

szegedi commented Nov 15, 2020

Hm, I can't reproduce this problem with a clean build. Ivy doesn't even download asm-test.jar for me and there's definitely no file named DefaultPackage.java or DefaultPackage.class anywhere on my system.

For me get-deps does:

get-deps:
    [mkdir] Created dir: /path/to/nashorn/build/nashorn/dependencies
[ivy:resolve] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
[ivy:resolve] :: loading settings :: file = ivysettings.xml
[ivy:resolve] :: resolving dependencies :: org.openjdk.nashorn#nashorn-core;[email protected]
[ivy:resolve] 	confs: [default]
[ivy:resolve] 	found org.ow2.asm#asm;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-commons;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-tree;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-analysis;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-util;7.3.1 in bintray
[ivy:resolve] :: resolution report :: resolve 112ms :: artifacts dl 7ms
	---------------------------------------------------------------------
	|                  |            modules            ||   artifacts   |
	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
	---------------------------------------------------------------------
	|      default     |   5   |   0   |   0   |   0   ||   13  |   0   |
	---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.openjdk.nashorn#nashorn-core [sync]
[ivy:retrieve] 	confs: [default]
[ivy:retrieve] 	5 artifacts copied, 0 already retrieved (355kB/10ms)

Note how my output says "5 artifacts copied" while yours says "13 artifacts copied". Indeed, build/nashorn/dependencies should only contain these five files:

asm-analysis.jar
asm-commons.jar
asm-tree.jar
asm-util.jar
asm.jar

@ansell
Copy link

ansell commented Nov 15, 2020

Here is my log file for the get-ivy and get-deps sections. Notably, it appears to be using a newer version of ivy, 2.5.0, but it looks like that is being fetched by the ant script and I don't remember installing ivy manually:

get-ivy:
    [mkdir] Created dir: /Users/path/to/nashorn/build/nashorn/ivy
      [get] Getting: https://repo1.maven.org/maven2/org/apache/ivy/ivy/2.5.0/ivy-2.5.0.jar
      [get] To: /Users/path/to/nashorn/build/nashorn/ivy/ivy.jar

get-deps:
    [mkdir] Created dir: /Users/path/to/nashorn/build/nashorn/dependencies
[ivy:resolve] :: Apache Ivy 2.5.0 - 20191020104435 :: https://ant.apache.org/ivy/ ::
[ivy:resolve] :: loading settings :: file = ivysettings.xml
[ivy:resolve] :: resolving dependencies :: org.openjdk.nashorn#nashorn-core;working@REDACTED
[ivy:resolve] 	confs: [default]
[ivy:resolve] 	found org.ow2.asm#asm;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-test;7.3.1 in bintray
[ivy:resolve] 	found org.junit.jupiter#junit-jupiter-api;5.3.2 in bintray
[ivy:resolve] 	found org.apiguardian#apiguardian-api;1.0.0 in bintray
[ivy:resolve] 	found org.opentest4j#opentest4j;1.1.1 in bintray
[ivy:resolve] 	found org.junit.platform#junit-platform-commons;1.3.2 in bintray
[ivy:resolve] 	found org.junit.jupiter#junit-jupiter-params;5.3.2 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-commons;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-tree;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-analysis;7.3.1 in bintray
[ivy:resolve] 	found org.ow2.asm#asm-util;7.3.1 in bintray
[ivy:resolve] 	found org.codehaus.janino#janino;3.0.11 in bintray
[ivy:resolve] 	found org.codehaus.janino#commons-compiler;3.0.11 in bintray
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm/7.3.1/asm-7.3.1-sources.jar ...
[ivy:resolve] ................................................................................................................................... (175kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm;7.3.1!asm.jar(source) (1238ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm/7.3.1/asm-7.3.1.jar ...
[ivy:resolve] ......................................................................................... (118kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm;7.3.1!asm.jar (722ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm/7.3.1/asm-7.3.1-javadoc.jar ...
[ivy:resolve] .................................................................................................................. (153kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm;7.3.1!asm.jar(javadoc) (877ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-commons/7.3.1/asm-commons-7.3.1.jar ...
[ivy:resolve] ..................................................... (69kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-commons;7.3.1!asm-commons.jar (713ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-commons/7.3.1/asm-commons-7.3.1-sources.jar ...
[ivy:resolve] ............................................................ (79kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-commons;7.3.1!asm-commons.jar(source) (715ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-commons/7.3.1/asm-commons-7.3.1-javadoc.jar ...
[ivy:resolve] ...................................................................................................... (136kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-commons;7.3.1!asm-commons.jar(javadoc) (728ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-tree/7.3.1/asm-tree-7.3.1.jar ...
[ivy:resolve] ........................................ (51kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-tree;7.3.1!asm-tree.jar (714ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-tree/7.3.1/asm-tree-7.3.1-sources.jar ...
[ivy:resolve] ........................................................ (74kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-tree;7.3.1!asm-tree.jar(source) (750ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-tree/7.3.1/asm-tree-7.3.1-javadoc.jar ...
[ivy:resolve] ...................................................................................................................... (158kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-tree;7.3.1!asm-tree.jar(javadoc) (751ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-util/7.3.1/asm-util-7.3.1.jar ...
[ivy:resolve] .............................................................. (82kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-util;7.3.1!asm-util.jar (758ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-util/7.3.1/asm-util-7.3.1-javadoc.jar ...
[ivy:resolve] ................................................................................................... (132kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-util;7.3.1!asm-util.jar(javadoc) (723ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-util/7.3.1/asm-util-7.3.1-sources.jar ...
[ivy:resolve] ........................................................... (77kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-util;7.3.1!asm-util.jar(source) (712ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-test/7.3.1/asm-test-7.3.1.jar ...
[ivy:resolve] ................................................................ (84kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-test;7.3.1!asm-test.jar (963ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/junit/jupiter/junit-jupiter-api/5.3.2/junit-jupiter-api-5.3.2.jar ...
[ivy:resolve] .................................................................................... (112kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.junit.jupiter#junit-jupiter-api;5.3.2!junit-jupiter-api.jar (724ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/junit/jupiter/junit-jupiter-params/5.3.2/junit-jupiter-params-5.3.2.jar ...
[ivy:resolve] ................................ (489kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.junit.jupiter#junit-jupiter-params;5.3.2!junit-jupiter-params.jar (2498ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar ...
[ivy:resolve] ... (2kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.apiguardian#apiguardian-api;1.0.0!apiguardian-api.jar (1704ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar ...
[ivy:resolve] ....... (6kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.opentest4j#opentest4j;1.1.1!opentest4j.jar (698ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/junit/platform/junit-platform-commons/1.3.2/junit-platform-commons-1.3.2.jar ...
[ivy:resolve] ......................................................... (75kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.junit.platform#junit-platform-commons;1.3.2!junit-platform-commons.jar (1046ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/ow2/asm/asm-analysis/7.3.1/asm-analysis-7.3.1.jar ...
[ivy:resolve] .......................... (32kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.ow2.asm#asm-analysis;7.3.1!asm-analysis.jar (704ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/codehaus/janino/janino/3.0.11/janino-3.0.11.jar ...
[ivy:resolve] ..................................................... (827kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.codehaus.janino#janino;3.0.11!janino.jar (2648ms)
[ivy:resolve] downloading https://jcenter.bintray.com/org/codehaus/janino/commons-compiler/3.0.11/commons-compiler-3.0.11.jar ...
[ivy:resolve] ............................. (37kB)
[ivy:resolve] .. (0kB)
[ivy:resolve] 	[SUCCESSFUL ] org.codehaus.janino#commons-compiler;3.0.11!commons-compiler.jar (875ms)
[ivy:resolve] :: resolution report :: resolve 24279ms :: artifacts dl 21280ms
	---------------------------------------------------------------------
	|                  |            modules            ||   artifacts   |
	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
	---------------------------------------------------------------------
	|      default     |   13  |   13  |   13  |   0   ||   21  |   21  |
	---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.openjdk.nashorn#nashorn-core [sync]
[ivy:retrieve] 	confs: [default]
[ivy:retrieve] 	13 artifacts copied, 0 already retrieved (1991kB/16ms)

The full file list that are showing in the dependencies list are:

$ ls -1 ../../build/nashorn/dependencies 
apiguardian-api.jar
asm-analysis.jar
asm-commons.jar
asm-test.jar
asm-tree.jar
asm-util.jar
asm.jar
commons-compiler.jar
janino.jar
junit-jupiter-api.jar
junit-jupiter-params.jar
junit-platform-commons.jar
opentest4j.jar

@szegedi
Copy link
Collaborator Author

szegedi commented Nov 16, 2020

You definitely hit on something. Implicit environmental dependencies apparently abound on my machine.

Running ANT_OPTS=-verbose:class ant get-deps uncovered that I have a copy of ivy.jar 2.2.0 (!!) sitting forgotten in ~/.ant/lib directory since 2011 (!!!).

Removing it switched to using another implicit version, this time 2.4.0 from /usr/local/Cellar/ant/1.10.8_1/libexec/lib (I'm running Ant from homebrew on Mac). To make matters funnier, the directory has a ivy-2.4.0.jar but libraries.properties in the same directory declares ivy.version=2.5.0 ¯_(ツ)_/¯.

I decided at this point that using Ivy is not worth it after all, and have reverted to manual dependency management for now.

@ansell
Copy link

ansell commented Nov 16, 2020

@szegedi That time the build completed, but I don't have a chance to test the functionality today. There were a few warnings during the build.

module-info declaration referencing org.openjdk.nashorn.shell which isn't currently present or isn't on the compile module path:

compile-nashorn:
    [javac] Compiling 593 source files to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn
    [javac] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:157: warning: [module] module not found: org.openjdk.nashorn.shell
    [javac]         org.openjdk.nashorn.shell;
    [javac]                            ^
    [javac] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:159: warning: [module] module not found: org.openjdk.nashorn.shell
    [javac]         org.openjdk.nashorn.shell;
    [javac]                            ^
    [javac] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:161: warning: [module] module not found: org.openjdk.nashorn.shell
    [javac]         org.openjdk.nashorn.shell;
    [javac]                            ^
    [javac] 3 warnings
    [javac] Creating empty /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/api/tree/package-info.class
    [javac] Creating empty /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/internal/objects/package-info.class
    [javac] Creating empty /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/api/scripting/package-info.class
     [copy] Copying 1 file to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/api/scripting/resources
     [copy] Copying 14 files to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/internal/runtime/resources
     [copy] Copying 1 file to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/tools/resources
     [copy] Copying 1 file to /Users/path/to/nashorn/build/nashorn/classes/org.openjdk.nashorn/org/openjdk/nashorn/internal/codegen

javadoc for NashornException.java:

javadoc:
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/api/scripting/NashornException.java:58: warning: no comment
  [javadoc]     private int column;
  [javadoc]                 ^
  [javadoc] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/api/scripting/NashornException.java:60: warning: no comment
  [javadoc]     private Object ecmaError;
  [javadoc]                    ^
  [javadoc] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/api/scripting/NashornException.java:52: warning: no comment
  [javadoc]     private String fileName;
  [javadoc]                    ^
  [javadoc] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/api/scripting/NashornException.java:54: warning: no comment
  [javadoc]     private int line;
  [javadoc]                 ^
  [javadoc] /Users/path/to/nashorn/src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/api/scripting/NashornException.java:56: warning: no comment
  [javadoc]     private boolean lineAndFileNameUnknown;
  [javadoc]                     ^
  [javadoc] 5 warnings

@szegedi
Copy link
Collaborator Author

szegedi commented Nov 16, 2020

@ansell thank you for all the work so far trying this out!

Those warnings are benign and I won't be addressing them:

module-info declaration referencing org.openjdk.nashorn.shell which isn't currently present or isn't on the compile module path:

I opted to separately compile nashorn-core and shell, so core is not aware of shell when it declares exports to it. It emits the exports correctly, though.

javadoc for NashornException.java:

Yeah, it complains that some private fields are not documented. I believe the only reason for this is that, extending Exception the class is serializable, so private fields' documentation would be part of the serialization format documentation. Again, not terribly exciting.

I agree these are somewhat annoying, but not blockers for the initial release.

@magicus
Copy link
Member

magicus commented Nov 17, 2020

Hi Attila,

I tried building the stand-alone Nashorn from this PR. It was a very smooth ride; apart from the warnings already mentioned, there were no issues. My build environment is macOS Mojave, with ant 1.10.9 from homebrew.

As confirmation of the build result, I tried launching the shell. It turned out that ant artifacts was not enough to build the jjs module. I looked through the build.xml and concluded that ant jar would do the trick, which it indeed did. You might want to update your build/test instructions.

Let me know if you need assistance in peeling off the build files from the common JDK build system that are no longer needed for the stand-alone Nashorn.

@sundararajana
Copy link
Member

ant clean; ant

target is fine. (build of jar and tests is okay)

When I applied diff on my local repo I got few whitespace issues. Saw three warnings during build

[javac] Compiling 593 source files to /Users/sundarajanathijegannathan/src/nashorn/build/nashorn/classes/org.openjdk.nashorn
[javac] /Users/sundarajanathijegannathan/src/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:157: warning: [module] module not found: org.openjdk.nashorn.shell
[javac]         org.openjdk.nashorn.shell;
[javac]                            ^
[javac] /Users/sundarajanathijegannathan/src/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:159: warning: [module] module not found: org.openjdk.nashorn.shell
[javac]         org.openjdk.nashorn.shell;
[javac]                            ^
[javac] /Users/sundarajanathijegannathan/src/nashorn/src/org.openjdk.nashorn/share/classes/module-info.java:161: warning: [module] module not found: org.openjdk.nashorn.shell
[javac]         org.openjdk.nashorn.shell;
[javac]                            ^
[javac] 3 warnings

@sundararajana
Copy link
Member

Basic jrunscript works as well..

$ cd $nashorn/build/nashorn/dist

$ jrunscript -J--module-path=.:../dependencies -J--add-modules=org.openjdk.nashorn
nashorn> java.util.List.of("foo", "bar")
[foo, bar]
nashorn> java.lang.System.getProperty("java.version")
15

@szegedi
Copy link
Collaborator Author

szegedi commented Nov 17, 2020

@magicus wrote:

As confirmation of the build result, I tried launching the shell. It turned out that ant artifacts was not enough to build the jjs module. I looked through the build.xml and concluded that ant jar would do the trick, which it indeed did. You might want to update your build/test instructions.

Hi Magnus, thanks for looking into this! I will update the description in the PR.

Let me know if you need assistance in peeling off the build files from the common JDK build system that are no longer needed for the stand-alone Nashorn.

Thank you for offering it! It's not using the common JDK build system anymore as far as I can tell, but rather just directly the make/nashorn/build.xml file that's the descendant of the original Ant build file from before Nashorn was incorporated into JDK. My hope is that we can transition to either Gradle or Maven, if we figure out how to subsume Nashorn's peculiarities (a custom test matrix and the "nasgen" build step) into either of these.

@szegedi szegedi changed the title First standalone version of Nashorn (15.0.0) 8256506: Create a standalone version of Nashorn for Java 15+ Nov 17, 2020
Copy link
Member

@sundararajana sundararajana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 'porting' Nashorn to build, test and run outside JDK 💯

  • I skimmed through many rename change sets (randomly checking few files)
  • We may need to revisit Nashorn internal class access from scripts (that currently failing sandbox test).
  • Unsafe usage for anonymous class loading. Perhaps we should just get rid of that eventually (sooner the better)

I did build, ran tests and tried few things with jrunscript (and not "jjs" yet). All seem fine.

@openjdk
Copy link

openjdk bot commented Nov 20, 2020

@szegedi This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

8256506: Create a standalone version of Nashorn for Java 15+

Reviewed-by: sundar

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the main branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the main branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Nov 20, 2020
@szegedi
Copy link
Collaborator Author

szegedi commented Nov 20, 2020

/integrate

@openjdk openjdk bot closed this Nov 20, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Nov 20, 2020
@openjdk
Copy link

openjdk bot commented Nov 20, 2020

@szegedi Pushed as commit 09d6ab7.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@szegedi szegedi deleted the standalone branch December 23, 2020 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants