Generic arrays

I want to make an array of LinkedLists of Doubles. I tried:
LinkedList<Double> buckets = new LinkedList<Double>[n];which gave me an error because I'm creating a generic array. On the other hand, if I do
LinkedList<Double> buckets = new LinkedList[n];I get a warning suggesting that the compiler was looking for the first version!
How do I do this?

McNepp wrote:
It seems to be a common misconception that one has to
resort to Reflection in order to create arrays
of generic types.It is not a misconception. On the contrary. It depends on what the library writer is trying to achieve. If I understand Neal Gafter in his blog http://www.gafter.com/~neal dated from September 23rd titled Puzzling Through Erasure: answer section correctly - currently his site is unavailable but you could still find cached page through Google -, that it should be fine to use reflection. Using reflection is perfectly legal if the library writer wants to design the API in such way that the type parameters are not erased. Type parameters are stored inside of the class using class literals. He says that in this case "you can instantiate using reflection (tClass.newInstance()), create arrays (Array.newInstance), cast (Class.cast), and do instanceof tests (Class.isInstance), though with a slightly different syntax than you might prefer".
I'm still learning generics and I might be wrong.
Best regards,
Andrej

Similar Messages

  • My generic array creation problem.

    I'm getting a "generic array creation" error on lines 6 and 14. I've googled it and I'm still having a hard time. Most things I find on it are pretty complicated and as you can see mine's not, I'm in a beginners course. I'm basically writing a class with methods for dealing with a file of donors.
    Here's my code:
    public class DonorList <dlist>
        //Create empty list
        public DonorList()
            storage = new dlist [MAX];
            count = 0;
        //Capacity as specified
        public DonorList (int cap)
            MAX = cap;
            storage = new dlist [MAX];
            count = 0;
        public boolean isEmpty()
            return count == 0;
        public void clear()
            count = 0;
        //Returns number of elements
        public int size()
            return count;
        //Item at position k, position starts at zero
        public dlist get (int k)
            if (k >= 0 && k < count)
                return storage [k];
            return null;
        // e becomes item at position k
        public dlist set (int k, dlist e)
            dlist old = null;
            if (k > 0 && k < count)
                    old = storage [k];
                    storage [k] = e;
            return false;
        //Returns the position of e or -1 if not found.
        public int indexOf (dlist e)
            int k;
            for (k = 0; k < count; k++)
                if (e.equals(storage[k]))
                    return k;
            return -1;
        //Appends e at the end of the list. Returns false on failure.
        public boolean append (dlist e)
            if (count < MAX)
                storage [count] = e;
                count ++;
                return true;
            return false;
        //Adds e at position k. Returns false on failure.
        public boolean add (int k, dlist e)
            int j;
            if (count == MAX || k < 0 || k > count)
                return false;
            for ( j = count; j > k; j--)
                    storage [j] = storage [j-1];
                    storage [k] = e;
                    count ++;
                    return true;
            return false;
        private int MAX = 100;
        private dlist [] storage;
        private int count;
    }Any help as to why I am getting these errors is very much appreciated. Thanks.

    You cannot create an array of a generic, instead you need to create an array of the class the generic extends (in this case Object)
    You then have to cast the array to the generic type which will give you an unchecked warning which you can turn off with @SuppressWarning("unchecked") on the class.
    Generics and arrays don't always play nicely together and this is one case. ;-)

  • Describe non-generic array cast in JLS3 as being unchecked

    This method :
        static <T, U extends T> U[] cast(T[] a) { return (U[]) a; }will generate the warning: [unchecked] unchecked cast, found: T[], required: U[].
    And it should. Wouldn't it be appropriate if
        static Object[] cast(String[] a) { return (String[]) a; }would produce the same warning?
    If you do that, you could translate the declaration
      T[] at = new T[255]
      String[] as = new String[255]into
    Array<T> at = Array.<T>newInstance(255);
    Array<String> as = Array.<String>newInstance(String.class, 255);where java.lang.reflect.Array would be something like
    package java.lang.reflect.Array;
    public final class Array<T> implements Iterable<T> {
        public final int length;
        private Type memberType;
        private Array(Type memberType, int length) {
            this.memberType = memberType;
            this.length = length;
        public native T getMember(int i);
        public native void setMember(int i, T member);
        public native java.util.Iterator<T> iterator();
       public static <U> Array<U> newInstance(int length) {
           return new Array<U>(null, length);
       public static <U> Array<U> newInstance(Class<U> memberClass, int length) {
           return new Array<U>(memberClass, length);

    Sorry, I created a bad example. It should have been:
        static <T, U extends T> T[] cast(U[] a) { return (T[]) a; }and
        static Object[] cast(String[] a) { return (Object[]) a; }The point is that an array of String is different from an array of Object and casts between them is unsafe. Throwing an ArrayStoreException if the wrong type is assigned is just a workaround for lack generic types in pre-Tiger Java. Now that we will have generics, I think it would be appropriate if Java arrays would be treated as proper generic types. For those that are afraid of breaking backwards compatiblility, the erasure mechanism should be able to take care of that.

  • Generic array deletion & insertion

    Hello,
    I was going through the options the generic Vector class offers to delete and/or insert items from/to an array, and it seems to me that the only way is by using the Splice method. For me, this method does a lot of work I dont utilize in my code (like creating a new array as a result etc.), hence
    is there an optimized way how to delete a certain item from a vector, instead of calling myVector.splice(idItemToRemove,1) ?
    Thanks for any answer!
    Tom

    that's it for array removal.  push() would be the usual method for adding elements

  • Returning Generic Arrays

    I'm trying to return an Array like such:
       public T[] main = (T[]) new Object[100];
       public int tracker = 0;
       public void getArray() {
          T[] temp = (T[]) new Object[tracker];
          for(int x = 0; x < temp.length; x++) {
             temp[x] = main[x];
          return temp;
       }It's part of a dynamic array im creating and this function return the actual trimmed array of type T but i've narrowed the problem down to be the actual assignment on the other side - for example if I was to write:
    private DArray<PolyGon> polygons = new DArray();
    private PolyGon[] test = polygons.getArray();This is where I get the error - can anyone explain why?

    yeh, sorry that was a typo but in my real source code I had
    public T[] getArray() and it still gives me a runtime exception - if I had put public void getArray() it wouldn't have compiled

  • I have type-safe generic array copying!

    Check this out. I get no warnings from this, and so far it seems to work fine, and it only takes twice the time of a normal array copy.
    All you have to do is pass in a dummy array of the same type as your inputArray, which under normal circumstances is very doable. The dummy array does not need to have the same dimension as the input array, which lets you use this as a static method in a utility class without feeling the burning need to make it throw an exception.
    It takes advantage of Collections' type-safe toArray() method.
         public static <T> T[] copyArray(T[] inputArray, T[] targetArray)
              return arrayToList(inputArray).toArray(targetArray);
         private static <T> ArrayList<T> arrayToList(T[] inputArray)
              ArrayList<T> returnValue = new ArrayList<T>();
              for(int i = 0; i < inputArray.length; i++)
                   returnValue.add(inputArray);
              return returnValue;

    And I like my tabs, thank you.Many people consider using tabs in code to be
    amatuerish. I can't say I disagree. Tabs are
    represented as different lengths depending on the
    editor. If you are using Eclipse, you can set it to
    insert a number of space when you hit tab instead of
    inserting tabs.I like tabs because they are an abstraction of indentation levels, something you don't get with spaces (unless you use one space per level), and therefore it makes more sense to me to use them. I use editors with good tab sizes that are also adjustable. Plus, I just like them better. So there.

  • How to create an array of generics?

    I have the following snippet of code using array of vectors:
    Vector[] tmpArr = new Vector[n];
    for(int j=0; j<n; j++)
    tmpArr[j] = new Vector();
    String str = ...
    if (!tmpArr[j].contains(str))
    tmpArr[j].add(str);
    And I want to convert to generics:
    Vector<String>[] tmpArr = new Vector<String>[n];
    for(int j=0; j<n; j++)
    tmpArr[j] = new Vector<String>();
    String str = ....
    if (!tmpArr[j].contains(str))
    tmpArr[j].add(str);
    But the first row gives me an error:
    -->Generic array creation.
    If I change it in
    Vector<String>[] tmpArr = new Vector<String>[n];
    (as I've seen in a pdf by G.Bracha talking aout collections)
    it gives me the error:
    -->cannot find symbol
    -->method add(String)
    in the
    tmpArr[j].add(str);
    row.
    The only way it seems to work is
    Vector<String>[] tmpArr = new Vector[n];
    but it gives me the unchecked conversion warning.
    How can I create an array of generics?
    Thank you!
    Matteo

    You can't
    Actually, that depends on the exact definition of a generic array. If by generic array someone means "an array comprised of elements defined by a type parameter", there is a solution.
    import java.lang.reflect.Array;
    public class Something<T> {
        private final Class<T> type;
        public Something(Class<T> type) {
            this.type = type;
        public String getTypeName() {
            return this.type.getName();
        public T[] newArray(final int length) {
            return (T[]) Array.newInstance(this.type, length);
    }The constructor introduces the type information (T) to the runtime environment, which means an instance of Something will know its type. Method newArray therefore does not cause a warning on unchecked type conversion, so this approach is typesafe.
    // Type parameter class is demanded by constructor...
    Something<String> stringThing = new Something<String>(String.class);
    // Cheating won't work, because the compiler catches the error...
    Something<Vector> vectorThing = new Something<Vector>(Integer.class);This approach, however, doesn't enable you to create an array of typed elements (like Vector<String>[]). If that is the definition of a generic array, then it is indeed not possible to create one.
    After all, while Vector[].class exists and can be resolved at runtime, there's no such thing as Vector<String>[].class, so there's no way you could provide the class definition of the component type to the constructor of Something.
    This may be a surprise to mdt_java, because if I remember correctly, templates in C++ cause actually different classes to be created for 'generic' types. This is not the case with Java.

  • Creating array of generic object

    hello, what i want to do is something like:
    public class AClass<K extends SomeObject>{
        SomeObject[] AnArray;
        public void amethod() {
            AnArray=new K[10];
    }So I want to create an array of some kind of object at runtime without already know the kind of the object. The thing is that I think that generics are only "known" at compiling time, so this AnArray=new K[10]; is propably completely wrong but I cannot think of any other way of creating an array without knowing in advance the kind of object....So if someone could enlighten me on how to do this...
    if this is of any help the reason i want to have such implementation is that this array is supposed to be a hashmap and the SomeObject is supposed to be a super class of some different kind of LinkedList classes, so I want the hashmap to be flexible on what kind of list will be used. Suggestions for completely different approach are also welcome offcourse, but I would prefer it if someone could give some brief explaination on how manipulating such a generic array issue...

    Hi Fraksia,
    Unfortunately, array creation of type parameters is not allowed, so you can't
    say new T[3]; That is because T doesn't exist at compile time. It is erased.
    It is misleading - I know. Because when you say
    AClass<SomeObject> aclass=new AClass<SomeObject>();you might thing that T becomes SomeObject in your class wheres
    what that does is that whenever you expect your type parameter in
    the calling code, compiler will insert a cast. See the example below:
    class MyClass<T> {
       T o;
       public MyClass(T o) {
          this.o=o;
       public T get() {
          return o;
    class CallingClass {
       public static void main(String[] args) {
          MyClass<String> m=new MyClass<String>("Test");
          String o=m.get();  //no cast needed here
    }Benefit: increased type safety, no casts needed in the CallingClass.
    What really happens is:
    class MyClass {
       Object o;
       public MyClass(Object o) {
          this.o=o;
       public Object get() {
          return o;
    class CallingClass {
       public static void main(String[] args) {
          MyClass m=new MyClass("Test);
          String s=(String)m.get();  // compiler inserts cast here based on your type parameter
    }That is why you can't do what you wanted - because "there is no spoon" ;)
    Generics in Java are only a compile time feature.
    Cheers,
    Adrian

  • Initializing an array of generics

    Hello all,
    I have declared an array of Vector with generics. The declaration is OK but the initialization gives me an error.
    This is the declaration
    Vector<Integer>[] x;This must be an array. Each element of the array is of type Vector<Integer>.
    I tried to initialize it using the line
    x = new Vector<Integer>[4];but it didn't work.
    I also tried
    x = new Vector[4]<Integer>;but didn't work also. The only initialization that worked is
    x = new Vector[4];But I want to put the generic tag in the initialization because it gives me warning.
    Any suggestions?
    Regards,
    Ahmed Saad

    x = new <Integer> Vector[4];When I compile that with Sun's javac compiler, I
    still get a warning.
    If you are not, it's a bug in the compiler you are
    using.
    As far as I know, the code above is no different
    from:
    x = new  Vector[4];
    yeah, I am trying to solve the same problem, and despite the person posting it worked, it didn't get rid of the problem for me...
    private Vector<Object> [] data;
    X.java:nn: generic array creation
    this.data = new Vector<Object>[2];
    X.java:nn: warning: [unchecked] unchecked conversion
    found : java.util.Vector[]
    required: java.util.Vector<java.lang.Object>[]
    this.data = new Vector[2];
    X.java:nn: warning: [unchecked] unchecked conversion
    found : java.util.Vector[]
    required: java.util.Vector<java.lang.Object>[]
    this.data = new <Object>Vector[2];
    ^

  • Getting bogged down in generics

    I have several similar Adapter classes and I am trying to refactor up to a common abstract class. My class needs to hang on to an array of "model" objects. When I initialize that array I seem to be forced to accept a warning. I suppose this is fine, but I suspect the warning is trying to tell me there's a better way. I could declare the array as the NamedModel type instead of the ModelType, but that seems bad because I want to express that these will always be of the more restrictive class (hopefully this makes sense).
    Here's my code:
    public abstract class NamedModelAdapter<ModelType extends NamedModel> extends BaseAdapter {
         private ModelType[] mModels;
            private Map<Integer, ModelType> mModelsAsAMap;
         public NamedModelAdapter(Context context, Cursor cursor) {
                    // this gives an error "Cannot create generic array of ModelType"
              // mModels = new ModelType[cursor.getCount()];
                    // this gives a warning "Unchecked cast from NamedModel[] to ModelType[]
              mModels = (ModelType[]) new NamedModel[cursor.getCount()];
                    // this gives an error "Cannot instantiate the type Map<Integer, ModelType>"
              //mModelsAsAMap = new Map<Integer, ModelType>(cursor.getCount());
    // stuff deleted
    }{code}
    Looking this over, I'm getting the strong feeling I'm missing something.  Please go easy on me, I'm still new to Java :-).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    As Walter indicated, generics and arrays do not mix well.
    public abstract class NamedModelAdapter<T extends NamedModel> extends Object {
        private final T[] modelsAsArray;
        private final List<T> modelsAsList;
        private final Map<Integer, T> modelsAsMap;
        public NamedModelAdapter(final Context context, final Cursor cursor) {
            modelsAsArray = createGenericArray(cursor.getCount());
            modelsAsList = new ArrayList<T>();
            modelsAsMap = new HashMap<Integer, T>();
         * Note the following is inadvisable.  Mixing generics and arrays is generally bad.
         * @param   length                  Desired length of array
         * @return  T[]                     Unsafe generic array
        @SuppressWarnings("unchecked")
        private T[] createGenericArray(final int length)
            return (T[]) new NamedModel[length];
    }- Saish

  • How to create an array of ArrayLists?

    Hello,
    I'm trying to compile the following code:
    ArrayList<Object> arr[];
    arr = new ArrayList<Object>()[size];in order to create an array of ArrayLists. I'm being met with the following compilation error:
    The type of this expression must be an array type but it resolved to ArrayList<Object>
    Can anyone show me how to correctly do this?
    Thanks

    {color:#3D2B1F}This line:
    List<Object>[] arr = new ArrayList<Object>[5];generates the compiler error: "generic array creation" (generics and arrays don't play well together)
    Since you are just parameterizing with Object, you can use non-generic collections:
    List[] arr = new ArrayList[5];Me? I don't like mixing arrays and collections. I would have a list of lists:
    List<List<X>> matrix = new ArrayList<List<X>>();{color}

  • Generic Method, How parameter type is determined

    For method
    <T> void fromArrayToCollection(T[] a, Collection<T> c) { ... } Why does
    fromArrayToCollection(sa, co);passes and
    fromArrayToCollection(oa, cs); fails.
    oa - Object Array, Object[]
    cs - Collection of String, Collection<String>
    sa - String Array, String[]
    co - Collection of Object, Collection<Object>
    What are the rules governing the type of T inferred by compiler?

    epiphanetic wrote:
    I think you still haven't fully understood the issue.
    I suggest, you also read the same generics tutorial by Gilad Bracha, section 6 from where I found this issue :). Ha! But I think it's misleading that that section uses arrays.
    In his words "It will generally infer the most specific type argument that will make the call type-correct." Its also mentioned that collection parameter type has to be supertype of Array parameter type but no reason is given. I wonder why it fails to infer correct type in second case.Assume you passed in an array of Objects, and a Collection of Strings, and it was possible that T would then be Object. Using Bracha's example implementation:
    static <T> void fromArrayToCollection(T[] a, Collection<T> c) {
       for (T o : a) {
          c.add(o); // correct
    }Now imagine you had this code making use of it:
    Object[] objects = {Integer.valueOf(1), "hi", new Object()};
    Collection<String> strings = new LinkedList<String>();
    fromArrayToCollection(objects, strings);
    String string = strings.iterator().next(); //get first String, which is actually an IntegerTrying to get the first String would give a ClassCastException. So clearly that method cannot not be safely invoked.
    The reason I think he's confusing things by using the array is because you might get it in your head that this would be OK:
    static <T> void fromCollectionToCollection(Collection<T> one, Collection<T> two) {
       for ( T t : one ) {
          two.add(t);
    Collection<Object> col1; Collection<String> col2;
    doSomething(col1, col2);When clearly it's unsafe, as now your Collection of Strings might have a non-String in it! That's why I said this is more a nuance of generic arrays than of type inference proper.

  • Trying to pass Oracle array/object type to Java

    I have a Java class with two inner classes that are loaded into Oracle:
    public class PDFJ
        public static class TextObject
            public String font_name;
            public int font_size;
            public String font_style;
            public String text_string;
        public static class ColumnObject
            public int left_pos;
            public int right_pos;
            public int top_pos;
            public int bottom_pos;
            public int leading;
            public TextObject[] column_texts;
    }I have object types in Oracle as such that bind to the Java classes:
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT" AS OBJECT
    EXTERNAL NAME 'PDFJ$TextObject'
    LANGUAGE JAVA
    USING SQLData(
      "FONT_NAME" VARCHAR2(25) EXTERNAL NAME 'font_name',
      "FONT_SIZE" NUMBER EXTERNAL NAME 'font_size',
      "FONT_STYLE" VARCHAR2(1) EXTERNAL NAME 'font_style',
      "TEXT_STRING" VARCHAR2(4000) EXTERNAL NAME 'text_string'
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT_ARRAY" AS
      TABLE OF "PROGRAMMER"."PDFJ_TEXT";
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN" AS OBJECT
    EXTERNAL NAME 'PDFJ$ColumnObject'
    LANGUAGE JAVA
    USING SQLData(
      "LEFT_POS" NUMBER EXTERNAL NAME 'left_pos',
      "RIGHT_POS" NUMBER EXTERNAL NAME 'right_pos',
      "TOP_POS" NUMBER EXTERNAL NAME 'top_pos',
      "BOTTOM_POS" NUMBER EXTERNAL NAME 'bottom_pos',
      "LEADING" NUMBER EXTERNAL NAME 'leading',
      "COLUMN_TEXTS" "PROGRAMMER"."PDFJ_TEXT_ARRAY" EXTERNAL NAME 'column_texts'
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN_ARRAY" AS
        TABLE OF "PROGRAMMER"."PDFJ_COLUMN";
    /I successfully (as far as I know) build a PDFJ_COLUMN_ARRAY object in a PL/SQL procedure. The PDFJ_COLUMN_ARRAY contains PDFJ_COLUMN objects; each of those objects contains a PDFJ_TEXT_ARRAY of PDFJ_TEXT objects (Example: pdf_column_array(i).pdf_text_array(i).text_string := 'something';). In this procedure, I pass this PDFJ_COLUMN_ARRAY as a parameter to a Java function. I assume the Java function parameter is supposed to be a oracle.sql.ARRAY object.
    I cannot figure out how to decompose this generic ARRAY object into a ColumnObject[] array. I also tried Googling and searching the forums, but I can't figure out matching search criteria. I was wondering if anyone here knows anything about passing user-defined Oracle type objects to a Java function and retrieving the user-defined Java class equivalents that they are supposedly mapped to--especially a user-defined array type of user-defined object types containing another user-defined array type of user-defined object types.

    Ok. I will try asking on the JDBC forum. So, don't
    flame me for cross-posting. :PWe won't, if over there you just post basically a
    link to this one.
    sigh Guess what, he did it the flame-deserving way. It's crossposted at:
    http://forum.java.sun.com/thread.jspa?threadID=602805
    <flame level="mild">Never ceases to amaze me how people don't think that posting a duplicate rather than a simple link isn't wasteful, as people could end up answering in both of them, not seeing each other's answers</flame>

  • RFE for new array type

    I was going to add an RFE for a new parameterized array type but first I wanted to know if anyone knew of an existing RFE for this.
    It has occurred to me that the solution to the 'array problem' might be to just create a 'new' array class and implement some operator overloading. The following demostrates the basic idea though the actual implementation could be very different:
    class Array<T>
        private final T[] internal;
        public final int length;
        public Array(int length)
            internal = (T[]) new Object[length];
            this.length = length;
        public T get(int element)
            return internal[element];
        public void set(int element, T item)
            internal[element] = item;
    }Something else that is interesting (to me) about this is that to some degree, generics makes the array type system obsolete, at least for Object types. There's no need for a different synthetic type for each array type. Generics achieves the same goal and does it better.
    The core of the request would be to implement the new array type with the overloading like the original array types such that we can do something like this:
    Array<String> a = new Array<String>(10); // or new Array<String>[10];
    a[0] = "test";
    String s = a[0];Any comments?

    OK, we all agree that from a theoretical standpoint
    arrays of subtypes should not be assignable to arrays
    of supertypes.
    But what strikes me is that this knowledge has been
    brought to general attention only after the
    Generics extension showed us what "variance" and
    related stuff really means.
    Before Generics, there has not been a
    pressing issue of rampant ArrayStoreExceptions in
    production code!
    Nor were there rampant ClassCastExceptions. The real value of generics is that it's much more expressive.
    The reason for this is probably that 90% of all array
    accesses are read accesses, where variance
    does not pose a problem.
    Right on the contrary, being able to treat a
    T[] as an Object[] is extremely
    convenient!
    So I'm playing devil's advocate here in saying that
    the initial design decision to make Java arrays
    variant was actually a good one!The real issue that this is meant to address is that we cannot create arrays of generic types, only cast to them (with warnings) and the array variance rules allow for raw types to be assigned to generic type array references without warnings. The net effect is that generic array types are destabilizing to generic code. The new typesafe array type would be a work-around for this issue.

  • ClassCastException with webservices with arrays

    Hi,
    I am trying to call a webservice from Fuego, where one of the webservice parameter is an array of string, which causes problems (when I remove this paramter everything works fine)
    When I invoke the call, I get the following ClassCastException.
    Could this be a bug of Fuego?
    Thank you
    Lui
    Details:
    The method 'CIL_mailAutorizado' from class 'BEA_Systems__Inc__.SolicitaCajeros.Default_1_0.Instance' could not be successfully executed.
    Caused by: java.lang.ClassCastException
    fuego.lang.ComponentExecutionException: The method 'CIL_mailAutorizado' from class 'BEA_Systems__Inc__.SolicitaCajeros.Default_1_0.Instance' could not be successfully executed.
         at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:496)
         at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:249)
         at fuego.fengine.FEEngineExecutionContext.invokeMethodAsCil(FEEngineExecutionContext.java:216)
         at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1068)
         at fuego.server.execution.TaskExecution.invoke(TaskExecution.java:391)
         at fuego.server.execution.TaskExecution.executeCIL(TaskExecution.java:475)
         at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:649)
         at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:610)
         at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:152)
         at fuego.server.execution.activities.XAutomatic.execute(XAutomatic.java:54)
         at fuego.metadata.Activity.execute(Activity.java:1019)
         at fuego.server.execution.ToDoItemAutomatic.execute(ToDoItemAutomatic.java:35)
         at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:290)
         at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:465)
         at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:543)
         at fuego.transaction.TransactionAction.start(TransactionAction.java:216)
         at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:116)
         at fuego.server.execution.DefaultEngineExecution.executeAutomaticWork(DefaultEngineExecution.java:56)
         at fuego.server.execution.EngineExecution.executeAutomaticWork(EngineExecution.java:42)
         at fuego.server.execution.ToDoItem.executeAutomaticWork(ToDoItem.java:265)
         at fuego.server.execution.ToDoItem.run(ToDoItem.java:536)
         at fuego.component.ExecutionThread.processMessage(ExecutionThread.java:752)
         at fuego.component.ExecutionThread.processBatch(ExecutionThread.java:732)
         at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:138)
         at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:130)
         at fuego.fengine.ToDoQueueThread$PrincipalWrapper.processBatch(ToDoQueueThread.java:429)
         at fuego.component.ExecutionThread.work(ExecutionThread.java:816)
         at fuego.component.ExecutionThread.run(ExecutionThread.java:395)
    Caused by: java.lang.ClassCastException
         at fuego.soaptype.SoapCall.fixInputArguments(SoapCall.java:303)
         at fuego.soaptype.SoapCall.invoke(SoapCall.java:242)
         at fuego.soaptype.SoapObject.invoke(SoapObject.java:283)
         at fuego.lang.Invokeable.invokeImpl(Invokeable.java:220)
         at fuego.lang.Invokeable.invoke(Invokeable.java:161)
         at BEA_Systems__Inc__.SolicitaCajeros.Default_1_0.Instance.CIL_mailAutorizado(Instance.java:2112)
         at BEA_Systems__Inc__.SolicitaCajeros.Default_1_0.Instance.CIL_mailAutorizado(Instance.java:2156)
         at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:489)
         ... 27 more

    Meanwhile, most suggestions offered for my original
    post add a type parameter for the inner class Entry.
    If I created an Entry object instead of an array of
    Entry objects, no type parameter would be necessary.
    Why should this not work for arrays?
    Not entirely sure I follow you, but this version, which is close to your original proposition will not compile:
    public class EntryArray<T> {
        private Entry[] data;
        public EntryArray() {
            data = new Entry[20];
        public void setValueAt(T value, int idx) {
            data[idx] = new Entry(value);
        public T getValueAt(int idx) {
            return data[idx].field;
        private class Entry {
            private final T field;
            private Entry(T newField) {
                field = newField;
      public static void main(String[] args) {
            EntryArray<String> thing = new EntryArray<String>();
            thing.setValueAt("foo",0);
            System.out.println(thing.getValueAt(0));   
    EntryArray.java [17:1] generic array creation
            data = new Entry[20];Obviously here we've made Entry a NON-static inner class again, thus every Entry has an enclosing EntryArray<T> and thus the compiler can't generate array creation code for it, not knowing what T is.
    If you're asking why this is, I believe the answer has to do with the way memory is allocated when an array is initialized. It needs to know what 'T' actually is to do it, and it can't know this because T has been erased. Perhaps someone else can provide a precise explanation?

Maybe you are looking for

  • My Zen 8GB Player is not being recognized by my

    What is happening is that I plug the player in the usb and it says docking but on Zen MicroPhoto Media Explorer it says "Device Not Found" Windows Media Player doesn't recognize it either nor does any other player. When I check in Device Manager it j

  • IMac external hard drive will not show up on desktop

    I have an external 60 GB hard drive that is attached to an IMac. I used to be to access this hard drive, but now the IMac will not see it and it does not appear on the desktop anymore. I have another Mac computer and have hooked this hard drive up to

  • Firewire connected camcorder

    I've got a Sony DCR-TRV20E camcorder (DV tape with firewire out) which I've pulled video before onto my MacBook Pro (now on Snow Leopard). I tried connecting this via firewire over the weekend but it didn't show up in iMovie or system profiler. The f

  • Port_based address Allocation

    hi, Can Port_based address Allocation is possible in cisco switch if possible kindly tell the switch model or any cisco / third party software reqiure. pls help......

  • Trial version of Elements 8 editor

    I bought adobe premiere elements 8 a long time ago, I just installed it on my new computer (not so new) and I want to update the trial version of editior. I already have adobe photoshop 5.0 but it can't do what I want and sucks on windows 7, I spent