How get the correct generic type from Class.forName()?

I have:
public class Test2 {
    void foo() throws ClassNotFoundException {
        Class<Test2> c = Class.forName("Test2");
}Of course, this doesn't compile:
javac -Xlint Test2.java
Test2.java:4: incompatible types
found   : java.lang.Class<capture#965 of ?>
required: java.lang.Class<Test2>
        Class<Test2> c = Class.forName("Test2");Other than casting to Class and suppressing the unchecked warning, how can I get the code to do what I think should be a common use case? I try
public class Test2 {
    void foo() throws ClassNotFoundException {
        Class<Test2> c = Class.forName("Test2").asSubclass(Test2.class);
}Which doesn't compile either:
javac -Xlint Test2.java
Test2.java:4: incompatible types
found   : java.lang.Class<capture#400 of ? extends Test2>
required: java.lang.Class<Test2>
        Class<Test2> c = Class.forName("Test2").asSubclass(Test2.class);Not sure I understand what the javac error is about.
Help!

kinmanc wrote:
This is just a simplified version of what I had. The name of the class being loaded is unknown at compile time, though it is known to implement an interface. Isn't this a common use case?Yes, its' quite common.

Similar Messages

  • Cannot get the correct data type in Oracle JDBC

    Dear ALL:
    I used JDBC ResultSetMetaData to get the column data type for Oracle Database. I created a table including 2 columns AAA, which is NUMBER type, BBB which is FLOAT type.
    However, I found a problem that either NUMBER or FLOAT data types are reported as NUMBER type in JDBC.
    IN SQL 2000, it is okay. SMALLINT, INT, TINYINT, etc..can be reported correctly.
    Can anybody tell me that what's wrong here? I will be very appreciated.

    hi,
    i guess its a bug which is fixed with 10i.
    Elango.

  • Problems to get the correct Ascii code from a char

    We need convert each of the chars into a string to a short number, send it to another application and then convert again each short to a char, and so retrieve the original string.
    We have tested this piece of code to convert from char to short and again from short to char:
    private static BufferedReader stdin = new BufferedReader (new
    InputStreamReader(System.in)); private static String user_key;
    String texto = "aeiounAEIOUN0123456789" ;
    for (int aux=0; aux<texto.length(); aux++)
    c = texto.charAt(aux); s = (short)c;
    System.out.printin ("char = '" + c + "' short = " + s);
    // Each time that the user press a key, we process a new char
    // from the String.
    try {user_key = stdln.readLine();} catch (lOException io) {}
    And when the program process the � (ascii 164) and � (ascii 165) chars, it does not work right.
    The output is:
    char='?' short=241
    char='D' short=209
    Instead, if we read directly from the keyboard, this code works right:
    while (true)
    try {user_key = stdln.readLine();} catch (lOException io) {}
    c = user_key.charAt(0); s = (short)c;
    System.out.printin ("char = '" + c + "' short = " + s);
    And we get these outputs when we press the � (ascii 164) and � (ascii 165) keys:
    char='?' short=164
    char='?' short=165
    Please can you say me how can I change the first piece of code to it works right with the 'n' and 'N' chars?
    Thanks in advance
    Jos?

    Run your application with "java -Dfile.encoding=CP850 ClassName", or change the encoding on run time to CP850 by using the appropriate constructor of InputStreamReader.
    I recommend the first option since the problem doesn't exist outside the DOS console of Microsoft Windows. If you use the second approach your program wont be portable.

  • Officejet Pro 8500 A909g do not get the correct IP address from DHCP

    Hi,
    We reconfigured our network to use 172.16.11.xxxx
    We assigned the IP addresses to our OfficeJet Pro 8500 A909g printers by using DHCP reservations.
    After joining the wireless network, all our printers have a 169.254.xxxx.xxx address.
    What am I missing?
    Thanks
    Christophe
    This question was solved.
    View Solution.

    Is DHCP still active on your router?  The printer will have to have DHCP active.
    169.254.x.x means the printer sees the router but is not getting a valid IP from it.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • AFTER I DOWNLOADED FIREFOX 4, EVERYTIME I OPEN THE PROGRAM I GET THE FOLLOWING MESSAGE- TYPE ERROR:COMPONENT.CLASSES[CID] IS UNDEFINED. HOW DO I CORRECT THIS?

    After upgrading to firefox 4, everytime I open the program, I get the following message, "TYPE ERROR:conponentclasses undefined." How do I correct this?

    That indicates that you are using an add-on that is not compatible with Firefox 4. For details of how to troubleshoot this to find out what one is causing the problem see https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Is there a way to get the correct order from the dependent types of a sche

    Hi ,
    I have a CT facing the following problem:
    When trying to built a SQL script to create all the object types within a schema using the DBMS_METADATA packages.
    Did insert in a table the names of the types that will be exported following a concrete order, next loop into the table and call the DBMS_METADATA package for each row.
    These type are depedent between them, there are some type attributes calling other types and here the issue
    First : try to generate the order by created column of dba_objects and when the generated SQL script is launched a lot of type appearing as incomplete state due to the order isn't correct.
    Second : try to insert the table ordering by object_id colums of dba_tables view, it appears incomplete types too.
    Currently want to insert the table using a recursive query with connect by against the dba_type_attrs starting with the rows when ATTR_TYPE_NAME is not null (the types that are called by other types), but this way has a issue dificult to resolve: the roots of hierarchy are the rows when ATTR_TYPE_NAME is not null and we've dependencies between roots nodes
    The question is is there a way to get the correct order from the dependent types of a schema?
    Platform: IBM SP AIX
    DB version: 9.2.0.7
    Any help will be appreciated .
    Thanks in advance.

    The xxx_dependencies view should give you the dependencies betwee nthe various types. I would look at something along the lines of:
    SELECT object_name, referenced_name
    FROM (SELECT o.object_name, d.referenced_name
          FROM user_objects o, user_dependencies d
          WHERE o.object_name = d.name(+) and
                o.object_type = d.type(+) and
                d.referenced_type(+) = 'TYPE' and
                o.object_type = 'TYPE')
    START WITH referenced_name IS NULL
    CONNECT BY PRIOR object_name = referenced_nameThe outer join between user_objects and user_dependencies is required to generate the names of types which are not dependent on other types, or do not have other types dependent on them.
    HTH
    John

  • How can i get the correct text from the url which has the mulitp-languages?

    hi, all
    i built a application and deployed it on sun application server 8.1. when i request a url which include some multi-languages (for example http://xxx.com/servlet?value=XXX. the 'XXX' may be simply chinese. ), i got the ??? instead of the correct text. how can i do it? in tomcat server, i can set the URIEncoding=GBK to get the correct code in server.xml. how can i do it in sun app server?
    thanks.

    Ok, it is unclear on what is happening here.
    Are you saying that when the webclient gets the data that it is not honoring the quote characters? Or the processing of the data buffer is causing issues?
    This is what I see the of your example text which is trying to be parse out:
    <a onmouseover="EnterContent('ToolTip','תווית על בגד: &rsquo;&rsquo;תן לאישה לכבס. זה תפקידה&rsquo;&rsquo;','<u><span style=color:#000099;>כתב: Spook בתאריך: 08.03.15 שעה: 22:11</span></u><br>מחאת טוויטר קמה בעקבות תוויות שוביניסטיות שהדפיסה חברת אופנה באינדונזיה לפיהן תפקיד הכביסה מוטל על האישה. החברה התנצלה אך כנראה רק עשתה רק יותר נזק לע...'); Activate();">";
    It appears to me that the  escapes `&rsquo;` does not have matching `&ldquo;` anywhere within the tooltip. So it appears that the page properly places left quotes in when processing the page, but the raw html has broken text.
    Hence a garbage in, garbage out situation.
    William Wegerson (www.OmegaCoder.Com)

  • How to get the correct value from check box

    hi guys,
    here is a program to read data from IKPF.
    with the user tick on the check box, the program will retrive
    corresponding records based on the inventory counted (zstat) status.
    however i don't get the correct output with the following selection.
    Please advise where is going wrong. Thank you.
    IF ph_ncnt = 'X'.
        v_zstat1 = SPACE.
      ENDIF.
      IF ph_pcnt = 'X'.
        v_zstat2 = 'A'.
      ENDIF.
      IF ph_acnt = 'X'.
        v_zstat3 = 'X'.
      ENDIF.
       select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       b~menge into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and ( a~zstat = v_zstat3 OR
            a~zstat = v_zstat2 OR
            a~zstat = v_zstat1 )
         and a~gjahr = p_gjahr.

    hi guys,
    i'll use the following to get the desire result. This is a bit "stupid" but at least it gives me the correct result.
      IF ph_ncnt = 'X'.
        v_zstat1 = SPACE.
      ENDIF.
      IF ph_pcnt = 'X'.
        v_zstat2 = 'A'.
      ENDIF.
      IF ph_acnt = 'X'.
        v_zstat3 = 'X'.
      ENDIF.
    IF ph_ncnt = SPACE AND ph_pcnt = SPACE
                         AND ph_acnt = SPACE.
         message I799(SA) with 'Which data to print?'.
         stop.
      ELSEIF ph_ncnt = 'X' AND ph_pcnt = 'X'
                           AND ph_acnt = 'X'.
       select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and a~gjahr = p_gjahr.
      ELSEIF ph_ncnt = 'X' AND ph_pcnt = 'X'.
       select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and ( a~zstat = v_zstat1 OR
            a~zstat = v_zstat2 )
         and a~gjahr = p_gjahr.
      ELSEIF ph_ncnt = 'X' AND ph_acnt = 'X'.
      select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and ( a~zstat = v_zstat1 OR
            a~zstat = v_zstat3 )
         and a~gjahr = p_gjahr.
      ELSEIF ph_pcnt = 'X' AND ph_acnt = 'X'.
      select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and ( a~zstat = v_zstat2 OR
            a~zstat = v_zstat3 )
         and a~gjahr = p_gjahr.
      ELSEIF ph_ncnt = 'X'.
      select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and a~zstat = v_zstat1
         and a~gjahr = p_gjahr.
      ELSEIF ph_pcnt = 'X'.
      select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and a~zstat = v_zstat2
         and a~gjahr = p_gjahr.
      ELSEIF ph_acnt = 'X'.
      select awerks bmatnr bcharg aiblnr bzeili agjahr a~gidat
       bmenge azstat into table t_data
       from ikpf as a
       inner join iseg as b
       on aiblnr = biblnr
       and agjahr = bgjahr
       where a~werks in s_werks
         and a~lgort in s_lgort
         and a~gidat in s_gidat
         and a~zldat in s_zldat
         and a~zstat = v_zstat3
         and a~gjahr = p_gjahr.
      ENDIF.

  • Hi, can you help?  My emails that I have received show the date received as either today, yesterday or July 28.  How can I get the correct date received?

    Hi, The emails that I have received show the date received as either today, yesterday or July 28.  How can I get the correct date received?

    That's very scary. They might do it, but I personally have never had Apple contact me re id's except on their site when signing in. I suggest you DO NOT respond until you have a phone conversation with Apple security. They can verify if they sent you the e-mail and why.
    While it's very possible it's true,again, I suggest you not respond until you speak to someone at Apple. I've often read here that when people sign in they are not allowed to because "someone else has used the id" type of statement.
    Also, you should be able to go to the app store and see what apps you have downloaded.
    Though it could have been a free app, have you checked to see if any were bought with your id account?
    I've gotten these types of e-mails from places like USPS and FedEx which look amazingly authentic and were from their website. I also received an odd e-mail from my cousin in Ireland last year that clearly was not from him. It was also sent to others in his family in Ireland. I e-mailed him that I only opened it because it had a .ie, but suggested he change... Days later I received mail from 'him' - same name, but at yahoo.com. 
    Again, I would call Apple. You can also report it at [email protected], but I would not settle for that given your situation. If nothing else, call Apple sales (sales depts. anywhere answer fast) and ask them to transfer you to security. Apple will not want anybody accessing their name, and while it's unlikely, it's not impossible that it is someone phishing.
    Hope this helps and can you let the support community know your results by posting on this thread when you're done? Thank you.
    Hope this helps.

  • Whenever I update my iPhone software, it asks me to sign in to iCloud with an old email address.  My other devices all have the correct address.  How can I get the correct address for my iPhone?  The only Apple ID that works for logging in is my new one.

    Whenever I update my iPhone software, it asks me to sign in to iCloud with an old email address.  My other devices all have the correct address.  How can I get the correct address for my iPhone?  The only Apple ID that works for logging in is my new one.

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iPhone (if you're using iOS 7), then sign back in with the ID you wish to use.  If you don't know the password for your old ID, or if it isn't accepted, go to https//appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Tap edit next to the primary email account, tap Edit, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https//appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • How do I get the correct ICloud account on my iOS devices?

    Hello. A few days ago, I changed my Apple ID username from my old email to my new one. Everything worked fine and I was able to re-login to the App Store, iMessage, etc. A few days later, I got a message from iCloud asking me to login. When I tried to login it failed and I realized that it was using my old Apple ID email to login to iCloud. So I went into accounts and tried to delete that account and add the account with the correct Apple ID. When I tried to delete the account it asked for my iCloud password to confirm, which doesn't work because it is using my old Apple ID. I then tried to add my current iCloud account without deleting the old one, but when I did it said it was already on the device. How do I get the correct ICloud account on my iOS devices?

    Log out of the old ID, then login using the new one with the correct pw.

  • Itunes 10.6.1.7 problem: when I change the file "media type" from 'Music' to 'Podcast' the file disapears from ITUNES. I do this via (1) right click, (2) select 'Get Info', (3) select 'options' tab, and (4) change media type. What is the problem?

    Itunes 10.6.1.7 problem: when I change the file "media type" from 'Music' to 'Podcast' the file disapears from ITUNES. I do this via (1) right click, (2) select 'Get Info', (3) select 'options' tab, and (4) change media type. What is the problem?

    Hi Memalyn
    Essentially, the bare issue is that you have a 500GB hard drive with only 10GB free. That is not sufficient to run the system properly. The two options you have are to move/remove files to another location, or to install a larger hard drive (eg 2TB). Drive space has nothing to do with SMC firmware, and usually large media files are to blame.
    My first recommendation is this: download and run the free OmniDiskSweeper. This will identify the exact size of all your folders - you can drill down into the subfolders and figure out where your largest culprits are. For example, you might find that your Pictures folder contains both an iPhoto Library and copies that you've brought in from a camera but are outside the iPhoto Library structure. Or perhaps you have a lot of purchased video content in iTunes.
    If you find files that you KNOW you do not need, you can delete them. Don't delete them just because you have a backup, since if the backup fails, you will lose all your copies.
    Don't worry about "cleaners" for now - they don't save much space and can actually cause problems. Deal with the large file situation first and see how you get on.
    Let us know what you find out, and if you manage to get your space back.
    Matt

  • How can I get the correct Ship To (KNVP-KUNNR2) for a Sales Document?

    I am trying to generate a report that will (among other things) display the Ship To ID and Name for a given Sales Document.  I know the following information:
    VBAK-VBELN - Sales Document
    VBAK-VKORG - Sales Org
    VBAK-VTWEG - Distribution Channel
    VBAK-SPART - Division
    VBAK-KUNNR - Sold To Party
    I know that the table KNVP will return a list of Ship-To Customer numbers (KUNNR2) for a Sold-To Customer (VBAK-KUNNR) if I also filter by VKORG, VTWEG, and SPART (using SE16N).  What I don't know is which one of the returned values is being used in a particular Sales Document.  The customer in question has 29 Ship-To locations.  How do I find out which Partner Counter (KNVP-PARZA) the Sales Document uses? I don't know where that value would come from.  Once I can get the correct Ship-To Customer Number, I should be able to search the table KNA1 by WHERE KUNNR = KNVP-KUNNR2 and return KNA1-NAME1 for the Name of the Ship-To location.

    For a sales document?  Use VBPA with PARVW = 'WE'.  Also, use the ADRDA field to determine whether the address on the document has been manually changed.  In any case, you can use one of the many address management functions or just ADRC directly to get the name, address, etc., using the ADRNR field from VBPA or if the address is from the customer master, KNA1.

  • How can i find the original picture in the correct event folder from an album folder picture?

    how can i find the original picture in the correct event folder from an album folder picture? I can find the link to the original event folder, but is there a way to get right to the picture without having to search visually the event folder?

    Depends on whatr you mean
    Deleting from your phone does not delete from anywhere else
    HOWEVER deleting from your Photo stream does delete from the Photostream so anyone looking at the PS from any device will no longer see the photo
    But if your Mac iPhoto is set to automatically impor tphotos form PS or is you have manually imported photos from PS then onc ethey are imported they are on your Mac and change to PS will not affect them
    for more on PS see http://support.apple.com/kb/HT4486?viewlocale=en_US&locale=en_US
    LN

  • I want to back up my 4S but I don't get the correct screen when I plug it into my Mac - Just iPhotos and iTunes (songs) pop up. How do I get to the screen where I can back up and restore?

    I want to back up my 4S but I don't get the correct screen when I plug it into my Mac - Just iPhotos and iTunes (songs) pop up. How do I get to the screen where I can back up and restore?

    Hi Spookola,
    I don't know how that could have happened. Go through the folders for the rolls and separate the 2005 rolls from the 2006 rolls, then import the 2006 rolls.

Maybe you are looking for

  • Can I use my iPad as a monitor for my iMac?

    I have an '06 model iMac running OS Lion.  Recently the screen gave up and it is difficult to see pictures.  I took it to the apple store and had it tested.  The good news is it is just the display, not the video card.  The bad news is I don't have a

  • Hardware clock and system clock don't match

    hello. i recently upgraded to kde 4.7, and i don't know if it's the culprit or not, but my system clock is now ahead of the hardware clock by the timezone offset. my timezone is Asia/Manila, which is UTC+8. so if the correct time is 00:00, the system

  • Is home sharing down?

    Anyone else having trouble with home sharing? It was working fine just yesterday. Today, my AppleTV doesn't see my computer and I can't use AirPlay from my iPhone. I rebooted the AppleTV, which wasn't even able to connect to iTunes. It connected just

  • Date format in sqlldr

    I need a help to loading the SQL Loader. A date format has to be done in the control script. in OPT_EXPRN_D column The below logic has to be included in the ctl file. Eg: select trunc(to_date('01-JAN-09'),'mm') + (6 - to_char(trunc(to_date('01-JAN-09

  • Quicktime file import failure in CS5 After Effects and PPro

    Running a Dell PC with a fresh install of Win 7 Pro, Intel Quad Core 2 with 4GB.  Ram.When I try to import quicktime files into AE or PPro, I get a file import failure or corrupted file message.  I am using quicktime version 7.6.6.  I have tried unin