The bounds on type parameters for methods

I have a method with a signature like so:
<T, S extends T & MyInterface> S method(T parameter)the idea being that it returns an object that is a subclass of the class of parameter, and implements MyInterface.
The compiler doesn't like this, complaining that 'a type variable may not be followed by other bounds', which I assume means that T can't be followed by MyInterface, but I don't understand why, the type specification is, to me, logical. Could anyone with a bit more/some knowledge of generics please enlighten me?
A bit more info; it seems that it will work if I remove the interface, leaving the definition as:
<T, S extends T> S method(T parameter)and also if the class of the parameter I pass already implements MyInterface, the original definition will work (but I want to be able to do it without implementing the interface).
This isn't critical, I've found a solution with casting, but I would firstly like to understand what's going on, and secondly it would be nicer if I could do it this way (to me). I get the feeling that the way I am using generics is slightly off?
Also, apologies if this has been answered before, but I have spent quite a while trawling the forum and I don't have the stamina to check out every message.
Regards,
Chris

Took me a while, but I found it:
http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#FAQ303
and scroll down to where it says "There is only one restriction: if a type parameter is used as the bound of another type parameter then there must not follow any further bounds" followed by an example similar to yours.
Unfortunately it doesn't give a reason for this restriction, and I can't see a reason for it either. But then a lot of Generics is still obscure to me.

Similar Messages

  • Too many type parameters for interface

    In JDev 11.1.1.0.0, I do a compile and I get 65 files with errors saying
    Error: too many type parameters for interface java.util.Map<java.lang.String, java.lang.Class<?>>
    but the class doesn't use the Map object.
    Other files get it for the Set object.
    Note that no line number was given as part of the error message.
    I installed the JDev 11.1.1.0.0 base from the zip file.
    What's wrong?

    Hi,
    And you do a compile on what exactly, Please post one of the erroneous class' code using the code within bracket tag so that we can help you.
    Regards,
    ~ Simon

  • Is there a way to dynamically determine the number of out parameters for a server side procedure?

    Hi,
    Below is a helper method used for calling a server-side function which loops through the inbound bindVars parameter to populate the function's IN parameters. Is there a way to dynamically determine the IN/OUT parameters based on the procedure name in the stmt parameter? No members of the CallableStatement class seemed promising, but the getParameterMetaData() method in the PreparedStatement class seemed like it could be helpful lead. However, I have not found any detailed descriptions (yet) of how to use it.
    protected Object callStoredFunction(int sqlReturnType, String stmt,
      Object[] bindVars) {
      CallableStatement st = null;
      try {
      // 1. Create a JDBC CallabledStatement 
      st = getDBTransaction().createCallableStatement(
      "begin ? := "+stmt+";end;",0);
      // 2. Register the first bind variable for the return value
      st.registerOutParameter(1, sqlReturnType);
      if (bindVars != null) {
      // 3. Loop over values for the bind variables passed in, if any
      for (int z = 0; z < bindVars.length; z++) {
      // 4. Set the value of user-supplied bind vars in the stmt
      st.setObject(z + 2, bindVars[z]);
      // 5. Set the value of user-supplied bind vars in the stmt
      st.executeUpdate();
      // 6. Return the value of the first bind variable
      return st.getObject(1);
      catch (SQLException e) {
      throw new JboException(e);
      finally {
      if (st != null) {
      try {
      // 7. Close the statement
      st.close();
      catch (SQLException e) {}
    James

    The PreparedStatement.getParameterMetaData() object is exactly what you need for this task.
    Once you have the ParameterMetaData you can ask it how many parameters are present and which mode they are. The parameters are numbered from 1 to n and you can use ParameterMetaData.getParameterMode(1); to get the mode of the 1st parameter. The modes are defined as static values in the ParameterMetaData object. Check out the doc at http://docs.oracle.com/javase/7/docs/api/java/sql/ParameterMetaData.html
    Timo

  • WRONG VALUE OF THE parameter file type(bdc-session method)

    Hi experts,
    when iam uploading vendor details,,,
    it is giving above error.
    chk the code once.....
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
       FILENAME                      = 'C:/VENDOR1.TXT'
       FILETYPE                      = 'DAT'
      TABLES
        DATA_TAB                      = IT_UPLOAD.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
       CLIENT                    = SY-MANDT
       GROUP                     = 'SRR'
       USER                      = SY-UNAME.

    Hi here  iam sending the whole code once to you. just chk it once and same error(WRONG VALUE OF THE parameter file type) is coming after the changes.
    if i use asc it is giving that no file exists.
    Table Declaration
    tables :rf02k,    "Maintain vendor master record screen and work fields
            lfa1,     "Vendor Master(general)
            lfbk,     "Vendor Master (Bank Details)
            lfb1,     "Vendor Master (Company Code)
            lfm1,     "Vendor master record purchasing organization data
            lfb5.     "Vendor master (dunning data)
    Data Declaration
    data : begin of it_UPLOAD occurs 0,
           LIFNR like rf02k-lifnr,     "vendor no
           BUKRS like rf02k-bukrs,     "company code
           EKorg like rf02k-ekorg,     "purchasing org
           KTOKK like rf02k-ktokk,     "account group
           anred like lfa1-anred,     "initial
           name1 like lfa1-name1,     "name of vendor
           sortl like lfa1-sortl,     "search term
           land1 like lfa1-land1,     "country
           akont like lfb1-akont,     "reconcillation a/c.
           fdgrv like lfb1-fdgrv,     "planning group
           zterm like lfb1-zterm,     "terms of payment key
           mahna like LFB5-MAHNA,     "dunning procedure
           waers like lfm1-waers,     "Purchase order currency
           END OF IT_UPLOAD.
    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    include bdcrecx1.
    start-of-selection.
    UPLOADING THE DATA TO IT_UPLOAD
    call function 'GUI_UPLOAD'
    exporting
    filename = 'C:\DASRR\VENDOR1.TXT'
    filetype = 'DAT'
    has_field_separator = 'X'
    HEADER_LENGTH = 0
    READ_BY_LINE = 'X'
    DAT_MODE = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    CHECK_BOM = ' '
    IMPORTING
    FILELENGTH =
    HEADER =
    tables
    data_tab = IT_UPLOAD
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    OTHERS = 17
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    *CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = 'C:/VENDOR1.TXT'
      FILETYPE                      = 'DAT'
    TABLES
       DATA_TAB                      = IT_UPLOAD.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
       CLIENT                    = SY-MANDT
       GROUP                     = 'SRR'
       USER                      = SY-UNAME.
      POPULATE INTERNAL TABL
    LOOP AT IT_UPLOAD.
    CLEAR IT_BDCDATA.
    REFRESH IT_BDCDATA.
    PERFORM POPULATE_DATA.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
        TCODE                  = 'XK01'
       TABLES
        DYNPROTAB              = IT_BDCDATA.
    ENDLOOP.
    *&      Form  POPULATE_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM POPULATE_DATA .
    PERFORM GETDATA USING 'X' 'SAPMF02K' '0100'.
    perform getdata using ' ' RF02K-LIFNR 'IT_UPLOAD-LIFNR'.
    perform getdata using ' ' RF02K-bukrs 'IT_UPLOAD-bukrs'.
    perform getdata using ' ' RF02K-EKORG 'IT_UPLOAD-EKORG'.
    perform getdata using ' ' RF02K-KTOKK 'IT_UPLOAD-KTOKK'.
    PERFORM GETDATA USING 'X' 'SAPMF02K' '0110'.
    perform getdata using ' ' LFA1-ANRED 'IT_UPLOAD-ANRED'.
    perform getdata using ' ' LFA1-NAME1 'IT_UPLOAD-NAME1'.
    perform getdata using ' ' LFA1-SORTL 'IT_UPLOAD-SORTL'.
    perform getdata using ' ' LFA1-LAND1 'IT_UPLOAD-LAND1'.
    PERFORM GETDATA USING 'X' 'SAPMF02K' '0210'.
    perform getdata using ' ' LFB1-AKONT 'IT_UPLOAD-AKONT'.
    perform getdata using ' ' LFB1-FDGRV 'IT_UPLOAD-FDGRV'.
    PERFORM GETDATA USING 'X' 'SAPMF02K' '0215'.
    perform getdata using ' ' LFB1-ZTERM 'IT_UPLOAD-ZTERM'.
    PERFORM GETDATA USING 'X' 'SAPMF02K' '0220'.
    perform getdata using ' ' LFB5-MAHNA 'IT_UPLOAD-MAHNA'.
    PERFORM GETDATA USING 'X' 'SAPMF02K' '0310'.
    perform getdata using ' ' LFM1-WAERS 'IT_UPLOAD-WAERS'.
    ENDFORM.                    " POPULATE_DATA
    *&      Form  GETDATA
          text
         -->P_0213   text
         -->P_0214   text
         -->P_0215   text
    FORM GETDATA  USING    VALUE(P_0213)
                           VALUE(P_0214)
                           VALUE(P_0215).
                        IF P_0213  = 'X'.
                        IT_BDCDATA-PROGRAM = P_0213.
                        IT_BDCDATA-DYNPRO = P_0214.
                        IT_BDCDATA-DYNBEGIN = P_0215.
                        ELSE.
                        IT_BDCDATA-FNAM = P_0214.
                        IT_BDCDATA-FVAL = P_0215.
                        ENDIF.
    ****************any error in coding just chk it*****************

  • How to define the Structure and FCC parameters for EDI file format.

    Hi All,
    I have a  EDI file(FTP)-->XI-->IDOC
    the source file content is as follows
    PR H01PHUPS         
    FH   SHP  0.0.5    
    H1   S0022323                            
    W6   7752508853                     D
    PT   1Z58R7070341111111           
    PT   1Z58R7070342222222           
    PT   1Z58R7070353333333          
    N1ST ZZ 142222                            
    N3ST 8827 D OLD
    N4ST MARCY                        
    N1WH ZZ 2070                              
    N3WH 401 QUALITY
    N4WH HARRIS
    DTENT20111206
    DTSHP201112061754
    N9LL BN20700033333333                               
    N9NT
    CD   CP      UPS
    IT026
    P1GD    VN A1111 
    PD   Product ID 1                   
    QTORD000000000000010CA
    QTSHP000000000000010CA
    AM U  000000000000000000M
    AM X  000000000000000000
    LTLT 1112811111                                       
    AM G  000000000000000000
    AM N  000000000000000000
    AM TAX000000000000000000
    AM SVC000000000000000000
    AM COD000000000000000000
    ST   00000000100000000010000000000000000000000000008500LB
    Can any body share me how to declare the structure in DataType.
    The first two characters in each record is constant , so this would be the keyfields right?
    ex:- PR,FH,H1,W6,PT,AM,N1,N3,N4......
    In Comm channel the FCC parameters
    i need to go for fieldFixedLengths?
    Thanks&Regards
    Sai_SHA

    Hi.
    if you need to convert an EDI to XML you need to use an Adapter specific (e.g Seeburger) because PI doesn't support EDI files.
    Also if you use a FCC , this configuration is for  two level Header and Detail.
    Check this.
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
    Regards
    Luis Ortiz

  • Getting cl_abap_structdescr for method parameters of LOCAL classes?

    Hi guys
    I have a bit of a of a problem with getting an instance of the cl_abap_structdescr class for a method parameter type of a local class. The RTTI structure abap_parmdescr can only be used to diffrentiate between the basic built-in ABAP types and whether types are structures, tables or references. The question now arrives that once you have diffentiated that the parameter is a structure how do you determine the actual structure TYPE name for local classes to create an instance of the cl_abap_structdescr to continue your run-time analysis. For dictionary classes the parameter type name can be retrieved from the seosubcodf table, to me it looks as if one would have to resort to scanning the source code of local classes to arrive at the actual  structure type name, but before I go to THAT kind of trouble I was wondering whether somebody out there might have a better solution for me. Your help would be grreatly appreciated and rewarded ;).
    Kind regards
    Ettienne Hugo

    Hello Uwe
    Thanks for your reply, I checked out the CL_OO_LOCAL_CLASSES class, unfortunately the class actually operates on the local classes declared for a dictionary class. I think to clarify my question I should point out that the parameters I'm trying to process are parameters that belong to classes that are defined and implemented using include programs, these include programs would then typically be used in Function Groups to construct applications so the classes that I refer to are actually not in any way related to dictionary classes. The cl_abap_classdescr class works fine on these types of classes when you refer to them using the "\PROGRAM=my_program\CLASS=my_class" format with the describe_by_name method, unfortunately the class just does not provide sufficient information for structure type parameters to actually construct them during run-time...
    Stay well
    Ettienne

  • Get-Acl : The input object cannot be bound to any parameters

    Hi I am trying to get a list of folder and permissions for network folders and I am getting the error Get-Acl : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its
    properties do not match any of the parameters that take pipeline input?
    $Files = "\\Server\Share"Get-ChildItem \\server\share| Where { $_.PSIsContainer } | Foreach {Get-Childitem $_.FullName} | Get-Acl $Files | Format-Table -property Owner | Where { $_.PSIsContainer } | Select-Object FullName, @{Name = 'AssociatedSecuirtyGroups'; Expression = {((Get-Acl $_).Access | ?{! $_.IsInherited} | Select-Object -ExpandProperty IdentityReference) -join ', '}}

    It looks like you're mixing up some actions in that line of code.  The first Get-ACL is receiving pipeline input of all of the grandchildren of $Files, but you're also giving it the $Files parameter - that's your error.
    You're also formatting output in the middle of the pipeline, I don't think that's going to work out well for you.  When you run get-acl you also lose the directory name, so the fullname attribute is meaningless at that point.
    Maybe try something more like this:
    $Root = "\\Server\Share"
    $Results = @()
    $Folders = Get-ChildItem $Root -exclude *.* | Foreach {Get-Childitem $_ -exclude *.*} | select fullname
    Foreach ($Folder in $Folders) {
    $ACL = Get-Acl $Folder.FullName
    Foreach ($Group in $ACL.Access) {
    If (!($Group.IsInherited)) {$Results += New-Object PSObject -Property @{Folder=$Folder.FullName;Group=$Group.IdentityReference;Owner=$ACL.Owner}}
    $Results
    Note that with Powershell v4 there's a -directory parameter for Get-ChildItem that would be better than this exclude.  I work with older systems so I use older PS to avoid any pitfalls.  In this case, if you have any files without extensions in those
    subdirectories you'll pick those up as well.

  • Bounded Return Type

    If I have following code:
    public class Cell<X>
       X value;
      public Cell<? super X> copyToAndReturn(Cell<? super X> other)
          other.value = value ;
          return other;
      static void foo()
         Cell<String> c = new Cell<String>();
         Cell<Object> o = new Cell<Object>();
         o = c.copyToAndReturn(o);
    }Then the line:
         o = c.copyToAndReturn(o);gives a compile error:
    Type mismatch: cannot convert from Cell<capture#3-of ? super String> to Cell<Object>
    Object is indeed super class of String. If I have done something wrong in the assignment then what should be the type of assigned variable?

    panopticon wrote:
    The error is in assigning return type to Cell<? super String> to a variable of Cell<Object>.And you are surprised by this why?
    Cell<String> sc = new Cell<String>();
    Cell<? super String> ssc = sc;
    Cell<Object> oc = ssc; // woups..Just because Object is a supertype of String it's not necessarily the supertype represented by the wildcard. If you want more control over the type, use a type variable:
    public <C extends Cell<? super X>> C copyToAndReturn(C other) {
        other.value = value ;
        return other;
    }Sadly the JLS does not allow lower bounds on type parameters, otherwise the solution would be somewhat sexier:
    public <S super X> C copyToAndReturn(Cell<S> other) {
        other.value = value ;
        return other;
    }With kind regards
    Ben

  • Best practice tunning parameters for tunning ADF apps?

    Hi all,
    I am tuning our 11g ADF app for around 3 billions (can be up to 10 billions records) and the concurrent connections up to 100. The app is running on a 16 core Intel chip and 8GB of RAM. The Weblogic used Rockit JDK. Any one have this experience please share and help me! I am considering what is the top ten crucial parameters for this tuning. Up to now I just have tunned some parameters from OS layer to app layers:
    - indexing for queries
    - open cursors, processes and pga memory
    - share pool for app module and jdbc pooling.
    - heap size of JVM memory only max value 1024 because of 32 bit Windows (Perhaps I must upgrade to 64 bit OSs to use more memory)
    The app was tested with Jmeter with only 10 concurrent connection and the test case is logging in and query and logging out. It ran very slow. I found out that the weblogic server did not use CPUs equally (only 1-2 CPus were used)
    Thank you and best regards.
    Elton Son.

    Hi,
    maybe this of interest:
    http://download.oracle.com/docs/cd/E12839_01/web.1111/e13814/toc.htm
    http://download.oracle.com/docs/cd/E15523_01/core.1111/e10108/adf.htm#CIHHGADG
    http://www.oracle.com/technetwork/articles/systems-hardware-architecture/tuning-adf-t-series-168445.pdf
    http://andrejusb.blogspot.com/2009/08/oracle-adf-tuning-preventing-sql-query.html
    Frank

  • SQL Data Sync - column type invalid for use as a key column

    Hello,
    our sync group is failing to do the sync. Here's a tracingID:
    For more information, provide tracing ID ‘e3e568b5-140a-4ae5-a4c8-c178c6bf805d’ to customer support.
    I must say, that the column in DB is not a PK or INDEX-ed, it was initially VARCHAR(MAX), after some reading I changed it to VARCHAR(200) and later to TEXT, but the result of syncing is still the same.
    Thank you,
    Bojan

    Hi Bojan,
    The error “column type invalid for use as a key column” could be due to the existence of unsupported data types or column properties when implementing the synchronization. I recommend you check your database according to this article:
    SQL Database Data Types supported by SQL Data Sync.
    Besides, before you design and implement a data synchronization plan, please check the following articles about system requirements for SQL Data Sync and so on.
    System Requirements for SQL Data Sync
    https://msdn.microsoft.com/en-us/library/azure/jj127278.aspx
    Known SQL Data Sync Limits
    https://msdn.microsoft.com/en-us/library/azure/jj590380.aspx
    SQL Data Sync Best Practices
    https://msdn.microsoft.com/en-us/library/azure/hh667328.aspx
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • MIRO-Account type/account for invoice reference does not match item-F5350

    Hi gurus
    please help
    When I tried to cancel an MIRO invoice, it is giving me the error
    Account type/account for invoice reference does not match item". "F5350 "
    Please advise.
    thanks
    MSJ

    Hello,
    This seems to be a configuration issue or you might be entering the wrong details.
    This is a standard transaction. IF you feel there is nothing wrong, then search for OSS notes on http://service.sap.com to see if there is a solution to this problem.
    cheers,
    sushil joshi

  • Standard Condition type used for Manual freight at item level

    Hello Gurus
    Can you please tell me the standard condition type used for entering freight manually at header as well as item level.
    Warm Regards
    Prashant Joshi.

    Prashanth,
    The freight Conditions that we use in Sales are two types
    HD00 - Header Level, wherein we have no access sequence
    KF00 - Item level, Wherein we have access sequence  KF00 - Freight
    But you want the condition types to be maintained manually, then you need item details screen of the respective condition type HD00/KF00 using Tcode V/06.
    Inside that Manual entry as "C". Similarly you need to maintain or activate "Manual" Indicator in pricing procedure. Then you can enter the freight Manually.
    Note:
    The difference In applying at the header level and item level is if you enter freight value at the header level it is applicable to all items in the item level. But if you want to apply freight  we can give freight to each item or selective item.
    Regards
    Sathya

  • Restructuring the basic IDoc type DELVRY03

    Hi experts,
    My rek  is to restructure the Basic Idoc type DELVRY03 for outbound delivery.
    I am using IDOC_OUTPUT_DELVRY.
    Is there any exit or badi for this.
    Thanks

    we31:
    Create your new segment.
    Save and remember release (edit-set release)
    we30:
    Create your new idoc type. Create like extension.
    In your linked idoc type fill your standard idoc type.
    Press create new sement button for add segments and put your Z segment created in we31 with min and max quantity.
    Save and release the idoc type
    Regards

  • Hide the characteristics grouping buttons depending on the sales order type

    Hi Gurus,
    I am trying to find a way to hide a characteristics grouping button (CU50) whenever a certain sales order type is issued.
    A condition was created that states that a certain characteristic will be invisible for the user depending on the sales order type chosen for that case. The characteristic is located inside a char. grouping button.
    I would like to know id there is a way to hide the button while the characteristic is hidden as well, just to avoid showing a button which is empty.
    If It is of any help, here is the condition created to turn the char invisible:
    $SELF.INVISIBLE = 'N01017_E'.
    *if not $self.N01017_E specified
    Thanks in advance.
    Kind regards.

    Hi!
    Sounds like you need a line-triggered output (with a message, which displays all lines of the order).
    Do you have problems to create a new output type?
    Regards,
    Christian

  • Consolidating Decimal/Numeric type parameters in GP

    Hi guys,
    Need some pointers here. I'm calling a webservice CO to populate my Adobe form in GP on initiation. That works fine. But, some how or rather, i can't seem to consolidate any of the 'decimal/numeric' type parameters. The 'group' functionality is just greyed out. Eg. 'insurance' parameter in the WS is type 'decimal' (from ECC) and i've created a decimal type field in Adobe form too. HOwever, i can't seem to consolidate those type of parameters. Any reasons why? Thanks

    Hi,
    Just an update on this. The fields in the WebService are actaully of type 'CURR' (ABAP type). How do i map this in GP? Thanks

Maybe you are looking for