You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by D Sledge <da...@yahoo.com> on 2010/03/11 18:10:43 UTC

[Lang] Question about Accessible Criteria

Looking at the method ConstructorUtils.getAccessibleConstructor(Constructor), I notice that the method checks if the declaring class is public.  Should it not also make sure that the declaring class is either a top-level one or its enclosing class hierarchy are all public, too?

D



      

Re: [Lang] Question about Accessible Criteria

Posted by D Sledge <da...@yahoo.com>.
Hadn't ran a test case, so I just now made the following changes to ConstructorUtilsTest:

public class ConstructorUtilsTest extends TestCase {
    ...

    public void testGetAccessibleConstructor() throws Exception {
        ...
        assertNull(ConstructorUtils.getAccessibleConstructor(
                NestedPrivateClass.DeeplyNestedClass.class,
                ArrayUtils.EMPTY_CLASS_ARRAY));
    }

    private static class NestedPrivateClass
    {
        public static class DeeplyNestedClass
        {
            public DeeplyNestedClass(){}
        }
    }
}

and it failed.  I'll submit it in JIRA.  It looks like Class.getModfiers() only returns the modifiers explicitly declared on the class.





________________________________
From: Henri Yandell <fl...@gmail.com>
To: Commons Developers List <de...@commons.apache.org>
Sent: Sat, March 27, 2010 3:51:44 PM
Subject: Re: [Lang] Question about Accessible Criteria

Interesting question.

I think it should - unless the method Modifier.isPublic method check
checks that already.

Have you tried a test case to see if this would return an invalid constructor?

On Thu, Mar 11, 2010 at 10:10 AM, D Sledge <da...@yahoo.com> wrote:
> Looking at the method ConstructorUtils.getAccessibleConstructor(Constructor), I notice that the method checks if the declaring class is public.  Should it not also make sure that the declaring class is either a top-level one or its enclosing class hierarchy are all public, too?
>
> D
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


      

Re: [Lang] Question about Accessible Criteria

Posted by Henri Yandell <fl...@gmail.com>.
Interesting question.

I think it should - unless the method Modifier.isPublic method check
checks that already.

Have you tried a test case to see if this would return an invalid constructor?

On Thu, Mar 11, 2010 at 10:10 AM, D Sledge <da...@yahoo.com> wrote:
> Looking at the method ConstructorUtils.getAccessibleConstructor(Constructor), I notice that the method checks if the declaring class is public.  Should it not also make sure that the declaring class is either a top-level one or its enclosing class hierarchy are all public, too?
>
> D
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org