commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <>
Subject Re: [BeanUtils2] In what cases can we expect to see an IllegalAccessException?
Date Thu, 21 Jun 2012 07:17:54 GMT
Hi Bene,

I'll need some time to read you email, I am close to a deadline and
still have few task to complete.

In the meanwhile, I'd sugest you to move exceptions outside the
`exception` package and drop it - exceptions should be packaged at
APIs level, not by their nature.

Have a look, just to mention a good example, at IOException[1] and
(some of) derivates - they are in the, not throws

Of course, there are also samples (not in the JDK that I know) where
exceptions are packaged in `exception(s)` package but... would you
move interfaces in the `interface(s)`? I wouldn't :P Just kidding ;)

best and thanks in advance for the hard work,


On Wed, Jun 20, 2012 at 9:52 PM, Benedikt Ritter
<> wrote:
> Hi,
> I'm still working on
> and I wanted to test if all the new exception get thrown correctly.
> For that reason I implemented a new class - ExceptionThrowingTestBean
> that properties and methods that throw exceptions when they get
> called. That way I can test if the InvocationTargetException gets
> wrapped correctly in.
> I also implemented getters and setters with default, protected and
> private visibility. I expected to get an IllegalAccessException
> wrapped in a PropertyNotAccessibleException. Instead I got:
> java.lang.Exception: Unexpected exception,
> expected<org.apache.commons.beanutils2.exception.PropertyNotAccessibleException>
> but was<org.apache.commons.beanutils2.exception.PropertyNotFoundException>
>        at org.junit.internal.runners.statements.ExpectException.evaluate(
>        at org.junit.internal.runners.statements.RunBefores.evaluate(
>        at org.junit.internal.runners.statements.RunAfters.evaluate(
>        at org.junit.runners.ParentRunner.runLeaf(
>        at org.junit.runners.BlockJUnit4ClassRunner.runChild(
>        at org.junit.runners.BlockJUnit4ClassRunner.runChild(
>        at org.junit.runners.ParentRunner$
>        at org.junit.runners.ParentRunner$1.schedule(
>        at org.junit.runners.ParentRunner.runChildren(
>        at org.junit.runners.ParentRunner.access$000(
>        at org.junit.runners.ParentRunner$2.evaluate(
>        at
>        at
>        at
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
>        at
>        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> Caused by: org.apache.commons.beanutils2.exception.PropertyNotFoundException:
> Property privateProperty not found in type
> org.apache.commons.beanutils2.testbeans.ExceptionThrowingTestBean
>        at org.apache.commons.beanutils2.DefaultBeanAccessor.get(
>        at org.apache.commons.beanutils2.GetPropertyTestCase.getPrivateProperty(
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
>        at java.lang.reflect.Method.invoke(
>        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
>        at
>        at org.junit.runners.model.FrameworkMethod.invokeExplosively(
>        at org.junit.internal.runners.statements.InvokeMethod.evaluate(
>        at org.junit.internal.runners.statements.ExpectException.evaluate(
>        ... 17 more
> Caused by: java.beans.IntrospectionException: Property
> 'privateProperty' does not exist in bean of type
> org.apache.commons.beanutils2.testbeans.ExceptionThrowingTestBean
>        at org.apache.commons.beanutils2.DefaultBeanProperties.getPropertyDescriptor(
>        at org.apache.commons.beanutils2.DefaultBeanProperties.getReadPropertyMethod(
>        at org.apache.commons.beanutils2.DefaultBeanAccessor.get(
>        ... 27 more
> I believe this is, because somewhere deep inside
> AccessibleObjectsRegistry everthing that is not public will be ignored
> (see line 352 in that class). So the AccessibleObjectsRegistry returns
> null for a property getter that is not accessible. Is this an
> acceptable behavior or do we have to change that?
> I believe that even if the user code has access to a
> method/property/constructor, the BU2 code won't have access. This is
> because client code may reside in the same class (private visibility),
> package (default visibility) or in an inheriting class (protected
> visibility), but the code that actually calls the methods is in BU2
> and won't have access. Am I right? What do we do about that?
> My suggestion would be instead of returning null (line 354) in
> AccessibleObjectsRegistry, we could throw an IllegalAccessException
> that could be caught and wrapped later on. What do you think?
> Regrads,
> Benedikt
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message