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

7.7.1: Repeated modifiers for a requires directive should be forbidden

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      In the JLS, chapter §7.7.1 Module Declaration - Dependences [1], the spec does not mention anything regarding multiple appearances of the requires modifiers (transitive and static), however javac errs if static is declared multiple times, and if transitive is declared twice or more, the second time the token is consumed as a module name, despite the syntax descriptor indicating any amount of {RequiresModifier} instances.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Save the included test case source in a module-info.java
      Attempt to compile with a simple `javac module-info.java` invocation

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A compiled module-info.class file
      ACTUAL -
      module-info.java:2: error: repeated modifier
          requires static static java.sql;
                          ^
      module-info.java:3: error: ';' expected
          requires transitive transitive java.desktop;
                                        ^
      module-info.java:3: error: module directive keyword or '}' expected
          requires transitive transitive java.desktop;
                                         ^
      3 errors

      ---------- BEGIN SOURCE ----------
      module test {
          requires static static java.sql;
          requires transitive transitive java.desktop;
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Avoid repeating transitive/static modifiers in a requires directive

      FREQUENCY : always


            gbierman Gavin Bierman
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: