Mercury Bugs - mercury
View Issue Details
0000339mercuryBugpublic2014-06-22 07:192015-07-14 17:30
Reportersebgod 
Assigned Tojuliensf 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformWindows NT 6.3 x86_64OSWindowsOS Version8.1
Product Version 
Target VersionFixed in Version 
Summary0000339: mmc --java with Oracle Java 1.8.0 fails on Windows
DescriptionMaking Java class files
An exception has occurred in the compiler (1.8.0). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: the -J flag should be caught by the launcher.
        at com.sun.tools.javac.main.Option$20.process(Option.java:330)
        at com.sun.tools.javac.main.Main.processArgs(Main.java:260)
        at com.sun.tools.javac.main.Main.compile(Main.java:414)
        at com.sun.tools.javac.main.Main.compile(Main.java:381)
        at com.sun.tools.javac.main.Main.compile(Main.java:370)
        at com.sun.tools.javac.main.Main.compile(Main.java:361)
        at com.sun.tools.javac.Main.compile(Main.java:56)
        at com.sun.tools.javac.Main.main(Main.java:42)
Steps To ReproduceCompile any program using the Java grade
Additional InformationBreak resulted only from installation of the Java JDK 8.0;
recompilation of the Mercury compiler did work but did not change the given output.
TagsNo tags attached.
Attached Filesdiff fix-java8-flag-reorder.diff (1,247) 2014-12-16 02:54
https://bugs.mercurylang.org/file_download.php?file_id=229&type=bug

Notes
(0000711)
juliensf   
2014-06-25 16:59   
Do you know if this occurred / occurs with older versions of Java on the same system?
(0000713)
sebgod   
2014-06-26 23:46   
On the same machine, I had Java 1.7.5x installed,
Mercury was working fine with that version.
Then I upgraded Java to 1.8.0_05,
When using the command line:
mercury --use-grade-subdirs -s java -m libmercury_misc (e.g.)
then I received the aforementioned error.
Rebuilding the compiler did not resolve that issue.
I could reproduce the error with Mercury 14_01 MinGW32 on Windows XP SP3
with Java 1.8.0 (okay that is not supported but still I got the same error)
(0000717)
wangp   
2014-06-27 11:13   
Can you try editing your lib/mercury/conf/Mercury.config file

This line has the wrong quoting

--java-flags "-J"-Xmx1024m""

Try fixing the quoting to

--java-flags "-J-Xmx1024m"

Or perhaps removing the line completely. It may not be needed any more.

(0000719)
sebgod   
2014-06-27 17:21   
Fixing the quoting to --java-flags "-J-Xmx1024m"
still resulted to the complain from the Java compiler,
removing on the other hand resulted in a successful compilation.
(0000720)
juliensf   
2014-06-27 17:29   
I believe that the quoting on Windows needs to be something like:

   --java-flags "-J\"-Xmx1024m\""

That seems to be what I've done in the binary packages for Windows at any rate.
(0000721)
sebgod   
2014-06-28 04:00   
Using (in the .config)
--java-flags "-J\"-Xmx1024m\""
yields the same error, I suppose this is a JDK bug.
I'll have to do some tests with "normal" Java programs
and will check the http://java.sun.com/webapps/bugreport
the javac compiler kindly provides.
(0000735)
sebgod   
2014-07-05 21:09   
(Last edited: 2014-07-05 21:11)
I've tracked down the bug,
Using the mmc -V option I received the content of the "javac @tempfile"
% Args placed in @C:\Users\SEBAST~1\AppData\Local\Temp\mtmp000.3D2: `-classpath <snip> -sourcepath <snip> -d <snip> -J-Xmx1024m Mercury\\java\\i686-pc-mingw32\\Mercury\\javas\\jmercury\\fmt_bug.java'
When invoking javac + the arg string directly on the command line, the compilation is successful.
On a side note, the -J flag is correctly escaped.

Now if I create that @tempfile manually, and running javac @tempfile myself,
I do get the original error with the -J flag not being captured.
Checking the Oracle online documentation for javac:
http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html
revleas that:
  @argfiles One or more files that lists options and source files.
The -J options are not allowed in these files.

I suspect that the assertion in the javac compiler was added in Java 8.0,
such that the -J flag passed via the @options-file was previously unnoticed (and most probably dysfunctional)

(0000823)
juliensf   
2015-04-05 15:18   
This was fixed in commit 9c85673.
(0000825)
juliensf   
2015-04-08 13:51   
Actually, commit 9c85673 only fixed the quoting issue. I'll look into fixing the issue with the -J
option being placed in the @options file.
(0000842)
juliensf   
2015-07-14 17:30   
Fixed (hopefully, for good) in commit d7857cf.

Issue History
2014-06-22 07:19sebgodNew Issue
2014-06-25 16:59juliensfNote Added: 0000711
2014-06-26 23:46sebgodNote Added: 0000713
2014-06-27 11:13wangpNote Added: 0000717
2014-06-27 11:13wangpNote Edited: 0000717bug_revision_view_page.php?bugnote_id=717#r25
2014-06-27 17:21sebgodNote Added: 0000719
2014-06-27 17:29juliensfNote Added: 0000720
2014-06-28 04:00sebgodNote Added: 0000721
2014-07-05 21:09sebgodNote Added: 0000735
2014-07-05 21:11sebgodNote Edited: 0000735bug_revision_view_page.php?bugnote_id=735#r29
2014-12-16 02:54sebgodFile Added: fix-java8-flag-reorder.diff
2015-04-05 15:18juliensfNote Added: 0000823
2015-04-05 15:18juliensfStatusnew => resolved
2015-04-05 15:18juliensfResolutionopen => fixed
2015-04-05 15:18juliensfAssigned To => juliensf
2015-04-08 13:51juliensfNote Added: 0000825
2015-04-08 13:51juliensfStatusresolved => assigned
2015-07-14 17:30juliensfNote Added: 0000842
2015-07-14 17:30juliensfStatusassigned => resolved