[x3d-public] SFImage regex; X3DUOM? X3DJSAIL? results from test.nashorn: Unclosed group in regex

Don Brutzman brutzman at nps.edu
Thu Jun 14 22:43:14 PDT 2018


Let me try to help figure this out:

On 6/14/2018 5:50 PM, John Carlson wrote:
> ~johncarlson/Downloads/apache-ant-1.10.3/bin/ant test.nashorn
> Buildfile: /Users/johncarlson/Downloads/www.web3d.org/x3d/stylesheets/java/build <http://www.web3d.org/x3d/stylesheets/java/build>
>    [taskdef] Could not load definitions from resource net/sf/antcontrib/antcontri
> 
> test.nashorn:
>       [echo] ===========================================
>       [echo] ant nashorn/build.xml test.nashorn
>    [taskdef] Could not load definitions from resource net/sf/antcontrib/antcontri

I just checked your nashorn/ sudirectory tree.  I have the same version as checked in sourceforge.

> test.nashorn:
>       [echo] Compile:
>      [javac] Compiling 1 source file to /Users/johncarlson/Downloads/www.web3d.or <http://www.web3d.or>
>       [echo] Copy:
>       [copy] Copying 1 file to /Users/johncarlson/Downloads/www.web3d.org/x3d/sty <http://www.web3d.org/x3d/sty>
>       [copy] Copying /Users/johncarlson/Downloads/www.web3d.org/x3d/stylesheets/j <http://www.web3d.org/x3d/stylesheets/j>
>       [copy] Copying 1 file to /Users/johncarlson/Downloads/www.web3d.org/x3d/sty <http://www.web3d.org/x3d/sty>
>       [copy] Copying /Users/johncarlson/Downloads/www.web3d.org/x3d/stylesheets/j <http://www.web3d.org/x3d/stylesheets/j>
>       [echo] Run:
>       [java] parameter: source file HelloWorldProgramOutput.x3d filesize 21195 by
>       [java] parameter: "-tojs" for conversion to X3DJSONLD JavaScript source
>       [java] parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nasho
>       [java] convert to JS JavaScript:
>       [java] Warning: toFileJavaScript() is overwriting prior file nashorn/exampl
>       [java] Script DEF=colorTypeConversionScript contains CDATA source-code text
>       [java] Script DEF=MaterialModulatorScript contains CDATA source-code text,
>       [java] TypeError: input.readAllBytes is not a function
>       [java] Error: Cannot read file [/Users/johncarlson/Downloads/www.web3d.org/ <http://www.web3d.org/>
>       [java] org.web3d.x3d.sai.X3DException: ScriptException when processing file
>       [java] at org.web3d.x3d.jsail.Core.X3DObject.toFileJavaScript(X3DObject
>       [java] at org.web3d.x3d.jsail.CommandLine.run(CommandLine.java:628)
>       [java] at org.web3d.x3d.jsail.CommandLine.main(CommandLine.java:163)
>       [java] [Error] TODO problem handling local exception within CommandLine, ex
>       [java] parameter: source file HelloWorldProgramOutput.x3d filesize 21195 by
>       [java] parameter: "-toJSON" for conversion to JSON encoding
>       [java] parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Java.
>       [java] convert to JSON:
>       [java] Warning: toFileStylesheetConversion(X3dToJson.xslt) is overwriting p
>       [java] Script DEF=colorTypeConversionScript contains CDATA source-code text
>       [java] Script DEF=MaterialModulatorScript contains CDATA source-code text,
>       [java] file conversion successful: HelloWorldProgramOutput.Java.json (40043
>       [java] parameter: source file HelloWorldProgramOutput.x3d filesize 21195 by
>       [java] parameter: "-toX3D" for conversion to X3D encoding
>       [java] parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Java.
>       [java] convert to X3D:
>       [java] Warning: toFileX3D() is overwriting prior file nashorn/examples/Hell
>       [java] file conversion successful: HelloWorldProgramOutput.Java.x3d (21195
>       [echo] ===========================================
>       [echo] HelloWorldProgramOutput.Java.x3d
> [xmlvalidate] 1 file(s) have been successfully validated.
> [xmlvalidate] 1 file(s) have been successfully validated.
>       [echo] matches HelloWorldProgramOutput.x3d: true
>       [echo] ===========================================
>       [echo] ===========================================
>       [echo] HelloWorldProgramOutput.Java.json
>       [echo] matches HelloWorldProgramOutput.json: false
>       [echo] ===========================================

Got this far OK.  The next lines in nashorn/build.xml are

<echo message="script:"/>
<!-- [... snip...] -->
<exec executable="jjs">
	<arg value="-J-Djava.class.path=${java.dir}/jars/X3DJSAIL.3.3.full.jar"/>
	<arg value="${nashorn.examples.dir}/HelloWorldProgramOutput.Nashorn.js"/>
</exec>

>       [echo] script:
>       [exec] Exception in thread "main" java.lang.ExceptionInInitializerError
>       [exec] at java.lang.Class.forName0(Native Method)
>       [exec] at java.lang.Class.forName(Class.java:348)
>       [exec] at jdk.nashorn.internal.runtime.Context.findClass(Context.java:1
>       [exec] at jdk.nashorn.internal.objects.NativeJava.simpleType(NativeJava
>       [exec] at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:
>       [exec] at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:
>       [exec] at jdk.nashorn.internal.objects.NativeJava.type(NativeJava.java:
>       [exec] at jdk.nashorn.internal.scripts.Script$1$X3Dautoclass.:program(n
>       [exec] at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Script
>       [exec] at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunc
>       [exec] at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntim
>       [exec] at jdk.nashorn.internal.runtime.Context.evaluateSource(Context.j
>       [exec] at jdk.nashorn.internal.runtime.Context.load(Context.java:839)
>       [exec] at jdk.nashorn.internal.objects.Global.load(Global.java:1545)
>       [exec] at jdk.nashorn.internal.scripts.Script$HelloWorldProgramOutput_N
>       [exec] at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Script
>       [exec] at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunc
>       [exec] at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntim
>       [exec] at jdk.nashorn.tools.Shell.apply(Shell.java:471)
>       [exec] at jdk.nashorn.tools.Shell.runScripts(Shell.java:400)
>       [exec] at jdk.nashorn.tools.Shell.run(Shell.java:179)
>       [exec] at jdk.nashorn.tools.Shell.main(Shell.java:143)
>       [exec] at jdk.nashorn.tools.Shell.main(Shell.java:119)
>       [exec] Caused by: java.util.regex.PatternSyntaxException: Unclosed group ne
>       [exec] (((\d|[1-9]\d+)(\s+(\d|[1-9]\d+)){2}(\s+((0x([a-f]|[A-F}|\d]){1,8})|
>       [exec]
>       [exec] at java.util.regex.Pattern.error(Pattern.java:1957)
>       [exec] at java.util.regex.Pattern.accept(Pattern.java:1815)
>       [exec] at java.util.regex.Pattern.group0(Pattern.java:2910)
>       [exec] at java.util.regex.Pattern.sequence(Pattern.java:2053)
>       [exec] at java.util.regex.Pattern.expr(Pattern.java:1998)
>       [exec] at java.util.regex.Pattern.compile(Pattern.java:1698)
>       [exec] at java.util.regex.Pattern.<init>(Pattern.java:1351)
>       [exec] at java.util.regex.Pattern.compile(Pattern.java:1028)
>       [exec] at org.web3d.x3d.jsail.fields.MFImageObject.<clinit>(MFImageObje
>       [exec] ... 23 more
>       [exec] Result: 1

my output is differrent but still erroneous:

===========================================
script:
../nashorn/examples/HelloWorldProgramOutput.Nashorn.js:1 TypeError: Cannot load script from nashorn/node/X3Dautoclass.js
Result: 102

got a few other output errors too.  that error log is attached.

the partial regex above is truncated, looks like the first part of MFImage regex (or possibly SFImage).  Full version from X3Dv4 schema:

	<xs:simpleType name="MFImage">
		<xs:annotation>
			<xs:appinfo>
				<!-- problem with pattern validation of default value 0 0 0 -->
				<xs:pattern value="(((\d|[1-9]\d+)(\s+(\d|[1-9]\d+)){2}(\s+((0x([a-f]|[A-F}|\d]){1,8})|[1-9]\d+|\d))*(\s)*(,)?(\s)*)*"/>
				MFImage is an array of SFImage values.
			</xs:appinfo>
			<xs:documentation source="http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFImageAndMFImage"/>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:minLength value="5"/>
		</xs:restriction>
	</xs:simpleType>

hmmm.  the fragment above [a-f]|[A-F} looks unbalanced.  checking with regex101.com shows that it is indeed incorrect.

fragments replaced with [a-f]|[A-F] and fixed another unmatched parenthesis in MFImage.  they both pass regex101 validation now.

just learned about static initializers in Java and then added regex confirmation in each of the field objects.  that should reduce the number of future surprises we experience.  example:

============================================================================================================
http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/SFVec3fObject.html#initialize--
============================================================================================================

// https://stackoverflow.com/questions/6454482/how-can-i-add-javadoc-to-a-static-initializer-in-java

// static initializer
static {
	try {
		// verify pattern is compiling OK, report exception if not
		java.util.regex.Pattern.compile(REGEX);

		// verify DEFAULT_VALUE matches pattern OK, report if not
		if ((new SFVec3fObject(DEFAULT_VALUE)).matches() == false)
		{
			System.err.println("SFVec3fObject.initialize() problem: failed to match default value DEFAULT_VALUE " + DEFAULT_VALUE);
		}
	}
	catch (java.util.regex.PatternSyntaxException exception)
	{
		System.err.println("Exception in SFVec3f initialization testing, regex pattern compilation failure");
		System.err.println("REGEX = " + REGEX);
		System.err.println(exception.getDescription());
	}
}
============================================================================================================
============================================================================================================

all checked in, now uploading x3d-4.0.xsd schema, X3DUOM v4, X3D Regular Expressions, X3DJSAIL.  should be done in a couple of hours.

and so, back to you!

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 --------------
ant -f E:\\x3d-code\\www.web3d.org\\x3d\\stylesheets\\java\\nashorn test.nashorn
test.nashorn:
Compile:
Compiling 1 source file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\classes
Compiling 1 source file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\classes
Copy:
Copying 1 file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples
Copying E:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.x3d to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.x3d
Copying 1 file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples
Copying E:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.json to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.json
Run:
parameter: source file HelloWorldProgramOutput.x3d filesize 21195 bytes, parsed using Document Object Model (DOM) X3DLoader
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:
Warning: toFileJavaScript() is overwriting prior file ../nashorn/examples/HelloWorldProgramOutput.Nashorn.js
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] TODO problem handling local exception within CommandLine, exiting
org.web3d.x3d.sai.X3DException: ScriptException when processing fileName ..\nashorn\examples\HelloWorldProgramOutput.Nashorn.js.intermediate.js, unable to save result: javax.script.ScriptException: TypeError: Cannot load script from nashorn/jvm-npm.js in ../nashorn/examples/HelloWorldProgramOutput.Nashorn.js.intermediate.js at line number 1
	at org.web3d.x3d.jsail.Core.X3DObject.toFileJavaScript(X3DObject.java:1662)
	at org.web3d.x3d.jsail.CommandLine.run(CommandLine.java:628)
	at org.web3d.x3d.jsail.CommandLine.main(CommandLine.java:163)
parameter: source file HelloWorldProgramOutput.x3d filesize 21195 bytes, parsed using Document Object Model (DOM) X3DLoader
parameter: "-toJSON" for conversion to JSON encoding
parameter: "-toFile" "../nashorn/examples/HelloWorldProgramOutput.Java.json" for result file name root ../nashorn/examples/HelloWorldProgramOutput.Java
convert to JSON:
Warning: toFileStylesheetConversion(X3dToJson.xslt) is overwriting prior file ../nashorn/examples/HelloWorldProgramOutput.Java.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.Java.json (40043 bytes)
parameter: source file HelloWorldProgramOutput.x3d filesize 21195 bytes, parsed using Document Object Model (DOM) X3DLoader
parameter: "-toX3D" for conversion to X3D encoding
parameter: "-toFile" "../nashorn/examples/HelloWorldProgramOutput.Java.x3d" for result file name root ../nashorn/examples/HelloWorldProgramOutput.Java
convert to X3D:
Warning: toFileX3D() is overwriting prior file ../nashorn/examples/HelloWorldProgramOutput.Java.x3d
file conversion successful: HelloWorldProgramOutput.Java.x3d (21195 bytes)
===========================================
HelloWorldProgramOutput.Java.x3d
1 file(s) have been successfully validated.
1 file(s) have been successfully validated.
matches HelloWorldProgramOutput.x3d: true
===========================================
===========================================
HelloWorldProgramOutput.Java.json
matches HelloWorldProgramOutput.json: false
===========================================
script:
../nashorn/examples/HelloWorldProgramOutput.Nashorn.js:1 TypeError: Cannot load script from nashorn/node/X3Dautoclass.js
Result: 102
===========================================
HelloWorldProgramOutput.Java.x3d
matches HelloWorldProgramOutput.Nashorn.js.new.x3d: false
===========================================
===========================================
HelloWorldProgramOutput.Java.json
matches HelloWorldProgramOutput.Nashorn.js.new.json: false
===========================================
../nashorn/examples/Nashorn.js:1 TypeError: Cannot load script from nashorn/node/X3Dautoclass.js
Result: 102
===========================================
HelloWorldProgramOutput.x3d
matches Nashorn.x3d: false
===========================================
===========================================
HelloWorldProgramOutput.x3d
matches Nashorn0.x3d: false
===========================================
../nashorn/examples/Json.js:1 TypeError: Cannot load script from nashorn/node/X3Dautoclass.js
Result: 102
===========================================
HelloWorldProgramOutput.x3d
matches Json.x3d: false
===========================================
HelloWorldProgramOutput.json
matches Json.json: false
BUILD SUCCESSFUL (total time: 18 seconds)


More information about the x3d-public mailing list