Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248843

java in source-file mode suggests javac-only options

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b24
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      A DESCRIPTION OF THE PROBLEM :
      When using `java` in source-file mode (see JEP 330 / JDK-8192920), it displays compiler notes which suggest using options which are only available for `javac`.
      This can be quite confusing because it causes an error and it is not directly clear how to use these options correctly.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a file called 'Test.java' containing the source code provided below
      2. Run `java ./Test.java`
      (i) It suggests using the `-Xdiags:verbose` option
      3. Run `java` with that option: `java -Xdiags:verbose ./Test.java`

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When running `java` in source-file mode and it displays compiler notes recommending the usage of an option, it should mention that this option might only work for `javac`.
      ACTUAL -
      `java` suggests using `java -Xdiags:verbose`. When using that, an error occurs:
      >Unrecognized option: -Xdiags:verbose
      >Error: Could not create the Java Virtual Machine.
      >Error: A fatal exception has occurred. Program will exit.


      ---------- BEGIN SOURCE ----------
      class Test {
          void use(String s) {}
          
          void test() {
              // This is wrong on purpose to trigger a compiler error
              use(1);
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              asotona Adam Sotona
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: