Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

automatic boxing / unboxing ?

Thread view: 
Tomba - 15 Nov 2005 13:21 GMT
Hi,

I'm working with Java 5.0 and somehow I can't figure out what the
problem is here:

Executing the following code:
try {
    setter.invoke(bean, new Object[] { value });
} catch (IllegalArgumentException ex) {
    System.out.println("Setter: " + setter + "\nArgument: " +
value.getClass().toString());
    ex.printStackTrace();
}

I get the following output:

Setter: public void util.Transformation.setRelative(boolean)
Argument: class java.lang.Boolean
java.lang.IllegalArgumentException: object is not an instance of
declaring class ...

The function defenately exists but the problem seems to be the
conversion with Boolean and boolean. Shouldn't Java actually make it
work by unboxing the Boolean to the primitive boolean?
Hope you can see what I'm missing here... :/

Thank you!
VisionSet - 15 Nov 2005 13:33 GMT
> try {
> setter.invoke(bean, new Object[] { value });
[quoted text clipped - 8 lines]
> java.lang.IllegalArgumentException: object is not an instance of
> declaring class ...

It looks to me that the problem lies in not providing the correct arguments
to the invoke method, this is what is throwing the exception. Without the
code for invoke() it is not possible to know, but I guess invoke is
expecting different objects in the Object[]

--
Mike W
Thomas Hawtin - 15 Nov 2005 13:40 GMT
>>try {
>>setter.invoke(bean, new Object[] { value });
[quoted text clipped - 13 lines]
> code for invoke() it is not possible to know, but I guess invoke is
> expecting different objects in the Object[]

Or bean is not a util.Transformation.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Tomba - 15 Nov 2005 13:45 GMT
>>> try {
>>> setter.invoke(bean, new Object[] { value });
[quoted text clipped - 18 lines]
>
> Tom Hawtin

Tested with some more output, and indeed bean is not a Transformation.
Made an error there. Thanks Tom


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.