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

java in source-file mode suggests javac-only Xlint flags

    XMLWordPrintable

Details

    • b18
    • generic
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      Follow-up for JDK-8248843

      When using `java` in source-file mode (see JEP 330 / JDK-8192920), it displays Xlint 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.

      Unlike with JDK-8248843, it might not desirable to simply enable and show all Xlint warnings by default (new users for whom `java` source-file mode is intended might be overwhelmed).
      So maybe in this case the best way would be to allow usage of `-Xlint` command line arguments for `java` in source-file mode?

      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 `-Xlint:deprecation` option
      3. Run `java` with that option: `java -Xlint:deprecation ./Test.java`


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The compiler should show more detailed warnings.
      ACTUAL -
      Starting the JVM fails:
      Unrecognized option: -Xlint:deprecation
      Error: Could not create the Java Virtual Machine.
      Error: A fatal exception has occurred. Program will exit.

      ---------- BEGIN SOURCE ----------
      class Test {
          <T> void test(T t, Object o) {
              T t1 = (T) o;
          }
          
          static class Generic<T> {
              T t;
              
              void raw(Generic raw) {
                  raw.t = "";
              }
          }
          
          void deprecation() {
              Thread.currentThread().stop();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Run `javac` with that flag; though might not be obvious for new users (for whom the source-file mode is intended)

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: