Is there any use for Class.getTypeParameters()?

This is a quote from another Thread in this forum:
How does erasure destroy reflection-related information? Methods getGenericInterfaces, getGenericSuperclass and getTypeParameters on java.lang.Class allow you to retrieve a lot of information on generic issues regarding a class. Obviously, that information is thus not destroyed.
While I do agree that Generics do not destroy reflection, I wonder what they add to it.
New types and methods are Class.getTypeParameters(), the interfaces java.lang.GenericDeclaration, java.lang.reflect.TypeParameter, java.lang.reflect.ParameterizedType etc...
Could someone please give me an example of what I could do with all these new types and methods?
It has been decided that Generics are implemented as a compile-time feature. At runtime, no information about the instantiated type parameters exists anymore. OK, so why clutter the core Java packages with a lot of seemingly useless new types and methods?

Could someone please give me an example of what I
could do with all these new types and methods?
It has been decided that Generics are implemented as a
compile-time feature. At runtime, no information about
the instantiated type parameters exists anymore. OK,
so why clutter the core Java packages with a lot of
seemingly useless new types and methods?This is a very good question, and something I've been wondering about myself. I cannot determine how to get the runtime to give me an instance of WildcardType or ParamaterizedType, for example.
Here's an extremely contrived example of how you can use Type bounds to effect runtime behaviour:
    class Processor<T> {       
    class StringProcessor<S extends String> extends Processor<S> {       
    public void whatKindOfProcessorIsItAnyway(Processor p) {
        Type processorType = p.getClass().getTypeParameters()[0].getBounds()[0];
        if ( String.class.equals(processorType) ) {
            System.out.println("I'm a string processor");
        } else {
            System.out.println("I process these: " + processorType);           
whatKindOfProcessorIsItAnyway(new StringProcessor<String>());
        whatKindOfProcessorIsItAnyway(new Processor<Integer>());Outputs:
I'm a string processor
I process these: class java.lang.Object
So you can see I can switch based on the type bounds compiled into the program, but I have no way of knowing that the second processor is actually instantiated with Integer, due to erasure.
Infact, the only reason I would know anything about the actual type argument in the first instance is because String is final so '? extends String' -> String, for what its worth.
Whether I can write a program that's actually useful using this information I've yet to determine, but I can imagine it could be useful for code generation.

Similar Messages

  • Now that Logic can be run in 64 bit is there any use for Plogue Bidule?

    Hi all.
    I have seen some videos of composers with Digital Performer running Plogue Bidule as some way to optimize their Mac's performance with large instances of Kontakt, millions of VSL instruments etc.
    I am wondering what the practical uses of a modular environment like Bidule would be for Logic, considering Logic's own Environment is so inclusive?
    I'm curious about the program, but don't want to buy anything until I can see some uses for it with Logic.
    many thanks

    yes, the built-in 32bit bridge in logic is unfinished at best and has many obvious stability issues.
    i decided to finally end the drama by getting ve pro. the good thing is that it plugs in like software instruments including routing of audio back into logic without the need of doing that externally which also means you can easily bounce your projects.
    another great thing is that with ve pro you can spread out your instruments over a network.

  • Are there any uses for a 4th. Gen AirPort Extreme that I am replacing with the 5th. Gen.?

    I have been using an AirPort Extreme 4th. Gen. with an Airport Express as an extender to increase the range in my home. I am now upgrading to a 5th. Gen. Extreme in hopes of increasing my wifi download speeds. I'm told in numerous articles and posts that the 5th. gen is much more powerful and faster. I'm wondering what use I can find for my 4th. gen extreme. Can it also be used as another extender ( I read both yes and no to this question) or is there some other useful function that it could perform, or should I just give it to one of my kids to use in their home?

    Thanks for your great advice and assistance. I have read the various articles that you linked and will try the new extended configuration using my old 4th gen as soon as my new 5th gen extreme arrives from Apple. I may also try using the express as well by going off in a somewhat different direction on the upstairs floor where the primary base unit is connected to the cable modem. My original reason for upgrading to the new 5th gen was not because the range and signal strength were inadequate, but rather to try and get some improvement in the wireless download speeds from the 4th gen extreme and the extended express. My Mac  using an Ethernet connection from the extreme was delivering download speeds of 49 to 50 Mbs all the time, while the wireless download speeds to my new iPad or my iPhone 5 were only about 15Mbs coming from the extreme and 7-8 Mbs if I was downloading through the express. I have been reading lots of comments on this subject for over a year now, with many others experiencing the same problem, but Apple never really acknowledging that there was even an issue. The only solution seemed to be that people who upgraded to the 5th gen. we're getting much better performance across all performance issues. Here's hoping for success in the next few days. Thanks again for your assistance.

  • Any uses for a old power mac g4

         Is there any use for a old powermac g4 since i have a new 2010 imac.  I love the thing so i tried to get some more use out of it by making it into a server but i can't find disc's for it.  So i tryied making it into a ubuntu server but they stop support for them long ago and i'm not to sad about it becuase i don't know much kernal.
         I just wanted to know if there is any use of still keeping a old mac around.  Not just for look.

    Without Install Discs, sadly it isn't worth much for anything other than threatening to go back to using the G4 if the new iMac gets tempermental!

  • Are there any shortcuts for creating Value Object Classes?

    Hi,
    I'm using a Remote Object to connect to my server
    (pyAMF/Django). I'm getting stuck with the creation of Value Object
    Classes. It doesn't seem very DRY to have a class on my server
    representing the data model and then have to recreate that class
    and all its properties in my Flex app.
    Are there any shortcuts for creating client side VOs from
    server side data?
    I was thinking about declaring an empty VO class in Flex, and
    then dynamically assigning/casting my Proxy object to that class.
    It seems like that approach may cause problems for the Flex
    compiler though.
    Any hints?
    Thanks!

    quote:
    Originally posted by:
    tptackab
    Oh man, do I feel your pain. I'm not sure what middle-tier
    technology you're using, but I'm using Java (w/Spring) and I
    absolutely hate having to create and maintain two sets of VO (aka
    data transfer - DTO) object for Java and Flex.
    One thing that has helped me in that area is a free tool from
    Farata Systems called
    DTO2Fx. If you're using Java and Eclipse, it's a great time saver.
    You simply install a (very lightweight) Eclipse plugin, add a
    single annotation to your Java VO classes, and it automatically
    generates your Flex VOs. It even creates a base and extended
    version of each VO on the AS3 side so you can add code to the
    extended VO without fear of having your changes overwritten when it
    regenerates your Flex VOs.
    Here's a like to thier
    PDF that
    gives instructions and a download link. I had it up and running in
    my application in less than 30 minutes!
    I'm using Python/Django serverside (PYAMF is my AMF
    serializer).

  • My iPod Touch 4G just shut off one day while i was using tap to post. tried everything and nothing is working not even iTunes! Is there any hope for me? my iPod is my LIFE!!!!!!!!!!!!!!!! oh by the way none of this happened until i updated to iOS 6.

    My iPod Touch 4G just shut off one day while i was using tap to post. tried everything and nothing is working not even iTunes! Is there any hope for me? my iPod is my LIFE!!!!!!!!!!!!!!!! oh by the way none of this happened until i updated to iOS 6.

    I have not had any experience in getting any devices repaired so I'm not sure which store to resort to. An official Apple store should more than likely get you what you need, but I'm guessing it's probably more expensive. (if any cost for your situation)
    I hope you get your problem resolved.
    ~Lt. Leviathan

  • Can i use turbo C on ipad ? Is there any app for that ?

    Can i use turbo C on ipad ? Is there any app for that ?

    No, I mean that all of the apps that will work on an iPad are in the App Store. If there is one that will allow you to use Turbo C, you'd find it there. "Turbo C" seems to be the most obvious search term. You might also do a Google search using both "turbo C" and "iPad" as terms.

  • Is there any tutorial for using ARM cortex-A processors of Zynq for digital signal processing ?

    Hello, everyone.
    Is there any tutorial for using ARM cortex-A processors(such as A9 and A53) of Zynq to deal with digital signal processing  problems?
    Please tell me , thanks.

    Hi
    Check below links
    http://www.xilinx.com/training/zynq/software-acceleration-for-dsp-functions-with-zynq.htm
    https://www.youtube.com/watch?v=ErEG7ZREcJQ
    http://www.xilinx.com/support/documentation/application_notes/xapp1170-zynq-hls.pdf
    http://www.xilinx.com/support/documentation/application_notes/xapp890-zynq-sobel-vivado-hls.pdf
    http://www.xilinx.com/support/documentation/application_notes/xapp1167.pdf

  • My boss is using Mac machine, whenever I send email from my windows machine he receives email as winmail.dat, is there any solutions for this ?

    My boss is using Mac machine, whenever I send email from my windows machine he receives email as winmail.dat, is there any solutions for this ?
    My boss is using Mac machine, whenever I send email from my windows machine he receives email as winmail.dat, is there any solutions for this ?

    Upgrading my work PC is NOT an option, but I'd like my Mac to be able to recognise the attachment for what it is
    Let see, you are using a proprietary file format that is only supposed to work with Outlook. It doesn't work for millions of Windows or Mac or Linux email users that depend on other email programs like Outlook Express, Thunderbird, Apple Mail, webmail, etc.
    Microsoft has had to publish instructions so that their program's users can make themselves compatible with the rest of the world.
    http://support.microsoft.com/kb/290809
    You are causing your own problem by not making a simple change in your program's options. Changes in the Outlook preferences can be made either Globally or by the Recipient.
    Follow these steps in Outlook 2007 to turn off TNEF:
    1. On the Tools menu, click Options.
    2. Click the Mail Format tab.
    3. In the Compose in this message format box, click Plain Text or HTML, and then click OK.
    Don't know of a better way to fix this problem for everyone concerned. Even if you get the fix to work with your machine, you will not enable all of the people receiving your emails to be able to work with you. That's a losing battle that's been caused by Microsoft.
    Now if Microsoft created a Mail plugin for other email programs like they do for their video format's and services (flip4mac, Office Live Plugin, etc), then I would consider using their email program to deal with my clients. Until then, I need to be compatible with many different programs in other countries, on different platforms. Maybe that's going to change when they bring out the new Office 2011 with Outlook for the Mac...

  • Is there any functionality for AVERAGE in ALV, like do_sum, subtot?

    Hi Experts,
    In my_alv report, am doing sub/totals for prices, by using do_sum, subtot functions.........fine. But, I need to do/display the AVERAGE value for Discount % column?
    Is there any functionality for AVERAGE in ALV, like do_sum, subtot?
    thanq

    hi
    check these links out
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    regards
    vijay
    reward points if helpful

  • I accidentally formatted my portable hard drive when setting it up for time machine. Is there any way for me to get back my lost files?

    I have an external hard drive of the brand Western Digital.
    Before I got my iMac I moved a lot of my important files from my PC to the hard drive and today I went on and connected it to my iMac to move my files over to it.
    When it had connected a window popped up that asked if I wanted to use this hard drive with the program Time Machine and create backups. Without thinking it trough enough and reading the warning properly (I'm stupid I know) I clicked "yes". I then realised how stupid it was and cancelled the formatting of the hard drive. But somehow the program still managed to delete all my important files and can't find any way to get them back. Neither can I connect the hard drive to my PC anymore so I can't check if the files are still there (which I doubt they are since I can't see them on my iMac either).
    And now I wonder: is there any way for me to get back my lost files or are they lost forever?
    Thank you in advance!
    //Gina

    A data recovery specialist or some data recovery programs should be able to help.  Most format simply rewrite the directory tree saying no files are on this disk.  The bits that represent the files are still flipped appropreiately so they still exists, you just don't have the location info to get at them.  Secure formats and erases rewrite each bit to a zero or 1 or random so the data is then truely gone.  This type of format takes a long time to complete.
    I'm not making a recomendation of a particular program but here is one company that does what you ask:
    http://www.remosoftware.com/mac-recovery  The cost is pretty high but I'm sure they don't sell many copies and need to cover their development costs.
    Good luck and don't write anything on the freshly formatted disk until you decide what to do.

  • Is there any option for voting on a list item in SharePoint 2013?

    Dear All,
    I am looking for a feature vote a for list item from multiple users and need to show consolidated results on that.
    for SharePoint 2013 we have "like", "rating" by using these can we show the consolidated results.
    otherwise is there any alternative for this.
    Thanks & Regards,
    Jithendar

    I haven't seen any OOB vote feature in sharepoint list. It's better to go with "like" or "ratting" options.
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer :)

  • Is there any hope for a Nano 6th gen that went through the washing machine?

    Is there any hope for a Nano 6th Gen that went through the washing machine?  All of the devices contents are showing up in iTunes when connected but the device itself is not working.

    Hello kpratta,
    There is some hope. I have heard of someone putting the ipod in a bag of dry rice and putting the bag in a dark place for a 4-5 days. After that they used this:
    www.apple.com/support/ipod/five_rs/
    This has the best chance. The rice absorbs any liquid in the ipod.
    Hope this helps.
    ~Julian

  • I recently gave my old iPhone to my nephew, he switched it to his phone account, but somehow I now have his contacts on my new iPhone 5. When I look at my iCloud account, it lists his contacts. Is there any way for me to get my contacts back?

    I recently gave my old iPhone to my nephew, I did not clear out my old phone before I gave it to him, when he transferred to his account, he had my iCloud info on the phone, and it updated the contacts on my new iPhone 5 to his contacts. Is there any way for me to get my contacts back?

    This is caused by using the same iCloud account on both phones.  When you do this any data you sync with the shared iCloud account such as contacts is merged and will appear on all devices connected to the account.  To fix this you both need to have separate iCloud accounts (you can continue to share the same Apple ID for purchasing from the iTunes and app stores). 
    Decide which iPhone will be keeping the current iCloud account.  On the one that will be changing accounts, if you have any photos in photo stream that are not in your camera roll or backed up somewhere else save these to your camera roll by opening the photo stream album in the thumbnail view, tapping Edit, then tap all the photos you want to save, tap Share and tap Save to Camera Roll. 
    Once this is done, go to Settings>iCloud, scroll to the bottom and tap Delete Account.  (This will only delete the account from this phone, not from iCloud.  The phone that will be keeping the account will not be effected by this.)  When prompted about what to do with the iCloud data, be sure to select Keep On My iPhone.  Next, set up a new iCloud account using a different Apple ID (if you don't have one, tap Get a Free Apple ID at the bottom).  Then turn iCloud data syncing for contacts, etc. back to On, and when prompted about merging with iCloud, choose Merge.  This will upload the data to the new account.
    Finally, to un-merge the data you will then have to go to icloud.com on your computer and sign into each iCloud account separately and manually delete the data you don't want (i.e., deleting your nephew's data from your account, and vice versa).
    As for recovering your lost contacts, if they aren't on icloud.com when you check from your computer, you will have to recover them from a backup source.  You could try restoring to your last backup but this doesn't always work for contacts.  (Chances are you nephew deleted your contacts from his phone, not realizing it would also delete them from yours.)

  • Is there any way for me to remove a broken audio jack stuck in my macbook?

    is there any way for me to remove a broken audio jack stuck in my macbook?

    You'll have to get a Dremel motor tool and some fine metal bits, make a jig to hold the Dremel so it's stationary, then a slider jig for the MacBook Pro so the bit can drill into the center of the stuck plug.
    Gently push the MBP against the drill bit so it drills into the stuck plug.
    Once the hole is drilled down deep enough, use some metal to metal epoxy resin to glue the bit into the drilled hole, then let it set up according to directions.
    Take a pair of vise-grips and get a good grip on the bit portion sticking out and gently pull it straight out, if you bend or twist, you can snap off the bit.

Maybe you are looking for

  • Tax statement item missing for tax code X0

    Hi All, While releasing sales document got the error message-- Tax statement item missing for tax code X0 Message no. FF805 Diagnosis No tax item exists for tax code X0 in a G/L account item. A possible cause is an incorrect transfer of parameters by

  • Update failed and now big problems

    Son updated his iPod touch a few hours ago and now it continues to turn itself off and on repeatedly.  Tried to restore the iPod but iTunes says it is unable to due to a missing disk.  Help!

  • Oracle RAC on 2 Microsoft hyper-v VMs

    Is it possible to setup a test Oracle RAC env on 2 Microsoft Hyper-v VMs like you can using VMware? I have setup a VMWare test Oracle RAC env following http://www.oracle-base.com/articles/10g/OracleDB10gR2RACInstallationOnCentos4UsingVMware.php and w

  • "System Extension cannot be used" when starting Parallels

    I'm using Parallels Desktop 4.0 to provide a platform for Windows XP on my MacBook. It works very well, but since a recent update of the package, I have been getting a message on startup which says: "System extension cannot be used The system extensi

  • Mouse Navigation stops working

    This is weird. I have a multi-forms application running (6i and 10g). At some point somehing seems to happen and I cannot mouse click into any fields in the form. The only way I can move to a new field is with a tab or enter keys. Once this happens,