How can I detect if a value passed via varargs has been autoboxed?

I'm running into an interesting and frustrating problem with auto-boxing and varargs. The problem is that calling a method with varargs, the varargs are autoboxed.
I have a utility method called invoke that looks like this:
public invoke(Object obj, String methodName, Object... args)
The invoke method uses Java reflection to find the appropriate method in obj's class and run it. The problem is when one of the arguments is a primitive. If I call:
invoke(someObject, "someMethod", 1, "SomeString");
and someObject's class contains:
public void someMethod(int i, String s)
I'll fail to find the method because the Invoke method will receive an Integer and a String instead of an int and a String.
Does anyone know how I can either:
1) call invoke in such a way that the int is not autoboxed
2) have invoke detect that an Integer is a auto-boxed int?
Any pointers are aprecciated,
Steve

I was afraid the answer was going to be "impossible", but I was hoping to find a sneaky way around it.
To answer your question about
void f(A a1, A a2)
void f(A a1, B b)
and invoke(obj, "f", new B(), new B())
My code will handle it in the sense that it will detect 2 methods that have signatures that can be used with the arguments given, and throw an AmbiguousMethodException (an exception class created for just such an occasion).
One way I can work around the problem would be in my signatureMatches method that I'm using to fetch the appropriate method. It gets all the methods for the class (and parents) and looks for the one method whose signature matches the agruments I have. when I get an argument that belongs to one of the 8 classes that can wrap a primitive (Integer, Boolean, etc), I can call it a match if the method has the primitive. However, this leads to some problematic results.
Scenario 1)
The class has method(int)
If I call invoke(obj, "method", 1) I get the result I want
but if I call invoke(obj, "method", new Integer(1)), I don't. Ideally, the second call should result in a NoSuchMethodException. Though with autoboxing, the code will probably work OK in most cases.
Scenario 2)
The class has both method(int) and method(Integer).
In this case, I always get AmbiguousMethodException when I try to call invoke. I would like to limit the number of times I get AmbiguousMethodException, as this limits the usefulness of my invoke method.
I'm hoping someone has a clever way for me to avoid my rather clumsy workaround.

Similar Messages

  • How can I recover my deleted web history once it has been cleared?

    in the Tools tab, there is a Clear Recent History function. In this, you can choose the time stipulant which you would like to be cleared... Once this is done, how can I recover the Recent history to see what has been browsed?

    Once deleted it can not be recovered.

  • How can i find my ipod touch 5th g that has been stole (it does have icloud but it says that it needs internet connection) i dont know what to do now plz help

    How can i find my ipod touch 5th g that has been stole (it does have icloud but it says that it needs internet connection) i dont know what to do now plz help

    What To Do If Your iDevice or Computer Is Lost Or Stolen
    If your Mac, iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should do in advance - before you lose it or it's stolen - and some things to do after the fact. Here are some suggestions:
      1. Reporting a lost or stolen Apple product
      2. Find my lost iPod Touch
      3. AT&T, Sprint, and Verizon can block stolen phones/tablets
      4. What-To-Do-When-Iphone-Is-Stolen
      5. Lost or Stolen iPhone? Here’s What to do
      6. 6 Ways to Track and Recover Your Lost/Stolen iPhone
      7. Find My iPhone
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
      1. Find My iPhone
      2. Setup your iDevice on MobileMe
      3. OS X Lion- About Find My Mac
      4. How To Set Up Free Find Your iPhone (Even on Unsupported Devices)
    Third-party solutions for computers:
      1. VUWER 1.5.4
      2. Sneaky ******* 0.2.0
      3. Undercover 4.7
      4. LoJack for Laptops Premium Mac
      5. STEM 2.1
      6. MacPhoneHome 3.5

  • How can I get alerts if a Wireless Access Point has been disconneted from the network?

    How can I get alerts if a Wireless Access Point has been disconneted from the network?
    Is it possible to get alerts via email from the WLC or WCS if Access-Point has been removed from the network?
    Thanks in advance.

    Hi,
    The below link will answer ur question!!
    http://www.cisco.com/en/US/docs/wireless/wcs/7.0/configuration/guide/7_0event.html#wp1229996
    Please dont forget to rate the usefull posts!!
    Regards
    Surendra

  • How can i block an unwanted 12 digit number that has been constantly calling me?

    how can i block an unwanted 12 digit number that has been constantly calling me? The number is >Number deleted<
    Message was edited by: Verizon Moderator

        Hi there irock2! I know how pesky those unwanted calls can become. Since the calls are not coming from a normal 10-digit American number, it may be someone international attempting to reach you. Our Usage Controls http://bit.ly/plz3pA feature offers the ability to block international calls, and even calls from private and restricted numbers. We also offer the option to change your number at no charge through My Verizon http://bit.ly/WJbRNG if you'd like.
    Thank you
    JenniferH_VZW
    Please follow us on Twitter @vzwsupport

  • How can I make my Apple ID security? It has been hacked three times in a week!

    Just in a week, I found my apple id(this id) has been hacked for three times!
    When I was trying to login in to the ITunes Connect, it returned following error,
        Your Apple ID or password was entered incorrectly.
    I'm sure I entered the password correctly that I checked it many times and it's never happens before. So every time it happens, I use the forget password tool to reset the password. Just in a week, the incorrect password occurred 3 TIMES and I have reseted my password 3 TIMES to get control back.
    I'm a developer so first time it happens I did aware of there might be hacker. So I cleared all password cache in my machine, scan virus and reset the password of Apple ID and my mailbox in a more complex letters.
    However, ever I did so, my password still goes wrong and the error happens again and again.
    And one thing I can't understand in this story is,
         - Every time I reset my password I got an email notification, it always works, during my 3 resets.
         - When my password is hacked (I can just assume it's a hack), there's no email notification. I can almost sure the email is not deleted, because no matter how fast it's delete, my mobile should receive a popup anyway.
    Now I have tried everything I can but my account is still not safe. I want report this issue to Apple that they can figure out the problem, to avoid a bigger security disaster. But I could not find a contact from apple for this problem, I sent a mail [email protected] but no reply. It's so terrible...
    So i ask for help in this forum, I'd appreciate if anybody can help either security suggestion to me or help find the contact of apple.

    account disabled for security reasons: http://support.apple.com/en-us/TS2446

  • HT1918 how  can i get the user manual  info back  which has  been  erased  from my  settings  icon  pafe  after  a restore from itunes

    how  can i   get  my user  manual info  back onto  my  settings   menu 
    this  heading  did  not  appear  on the settings  menu following  a  restore  necessitated  bt  a  freezing screen  glitch  thanks

    I'm not entirely sure what you are referring to, there isn't a user manual section in the iPad's Settings app. If you want an iPad then you can either download it from here : http://support.apple.com/manuals/ipad/
    Or if you download the iBooks app then there should be a copy in the ibookstore in it

  • How can I fix an error message saying, "This operation has been cancelled due to restrictions in effect on this computer " when I try to open a webpage from a hyperlink in Outlook?

    When I click on a hyperlink in an email (Outlook), I get the error message "This operation has been cancelled due to restrictions in effect on this computer " and it won't open the hyperlink. None of my Outlook settings are blocking the hyperlink. How can I fix it?

    When I click on a hyperlink in an email (Outlook), I get the error message "This operation has been cancelled due to restrictions in effect on this computer " and it won't open the hyperlink. None of my Outlook settings are blocking the hyperlink. How can I fix it?

  • How can i check if a Final Cut Studio licence has been used or not?

    Hello there,
    How can i check if my 'Final Cut Studio 3 Retail' set has a usuable licence or they have been used allready? It is second hand and i no longer have a Mac and wish to sell the product. In the box it has 2 of the same serials so i gather it can be used twice?
    Any help would greatly be appreciated
    Kind Regards
    Tim

    If your serial is printed on the official sticker you will have no problems and should the new owner register it, any previous registrations will be deleted.
    Officially you can only use it on one Desktop and one Laptop but there is no physical limit to the number of computers you can install it on.

  • Can I interrupt an automatic update to iPhoto? If so, how? And how can I stop automatic updates? This current update has been running for over 4 hours now. I have a MacBook Pro w/OSX 10.9.1

    Can I interrupt an automatic update to iPhoto? Also, how can I turn OFF  automatic updates?

    as Larry said, just a caution about the App Store Preferences:
    If you do not want your software to update automatically, disable "Install app updates".  But better not disable the option "Install system data files and security updates".  If there are security updates available, it is important to get them installed asap.

  • How can I retrievew history from 2 weeks ago that has been deleted?

    How can I retrieve my history from two weeks ago? It's been deleted and I desperately need it to prove that I was on the computer (facebook) at a certain time. HELP!!!!
    == This happened ==
    Not sure how often
    == How can I retrieve my history from two weeks ago? It's been deleted.

    Sorry, unless you specifically backed up the places.sqlite file in your Profile folder, that data is gone and all but impossible to recover without using a data recovery program.

  • How can I file a complaint about an employee who has been messing with me on purpose (on trades)?

    Hello. What's the best way to file a complaint against an employee who basically tried to ruin all game trades for me?
    She just stands there in the customer service section doing nothing, she paces back and forth while customers are waiting, and she only takes calls to avoid talking to customers in person. She messes up trades on purpose.
    I had a problem with a trade-in once with an awful supervisor and I called the Executive Resolution Team and the lady on the line just told me that they would call the store to hear the "other side" of the story. Honestly, I just told her what happened.
    I went in there for a trade-in earlier that day and the woman taking my trade refused to enter my phone number for my bonus. She flat out refused it five or six times. It was insane. I explained to her how the system works and she called her supervisor. The supervisor acted like I was trying to steal the bonus even though I paid for the subscription. I politely explained to her how it works and I told her all the things that came with the subscription. I told her that all they need to do is input my number in the correct space and it should apply automatically.
    She didn't believe me but she said that I could get a discount higher than what I asked to get as the bonus and I told her that it was actually lower because it was due to the base. She said it's fine and I said that I wasn't planning to buy anything that day. I just wanted to clear some space and get some credit in case there was a decent online sale later that week. She said that she could only give me a discount on something and I said, "Then can I get an Amazon card?" and she said something like "Go get it."
    I came back with the card and she gives me a discount lower than what she said she would give me, but it's still a little bit higher than my bonus, so I let it go.
    I went home and I had dinner and I got some more games ready and I went back to the store. A different lady was there and she got through most of my trade faster than the woman who kept refusing to enter my number for my bonus. She also couldn't get the bonus to work and she gave up on the first try so she calls a supervisor. I just wanted to sweep up all my games and run because I knew that she was calling the same supervisor, but I stood there because I didn't do anything wrong.
    At this point, the woman who keeps giving me trouble in my recent trips there appears and like always, she's doing nothing. Anyway, let's just call this woman L. The supervisor is K. K walked back behind the counter and she says something like, "You again? No. You're not doing this again." I say, "Doing what?" I feel insulted but I tell her that all they need to do is enter my number in the correct place for Gamer's Club Unlocked. L heard this but she just turned around like she didn't hear anything and she's busy. She did this because she's the one who got the registration card for Gamer's Club Unlocked for me. Back when she did that, she mentioned that she was from the Gaming Department. She knew that I was right but she let the supervisor get aggressive with me.
    K kept threatening to cancel my trade. I kept trying to reason with her. All she needed to do was her job. I told her how to figure it out. She kept repeating, "I will cancel it." I said, "cancel it." She canceled it and she had this egomaniac look on her face like, "I won."
    I take my games and I look back and L is pacing back and forth like a beheaded chicken.
    Anyway, for the Titanfall promo, I go into the store and I want to trade two copies of Call of Duty Ghosts and a copy of Thief. I got a copy of Ghosts from a friend who was busier than me. I was very busy those few days, so I went on the last day after classes. I have evening classes, so I got there near closing time. L rejected one of my copies of Ghosts and I asked her why and she said it was store policy even though it's not. She just cost me $11 or something because of the non-promo and promo difference.
    She insisted on doing the Thief and Ghosts trades separatetly for no reason even though I insisted that she do them together so she will only need to enter GCU once and I only need to sign twice and I get one gift card. She's just acting like a jerk, so I said, "whatever". She asked me for my number for the GCU bonus after I tell her about it. It's input and it's in the right place. It was done on the first try. She finished the Ghosts trade and I signed everything but she wouldn't give me my gift card. She started the second trade and she asked me for my number and she input it. I signed the pad and as I'm signing the paper that should be correct because she asked me for my number, I notice that my bonus is missing and I strike out the signature. I told her and she already knew. She was just shocked that I struck out the signature. She said that there was no prompt for it. She obviously lied. She asked me for my number and she input it. I told her, "You should have said something." She just took a relaxed pose and she told me that it's already tendered so she can't undo it. I told her that it's not final until I sign the final paper. I knew that I was pushing my luck because it was the last day and it was near closing time, but I kept telling her that she could fix it.
    She just wanted me to cave at that point, so she says that she will go ask a supervisor about it and she just walked into a room and she walked out in a few seconds saying the same thing. She just pretended to ask about it. She said that I can call the customer service line and get the bonus added. I signed it and she gave me the two cards. Oh, and when she left to "ask a supervisor", she took the card that was already legally mine with her. I had two cards, so I wanted to combine them. I took them to the register with a minute or two to spare and it turned out that they could not be combined because they were store credit cards and not gift cards, like it states on the website.
    So I want to file a complaint against her now and I want to get the bonus she took from me. What's the best way to do that?

    Hello r555,
    Thank you for being a My Best Buy member, and thank you for visiting our forum.  I am very sorry to hear that it has not always been easy for you to receive your Gamers Club Unlocked bonus when trading in games.  I'll be happy to talk to you about your experience.
    I get the impression you are quite familiar with the trade-in process and how the bonus is applied, and it is disappointing to hear that a store associate wouldn't attempt to complete that process.  I will be sending you a private message so we can get some more specific information regarding which store you were at as well as the trade in question where you did not receive the bonus.  Please watch for a message from me shortly.
    Sincerely,
    Mike|Social Media Specialist | Best Buy® Corporate
     Private Message

  • HT4759 How can I find the serial number toy device that has been stolen? I have looked in my account on iTunes and go to manage devices but only option is to delete that device?

    My daughters iPod was stolen today and I disabled it and tracked it on the find iPhone to an address but law enforcement can't do anything yet since they have now turned the iPod off which means it's off the radar now but for the life of me I can not find the serial number in my iTunes account to give the investigator so that he can put the info into a data base for pawn shops. Help???

    Try here >  How to find the serial number of your Apple hardware product
    I hope you find it.

  • How can I retreive my photos now that photoalbum starter has been discontinued?

    I tried to register but was told that adobe no longer supported this product. I tried unlocking with the code 79f38d43 but the unlock screen only gives me the option to exit without unlocking. When I downloaded the photos off my camera the program deleted them from the camera so now these locked images are the only copies. Can anyone help?

    Hi,
    It is likely that your photos are somewhere on your hard drive.  This was a really good product that I wish they still supported. I'm guessing you are on Windows so I'll give you the way to find them for Windows.  If it's Mac, it's slightly different but the same idea it's just different selections to do the search. I also don't know how sophisticated of a user you are, but I'm judging you aren't really technical, so if I'm too detailed in my instructions here, please forgive me I just want to be sure you find them.  It's a very anxious situation when you think you've lost your pictures. Experienced and technical users have their own ways to do these things that are quicker and easier and I know that.  But I'm absolutely sure this way will work so you may know of another way to do any part of this.  But I'm writing these instructions in such a way that there is no ambiguity or uncertainty for different Windows configurations, personalizations, or setups.  I'm almost certain these steps will ALWAYS work.  I'm also assuming that Photoshop album isn't working for you anymore and that windows is the only way you can see them.
    The Basic idea is that you need to search your hard drive for the photos using the time they were created.  First, I'll tell you how to get to the place where you can search, then I'll give you some ideas of what criteria you should search with from very specific to more general. Luckily Adobe Photoshop Album Starter Edition imports them to the hard drive and stores them just like any other Windows file.  The tags, collections, and timeline and all that stuff is within the program, but unless you tell the program to delete the file specifically, it's probably still there.
    To Search the whole computer in Windows:
    Left-click the Start button
    Right-click My Computer to get a little menu
    Left-click the Search option from the menu
    This will give you a dialog box or window that says Search Results at the top.  The choices you make here will determine how many results you will have to sort through to find what you want.
    The Simple way (if they are typical picture files) LOTS OF RESULTS
    Left-click Pictures, music, or video
    Left-click the box next to Pictures and Photos
    Left-click the grey box that says Search
    This will then search your entire computer and all the hard drives, memory cards, cameras attached to it for anything that looks like a picture and put the results on right hand side of the Search Results box.  It will look in My Pictures first then go on to the rest of the hard drive then everything else and it will skip the obvious places like the "system" and "hidden" areas for your pictures.  So, the good thing is that if it is in My Pictures, which is likely, your pictures will be at the top of the list.  You don't have to wait till its' done, you can look while it's searching and if you find the pictures, click the grey button that says Stop (same button that used to say Search).  Then you can do what you want with the pictures
    On my computer, it gives me thumbnails of each picture it finds, but yours may give you a list.  If it is a list, and you want thumbnails, click the View choice at the top of the Search Results, Thumbnails window to get thumbnail pictures.  You can scroll through the list and look at all the thumbnails for your picture.  WARNING: IF YOU HAVE A LOT OF PICTURES THIS CAN TAKE A VERY LONG TIME (HOURS IS POSSIBLE) TO MAKE ALL THE THUMBNAILS
    If it's a list, you might be able to tell by the Date Modified or Date Created if one of these things is what you are looking for.  If you see one you  then you should open it up and look at it to see if it's what you want.  If you have always used Adobe Photoshop Album Starter Edition to do that and need help with that you can write another message here asking for help.
    If you don't find it this way, it may be identified as something other than what Windows calls a picture.  If that's the case, close the Search Results window, repeat the To Search the whole computer in Windows, steps above, but then
    A TIME-SPECIFIC WAY
    Left-click All files and folders
    Left-click When was it modified and specify when the pictures were taken and/or when you put them on the computer.  Don't choose I don't remember. Make a guess to narrow down the list you will get. Try the date you think you put them on the computer first.  If you don't find something you recognize, try the date you took the picture.
    Left-click the grey box that says Search
    If you still can't find it, repost and I or someone else will try and help you, but you should find them this way.
    Good Luck
    PS I ask anyone who reads this and thinks that this is the "long" way to do it to just refrain from criticizing my instructions.  This isn't the way I would do it either, but I don't think leilah is all that technical so I'm trying to make it foolproof versus quick

  • How can I see if iChat AV 3.1 certificate has been set up?

    When I got the upgrade to either iChat AV 3.1 or OS 10.4.3, it told me that I would be receiving an email with a certificate in it for iChat AV to use to do encryption, since I am a .Mac member.
    The problem is, I never received such an email.
    In my iChat AV 3.1 preferences, for my .Mac chat account, on the "Security" tab, it says "encryption is enabled" and has a button next to it to let me "Disable".
    How do I tell what, if any, certificate is being used by iChat for encrypting my conversations?
    If I should have received a certificate in my email for use with iChat AV 3.1 - but did not for some reason - how do I initiate a request for it to be resent?
    This encryption capability for iChat sounds like a great feature. Since I have bought all the required software/service, I would like to be able to use it.

    HI JoRoCo,
    I would check the Real people in this list/FAQ
    Check which ones have @mac accounts and see what their experiences are. Some only use Trial accounts which will not be able to use encryption.
    For certain I know mine is a trial account and is not listed in my old Discussions info which is still accessible from that link. Defcom also had a trial account. Ryan had a trial account but I do not think it is even listed either.
    This should give you a start.
    Ralph

Maybe you are looking for

  • Reg BAPI_SALESORDER_CREATEFROMDAT2

    Hi All, We are creating the sales order using the BAPI BAPI_SALESORDER_CREATEFROMDAT2 the BAPI is successfully creating Sales order successfully with out any issues,but the problem is the sales order line item which has been created through BAPI is b

  • Install of OEHR not working on Apex 3.0.1 and Oracle 10.2.0.3

    Hi, I've tried this about 10 times and it's driving me mad. I'm trying to install the OEHR sample application in to new workspace and after the install finishes and it all looks like it worked perfectly. However there seems to be a problem in that on

  • JMenu dismissal action in WindowsLookAndFeel changed for 1.4.1_02 ?

    Hi all, It seems to me that the way menus are 'dismissed' in WindowsLookAndFeel has changed in the 1.4.1_02 release. The example program included in this post, when run on 1.3.1_06 (in WindowsLookAndFeel mode) keeps the menu visible until the selecte

  • Export settings for viewing on laptop

    I have a 40 minute DV NTSC sequence that I exported as Quicktime Movie and then dropped into iDVD and burned a DVD for viewing on TV. That worked fine. I now want to burn another DVD for viewing from laptops. What export setting would I use for that?

  • High enq: TX - row lock contention on RAC database

    Hi Gurus, I have SAP applications running on 5 Oracle 10g (10.2.0.5) RAC nodes. I could observe high row lock contention in the database. db file sequential read          13.555.789.712     7.148.542.630     5.27     65 enq: TX - row lock contention