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

Support classpaths relative to shebang launch scripts (JEP 330)

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 15
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Relevant JDK versions: 11 - 15

      A DESCRIPTION OF THE PROBLEM :
      In the current implementation a shebang starting with

      #!/usr/bin/env -S java --class-path myclasses.jar --source 11

      the location of myclasses.jar is resolved relative to the user's current directory. This is unfortunate because the script only works if invoked from the same directory. The workaround is to specify an absolute path to the jar file--which is generally undesirable.

      Since scripts seem to generally enjoy unfettered access to system resources, I can scarcely see any security issues with such an enhancement. (If I were implementing this and could not devote the time to consider security implications from all angles, I'd limit the "ScriptFileClassLoader" to a singleton that can only load a single file.)

      PS In searching for a workaround, I noticed that the MemoryClassLoader does not fill a class's relevant CodeSource with a location URL: it's null. It would also be nice if the script's classloader reported the script file-URL as the location of its own CodeSource.


        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: