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

Options singleton is used before options are parsed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 25
    • tools
    • None
    • jdk-25+5-29-g665c39c9310

    • b07
    • generic
    • generic

      In the compiler the Options context singleton is used in a lot of places. However, there are some uses that occur before the compiler's command-line arguments have been parsed.

      In this scenario, it just appears as if whatever option the code is checking for is not set, even if it actually is, making it too easy to create subtle bugs.

      Recommendations:

      - Fix the existing bugs (see below)

      - Add assertions to detect premature access to the Options instance

      - Add a convenience method Options.whenReady(Runnable) that performs some action when the Options instance is ready (immediately if already ready). This relieves client code from having to worry about when that happens.

      The following abbreviated call traces represent existing premature access bugs:

      Main.compile()
      -> Log.instance()
      -> JCDiagnostic.Factory.instance()
      -> JavacMessages.instance()
      -> options.isSet("rawDiagnostics")

      Main.compile()
      -> Log.instance()
      -> JCDiagnostic.Factory.instance()
      -> JCDiagnostic.Factory.initOptions()
      -> options.isSet("onlySyntaxErrorsUnrecoverable")

      Main.compile()
      -> BasicJavacTask.initPlugins()
      -> Depend.init()
      -> Depend.addExports()
      -> JavacTool.getStandardFileManager()
      -> new JavacFileManager()
      -> JavacFileManager.setContext()
      -> BaseFileManager.setContext()
      -> options.get("procloader");

            acobbs Archie Cobbs
            acobbs Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: