Odd scenario where type inference doesn't work

I've come across an odd scenario where type inference doesn't work and instead I'm greeted with a message:
incompatible types
found : java.lang.Object
required: java.util.Set
Here's the scenario (built with JDK6, javac):
public class GenericTest {
     public static void test() {
          Set testList = GenericTest.method1(new Class[] { ArrayList.class });
     public static <I> I method1(Class<List>[] params) {
          return null;
}Yet when I remove the type information from the method1 params, the class builds.
public class GenericTest {
     public static void test() {
          Set testList = GenericTest.method1(new Class[] { ArrayList.class });
     public static <I> I method1(Class[] params) {
          return null;
}Why would removing the type information from the parameter have any effect whatsoever on the return type?

ilmaestro wrote:
Though casting the parameter as you mentioned resolves the error (because it eliminates the generic), it still doesn't explain why changes to the parameter effect an error message having to do with the return type.It is due the call to the method with the "erased" type Class[] (not a Class<?>[], for example) and a return type resolution. Unchecked conversion (from the raw type to the parametrized type) is applied to the method argument and the return type of the method is determined as an erasure of the declared return type (JLS 3rd edition, [Method Result and Throws Types|http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.2.6], first bullet, second sub-bullet). Erasure of the return type is a java.lang.Object, which is incompatible with the java.util.Set.
In the second example, method parameter is already a raw type, and unchecked conversion is not required. The return type of the method is I and is correctly inferred to the java.util.Set.
If the method is called with a non-raw type, then return types are inferred correclty. For example, following code compiles fine.
public class GenericTest {
  public static void test() {
    Set testList = GenericTest.method1((Class<List>[]) (new Class[] { ArrayList.class }));
  public static <I> I method1(Class<List>[] params) {
    return null;
}This example is not "correct" due to the cast to Class<List>[], because such array can't contain Class<ArrayList> as an element (Class<ArrayList> is not a child of Class<List>). And this makes definition Class<List>[] almost useless, because such array should contain only List.class values.

Similar Messages

  • XMLType setNull(nnn, Types.NULL) doesn't work in a ps.executeBatch()

    All,
    Sorry below was originally posted in another OTN forum ( XMLType setNull(nnn, Types.NULL) doesn't work in a ps.batchUpdate() ) and I feel that it maybe more relevant here, so if you have already read it... my apologies:
    A little background: Java version 1.5.0.08 on Solaris 10 with Oracle 10g R2. The XMLDB is using the Object Relational setup with a large XSD being shredded, the schema in question has three XMLType columns two of which are nullable, but all reference the same XSD. Everything i reference below will be in Java code that compiles(all of the time) and runs (most of time depending on which code is implemented). To my knowledge no patches were applied to the DB server when it suddenly stopped working.
    Until recently the setNull (using java.sql.Types.NULL for the data type) was working in a batch update (ps.updateBatch()) . Now we get the following stack trace:
    java.lang.NullPointerException
    at oracle.jdbc.driver.T4CTTIoac.init(T4CTTIoac.java:354)
    at oracle.jdbc.driver.T4C8Oall.initBindsDefinition(T4C8Oall.java:1217)
    at oracle.jdbc.driver.T4C8Oall.marshal(T4C8Oall.java:372)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:202)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10620)
    Interestingly enough we can execute the same code but only changing the executeBatch to be ps.executeUpdate(). I know that executeBatch() works as we have other tables being inserted into using XMLTypes with no problem, however none of the columns are nullable. I'm not sure if this is a configuration issue that has been introduced while trying to increase/tweak insert performance (on the DB server), or if something else altogether. Does anyone have any insight into this?
    Regards,
    Stefan

    Does something like this help
         while (resultSet.next())
            xml = (XMLType) resultSet.getObject(1);
            Reader reader = new InputStreamReader(xml.getInputStream());
            FileOutputStream fos = new FileOutputStream("c:\\temp\\output.xml");
            Writer writer = new OutputStreamWriter(fos);
            int n;
            char[] buffer = new char[CLOB.MAX_CHUNK_SIZE];
            while (-1 != (n = reader.read(buffer)))
              writer.write(buffer,0,n);
            writer.flush();
            fos.close();
            xml.close();
           resultSet.close();
           statement.close();
           getConnection().close();
          

  • Where used list doesn't work for global data

    Hi,
    When i try to do where used list on a constant in an include, it doesn't give the results for classes.
    The class contains the include in a method that uses the constant, and the where used list for that constant doesn't find the appearance of the constant in the class.
    I tried to look for oss note that solves the problem but i couldn't find any.

    I tried to update the navigation index but it still doesn't work. from my debuging i found out that it just doesn't look in classes, all classes. I mean even in the where used itself there is not an option for used in classes. I checked it and it's a generic problem of the where used list for global data.
    Edited by: Cohen Lior on Apr 14, 2010 6:52 PM

  • Dynamic Linq with Where and ObjectParameter doesn't work

    Hello !
     I have this code :
    Imports System.Linq.Dynamic
    Dim mylist As IQueryable(Of Myobject)
    Dim ob1 As New List(Of ObjectParameter)
    Dim dynstr as string=string.empty
    dynstr += "it.id= @id"
    ob1.Add(New ObjectParameter("id", 26))
    mylist=context.MyObjects.Where(dynstr,ob1.ToArray()).Tolist
    I'm expecting that MyList contain only 1 object with id=26 , but MyList contains all the objects inside MyObjects. So it seems that the Where clause has no effect.
    And it's strange because if i change the dynstr to simply dynstr+="it.id=26" , everything works ok . It seems that the objectparameter list "doesn't communicate" with dynstr.?????????
    What's wrong ? Thank you !

    apology for not understanding your question correctly.
    " It seems that the objectparameter list "doesn't communicate" with dynstr.?????????"
    probably you have to change
    mylist=context.MyObjects.Where(dynstr,ob1.ToArray()).Tolist
    to below perhaps? since obj1 is already a collection.  i have not tried it though.
    mylist=context.MyObjects.Where(dynstr,ob1).Tolist
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • XMLType setNull(nnn, Types.NULL) doesn't work in a ps.batchUpdate()

    All,
    A little background: Java version 1.5.0.08 on Solaris 10 with Oracle 10g R2. The XMLDB is using the Object Relational setup with a large XSD being shredded, the schema in question has three XMLType columns two of which are nullable, but all reference the same XSD. Everything i reference below will be in Java code that compiles(all of the time) and runs (most of time depending on which code is implemented). To my knowledge no patches were applied to the DB server when it suddenly stopped working.
    Until recently the setNull (using java.sql.Types.NULL for the data type) was working in a batch update (ps.updateBatch()) . Now we get the following stack trace:
    java.lang.NullPointerException
    at oracle.jdbc.driver.T4CTTIoac.init(T4CTTIoac.java:354)
    at oracle.jdbc.driver.T4C8Oall.initBindsDefinition(T4C8Oall.java:1217)
    at oracle.jdbc.driver.T4C8Oall.marshal(T4C8Oall.java:372)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:202)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10620)
    Interestingly enough we can execute the same code but only changing the executeBatch to be ps.executeUpdate(). I know that executeBatch() works as we have other tables being inserted into using XMLTypes with no problem, however none of the columns are nullable. I'm not sure if this is a configuration issue that has been introduced while trying to increase/tweak insert performance (on the DB server), or if something else altogether. Does anyone have any insight into this?
    Regards,
    Stefan

    Does something like this help
         while (resultSet.next())
            xml = (XMLType) resultSet.getObject(1);
            Reader reader = new InputStreamReader(xml.getInputStream());
            FileOutputStream fos = new FileOutputStream("c:\\temp\\output.xml");
            Writer writer = new OutputStreamWriter(fos);
            int n;
            char[] buffer = new char[CLOB.MAX_CHUNK_SIZE];
            while (-1 != (n = reader.read(buffer)))
              writer.write(buffer,0,n);
            writer.flush();
            fos.close();
            xml.close();
           resultSet.close();
           statement.close();
           getConnection().close();
          

  • Window Type Character doesn't work

    When I open Illustrator CS6 and go to Window > Type > Character the Character box doesn't pop up.
    When I try the Ctrl + T shortcut nothing happens and the Checkmark that is normally next to "Character is not there"
    I called support and they said there was a solution but they wouldn't tell me what it was without paying them $39.
    Does anyone have an idea how to fix this?

    Hi Alan,
    Give it a try by clearing the Illustrator preferences at:
    PC :  <startupdrive>\Users\<username>\AppData\Roaming\Adobe\Adobe Illustrator CS6 Settings\en_US
    Mac: <startupdrive>/Users/<username>/Library/Preferences/Adobe Illustrator CS6 Settings/en_US
    Let me know if it gets solved!
    Thanks,
    Nikita

  • CSS 11150 - "Keepalive type http" doesn't work.

    I've two webservers, A and B, sharing the same webdata on a NetApp filer. A CSS 11150 (5.033) have a content rule, C, with a VIP registred in internet DNS.
    I've added A and B to C. When using default "Keep alive type (ICMP)" on services the site is fully functional. When I disable the site on webserver A, clients attached to this server get errors and are not redirected to the B webserver. This is because the CSS doesn't check the for "Keepalive type http".
    The CSS thinks that A is online because it is answering for ping. This solution is not good so I tried to change the "Keepalive type" to http. This is better when something is wrong with one of the load-balanced webservers, but when activating "Keepalive type http" the CSS marks A and B down and site is offline.
    Is something wrong with my configuration???
    service lbws1.kov
    ip address xx.xx.193.25
    protocol tcp
    port 80
    active
    service lbws2.kov
    ip address xx.xx.193.27
    port 80
    protocol tcp
    active
    owner KOV
    content D
    protocol tcp
    add service lbws1.kov
    add service lbws2.kov
    balance aca
    port 80
    advanced-balance sticky-srcip-dstport
    vip address xx.xx.193.245
    active
    content C
    add service lbws1.kov
    add service lbws2.kov
    protocol tcp
    port 80
    balance aca
    advanced-balance sticky-srcip-dstport
    vip address xx.xx.193.28
    active

    By default the CSS will attempt to read http:///index.html
    It looks like that may not exist. Try to access the index page yourself from each of the services.

  • LIBRARY LINK IN THE JSP TYPE PAGE DOESN'T WORK

    Hi Gurus
    I have loaded my jsp file as jsp type page. The jsp uses oracle's sqltaglib in
    it. When I try to
    open that page, it looks for the sqltaglib.tld
    I have tried to add the .tld as an item and used the url of that item in the
    code. it didn't work.
    I am not sure how to tackle this. Can I get some help on this.
    Thanks in Advance.

    See here:  If sharing options and Markup are missing after you install OS X Yosemite
    This resolved the issue for me.
    Rick

  • SELECT...where ROWNUM 1 doesn't work??

    Hi all,
    We're working to try to eventually update some rows on a table that an application has threads processing.
    We're trying to basically update the value of one field it uses to 'mark' which is owned by that process.
    while doing this, we were trying to just reset this field on some rows above where it is working. We tried using rownum.
    This didn't work, so in trying to troubleshoot...we tried just a basic select to see if it would return any values to make sure rownum would work (dunno why it wouldn't).
    If I try the following I get weird results
    select count (*) from table1.
    Returns like 13000 rows for a count.
    I do this
    select count (*) from table1 where rownum > 1
    I get no rows.
    The table has 13000 rows in it....
    Now, if I do something like a select col1 from table1 where rownum < 10,
    I get 9 rows...
    I'm puzzled by this...
    This originally came up with trying to update like I said, and was trying to do something like:
    update table1 set field1 = 'value' where rownum between 1000 and 3000;
    No rows updated.
    I've not played with rownum in awhile, can someone give me some insight on what is going on here, or some links to info?
    Thanks in advance,
    cayenne

    Keep in mind, rownum is query pseudo-column given row number in the outpup result.
    I'll try to resume what Oracle is doing when testing rownum>1 :
    1. based on your where clause, Oracle will retrieve one row, rownum=1 (because it is the first row returned), test if it is >1, it is not, then don't get this row, then rownum go back to its previous value, 0
    2. Oracle will retrieve an other row, rownum=previous value(=0) + 1=1 (because no rows have been returned yet), test if it is >1, it is not, then don't get this row neither, then rownum go back to its previous value, 0
    3. see the 2 point
    4. finally, no of the row is returned because rownum is always stuck to "0"
    Nicolas.

  • Lumia 920 - internet sharing doesn't work: Connect...

    Hello all,
    I'm experiencing a serious problem with the lumia 920. It seems impossible to share my internet connection. Something I normally use for several hours a day. If this problem can't be fixed soon, ill be forced to swithc back to iphone or htc.
    Problem description:
    When turning "internet sharing" on:
    Connection not shared - There is no cellular data connection to share right now. Check your cellular settings and signal, and try again.
    Important remarks
    Belgium - cellular provider is Mobistar
    I can browse, sync email, etc over the provider's network ans send and receive MMS.
     Provider does not block internet sharing. Have always used this.
    OS Version 8.0.10211.204
    Firmware revision: 1232.5957.1308.0002
    Access point :
     Nokia Access Point version:3.4.1.7 - db 2.0.0.100 - lib 1.2.0.7
     The default access point provided in the Nokia Access Point app does not work: can't even browse.
     Using a manually added APN:
     Data type (default / LTE) tried both. Everything keeps working - except internet sharing...
     APN pro.web.be  (for professional subscribers)
    MMS APN mms.be
    MMSC address: https://mmsc.mobistar.be
    What have i tried to remedy the situatiuon?
     updated the Nokia Access Point app
     changed language to spanisch using OTA update (silly, but read on a forum this might help)
     soft reset of the phone (often!)
     deleted the manually created access point
     Hard reset of my phone
    I'm interested, of course, in any tips to solve this serieus bug / issue / problem.
    (my best guess is that Nokia tries to help their customers with the Access point app, but fails to do so).
    Please, if any of you experience the same problem please respond to this post so we can get an idea about how big of a problem this is.

    Hi,
    I had the same problem. But I let it go after weeks of corresponding with Mobistar.
    Yesterday I went to a Mobistar shop, the guy tried lots of thing I already tried (different apn's, ...).
    Then he told me the it's a problem with business clients. They have to use the apn web.pro.be, where internet sharing doesn't work (he doesn't know why).
    But, that if I call to Mobistar and ask to activate apn mworld.be on my telephone number, it should work.
    Today I called Mobistar Business (you can find the helpdesk number on your invoices), asked to activate mworld.be to have internet sharing access on a windows phone.
    Half an hour later, using mworld.be as apn i have internet access, and I can share my internet connection.
    regards,
    Stijn

  • Impdp work with system but doesn't work with another user

    Hi,
    We have troubles with import of transportable tablespace, when i try to import it with system the import is done currectly, when i try to use another user we receive this message :
    impdp bmcese/***** directory=TTS_DIR dumpfile=RMCCO_RMC_ANA_STS_ABB_CO121001.dmp TRANSPORT_DATAFILES=/data/TTS/RMCCO_RMC_ANA_STS_ABB_CO121001.dbf logfile=tts_imp_proc.log
    ORA-31626: il job non esiste
    ORA-31633: impossibile creare la tabella principale "BMCESE.SYS_IMPORT_TRANSPORTABLE_05"
    ORA-06512: a "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: a "SYS.KUPV$FT", line 1020
    ORA-00959: tablespace 'RMCCO_RMC_UTZ_PP080531' inesistente
    this happens only on development server and it work into test server, so i don't think that the problem is in grants(i controlled that are the same and i have tried with DBA grant too and we received the error).
    Another strange thing is that tablespace 'RMCCO_RMC_UTZ_PP080531' is not included into the dump that i try to import and it doesn't exist in the database.
    Thx
    Edited by: user11272630 on 10-ott-2012 8.40

    I've extraced the role/privs granted to BMCESE using this query
    select granted_role from DBA_ROLE_PRIVS where grantee='BMCESE'
    union
    select privilege from DBA_SYS_PRIVS where grantee='BMCESE';
    Result on Server where the impdp doesn't work:
    GRANTED_ROLE
    CONNECT
    CREATE ANY TABLE
    CREATE PROCEDURE
    CREATE SESSION
    CREATE TABLE
    CREATE TABLESPACE
    CREATE TRIGGER
    CREATE VIEW
    DATAPUMP_IMP_FULL_DATABASE
    DROP TABLESPACE
    EXECUTE_CATALOG_ROLE
    EXPORT FULL DATABASE
    IMPORT FULL DATABASE
    IMP_FULL_DATABASE
    QUERY REWRITE
    RESOURCE
    UNLIMITED TABLESPACE
    results on server where the impdp work:
    GRANTED_ROLE
    CONNECT
    CREATE PROCEDURE
    EXECUTE_CATALOG_ROLE
    IMP_FULL_DATABASE
    UNLIMITED TABLESPACE
    BMCESE has more grant and privs on the server where the impdp doesn't work.
    I've controlled the grant of read, write on the directory.
    I've tried to give DBA priv too to the user.
    So i don't think in a priv problem, i think that the problem is in the unexistent tablespace reported in the error.
    Someone has another suggest to give.
    Thx

  • SetNull() doesn't work?

    The code
    cs.setNull(i, Types.NULL);
    doesn't work with the latest 9.2.0.5 JDBC driver. It throws a
    java.sql.SQLException: Ungültiger Spaltentyp
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:6411)
         at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:1358)
         at weblogic.jdbc.wrapper.PreparedStatement.setNull(PreparedStatement.java:294)
    rughly translated: "Invalid column type". As my methodis generic and just checks if an object is null, I don't know the type of the object if it's null. So, the type Types.NULL should work:
    cs.setNull(i, Types.NULL);
    but it doesn't. Is this still a bug in the 9.x driver?

    Hi Hilpert,
    Using "Types.NULL" never worked for me. I always supply the (data) type of the relevant column. So if the column has a NUMBER data type (for example), you need to do this:
    cs.setNull(i, Types.NUMERIC);My (generic) "executeQuery()" method takes three parameters:
    1. the SQL statement
    2. the parameter values
    3. the parameter data types
    So if one of the parameter values is null, I can safely invoke the "setNull()" method, since I have the correct data type.
    Good Luck,
    Avi.

  • CTRL+Z Doesn't Work in Direct Link

    So...oddly, CRTL+Z for undo doesn't work for me when I'm Direct Linked. My UI pulls up the Timeline window though (as in settings not actual timeline) which doesn't do anyone any good because you can't adjust anything there anyway
    Thoughts? Anyone else?
    I'm on Win 8.1 (HP ZBook) - latest updates in Adobe across the board.

    Hi!
    Sometimes I also have this problem, which is very annoying. I did not find out, why it happens.
    However a restart of speedgrade helps.

  • I need to use an hp 6215 printer with my mac book pro.  the driver installation disk doesn't work.  where can i get a driver that will work?  i use OS X

    i need to use an hp 6215 printer with my mac book pro.  the driver installation disk doesn't work.  where can i get a driver that will work?

    With the Lion it is essentially unnecessary to resort to external driver disks. What's more, most of those disks are incompatible with the OS and should not be used. The system already carries a wide variety of printer description files (aka PPDs, which is what modern printing systems use as "drivers") for a lot of brands. And there was an HP printer update just two days ago.
    Just checked in mine and did indeed find that the HP OfficeJet 6200 Series, with or without Fax, is covered with the latest update.
    So just go thru the motions of creating a proper printer instance:
    Make sure the Mac "sees" the printer on the network.
    System Preferences / Print & Scan
    Click on the + button on the left column
    Select the appropriate type of printer, will use IP for the rest of this
    Select HP Jetdirect - Socket, default for HP network printers
    Type the IP address or look it up
    Name the printer for easy identification on the print dialog
    Let the Mac identify the printer model or manually choose the driver
    Click Add.
    Once the instance pops up in the list, can click on Options & Supplies for further config.

  • I imported videos from photo into iMovie when I set up iMovie (obvious mistake) and now iMovie doesn't work properly, nor can I move specific videos into a folder where I want them. How do I fix this?

    I imported videos from photo into iMovie when I set up iMovie (obvious mistake) and now iMovie doesn't work properly, nor can I move specific videos into a folder where I want them. How do I fix this? I even tried deleting iMovie, bought a new copy and installed it, but the folder "iPhoto Videos" is still there and I can't get new clips loaded to iMovie, especially where I want them. Please help.

    The iPhoto Videos do occasionally have problems. I've seen a lot of people write messages to this Discussion group describing similar problems. The only thing that seems to get around this problem is to pull the video clips out of iPhoto then import them directly into iMovie. Once the troubles with iPhoto Videos starts, I haven't yet seen anyone write back with something that they did to fix it.
    The most difficult part of doing this is the movies in iPhoto might be a little difficult to track down. But you can create a smart alum that does that for you. Go to iPhoto > File Menu > New Smart Album:
    Set the first pulldown menu to keyword, second to contains, then in the last box type Movie with a capital 'M'. Then click OK. This smart album more or less does as search of the whole iPhoto Library and only displays items that match your search tearm of "Movie" exactly. In that smart album then you can find the original Movies you want to move out of iPhoto and into iMovie, <CTRL> click on the Movie clip, then choose Reveal in Finder. That will jump you out of iPhoto temporarily and into the iPhoto Library folder. From there you can move that movie file to the desktop. Move all the clips you want, once they're all collected up go to iMovie and go to the File Menu > Import Files. Then point it to the desktop where you moved your video clips.
    This will put all those videos into an Event folder in iMovie and bypass iPhoto Videos altogether.

Maybe you are looking for