2024-11-22 00:11 AEDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000339mercuryBugpublic2015-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 Files
  • diff file icon fix-java8-flag-reorder.diff (1,247 bytes) 2014-12-16 02:54 -
    diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
    index cd6f956..0722f7f 100644
    --- a/compiler/compile_target_code.m
    +++ b/compiler/compile_target_code.m
    @@ -1125,10 +1125,18 @@ compile_java_files(ErrorStream, JavaFiles, Globals, Succeeded, !IO) :-
         % Also be careful that each option is separated by spaces.
         JoinedJavaFiles = string.join_list(" ", JavaFiles),
         string.append_list([InclOpt, DirOpts,
    -        Target_DebugOpt, JAVAFLAGS, " ", JoinedJavaFiles], CommandArgs),
    +        Target_DebugOpt, " ", JoinedJavaFiles], CommandArgs),
    +    % The -J flags for the Java launcher called by javac must not be put into
    +    % an @argument file, so iff they are set, they are added directly to
    +    % the executable path.
    +    ( JAVAFLAGS = "" ->
    +        JavaCompilerWithFlags = JavaCompiler
    +    ;
    +        JavaCompilerWithFlags = JavaCompiler ++ " " ++ JAVAFLAGS
    +    ),
         invoke_long_system_command_maybe_filter_output(Globals, ErrorStream,
    -        cmd_verbose_commands, JavaCompiler, CommandArgs, MaybeMFilterJavac,
    -        Succeeded, !IO).
    +        cmd_verbose_commands, JavaCompilerWithFlags, CommandArgs,
    +        MaybeMFilterJavac, Succeeded, !IO).
     
     :- func java_classpath_separator = string.
     
    
    diff file icon fix-java8-flag-reorder.diff (1,247 bytes) 2014-12-16 02:54 +

-Relationships
+Relationships

-Notes

~0000711

juliensf (administrator)

Do you know if this occurred / occurs with older versions of Java on the same system?

~0000713

sebgod (reporter)

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 (developer)

Last edited: 2014-06-27 11:13

View 2 revisions

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 (reporter)

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 (administrator)

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 (reporter)

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 (reporter)

Last edited: 2014-07-05 21:11

View 2 revisions

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 (administrator)

This was fixed in commit 9c85673.

~0000825

juliensf (administrator)

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 (administrator)

Fixed (hopefully, for good) in commit d7857cf.
+Notes

-Issue History
Date Modified Username Field Change
2014-06-22 07:19 sebgod New Issue
2014-06-25 16:59 juliensf Note Added: 0000711
2014-06-26 23:46 sebgod Note Added: 0000713
2014-06-27 11:13 wangp Note Added: 0000717
2014-06-27 11:13 wangp Note Edited: 0000717 View Revisions
2014-06-27 17:21 sebgod Note Added: 0000719
2014-06-27 17:29 juliensf Note Added: 0000720
2014-06-28 04:00 sebgod Note Added: 0000721
2014-07-05 21:09 sebgod Note Added: 0000735
2014-07-05 21:11 sebgod Note Edited: 0000735 View Revisions
2014-12-16 02:54 sebgod File Added: fix-java8-flag-reorder.diff
2015-04-05 15:18 juliensf Note Added: 0000823
2015-04-05 15:18 juliensf Status new => resolved
2015-04-05 15:18 juliensf Resolution open => fixed
2015-04-05 15:18 juliensf Assigned To => juliensf
2015-04-08 13:51 juliensf Note Added: 0000825
2015-04-08 13:51 juliensf Status resolved => assigned
2015-07-14 17:30 juliensf Note Added: 0000842
2015-07-14 17:30 juliensf Status assigned => resolved
+Issue History