What's the general consensus regarding Generics in Java?

Just curious what folks think about how it's implemented in Java and whether you're in favor of it or not (not that it will make any difference).
I haven't been using it yet because I am still working on 1.4.x, but I've been familiarizing myself as best as I can with how to use them.
I realize they fill an important need, but I am not convinced they were/are worth the rather steep price paid for readability.
Curious to get others opinions on this. Regards,
~Bill
Message was edited by:
abillconsl

So "new MyWrapper(aString)" is untyped, we need to
use "new MyWrapper<String>(aString)" whichviolates
the principle of Dont-repeat-yourself.I don't think so... what if I wanted to create
something like this?
new MyWrapper<Number>(new Integer(4))That's still possible. My problem is that it works exactly as I'd like it to work as long as I call a method, but not when I instanciate a new object. Let's assume for a second that MyWrapper has a static generic method createWrapper() that just calls the constructor:
public class MyWrapper<T> {
     private T foo;
     public MyWrapper(T foo) {
          this.foo = foo;
     public T getFoo() {
          return foo;
     public static <WT,VT extends WT> MyWrapper<WT> createWrapper(VT foo) {
          return new MyWrapper<WT>(foo);
}Here WT is the generic type of the returned wrapper (WrapperType) and VT is the type of the value(ValueType).
Now we see a strange discrepancy on how the object instanciation ("call of a constructor", so to speak) works and how calling another Method works:
MyWrapper<Integer> i1 = new MyWrapper(Integer.valueOf(1)); //unsafe, not infered
MyWrapper<Integer> i2 = MyWrapper.createWrapper(Integer.valueOf(1)); //ok, everything fine
MyWrapper<Number> n1 = new MyWrapper(Integer.valueOf(1)); //unsafe, not infered
MyWrapper<Number> n2 = MyWrapper.createWrapper(Integer.valueOf(1)); //ok, everything fineIf you compile this code (or simply paste it in any modern IDE) you'll see that you'll get warning in the two lines calling the constructor. While the lines calling createWrapper() seem ok. So somehow the compiler can infer the type information when calling a method but can't do that when calling a constructor. That's what's troubling me.

Similar Messages

  • What is the general consensus on the

    What's the gneral consensus on this: using the gmail app vs. setting it through "mail, contacts, calendars" on the iphone $?

    Sorry for the spelling/grammar issues, below is the after coffee correct question:
    What's the gneral consensus on this: using the gmail app vs. setting it up through "mail, contacts, calendars" on the iPhone 4? On another note, I've read that gmail and Apple mail don't play nice in the playground together and I can confirm that by trying to use it in Apple mail on Lion 10.7.4. I read a bit of an outdated article in which the iphone4 user set up icloud, even I know that, exchange for google contacts and calendars for sync purposes and then chose "other" and named it Gmail for Apple mail something to that effect and it played nice with Apple mail, thoughts or should I replost this under another category?

  • What is the general way to invoke a rpc/encoded webservice?

    Hi,
    I have some confusion in invoking webservices, ok, let me explain my question in detail:
    Usually, we access a web service througt its wsdl file, for a rpc/encoded style, for example, in Axis enviroment, I will need the java object for the complex message types, how can I get these java files? If I use the Sun provided WSDP tool to compile the wsdl file and get these java files, do they work? If I am not in the Axis enviroment, maybe I will compose the SOAP request directly, so, what is the general way?
    Thanks.

    Hello,
    When you want to invoke a Web Services (RPC or Document style) you generally as you said create a set fo Java class to: map the messages information to Java code, and create a proxy/stub to do the call.
    Using Oracle Application Server Web Service framework you have several way of creating this client classes:
    - using Oracle JDeveloper just do a File>New>Web Services>Web Service Proxy
    - using the command line tool, and associated Ant tasks (WSA:Web Service Assembler), see the Web Services Developer Guide
    Regards
    Tugdual Grall

  • What are the general errors will come in data uploading

    Hi Friends,
    What are the general errors will come in data uploading
    Thanks in Advance

    Paul
    It all depends on how we configure the system. Errors may be different for different scenerios like
    User ALEROMOTE Loacked for master data's
    Data Sourcs has to be replicated
    Activation Failures
    Error occures in data Selection Etc.
    Do you have any specific error so that we can work on that.
    Thanks
    Sat

  • What are the general properties that must be in target machine for clone ?

    What are the general properties that must be in target machine for clone ?
    like must intall EBS frist.
    must have same users name
    must run in the same linex .
    etc..

    Hi Micel,
    Thanks for the OS version Update
    Micel 811 wrote:
    sourse :Red Hat Enterprise Linux Server release 5.3
    Target :Red Hat Enterprise Linux Server release 6.0 (Santiago)
    is there problem with this differences ?Yes
    whats your EBS version?
    assuming you are on R12
    You need to upgrade the database to 11.2.0.3 and Oracle Application Server 10gR3 to 10.1.3.5 -- See the following docs for details.
    Oracle E-Business Suite Installation and Upgrade Notes Release 12 (12.1.1) for Linux x86 [ID 761564.1]
    Oracle E-Business Suite Installation and Upgrade Notes Release 12 (12.1.1) for Linux x86-64 [ID 761566.1]
    and can i take clone for tow nodes and put in one node ?Yes
    Already answered in my last post
    FAQ: Cloning Oracle Applications Release 11i [ID 216664.1]
    have you refered the doc above ?
    and As I understand I do not need to new fresh EBS setup for target node.Yes No need ;)
    Beauty of Rapid clone :P
    ;) Appsmasti ;)
    Sharing is Caring

  • What are the pros and cons of installing java+abap stack for portal?

    Hi all,
      1.What are the pros and cons of installing java+abap stack for portal?
      2.what effect it does on the ume options to be choosen??
      3.for the purpose of integration of r3,bw and crm on portal and crm 4.0 60.2.3 business package which option of stack(java or abap or both)will be good option and which ume option while installation should be choosen?
    regards
    Rajendra

    Hi Rajendra,
    The NetWeaver Installation Master Guide offers some good scenarios on the pros and cons:
    https://websmp201.sapag.de/~sapidb/011000358700005412792005E.pdf
    In a nutshell:
    ABAP+JAVA
    Pros
    - Decrease # of servers required to administer the portal
    - Less costly
    Cons
    - Upgrades could be dependent on ABAP and Java release level
    - Additional load on the server due to ABAP stack
    - Limited scalability
    JAVA and ABAP on separate server
    Pros
    - Improved performance
    - Allows each system to be single-use purpose therefore downtime does not affect other components
    - More scalable
    Cons
    - Adds complexity to landscape
    - Additional costs
    Regards,
    Thomas Pham

  • What is the BEST practice - use BO or Java Object in process as webservice

    Hi All,
    I have my BP published as web service. I have defined My process input & output as BOs. My BP talks to DB through DAO layer(written in JAVA) which has Java objects. So I have BO as well as java Objects. Since I am collecting user input in BO, I have to assign individual values contained in BO to Java object's fields.
    I want to reduce this extra headache & want to use either of BO or Java object.I want to know What is the best practice - use BO or Java object as process input. If it is BO,how I can reuse BOs in Java?
    Thanks in advance.
    Thanks,
    Sujata P. Galinde

    Hi Mark,
    Thanks for your response. I also wanted to use java object only. When I use java object as process input argument..it is fine. But when I try to create Process web service, I am getting compilation error - "data type not supported".....
    To get rid of this error, I tried to use heir (BO inheriting from java class). But while invoking process as web service, it is not asking for fields that are inherited from java class.
    Then I created Business Object with a field of type java class... This also is not working. While sending request, it is giving an error that - field type for fields from java class not found.
    Conclusion - not able to use java object as process(exposed as web service) input argument .
    What is the Best & feasible way to accomplist the task - Process using DAO in Java & exposed as web service.
    Thanks & Regards,
    Sujata

  • What is the repalcement of .exe file in Java  ??

    What is the repalcement of .exe file in Java .
    i want to launch my java code in .exe fashion just clickk and u get output.....
    but as far i have seen in java there is only class file as output and every time to
    launch the output of code u have to run it from netbean compiler.
    Ya i have sen some file with jnlp extension which launch application just by clicking how to make that........

    What is the repalcement of .exe file in Java .Though there is no replacement as it would defy java's claim 'write once run anywhere' (or whatever it is) but jars are as good as exes if you have jre installed....
    i want to launch my java code in .exe fashion just clickk and u get output.....try :
    [http://www.ej-technologies.com/products/exe4j/overview.html]
    [http://www.ej-technologies.com/products/install4j/overview.html]
    but as far i have seen in java there is only class file as output and every time to
    launch the output of code u have to run it from netbean compiler.who says so?? don't you know how to use the command line..... :-)
    Ya i have sen some file with jnlp extension which launch application just by clicking how to make that........Yeah that files are made using Java Web Start feature of java and I like that feature, search on Google to know about it..........

  • What is the good voice xml api for java

    dear buddies,
    what is the best voice xml api for java? has somebody comeacross and work involving this, i would like to hear more about this
    thanks
    Kuha

    Maybe the VXML forum is a better place: http://www.voicexml.org/
    Good luck.

  • What are the PDA or phone that supporte java ????

    what are the PDA or phone that supporte java ????
    I want to integrate a java application, but tryed to integred on the Mondo Trium with Pjava, so it's too slow, is there any phone or PDA than supported my application
    My application download some maps from server and put up on panel, so it required a good machine ?????
    Please Help !!!!!

    You could try Personal JAVA with WinCE 2.11
    http://java.sun.com/products/personaljava/

  • Could anyone tell me what is the minium requirement to run a java program.

    I am new to java. Could anyone tell me what is the minium requirement to run a java program. Thanks in advance.

    Lara1983 wrote:
    Could anybody give me a direct answer? I think the minium requirement to run a java program is JVM and Java API. Is this right?What does Google tell you?
    BTW in order to get a direct answer, one must ask a direct unambiguous question. Are you asking for the minimum software or hardware requirements to run an application developed in Java or to develop an application in Java. What environment? Details are important and again Google is an interactive search engine, try it!
    Mel

  • What is the general cost for NW SSO 2.0 solutions?

    Hello Masters,
    Besides "Account Manager on SAP side" mentioned in OSS Note 1876552 could somebody be able to share some experiences/ideas what the general cost is about each NW SSO 2.0 solution? As different solution need different components, right? So I would understand how to license each solution? Is it number of user based or component based or other approaches to calculate?
    S1: Single Sign-On with Kerberos
    - Secure Login Client
    - Secure Login Library
    - SPNego for ABAP
    - Plus, any additional cost if HTTPS used
    etc...
    S2: Single Sign-On with Certificates
    - Secure Login Client
    - Secure Login Server
    - Secure Login Library
    - SPNego for ABAP/JAVA
    - Plus, any additional cost if HTTPS used
    etc...
    S3: Single Sign-On with SAML 2.0
    S4: Password Manager
    Kind Regards,
    Jinlong

    SCN is not the right place for licensing discussions. You might want to check out the list prices on SAP Store. Pricing is based on the amount of users (external/internal) not on which features are used.

  • What is the generally accepted Business Practice in developing Data Flow Edit Tasks in SSIS

    We have lots of data edits that we need to create for some 3rd party data that is coming into us. Is the generally accepted business practice to perform these data edits against our database in one Stored Procedure or multiple Data Flow Tasks?
    Kind of new to SSIS and just don't know what the most efficient means is to perform these edits and whether to create multiple Data Flow Tasks to perform these edits against our SQL Server Database or perform these edits in one whole SQL Server Stored Procedure.
    Thanks for your review and am hopeful for a reply.

    Like I have to perform some drill down edits on my 3rd party data against our SQL Server Database
    Does the First Name and Last name Match?
    Does the Zipcode Match?
    Does the Birth Date Match?
    Things of that nature. My feeling is to put it into a Stored Procedure. That way if we need to flex the matching criteria down the pike here, it's all in one place...rather than in a Stored Procedure and a Data Flow Task somewhere. Just seems to be more
    logical and organized to keep it all in one place and then call the Eedit Stored Procedure from SSIS.

  • What are the general effects of using recovery mode, and is it possible for one's data to be backed up on to it afterwards?

    My iPad, in my opinion is a great device to have whenever I need to use it for work - mainly using it for creating music.  However I feel that it's a bit outdated, and I plan to get a new iPad Air for this holiday season and give this one to my children.  That being said, I have stumbled across a weird problem that keeps me from backing my iPad (generation 2) up to my computer.  The error in question states that "The iPad is currently owned by another computer."  By looking around on the internet, I was able to deduce that one of the ways to solve this problem was to put it in recovery mode to get rid of the 'ownership', and this seems logistical.  The problem I'm facing now, is that, after trying to find the answer, I do not know how recovery mode has an impact on all the data stored on my iPad.  To clarify the question into three parts:
    1)  Is there a way to back up files from my iPad and easily retrieve them without the use of iTunes?
    2)  If not, is there a way to get rid of the 'ownership' of another computer other than recovery mode WITHOUT jailbreaking it?
    3)  If still no, then what are the effects of putting my iPad into recovery mode, and will all of my songs and data be safe?
    Thank you for answering, if possible.

    Was the iPad originally set up on a different computer, and hasn't been synced to the one that you are now trying to use ? There are some instructions on this page for syncing to a new computer : https://discussions.apple.com/docs/DOC-3141
    (Before trying that you could copy any important files/documents off the iPad so that you have you own backup copy of them e.g. depending upon what the apps support then email them to yourself, use Dropbox, copy them to your computer via your wifi-network.)
    You should be able to copy iTunes purchases off the iPad and over to that computer's iTunes via File > Devices  Transfer Purchases, but if you have music from other sources (e.g. copied from CDs) which aren't in that computer's iTunes (and you haven't got a backup to copy them onto it from) then there are some programs listed half-way down this page which should be able to copy them back : https://discussions.apple.com/docs/DOC-3991
    For recovery mode, that will result in your iPad being put back to factory defaults i.e. all of your content will be removed from it

  • What is the general problem with this OriginLab VI?

    I'd like to use some VIs provided by OriginLab for their graphing and analysis software.  They apparently haven't updated their VIs since Labview version 8.5  The attached screenshot is an example of the general problem I'm seeing in their VIs.  If I hover over the property nodes, the Labview context help gives the error "This property is not valid for this class."  It looks to me like these are Origin classes and Origin properties, so I'm surprised by that error.
    Any idea about the reason for this problem?  I'd like to explain it to them in a little more detail and try to motivate them to fix it.  Still, I doubt it will happen soon.  Any suggestions about whether it's something I could fix myself?
    Thanks!

    The activeX interface might be inside a *.ocx, *.dll and even a *.exe file. So manually browsing and trying files with these endings might work. You could even try a text search with a hex editor to identify possible ActiveX components, you should find the keywords IDispatch and IUnknown in them.
    The proper way would be when they show up in the list. This actually is derived from some registry keys (I think it was a bit cryptic to track in the registry, as it involved searching for CLSID or the like). Proper registration is done by command line regsrv32 (if memory serves right). Normally this is automatically called from the installer.
    So it might be the best you just try to reinstall Origin.
    Also search the Origin folder if there are some other examples included there (and if they work).
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

Maybe you are looking for

  • How to access attribute value from another VO using groovy?

    Hello, I am using JDeveloper 11.1.2.3.0 I read a lot of information about this but still I am missing something. I am trying to set the value of a bind variable through Groovy expression in my VO. I want this Bind variable to have the value from an a

  • IDOC-XI-EDI : Sender Party in IDOC with LS Partner Type

    Hi Does anyone know of a way to have IDOCs sent from SAP to XI to arrive with a sender party. <b>Note</b> The Partner Type of the original IDOC is LS. [I know how to do this with e.g. KU Partner Type.] Thx, Duncan

  • Example of calling PDF report in APEX application

    Hi, Can anyone direct me where to download this sample APEX application - http://apex.oracle.com/pls/otn/f?p=31057? This app is a great example on how to fill up government form and print it out in PDF. The link provided by the author (Marc Sewtz) is

  • Client Settings non modifiable for  ob52, ob58 etc

    Certain objects in the IMG need to be modifiable in all our clients, specifically transaction OB58 (maintain financial statement version). Currently, any updates to the standard financial statement (for example, when a new G/L account is created and

  • Got NullPointerException we I try to run the attachment example of Axis1.4.

    Hi, Enviroment: OS: Ubuntu 7.04. Server: Apache Tomcat6. IDE: Eclipse3.2 + MyEclipse5.01 Axis1.4. I have been trying to run the attachment example which locate ../samples.attachments. I composed program arguments as below according to README file whi