Equality with generics?

Here's my code:
public boolean equals(Object anObject)
          if (!(anObject instanceof SearchNode)) return false;
          SearchNode<T> node = (SearchNode<T>)anObject;
          return getInnerNode().equals(node.getInnerNode());
     }Questions:
1.     Why am I getting the unchecked cast exception on the second line (the assignment)?
2.     How do I fix it?
3.     Is there nothing better to do than just suppress it?
4.     Is there some way I can do this without casting?

You are getting the exception because you are casting anObject as a SearchNode, but the SearchNode's content is still unknown, so you are forcing it to be of type T.
To solve it, you can use as argument a SearchNode<T> instead an Object, but I think is not a good idea.
But, you can omit the generics, just rewrite the second line: SearchNode node = (SearchNode)anObject; The polymorphism will do the rest.

Similar Messages

  • Error in Extraction with Generic Datasource via Function Module

    Dear Gurus,
    Iam working for BI-HR module.We are extracting data with generic data source via function module. The client some more extra fields in already existing DS. So we made a copy of that Function module and tried to create new generic DS, we got error while extraction like "Error occured during the extraction process". Can you please help in resolving this issue, your valuable suggestion would be highly appreciated.
    Thanks and regards
    Arun S

    Hi,
    Which structure are you using??
    Are you using the same old structure for this function module as well.
    Have you enhanced the structure with new required fields.
    New extrac fields needs to be added to existing structure if you are using the same or create a new one and make sure that you have all the fields in the structure which you are going to use in the data source.
    You need to take care for the append as well and the issue could be in the code as well.
    Make sure you have written the proper code and just for the new fields done an append
    Thanks
    Ajeet

  • Import from database an internal table with generic Type : Web Dynpro ABAP

    Hi everyone,
    i have a requirement in which i'm asked to transfer data flow between two frameworks, from WD Component to another. The problem is that i have to transfer internal tables with generic types. i used the import/ export from database approache but in that way i get an error message saying "Object references and data references not yet supported".
    Here is my code to extract a generic internal table from memory.
        DATA l_table_f4 TYPE TABLE OF REF TO data.
      FIELD-SYMBOLS: <l_table_f4> TYPE STANDARD TABLE.
      DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
      DATA: ls_indx TYPE indx.
      lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
      lo_componentcontroller->fire_vh_search_action_evt( ).
      ASSIGN l_table_f4 TO <l_table_f4>.
    *-- Import table for Help F4
      IMPORT l_table_f4 TO <l_table_f4> FROM DATABASE indx(v1) TO ls_indx ID 'table_help_f4_ID'.
    The error message is desplayed when last instruction is executed " IMPORT l_table_f4...".
    I saw another post facing the same problem but never solved "Generic Type for import Database".
    Please can anyone help ?
    Thanks & Kind regards.

    hi KIan,
    go:
    general type
    TYPE : BEGIN OF ty_itab,
               field1 TYPE ztab-field1,
               field2 TYPE ztab-field2,
    *your own fields here:
               field TYPE i,
               field(30) TYPE c,
               END OF ty_itab.
    work area
    DATA : gw_itab TYPE ty_itab.
    internal table
    DATA : gt_itab TYPE TABLE OF ty_itab.
    hope this helps
    ec

  • Error 500 with generic Apache

    Hi,
    I am trying to user Apex Listener 1.0.2 on OC4J fronted with generic Apache 2.0. I configured mod_oc4j and the combination seems to work.
    When i ran apex/listenerConfigure the configuration page shows up. But when I try to Apply changes I constantly get
    500 Internal Server Error
    Servlet error: An exception occurred. The current application deployment descriptors do not allow for including it in this response. Please consult the application log for details.
    Any idea what would be the cause?
    Janis

    Thank you for the answer. This is the log. I hope it helps
    10/10/27 12:39:04.951 apex: 10.1.3.5.0 Started
    10/10/27 12:56:51.975 apex: Servlet error
    java.lang.NoSuchMethodError: java.lang.String.getBytes(Ljava/nio/charset/Charset;)[B
         at oracle.dbtools.apex.utilities.Text.getBytes(Text.java:31)
         at oracle.dbtools.apex.ModApex.notifyNotConfigured(ModApex.java:257)
         at oracle.dbtools.apex.ModApex.doConfig(ModApex.java:98)
         at oracle.dbtools.apex.ModApex.doGet(ModApex.java:92)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    10/10/27 12:59:11.662 apex: Servlet error
    java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
         at oracle.dbtools.apex.admin.AdminManager.validConnection(AdminManager.java:337)
         at oracle.dbtools.apex.admin.AdminManager.validateInfo(AdminManager.java:168)
         at oracle.dbtools.apex.admin.AdminManager.processAdministration(AdminManager.java:81)
         at oracle.dbtools.apex.admin.Admin.doPost(Admin.java:87)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

  • Converting enumerations to lists with generics

    hello...
    i want to list off system properties and sort them.
    how can you convert enumerations to lists with generics?
    i tried the following in eclipse, but it fails...
         Properties properties = System.getProperties( ) ;
         Enumeration<?> enumeration = properties.propertyNames( ) ;
         ArrayList<String> arrayListEnum = Collections.list( enumeration ) ;
         Collections.sort( arrayListEnum ) ;

    Because the type parameter of Enumeration (<?>) is not compatible with the type parameter of ArrayList (<String>).
    You'll have to do some manual casting yourself.
    Unfortunately, there's nothing to guarantee that system property keys or values are strings (hence why Enumeration<?> and no Enumeration<String>) so you'll need to cope if you find one that isn't.

  • Program with generics compiles without -source 1.5 but doesn't run.

    This could probably be considered a bug in J2SE1.5 beta 1.
    A program with generics that is compiled with JDK 1.5 beta1 without the "-source 1.5" option behaves oddly: it compiles but sometimes fails to execute. It shouldn't behave like that. It should fail in the compilation, with a complaint about using the wrong version of the language.
    This odd behaviour doesn't always occur! In the small program below, I get that behaviour when using the EnumSet.range method.
    If I only use the basic EnumSet, it does executes.
    -- Lars
    import java.util.EnumSet;
    import java.util.*;
    public class Example {
         public enum Season { WINTER, SPRING, SUMMER, FALL }
         public static EnumSet<Season> warmSeason = EnumSet.range(Season.SPRING, Season.FALL);
         public static void main(String[] args) {
              System.out.println("Season: ");     
              for (Season s : Season.values()) {
              System.out.println(s);
              System.out.println("Cold Season: ");     
              for (Season s : warmSeason) {
              System.out.println(s);

    Example.java:6: warning: as of release 1.5, 'enum' is a keyword, and may not be used as an identifier
        public enum Season { WINTER, SPRING, SUMMER, FALL }
               ^
    Example.java:6: ';' expected
        public enum Season { WINTER, SPRING, SUMMER, FALL }
                           ^
    Example.java:12: ';' expected
            for (Season s : Season.values()) {
                          ^
    Example.java:17: illegal start of expression
            for (Season s : warmSeason) {
            ^
    Example.java:20: ';' expected
        ^
    4 errors
    1 warning

  • Doubts with generic service in "HCM processes and forms"

    Hello friends:
        Im having troubles trying to figure out how to use generic services. I implemented a badi with generic services and this have the following methods:
    IF_HRASR00GEN_SERVICE~GET_SPECIAL_FIELDS
    IF_HRASR00GEN_SERVICE~GET_FIELD_INFO
    IF_HRASR00GEN_SERVICE~GET_OPERATIONS
    IF_HRASR00GEN_SERVICE~INITIALIZE
    IF_HRASR00GEN_SERVICE~DO_OPERATIONS
    IF_HRASR00GEN_SERVICE~GET_HELP_VALUES
       I could initialize values of my form using only INITIALIZE method, and I could perform some validation using  and then DO_OPERATIONS.
       I cant understand what is the usage of methods like GET_FIELD_INFO and GET_OPERATIONS?? according to the badis help, get_field_info must be implemented, but i didnt do so and it worked anyway?
    I will be grateful with all your help,
    Best regards,

    GET_FIELD_INFO is for adding fields. Suppose you are using the generic service for IT0008 data. The IT0008 fields
    which need to be used on the adobe form has to be added in this method. You need to add field name and data element
    to the field_infos table. GET_OPERATIONS is used to define operations associated with the fields. Suppose you have a
    scenario when user selects personnel area all personnel subareas associated with the selected value should come.
    Then you need to group together personnel area and sub area together into an operation. Also even if a field is not aasociated
    with any operation, to add a field to form scenario you need group them into operations in GET_OPERATIONS.
    Check the class CL_IM_HRRCF_REQUI_REQUEST to determine how this can be used.
    Thanks,
    Aravind

  • Install problem JDeveloper 12c (12.1.2.0.0) (Build 6668) with Generic Installer on windows

    Hi,
    I am trying to install JDeveloper 12c (12.1.2.0.0) (Build 6668) with Generic Installer on windows .
    C:\Program Files\Java\jdk1.7.0_25\bin>java -jar C:\jdev_suite_121200.jar
    I get the following error :
    Extracting files................................................................
    Unsupported platform (unable to determine the startup directory location).
    The Oracle Universal Installer failed.  Exiting.
    When I try with windows install ( right click jdev_suite_121200_win32.exe and "run as administrator") , I get the following error:
    ERROR Launch:No such file or directory
    In the discussion (https://forums.oracle.com/thread/2573396?start=0&tstart=0) , it is said to be solved by "running as administrator" but it didn't work for me ...
    Thanks ...

    Hi,
      Can you please tell whether you are using 32-bit or 64-bit windows.
      If it is 64-bit then you must run as administrator. In Windows 7x64, just right click on the jDeveloper exe and choose "run as administrator..."
      Remove the existing Oracle folder and restart the system.
      Try to install in new drive.
      Oracle Fusion Middleware Installation Guide for Oracle JDeveloper - 11g Release 2 (11.1.2.4.0) Hope this link will give you more idea in installation.
    Thanks
    Pramila
    Message was edited by: d6866663-7e0d-4497-89df-99f670c41872

  • Factory Patterns with Generics

    I am trying to combine the good old factory pattern with generics and could use some advice.
    I have the following
    //Base class from which all my things extend
    public abstract class Thing {
    //one kind of thing
    public class ThingOne extends Thing {
    //another kind of thing
    public class ThingTwo extends Thing {
    //interface for my factory
    public interface ThingFactory<T> {
    public T create(long id);
    //a factory for thingones
    public class ThingOneFactory<T> implements ThingFactory<T> {
    public T create(long id) {
    return (T) new ThingOne();
    public class TestClass{
    public <T extends Thing> T getThing(ThingFactory<T> tf){
    //do a bunch of generic stuff to figure out id to call create
    ThingFactory<T> instance = tf;
    return (T) instance.create(Long id);
    }My calling code would know what kind of thing it needs but necessarily the things id. Which can be computed in a generic way.
    TestClass gt = new TestClass();
    gt.getThing(new ThingOneFactory<ThingOne>());This all seems to work properly but I am getting "Type safety: Unchecked cast from ThingOne to T" in my ThingOneFactory
    My T's will always extend Thing, what am I missing? Is there a better way to do this?
    Edited by: nedry on Dec 29, 2009 5:39 PM

    I thought of that after I posted. But that just moves my unsafe cast warning into TestClass.Why?
    return (T) instance.create(Long id);That can't have ever compiled. What is the exact code? And why did you have to cast (what was the warning/error)?

  • Working with generics generates a compilation error

    hi again,
    i?m trying to work with generics but when i try to compile my work i get a "generics are not supported in -source 1.4" error, i am working with BlueJ, and i have jdk1.5.0_06 installed in my computer, why am i getting this error? is there any parameter I need to change in blueJ, if ti is so, Which one?
    thanks again...

    I actually think that the OP is compiling with Java 5, but he has set source compability to 1.4 on the project (or default settings). The error message "generics are not supported in -source 1.4" indicates the the compiler knows about generics.
    @OP. Look for something like source compability. I have never used BlueJ, but I would guess that you can find it under building/compiling, probably in some project settings.
    Kaj

  • Need help with generics

    I have written a java program using jdk1.5. After completing my program I noticed that the compiler was outputting a warning. It tells me that there were a few unsafe operations in my code. Anyway I found out that my code needed to include generics. I was able to figure out how too include some of the generics. I am having trouble with the following:
    [javac] /home/paul/Documents/java/PersonalInfo/src/personalInfo/logic/DB.java:105: warning: [unchecked] unchecked conversion
    [javac] found : personalInfo.logic.FNComparator
    [javac] required: java.util.Comparator<? super java.lang.Object>
    [javac] Arrays.sort(sort, fn);
    [javac] ^
    [javac] /home/paul/Documents/java/PersonalInfo/src/personalInfo/logic/DB.java:105: warning: [unchecked] unchecked method invocation: <T>sort(T[],java.util.Comparator<? super T>) in java.util.Arrays is applied to (java.lang.Object[],personalInfo.logic.FNComparator)
    [javac] Arrays.sort(sort, fn);
    [javac] ^
    [javac] /home/paul/Documents/java/PersonalInfo/src/personalInfo/logic/DB.java:109: warning: [unchecked] unchecked conversion
    [javac] found : personalInfo.logic.LNComparator
    [javac] required: java.util.Comparator<? super java.lang.Object>
    [javac] Arrays.sort(sort, ln);
    [javac] ^
    [javac] /home/paul/Documents/java/PersonalInfo/src/personalInfo/logic/DB.java:109: warning: [unchecked] unchecked method invocation: <T>sort(T[],java.util.Comparator<? super T>) in java.util.Arrays is applied to (java.lang.Object[],personalInfo.logic.LNComparator)
    [javac] Arrays.sort(sort, ln);
    [javac] ^
    The FN/LNComparator class implements the java.util.Comparator class. I have looked at the generics tutorial on the java.sun.com website. I can't figure out what I replace the <T> with to make the code compile and the warning to go away. I have tried <Comparator> but that just gives me an error that says FNComparator does not take any parameters.
    If anyone knows how to fix these warnings let me know
    -Hockeyfan

    I know how to fix it.
    Step 1. Stop writing subject-lines like "Need help with generics". Everyone who starts a topic needs help, that's why people post here!
    Step 2. Don't just post the error message, post the relevant code. In [code ][code ] tags of course.
    Step 3. Stop watching hockey, it'll stunt your growth
    Step 4. Have the FN/LNComparator implement, not the raw Comparator, but Comparator<Object>

  • Issue with generic extraction (Generic Delta)

    I have one more issue with Generic Delta Extraction. Here I selected the field related to my requirement but when I am trying to save I am getting error Still OLTP have errors.
    I need some help when we select generic delta wht are the settings. Like now I am working on Inventory Management.
    Please Some one help me as soon as possible.
    Thanks In advance.....
    Regds
    SDR.

    Hi ,
    I think there are some of the Keyfigure fields which needs 0Unit or 0Currency field to be present in the Extract Structure but they are not present . Check All unit of measure and Currency unit fields are not hidden .
    Regards,
    Vijay.

  • Need help with generic class with comparable type

    Hi. I'm at University, and I have some coursework to do on writing a generic class which offers ordered binary trees of items which implement the comparable interface.
    I cant get the code to compile which I have written.
    I get the error: OBTComparable.java uses unchecked or unsafe operations
    this is the more detailed information of the error when I compile with -Xlint:unchecked
    OBTComparable.java:62: warning: [unchecked] unchecked call to insert(OBTType) as
    a member of the raw type OBTComparable
    left.insert(insertValue);
    ^
    OBTComparable.java:64: warning: [unchecked] unchecked call to insert(OBTType) as
    a member of the raw type OBTComparable
    right.insert(insertValue);
    ^
    OBTComparable.java:75: warning: [unchecked] unchecked call to find(OBTType) as a
    member of the raw type OBTComparable
    return left.find(findValue);
    ^
    OBTComparable.java:77: warning: [unchecked] unchecked call to find(OBTType) as a
    member of the raw type OBTComparable
    return right.find(findValue);
    ^
    and here is my code for the class
    public class OBTComparable<OBTType extends Comparable<OBTType>>
      // A tree is either empty or not
      private boolean empty;
      // If the tree is not empty then it has
      // a value, a left and a right.
      // These are not used it empty == true
      private OBTType value;
      private OBTComparable left;
      private OBTComparable right;
      // Create an empty tree.
      public OBTComparable()
        setEmpty();
      } // OBTComparable
      // Make this tree into an empty tree.
      private void setEmpty()
        empty = true;
        value = null; // arbitrary
        left = null;
        right = null;
      } // setEmpty
      // See if this is an empty (Sub)tree.
      public boolean isEmpty()
      { return empty; }
      // Get the value which is here.
      public OBTType getValue()
      { return value; }
      // Get the left sub-tree.
      public OBTComparable getLeft()
      { return left; }
      // Get the right sub-tree.
      public OBTComparable getRight()
      { return right; }
      // Store a value at this position in the tree.
      private void setValue(OBTType requiredValue)
        if (empty)
          empty = false;
          left = new OBTComparable<OBTType>(); // Makes a new empty tree.
          right = new OBTComparable<OBTType>(); // Makes a new empty tree.
        } // if
        value = requiredValue;
      } // setValue
      // Insert a value, allowing multiple instances.
      public void insert(OBTType insertValue)
        if (empty)
          setValue(insertValue);
        else if (insertValue.compareTo(value) < 0)
          left.insert(insertValue);
        else
          right.insert(insertValue);
      } // insert
      // Find a value
      public boolean find(OBTType findValue)
        if (empty)
          return false;
        else if (findValue.equals(value))
          return true;
        else if (findValue.compareTo(value) < 0)
          return left.find(findValue);
        else
          return right.find(findValue);
      } // find
    } // OBTComparableI am unsure how to check the types of OBTType I am comparing, I know this is the error. It is the insert method and the find method that are causing it not to compile, as they require comparing one value to another. How to I put the check in the program to see if these two are of the same type so they can be compared?
    If anyone can help me with my problem that would be great!
    Sorry for the long post, I just wanted to put in all the information I know to make it easier for people to answer.
    Thanks in advance
    David

    I have good news and undecided news.
    First the good news. Your code has compiled. Those are warnings not errors. A warning is the compiler's way of saying "I understand what you are asking but maybe you didn't fully think through the consequences and I just thought I would let you know that...[something] "
    In this case it's warning you that you aren't using generics. But like I said this isn't stopping it from compiling.
    The undecided news is the complier is warning you about not using generics. Are you supposed to use generics for this assignment. My gut says no and if that's true then you have no problem. If you are supposed to use generics well then you have some more work.

  • Simple method but hard with generics: compareTo()

    I adjusted my getMaximum() method to generics to avoid the compiler warnings:
        static public Comparable<Comparable> getMaximum(Comparable<Comparable> comparable1, Comparable<Comparable> comparable2) {
            Comparable<Comparable> result = (comparable1 != null) ? comparable1 : comparable2; //init
            if (comparable1 != null && comparable2 != null) {
                int c = comparable1.compareTo(comparable2);
                result = (c > 0) ? comparable1 : comparable2; //comparable1 > comparable2?
            return result;
        }//getMaximum()But now, my other classes that call this method e.g. with 2 dates or with 2 numbers don't compile anymore. I tried
        static public Comparable<? extends Comparable> getMaximum(Comparable<? extends Comparable> comparable1, Comparable<? extends Comparable> comparable2) {
            Comparable<? extends Comparable> result = comparable1; //default
            if (comparable1 != null && comparable2 != null) {
                int c = comparable1.compareTo(comparable2); //compile error
                if (c <= 0) {
                    result = comparable2;
            } else if (comparable1 == null) {
                result = comparable2;
            return result;
        }//getMaximum()but this code doesn't compile:
    Bound mismatch: The method compareTo(? extends Comparable) of type
    Comparable<? extends Comparable> is not applicable for the arguments
    (Comparable<? extends Comparable>). The wildcard parameter ? extends
    Comparable has no lower bound, and may actually be more restrictive than argument
    Comparable<? extends Comparable>

    Whilst I know this thread is quite old, I found it whilst trying to solve the same problem.
    For reference, the following code can be used to overcome the 1.5 compiler warning for the COMPARABLE_COMAPRATOR function in Sun's TableSorter.java.
    public static final Comparator<Object> COMPARABLE_COMAPRATOR = new Comparator<Object>()
        public int compare(Object o1, Object o2)
          int retval = -1;
          Class o1class = o1.getClass();
          Class o2class = o2.getClass();
          if (o1class.equals(o2class))
            try
              Method method = o1class.getDeclaredMethod("compareTo", new Class[]
                                                        {o2class});
              try
                Integer answer = (Integer) method.invoke(o1, o2);
                retval = answer.intValue();
              catch (Exception e)
                System.out.println("Call to method failed.");
            catch (NoSuchMethodException e)
              System.out.println("No compareTo() method.");
          return retval;
      };Hope this helps someone.
    Regards,
    Ray

  • A question about a method with generic bounded type parameter

    Hello everybody,
    Sorry, if I ask a question which seems basic, but
    I'm new to generic types. My problem is about a method
    with a bounded type parameter. Consider the following
    situation:
    abstract class A{     }
    class B extends A{     }
    abstract class C
         public abstract <T extends A>  T  someMethod();
    public class Test extends C
         public <T extends A>  T  someMethod()
              return new B();
    }What I want to do inside the method someMethod in the class Test, is to
    return an instance of the class B.
    Normally, I'm supposed to be able to do that, because an instance of
    B is also an instance of A (because B extends A).
    However I cannot compile this program, and here is the error message:
    Test.java:16: incompatible types
    found   : B
    required: T
                    return new B();
                           ^
    1 errorany idea?
    many thanks,

    Hello again,
    First of all, thank you very much for all the answers. After I posted the comment, I worked on the program
    and I understood that in fact, as spoon_ says the only returned value can be null.
    I'm agree that I asked you a very strange (and a bit stupid) question. Actually, during recent months,
    I have been working with cryptography API Core in Java. I understood that there are classes and
    interfaces for defining keys and key factories specification, such as KeySpec (interface) and
    KeyFactorySpi (abstract class). I wanted to have some experience with these classes in order to
    understand them better. So I created a class implementing the interface KeySpec, following by a
    corresponding Key subclass (with some XOR algorithm that I defined myself) and everything was
    compiled (JDK 1.6) and worked perfectly. Except that, when I wanted to implement a factory spi
    for my classes, I saw for the first time this strange method header:
    protected abstract <T extends KeySpec> T engineGetKeySpec
    (Key key, Class<T> keySpec) throws InvalidKeySpecExceptionThat's why yesterday, I gave you a similar example with the classes A, B, ...
    in order to not to open a complicated security discussion but just to explain the ambiguous
    part for me, that is, the use of T generic parameter.
    The abstract class KeyFactorySpi was defined by Sun Microsystem, in order to give to security
    providers, the possibility to implement cryptography services and algorithms according to a given
    RFC (or whatever technical document). The methods in this class are invoked inside the
    KeyFactory class (If you have installed the JDK sources provided by Sun, You can
    verify this, by looking the source code of the KeyFactory class.) So here the T parameter is a
    key specification, that is, a class that implements the interface KeySpec and this class is often
    defined by the provider and not Sun.
    stefan.schulz wrote:
    >
    If you define the method to return some bound T that extends A, you cannot
    return a B, because T would be declared externally at invocation time.
    The definition of T as is does not make sense at all.>
    He is absolutely right about that, but the problem is, as I said, here we are
    talking about the implementation and not the invocation. The implementation is done
    by the provider whereas the invocation is done by Sun in the class KeyFactory.
    So there are completely separated.
    Therefore I wonder, how a provider can finally impelment this method??
    Besides, dannyyates wrote
    >
    Find whoever wrote the signature and shoot them. Then rewrite their code.
    Actually, before you shoot them, ask them what they were trying to achieve that
    is different from my first suggestion!
    >
    As I said, I didn't choose this method header and I'm completely agree
    with your suggestion, the following method header will do the job very well
    protected abstract KeySpec engineGetKeySpec (Key key, KeySpec key_spec)
    throws InvalidKeySpecException and personally I don't see any interest in using a generic bounded parameter T
    in this method header definition.
    Once agin, thanks a lot for the answers.

Maybe you are looking for

  • How to create new purchasing group in EBP

    Hi All, I am working in Extended Classic Scenario.. I have one doubt regarding Purcashing group creation. Can someone tell me, from where the purchasing group get determined in EBP. Do we create Purchasing group in EBP , if yes  then How? or it get d

  • Execute Permission Denied on Stored Procedure for SSRS Report

    I have a report in SSRS 2008R2.  The report is running against a 2005 instance.  This report, encapsulated as a stored procedure, runs fine in BIDS.  When I deploy it to the Report Manager I suddenly get" The EXECUTE permission was denied on the obje

  • How to change the calyearmonth data format in psa

    Hi all, my requirement is to load data to dso from csv file it contains 0calmonth characteristic and carparc keyfigure and i have created a transactional datasource and when i am loading the data in csv file my data format is 201101 but in psa it is

  • WD Caviar Green 2TB - disappearing drive

    Hi all, I have installed a 2TB WD drive for use as a time machine drive. (expanding from 1TB external) Sometimes the disk displays odd characteristics, such as: • Overnight (last night for example) TM didn't do any further backups after 7.43pm. This

  • Using C# program in Labview

    Hello, I am new to LabView. I have version 7.1. I have developed experiments in MS Visual Studio using C#. The department that I work for wants to convert to LabView is there anyway that LabView can read the code that was developed in C#. Thank you a