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

Make import not complain if Java already has already imported the specific Java class

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.2
    • Fix Version/s: JRuby 1.4
    • Component/s: Java Integration
    • Labels:
      None
    • Number of attachments :
      0

      Description

      jr -e 'require "java"; import java.util.Hashtable; import java.util.Hashtable'
      

      The second import could be a no-op if it checks Java::* and see it is already defined. This would make programmers need be less aware of importing...

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        I went ahead and fixed this. The logic now is:

        if the constant is not defined
        or it is defined and != the imported class
        assign the constant

        So in cases where the constant is already defined and points at the same class, there will be no warning. But if it's defined and points at something else, you'll get the warning.

        Pushed in 8b7d51f.

        Show
        Charles Oliver Nutter added a comment - I went ahead and fixed this. The logic now is: if the constant is not defined or it is defined and != the imported class assign the constant So in cases where the constant is already defined and points at the same class, there will be no warning. But if it's defined and points at something else, you'll get the warning. Pushed in 8b7d51f.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Thomas E Enebo
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: