Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: JRuby 1.5.1
    • Fix Version/s: JRuby 1.6RC1
    • Component/s: Java Integration
    • Labels:
      None
    • Number of attachments :
      0

      Description

      We setAccessible methods when security policies allow it and they might need to be accessible (such as when dealing with protected or package-visible members). However, it appears we are not doing this for constructors in the same way. We should make this logic consistent for constructors as well.

      Notice in the following example that the Foo constructor is package-visible and can't be invoked, but the blah method is also package-visible and invokes fine:

      ~/projects/jruby ➔ cat blah/Foo.java
      package blah;
      
      public class Foo {
        Foo() {}
        public static Foo getFoo() {
          return new Foo();
        }
        void blah() {
          System.out.println("Hello");
        }
      }
      
      ~/projects/jruby ➔ jruby -rjava -e "java_import 'blah.Foo'; Foo.new"
      -e:1:in `new_proxy': no public constructors for Java::Blah::Foo (TypeError)
      	from -e:1
      
      ~/projects/jruby ➔ jruby -rjava -e "java_import 'blah.Foo'; Foo.foo.blah"
      Hello
      

        Activity

        Hide
        Douglas Campos added a comment -

        thats was fixed already on 02b4c702

        Show
        Douglas Campos added a comment - thats was fixed already on 02b4c702
        Hide
        Charles Oliver Nutter added a comment -

        So here's the funny thing...JRUBY-3102 explicitly set up this behavior to prevent package and private constructors from being callable, with specs and all. This bug is correct...the behavior is inconsistent, but we made a decision to limit constructor access because of odd method-selection effects it can cause. Since I put the behavior in place, and I filed this bug...I have decided to close it as "not a bug", since otherwise I would look stupid.

        Show
        Charles Oliver Nutter added a comment - So here's the funny thing... JRUBY-3102 explicitly set up this behavior to prevent package and private constructors from being callable, with specs and all. This bug is correct...the behavior is inconsistent, but we made a decision to limit constructor access because of odd method-selection effects it can cause. Since I put the behavior in place, and I filed this bug...I have decided to close it as "not a bug", since otherwise I would look stupid.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: