docs: public static String getPackage(Class<?> cls) {
          // cls.getPackage() sometimes returns null, in which case fall back to string massaging.
          java.lang.Package pkg = cls.isArray() ? cls.getComponentType().getPackage() : cls.getPackage();
          if ( pkg == null ) {
              int dotPos;
              int dolPos = cls.getName().indexOf( '$' );
              if ( dolPos > 0 ) {
                  // we have nested classes, so adjust dotpos to before first $
                  dotPos = cls.getName().substring( 0, dolPos ).lastIndexOf( '.' );
              } else {
                  dotPos = cls.getName().lastIndexOf( '.' );
              }
                  
              if ( dotPos > 0 ) {
                  return cls.getName().substring( 0,
                                                  dotPos );
              } else {
                  // must be default package.
                  return "";
              }
          } else {
              return pkg.getName();
          }
      }