JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-4717

[1.9.2] New digest methods are missing (base64digest and base64digest!)

    Details

    • Number of attachments :
      1

      Description

      From MRI NEWS:

      digest
        new methods:
            - Digest::Class.base64digest
            - Digest::Instance#base64digest
            - Digest::Instance#base64digest!
      

      Apparently, the rubyspecs are missing too.

        Issue Links

          Activity

          Hide
          Hiroshi Nakamura added a comment -
          % ruby -rdigest -ve 'p Digest::SHA1.base64digest("foo")'
          ruby 1.9.2p289 (2011-07-04 revision 32391) [x86_64-linux]
          "C+7Hteo/D9vJXQ3UfzxbwnXaijM="
          % jruby163 --1.9 -rdigest -ve 'p Digest::SHA1.base64digest("foo")'
          jruby 1.6.3 (ruby-1.9.2-p136) (2011-07-07 965162f) (Java HotSpot(TM) 64-Bit Server VM 1.7.0) [linux-amd64-java]
          NoMethodError: undefined method `base64digest' for Digest::SHA1:Class
            (root) at -e:1
          

          May I take this?

          Show
          Hiroshi Nakamura added a comment - % ruby -rdigest -ve 'p Digest::SHA1.base64digest("foo")' ruby 1.9.2p289 (2011-07-04 revision 32391) [x86_64-linux] "C+7Hteo/D9vJXQ3UfzxbwnXaijM=" % jruby163 --1.9 -rdigest -ve 'p Digest::SHA1.base64digest("foo")' jruby 1.6.3 (ruby-1.9.2-p136) (2011-07-07 965162f) (Java HotSpot(TM) 64-Bit Server VM 1.7.0) [linux-amd64-java] NoMethodError: undefined method `base64digest' for Digest::SHA1:Class (root) at -e:1 May I take this?
          Hide
          Charles Oliver Nutter added a comment -

          Nahi: Go for it!

          Show
          Charles Oliver Nutter added a comment - Nahi: Go for it!
          Hide
          Hiroshi Nakamura added a comment -

          Sorry to be late. Fixed master at 51bf9d9f. I'll merge it to jruby-1_6 tomorrow.

          commit 51bf9d9f64452c00278ffa537f888084efe09741
          Author: Hiroshi Nakamura <nahi@ruby-lang.org>
          Date:   Mon Aug 1 22:51:29 2011 +0900
          
              Fix JRUBY-4717: implement new digest methods.
              
              Use method-definitions in lib/ruby/1.9/digest.rb instead of our native
              implementation in RubyDigest.java.
              
              This commit causes 5 failures in ant spec (see [5 failures] below), but
              it's from;
               - JRUBY-4033 (IO.sysopen can't handle directories) and
               - JRUBY-4082 (File.open(dir) raises Errno::EACCESS)
              so I left it as-is for now.
          

          As I wrote in the commit log, this fix causes additional 5 failures that says;

          Digest::SHA512.file raises a Errno::EISDIR when passed a path that is a directory FAILED
          Expected Errno::EISDIR but got Errno::EACCES (Permission denied - .)
          

          This patch solves the failures but I don't think it should be applied. We should solve JRUBY-4033 and JRUBY-4082 first.

          diff --git a/src/org/jruby/util/io/ChannelDescriptor.java b/src/org/jruby/util/io/ChannelDescriptor.java
          index 25635a7..1320cb3 100644
          --- a/src/org/jruby/util/io/ChannelDescriptor.java
          +++ b/src/org/jruby/util/io/ChannelDescriptor.java
          @@ -832,7 +832,7 @@ public class ChannelDescriptor {
                   } else {
                       JRubyFile theFile = JRubyFile.create(cwd,path);
           
          -            if (theFile.isDirectory() && flags.isWritable()) {
          +            if (theFile.isDirectory()) {
                           throw new DirectoryAsFileException();
                       }
           
          

          Can I tag those 5 failures as specs?

          Show
          Hiroshi Nakamura added a comment - Sorry to be late. Fixed master at 51bf9d9f. I'll merge it to jruby-1_6 tomorrow. commit 51bf9d9f64452c00278ffa537f888084efe09741 Author: Hiroshi Nakamura <nahi@ruby-lang.org> Date: Mon Aug 1 22:51:29 2011 +0900 Fix JRUBY-4717: implement new digest methods. Use method-definitions in lib/ruby/1.9/digest.rb instead of our native implementation in RubyDigest.java. This commit causes 5 failures in ant spec (see [5 failures] below), but it's from; - JRUBY-4033 (IO.sysopen can't handle directories) and - JRUBY-4082 (File.open(dir) raises Errno::EACCESS) so I left it as-is for now. As I wrote in the commit log, this fix causes additional 5 failures that says; Digest::SHA512.file raises a Errno::EISDIR when passed a path that is a directory FAILED Expected Errno::EISDIR but got Errno::EACCES (Permission denied - .) This patch solves the failures but I don't think it should be applied. We should solve JRUBY-4033 and JRUBY-4082 first. diff --git a/src/org/jruby/util/io/ChannelDescriptor.java b/src/org/jruby/util/io/ChannelDescriptor.java index 25635a7..1320cb3 100644 --- a/src/org/jruby/util/io/ChannelDescriptor.java +++ b/src/org/jruby/util/io/ChannelDescriptor.java @@ -832,7 +832,7 @@ public class ChannelDescriptor { } else { JRubyFile theFile = JRubyFile.create(cwd,path); - if (theFile.isDirectory() && flags.isWritable()) { + if (theFile.isDirectory()) { throw new DirectoryAsFileException(); } Can I tag those 5 failures as specs?
          Hide
          Hiroshi Nakamura added a comment -

          Sorry, I broke digest lib for 1.8 at 51bf9d9f and Nick fixed it at 288ef4ae. It's because I wrongly updated tool/global_1_8_7.rb locally and it created an uncommitted file lib/ruby/1.8/digest.rb.

          I merged this update at 08c38b4e.

          commit 08c38b4ebe8d68124b532ca58d94115f29fd5690
          Author: Hiroshi Nakamura <nahi@ruby-lang.org>
          Date:   Tue Aug 2 11:18:02 2011 +0900
          
              JRUBY-4717: Import digest.rb from CRuby stdlib.
              
              I broke digest lib for 1.8 at 51bf9d9f and Nick fixed it at 288ef4ae.
              And this is a new try for re-fixing digest library for JRUBY-4717.
              
               * Update tool/globals_1_8_7.rb to import digest.rb for 1.8 as same as
                 1.9.
               * Remove Java implementation of Digest.const_missing. It's defined in
                 lib/digest.rb for both 1.8 and 1.9.
               * Revert 288ef1ae. It does not mean that 288ef4ae is wrong. It's
                 51bf9d9f which should be fixed and needs above fixes. 288ef4ae was
                 needed.
              
              With importing lib/digest.rb for 1.8 mode, Digest function start working
              for 1.8 as same as CRuby.
              
              % ruby187 -rdigest -e 'p Digest("SHA2")'
              Digest::SHA2
              
              % jruby -rdigest -e 'p Digest("SHA2")'
              Digest::SHA2
              
              % jruby163 -rdigest -e 'p Digest("SHA2")'
              NoMethodError: undefined method `Digest' for main:Object
                (root) at -e:1
          
          Show
          Hiroshi Nakamura added a comment - Sorry, I broke digest lib for 1.8 at 51bf9d9f and Nick fixed it at 288ef4ae. It's because I wrongly updated tool/global_1_8_7.rb locally and it created an uncommitted file lib/ruby/1.8/digest.rb. I merged this update at 08c38b4e. commit 08c38b4ebe8d68124b532ca58d94115f29fd5690 Author: Hiroshi Nakamura <nahi@ruby-lang.org> Date: Tue Aug 2 11:18:02 2011 +0900 JRUBY-4717: Import digest.rb from CRuby stdlib. I broke digest lib for 1.8 at 51bf9d9f and Nick fixed it at 288ef4ae. And this is a new try for re-fixing digest library for JRUBY-4717. * Update tool/globals_1_8_7.rb to import digest.rb for 1.8 as same as 1.9. * Remove Java implementation of Digest.const_missing. It's defined in lib/digest.rb for both 1.8 and 1.9. * Revert 288ef1ae. It does not mean that 288ef4ae is wrong. It's 51bf9d9f which should be fixed and needs above fixes. 288ef4ae was needed. With importing lib/digest.rb for 1.8 mode, Digest function start working for 1.8 as same as CRuby. % ruby187 -rdigest -e 'p Digest("SHA2")' Digest::SHA2 % jruby -rdigest -e 'p Digest("SHA2")' Digest::SHA2 % jruby163 -rdigest -e 'p Digest("SHA2")' NoMethodError: undefined method `Digest' for main:Object (root) at -e:1
          Hide
          Hiroshi Nakamura added a comment -

          Backported to jruby-1_6 at a432afe6.
          Tagged at 3b91cb17 for master, and 1557a036 at jruby-1_6.

          Show
          Hiroshi Nakamura added a comment - Backported to jruby-1_6 at a432afe6. Tagged at 3b91cb17 for master, and 1557a036 at jruby-1_6.

            People

            • Assignee:
              Hiroshi Nakamura
              Reporter:
              Vladimir Sizikov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: