[x3d-public] Errors in my X3DJSAILHelloWorldProgramOutput.javacommandline, generating XML, JSON and JS

John Carlson yottzumm at gmail.com
Sat Jan 13 18:03:59 PST 2018


Replaced Nashorn in filenames with Java to reflect that the output is coming from Java, not Nashorn (some are coming from Nashorn, and some are Nashorn, which I left).
Differences from previous patch is build.xml, but included comprehensive patch to www.web3d.org/x3d/stylesheets (unpack in that folder).

Attached.

It’s probably best to unpack by hand, but please rename JSON and X3D XML file names output from HelloWorldProgramOutput.java for accuracy—They are not nashorn files even though they appear in the Nashorn folder—except for the ones that are Nashorn source code.  There is one X3D XML file which is output from Nashorn JS so far.   That is the “new” one. If the “new” one doesn’t appear after running test.nashorn in java/nashorn/examples, then investigate. The new XML file is generated by running the JS file left over from the ‘-toJS’ conversion.

Personally, I thought the files with .js would plain enough to be Nashorn files.  I am not sure why we introduced “Nashorn” at all. Replacing “OutputOutput” with “Output.java” is a good idea.

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Saturday, January 13, 2018 8:28 PM
To: Don Brutzman
Cc: X3D Graphics public mailing list
Subject: RE: Errors in my X3DJSAILHelloWorldProgramOutput.javacommandline,generating XML, JSON and JS

Okay, I checked out relevant portions of www.web3d.org early, and applied my patches, then generated a new set of patches for nashorn, java and x3d/stylesheets.  Here they are:

Attached.

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Saturday, January 13, 2018 7:33 PM
To: Don Brutzman
Cc: X3D Graphics public mailing list
Subject: RE: Errors in my X3DJSAIL HelloWorldProgramOutput.javacommandline,generating XML, JSON and JS

Further improvement patches.  Note that I use file names instead of paths because they are JavaScript filenames--paths don’t work—but by all means try to get paths to work. I just don’t think you’ll be able to do it—and it will be a hairy mess.

2 patches attached.  Patching same two files as last time (see below included message).

Note that there may be future patches, especially related to comments in the JavaScript serializer.

I am hoping this patch will make test.nashorn work for you 😊.

As soon as these patches are integrated, I will be doing a full checkout of www.web3d.org for a final test.

MetadataString still missing from JS outputted X3D XML (I’m hoping you get this this time, I don’t think you’ve seen it before).  Probably because it’s missing from the JSON and JS, but I haven’t investigated this time.

John

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Saturday, January 13, 2018 4:04 PM
To: John Carlson
Cc: X3D Graphics public mailing list
Subject: Re: Errors in my X3DJSAIL HelloWorldProgramOutput.java commandline,generating XML, JSON and JS

On 1/13/2018 4:49 AM, John Carlson wrote:
> Here are the deltas, and a pointer to a new nashorn zip
> 
> 2 files attached. One for www.web3d.org/x3d/stylesheets/java/build.xml 
> <http://www.web3d.org/x3d/stylesheets/java/build.xml> and one for 
> www.web3d.org/x3d/stylesheets/CreateX3dSceneAccessInterfaceJava.xslt
> 
> https://coderextreme.net/X3DJSONLD/nashorn3.zip

thanks for helpful patches.  all integrated, made some changes along the way.

- yes overriding XSLT engine for json/javascript conversions, but then restoring prior setting.

- am copying files from parent examples directory to ensure comparisons look at correct latest release version.

-  some further cleanup appears possible.  please also check that added comments match your intent.

- HelloWorldProgramOutputOutput is too recursive for filename comprehension, replaced with
   HelloWorldProgramOutput.Nashorn.x3d etc.

- improved test.nashorn task, it mostly works now (and also reports a conversion diff) until the "line 3" failure.

all these changes are checked in, upload in progress.  console log follows, back to you John.

========================================================================================================================
     <target name="test.nashorn" description="Test Nashorn output from X3DJSAIL">
                                <echo message="Compile:"/>
                 <!-- local developer modification checks, apparently -->
                                <javac srcdir ="${java.examples.dir}"
                                                   classpath=""
                                                   destdir="${java.classes.dir}"
                                                   debug="on"
                                                   verbose="${javac.verbose}"
                                                   includeantruntime="false" fork="${fork}">
                                </javac>
                 <!-- Dev testing: copying of originals, reconversion and then comparison of files -->
                                <echo message="Copy:"/>
                 <copy file="examples/HelloWorldProgramOutput.x3d"  tofile="nashorn/examples/HelloWorldProgramOutput.x3d"  overwrite="true" verbose="true"/>
                 <copy file="examples/HelloWorldProgramOutput.json" tofile="nashorn/examples/HelloWorldProgramOutput.json" overwrite="true" verbose="true"/>
                                <echo message="Run:"/>
                 <java classname="HelloWorldProgramOutput" classpath="${java.classes.dir};${java.jars.dir}/${jsai.full.archive.jar.name}" fork="${fork}">
                     <arg value="examples/HelloWorldProgramOutput.x3d"/>
                     <arg value="-toJS"/><!-- alternatively -toJavaScript -->
                     <arg value="-toFile"/>
                     <arg value="nashorn/examples/HelloWorldProgramOutput.Nashorn.js"/>
                 </java>
                 <java classname="HelloWorldProgramOutput" classpath="${java.classes.dir};${java.jars.dir}/${jsai.full.archive.jar.name}" fork="${fork}">
                     <arg value="examples/HelloWorldProgramOutput.x3d"/>
                     <arg value="-toJSON"/>
                     <arg value="-toFile"/>
                     <arg value="nashorn/examples/HelloWorldProgramOutput.Nashorn.json"/>
                 </java>
                 <java classname="HelloWorldProgramOutput" classpath="${java.classes.dir};${java.jars.dir}/${jsai.full.archive.jar.name}" fork="${fork}">
                     <arg value="examples/HelloWorldProgramOutput.x3d"/>
                     <arg value="-toX3D"/>
                     <arg value="-toFile"/>
                     <arg value="nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d"/>
                 </java>
                                <echo message="==========================================="/>
                                <echo message="HelloWorldProgramOutput.Nashorn.x3d"/>
                                <xmlvalidate lenient="yes" warn="yes" file="nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d"/>
                                <xmlvalidate lenient="no"  warn="yes" file="nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d"/>
                                <condition property="Nashorn.x3d.match" value="true">
                     <filesmatch file1="nashorn/examples/HelloWorldProgramOutput.x3d"
                                 file2="nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d"/>
                                </condition>
                                <!-- otherwise --><property name="Nashorn.x3d.match" value="false"/>
                                <echo message="matches HelloWorldProgramOutput.x3d: ${Nashorn.x3d.match}"/>
                                <echo message="==========================================="/>
                                <echo message="script:"/>
<!--    <script language="nashorn"> TODO debugging -->
                                <script language="javascript" manager="javax">
                                                <classpath>
                                                                <fileset dir="${saxon.dir}"      includes="${saxon.jar}"/>
                                                                <fileset dir="${exificient.dir}" includes="${exificient.jar}"/>
                                                                <fileset dir="${openexi.dir}"    includes="${openexi.jar}"/>
                                                                <fileset dir="${java.jars.dir}"  includes="${jsai.classes.archive.jar.name}"/>
                                                </classpath>
                                                load('nashorn/jvm-npm.js');
                                                load('nashorn/repeatPolyfill.js');
                                                /*
                                                load('nashorn/examples/HelloWorldProgramOutputNashorn.js.intermediate.js');
                                                */
                                                load('nashorn/examples/HelloWorldProgramOutputNashorn.js');
                                </script>
     </target>

========================================================================================================================
ant -f C:\\x3d-code\\www.web3d.org\\x3d\\stylesheets\\java test.nashorn
test.nashorn:
Compile:
Compiling 1 source file to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\classes
Copy:
Copying 1 file to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples
Copying C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.x3d to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.x3d
Copying 1 file to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples
Copying C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.json to C:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.json
Run:
parameter: source file HelloWorldProgramOutput.x3d filesize 20715 bytes
parameter: "-toJS" for conversion to X3DJSONLD JavaScript source
parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.js" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn
convert to JS JavaScript:
Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
[Error] file conversion unsuccessful!
parameter: source file HelloWorldProgramOutput.x3d filesize 20715 bytes
parameter: "-toJSON" for conversion to JSON encoding
parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.json" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn
convert to JSON:
Warning: toFileStylesheetConversion(X3dToJson.xslt) is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Nashorn.json
Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
file conversion successful: HelloWorldProgramOutput.Nashorn.json (39061 bytes)
parameter: source file HelloWorldProgramOutput.x3d filesize 20715 bytes
parameter: "-toX3D" for conversion to X3D encoding
parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn
convert to X3D:
Warning: toFileX3D() is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Nashorn.x3d
file conversion successful: HelloWorldProgramOutput.Nashorn.x3d (20715 bytes)
===========================================
HelloWorldProgramOutput.Nashorn.x3d
1 file(s) have been successfully validated.
1 file(s) have been successfully validated.
matches HelloWorldProgramOutput.x3d: true
===========================================
script:
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\build.xml:186:
javax.script.ScriptException: TypeError: Cannot load script from nashorn/jvm-npm.js in <eval> at line number 3
                at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
                at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454)
                at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
                at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
                at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
                at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:498)
                at org.apache.tools.ant.util.ReflectUtil.invoke(ReflectUtil.java:109)
                at org.apache.tools.ant.util.ReflectWrapper.invoke(ReflectWrapper.java:81)
                at org.apache.tools.ant.util.optional.JavaxScriptRunner.evaluateScript(JavaxScriptRunner.java:103)
                at org.apache.tools.ant.util.optional.JavaxScriptRunner.executeScript(JavaxScriptRunner.java:67)
                at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:53)
                at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
                at sun.reflect.GeneratedMethodAccessor413.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:498)
                at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
                at org.apache.tools.ant.Task.perform(Task.java:348)
                at org.apache.tools.ant.Target.execute(Target.java:435)
                at org.apache.tools.ant.Target.performTasks(Target.java:456)
                at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
                at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
                at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
                at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
                at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
                at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
                at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: <eval>:3 TypeError: Cannot load script from nashorn/jvm-npm.js
                at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
                at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
                at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
                at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
                at jdk.nashorn.internal.runtime.Context.load(Context.java:868)
                at jdk.nashorn.internal.objects.Global.load(Global.java:1545)
                at jdk.nashorn.internal.scripts.Script$4$\^eval\_.:program(<eval>:3)
                at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
                at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
                at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
                at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
                ... 28 more
BUILD FAILED (total time: 16 seconds)
========================================================================================================================

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180113/5bb4ff0b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stylesheets.patch
Type: application/octet-stream
Size: 9250 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180113/5bb4ff0b/attachment-0001.obj>


More information about the x3d-public mailing list