```ruby
require 'open-uri'
require 'open_uri_redirections'
require 'openssl'
require 'digest'

module JavaSE
  class <<self
    def download(url, file, limit = 5)
      raise ArgumentError, 'too many download failures' if limit == 0
      uri = URI(url)
      begin
        open(uri,
          'Cookie' => 'oraclelicense=accept-securebackup-cookie',
          allow_redirections: :all,
          ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |fin|
          open(file, 'w') do |fout|
            while (buf = fin.read(8192))
              fout.write buf
            end
          end
        end
      rescue
        download(url, file, limit - 1)
      end
    end

    def valid?(file, checksum)
      sha256 = Digest::SHA256.file file
      sha256.hexdigest == checksum
    end

    def validate(file, checksum)
      raise "#{file} does not match checksum #{checksum}" unless valid?(file, checksum)
    end
  end
end
```

Fix library load gem issue
user
```ruby
require 'open-uri'
require 'openssl'
require 'digest'

module JavaSE
  class <<self
    def load_open_uri_redirections
      # Libraries are loaded before recipes are compiled, so you can't install gems for direct use by libraries.
      require 'open_uri_redirections'
    end

    def download(url, file, limit = 5)
      raise ArgumentError, 'too many download failures' if limit == 0
      load_open_uri_redirections
      uri = URI(url)
      begin
        open(uri,
          'Cookie' => 'oraclelicense=accept-securebackup-cookie',
          allow_redirections: :all,
          ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |fin|
          open(file, 'wb') do |fout|
            while (buf = fin.read(8192))
              fout.write buf
            end
          end
        end
      rescue
        download(url, file, limit - 1)
      end
    end

    def valid?(file, checksum)
      sha256 = Digest::SHA256.file file
      sha256.hexdigest == checksum
    end

    def validate(file, checksum)
      raise "#{File.basename(file)} does not match checksum #{checksum}" unless valid?(file, checksum)
    end
  end
end
```
assistant