[x3d-public] X3DJSAIL running generated Java program to produce Java

John Carlson yottzumm at gmail.com
Fri Jul 20 06:13:58 PDT 2018


I run this in  java/classes after running ant test.nashorn, so our invocations are slightly different.  I am trying to debug the HelloWorldProgramOutput.java, which I don’t know if you’ve tried to debug or not.

HelloWorldProgramOutput.class is a file in my classes folder, so yes it’s executable.  I’m trying to run it to dump out Java, JSON, etc.

My problems are still current:

coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/java/classes
$ java -cp ../jars/X3DJSAIL.3.3.full.jar";." HelloWorldProgramOutput -tofile foo.java -toJava
parameter: "-tofile" "foo.java" for result file name root foo
parameter: "-toJava" for conversion to Java source code
[Error] Source model file name is empty, therefore file loading not possible.
Java program "HelloWorldProgramOutput" self-validation test results: success


Please test with HelloWorldProgramOutput.class, thanks! I’m trying to debug X3dToJava.xslt AND X3DJSAIL. If output from X3dToJava.xslt no longer takes arguments, please take that code out, or replace it with something that works.

Note that I do not have a -jar argument. That is intentional.

John

Sent from Mail for Windows 10

From: Don Brutzman
Sent: Friday, July 20, 2018 6:32 AM
To: John Carlson
Cc: X3D Graphics public mailing list
Subject: Re: X3DJSAIL running generated Java program to produce Java

Thanks for the report.

First I think that your jar is likely out of date, the diagnostics are familiar from the past but do not match current configuration.

http://www.web3d.org/specifications/java/X3DJSAIL.html#Downloads

Second, the error is trying to tell you that the file "HelloWorldProgramOutput" is not found.

I get the following:

[Error]  [org.web3d.x3d.jsail.CommandLine] file not found: HelloWorldProgramOutput
Usage: java [-classpath X3DJSAIL.*.jar] org.web3d.x3d.jsail.CommandLine [sourceModel.x3d | package.path.ProgramName | -help | -page | -resources | -tooltips]
        [-tofile [resultFile.*]] [-properties [propertiesFile]] [-validate]
        [sourceModel.exi -fromEXI] [sourceModel.gz -fromGZIP] [sourceModel.zip -fromZIP]
        [-toX3D | -toXML | -toHTML | -toMarkdown | -toTidy | -toClassicVrml | -toJava | -toJSON | -toVRML97 | -toX3DOM | -toX_ITE | -toEXI | -toGZIP | -toZIP]

Which likely makes sense for your system too, since the examples/ directory does not have any file "HelloWorldProgramOutput" except for those with a file extension added.

Incidentally to facilitate such testing using IDE debug mode, I added a utility method CommandLine.run(String arguments) which will accept a single string and split it into args.  Example use is now in HelloWorld.java main method, adapted here:

   // Quick test of CommandLine capability to facilitate debugging:
   org.web3d.x3d.jsail.CommandLine.run("HelloWorldProgramOutput  -tofile foo.java -toJava"); // allows simple testing

On 7/17/2018 6:51 PM, John Carlson wrote:
> Trying to produce Java source code from Java class, not working ,please advise:
> 
> coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/java/classes
> 
> $ java -cp ../jars/X3DJSAIL.3.3.full.jar";." HelloWorldProgramOutput -tofile foo.java -toJava
> 
> parameter: "-tofile" "foo.java" for result file name root foo
> 
> parameter: "-toJava" for conversion to Java source code
> 
> [Error] Source model file name is empty, therefore file loading not possible.
> 
> Java program "HelloWorldProgramOutput" self-validation test results: success
> 
> coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/java/classes
> 
> $ java -cp ../jars/X3DJSAIL.3.3.full.jar";." HelloWorldProgramOutput ../examples/HelloWorldProgramOutput.x3d -tofile foo.java -toJava
> 
> WARNING: "HelloWorldProgramOutput" model invocation is attempting to load file "../examples/HelloWorldProgramOutput.x3d" instead of simply validating itself...
> 
> No, CommandLine is not the correct answer.

actually yes I think precise CommandLine invocation was the answer.  given that your invocation was different than mine, you might have also been getting Java treating "HelloWorldProgramOutput" as an executable referrence.  Whatever - recommend omitting "HelloWorldProgramOutput" above and getting switches correct.

> Are we trying to provide a secure mechanism for people to write code so you can’t get the X3D XML or Java source code back out?    What about decompilers?
nope, no hidden protections.  CommandLine source shows that most of the code is simply trying to parse arguments correctly.

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/20180720/a3c3f692/attachment-0001.html>


More information about the x3d-public mailing list