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

doc error in jdk.internal.module.Resources.toPackageName(String)

    XMLWordPrintable

Details

    Description

      A DESCRIPTION OF THE PROBLEM :
      The javadoc of jdk.internal.module.Resources.toPackageName(String) does not match its implementation:
      > This method returns null if the resource name ends with a "/"

      Implementation:
      ```
      int index = name.lastIndexOf('/');
      if (index == -1 || index == name.length()-1) {
          return "";
      }
      ```

      See https://github.com/openjdk/jdk/blob/b6d51e15549e11be583625d908192d9f7f049489/src/java.base/share/classes/jdk/internal/module/Resources.java#L62

      Maybe it would be saner to follow the documentation comment and return `null` instead of an empty String, otherwise this could accidentally or maliciously cause unwanted behavior.


      Attachments

        Activity

          People

            alanb Alan Bateman
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: