[ANN] Java IDE with generic type support

Hello all!
We are proud to announce that we have just released version 5.0 of our Java IDE CodeGuide.
CodeGuide 5.0 offers full support for generic types as defined in JSR 14. Features are:
- Fast incremental on-the-fly compilation
- On-the-fly error checking of the whole project
- Code completion
- Usage search
- Refactoring (like Renaming, Class moving, etc.)
- and more...
A 30-day trial can be downloaded from our web page at
http://www.omnicore.com
Any feedback regarding JSR 14 support is much appreciated.
Best regards,
Dennis Strein
Omnicore Software

I wrote a class MultiMap<K, V> extends Map<K, Set<V>>
    // Various constructors, methods, fields.
    public Set<V> get(K key)
        // Implementation
} It compiles fine with the Sun reference compiler, but a friend tells me that CodeGuide 5.0 build 504 complains "There already is another method with the same erasure." It could be that CodeGuide is correct and Sun wrong, because I can see that there might be issues with overriding the get(Object) method with a get(K), but I thought I'd mention it.

Similar Messages

  • 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

  • BUG: error rebuilding SQLJ files along other java files with generic

    I have done a rebuild on a package containing some SQLJ files, and (consistently) got the following error:
    C:\TeleMessage\trunk\src\telemessage\db\impl\dbAdmin.sqlj
        Error(44,18): Java Parsing. Encountered: <
        Expected: <IDENTIFIER> ...; "[" ...; The error at the cursor in the given file is not possible, since there was no '<' there, and besides - if I non-aggresively changed the file, e.g. narrowed imports, changed whitespace or added comments - the error remained in the same location.
    I went and done a search using regex in the package, for a line starting with 17 chars followed by a '<'.
    I found it in one of the normal JAVA files (not-SQLJ), at line 44 (surprise!) - in a Java 5 generics declaration, e.g. Map<String,Integer>. the 18th character was indeed the '<'.
    I'm guessing that the SQLJ translator (accidentally?) parses non-SQLJ files.
    If this cannot be fixed, it is really bad - it is one thing that JDeveloper cannot support Java 5 language features because of its dependancy in the SQLJ translator (which is not known to be upgraded until version 11g if at all), but the inability to compile SQLJ files in a project containing other non-SQLJ java files with Java 5 features is hard.
    I could only workaround this by rebuilding SQLJ files one at a time!
    I also have another type of error, when rebuilding the same project in a higher-level pacakge (root or "Application Sources"):
    C:\TeleMessage\trunk\src\dbtools\CallbackNumberFiller.sqlj
        Error(24,8): Missing semicolon.
        Error(24,8): Unbalanced curly braces.Again, the specified file could not be the one to blame - the location of the error is in the middle of the public modified keyword in a method declaration; nothing is neither missing nor unbalanced.
    This appears to be different, as it pops in the log near the end of the build process, when the JSPs are being built, specfically during the time the message log fills with "writing <...>" lines (after "translating <...>" and "compiling <...>".
    I can consistently reproduce both cases - please advise how I can help you find out what causes this.
    Regards,
    Yaniv Kunda

    First of all, this bug not JDeveloper's problem, but the SQLJ team's.
    You can read more posts about this:
    Re: BUG: Cannot translate SQLJ files with Java5 generics code
    Re: How to use SQLJ with Java 1.4 and 1.5?
    Re: SQLJ discontinued??
    And if we're at it, this is strange - I can't seem to find the oracle doc you quoted...
    SQLJ 11g? The latest release is a part of JPublisher 10.2 available from
    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
    I also didn't find anything on google on 11g, nor about the part number you specified.
    Didn't find any Java 1.5 supporting SQLJ translators from other vendors as well.
    Do you have any link to this statement?
    But if we examine this bug again, the problem involves JDeveloper passing Java 5 featured JAVA files to the SQLJ translator.
    Isn't there a way to instruct the translator to use CLASS files compiled by a normal Java 5 compiler, instead of trying to compile the files itself?
    Regards,
    Yaniv Kunda

  • How to create an array with Generic type?

    Hi,
    I need to create a typed array T[] from an object array Object[]. This is due to legacy code integration with older collections.
    The method signature is simple:public static <T> T[] toTypedArray(Object[] objects)I tried using multiple implementations and go over them in the debugger. None of them create a typed collection as far as I can tell. The type is always Object[].
    A simple implementation is just to cast the array and return, however this is not so safe.
    What is interesting is that if I create ArrayList<String>, the debugger shows the type of the array in the list as String[].
    If I create ArrayList<T>, the class contains Object[] and not T[].
    I also triedT[] array = (T[]) Array.newInstance(T[].class.getComponentType(), objects.length);And a few other combinations. All work at runtime, create multiple compilation warnings, and none actually creates T[] array at runtime.
    Maybe I am missing something, but Array.newInstace(...) is supposed to create a typed array, and I cannot see any clean way to pass Class<T> into it.T[].class.getComponentType()Returns something based on object and not on T, and T.class is not possible.
    So is there anything really wrong here, or should I simply cast the array and live with the warnings?
    Any help appreciated!

    Ok. May be you could keep information about generic type in the your class:
    public class Util {
        public static <T> T[] toTypedArray(Class<T> cls, Object[] objects){
            int size = objects.length;
            T[] t = (T[]) java.lang.reflect.Array.newInstance(cls, size);
            System.arraycopy(objects, 0, t, 0, size);
            return t;
    public class Sample<T> {
        Class<T> cls;
        T[] array;
        public Sample(Class<T> cls) {
            this.cls = cls;
        public void setArray(Object[] objects){
            array = Util.toTypedArray(cls, objects);
        public T[] getArray(){
            return array;
        public static void main(String[] args) {
            Object[] objects = new Object[] { new LinkedList(), new ArrayList()};
            Sample<List> myClass = new  Sample<List>(List.class);
            myClass.setArray(objects);
            for(List elem: myClass.getArray()){
                System.out.println(elem.getClass().getName());
    }

  • Most versatile IDE with multiple language support IYO ?

    Im trying to gauge which IDE would be best for coding a variety of languages (C/C++, Python, Java...). I'd ideally like something with plugin support, so that you can extend its functionality as desired, and write your own add-ons should the need arise. It'd be great if there was inbuilt support for less common languages such as OCAML, and for more recent languages like Ruby.
    I've been using a solely CLI-based setup for 6 months now, with firefox being the only gui app I've used (coding: vim, IM: centericq, IRC: weechat, Music: mpd). I converted to that setup thinking that it would boost my efficiency, since Ratpoison with GNU Screen makes every mouse action replaceable with a keyboard combo. Recently though, I've been frustrated at certain limitations of Ratpoison, and while I have gained speed with some of its features, I've lost speed with others.
    The gist of this is that I'm going to go back to Openbox with the expose-like Skippy, and the Mac OS Dock-like yab (via adesklets). I'll miss the versatility of using nought but the terminal, but it sure will be a breath of fresh air to seem some aesthetically pleasing interfaces, lol
    Ive looked at what IDEs are on offer, and the most interesting ones are jEdit (perhaps you'd like to convince me Dusty? ), Eclipse (which I've used for Java and Python, and I like it, but it's so fat! lol) and PIDA (not used and can't find screenshots - the ones on the Berlios project page for it won't display: they say I'm unauthorized for access). I'd love to hear any feedback from people who've used any of these development environments and wish to sing their praises, or point out any flaws. Similarly, it'd be great to hear of any other software that Archers have used and found to be productive.
    Any offers?

    phrakture wrote:Everyone hates vim, methinks:
    [URL=http://img422.imageshack.us/my.php?image=screenshot200512270240442fo.png][/URL]
    I already wrote this, but it disappeared... weird.
    I don't hate Vim by any means; I think it's a very impressive piece of software, and very efficient in terms of speed. But I'm no longer of the school of thought who consider mouse-usage alone to be the most efficiest interface, or the opposing school of thought that consider just using keyboard combos is the way forward.
    I used to think the latter, but after using ratpoison and CLI apps for so long, I've changed my mind. It is very fast to use the keyboard for coding - keyboard shortcuts for auto-completion, indentation etc, very handy. But what if you want to traverse a tree of modules you're working on, looking at separate, random pieces of code you've written in different files. It's a lot faster to just click on whatever module/interface/whatever you want to see the code of, rather than manually scrolling up or down said tree.
    Also, for something as simple as scrolling page contents, I prefer to use a mouse. it feels more pleasant than using the keyboard, and it's faster when using the mousewheel. If there's a particular chunk of code on the page that you want to see in the centre of the window, with the keyboard you'd first use the page up/down shortcut to get near the desired area (which has a limited speed), and then you have to manually shift the page up or down by a few lines to get bang on whatever you wish to see. Using a mouse to do the same thing is much quicker. The same argument applies for copy-and-paste.
    Some things in Ratpoison are very fast, like being able to launch applications via easily-customizable keyboard shortcuts. But other things, like window resizing (or rather, frame resizing in Ratpoison ) are very slow. True, you can set pre-defined frame layouts, and also resize frames with key combos... but I hate the inflexibility of this. Frame resizing via the keyboard is so slow; it's something you could do in a second or less using a mouse; the same with moving windows around - a simple action to perform via the mouse, yet in Ratpoison moving frames around is difficult, and moving windows around involves combinations of swapping frame contents, tabbing through available windows, or looking to see what number the window you want is, and THEN switching to it by number. This is slow IMO.
    Don't get me wrong, I still think Ratpoison is really good, and completely achieves what it's going for - the easy-to-use Screen-esque WM - but as I say, I just feel that a keyboard-mouse combo is the way forward.
    Some people may say that it's better to use CLI-only apps for SSHing, since if you've got a low speed connection, they're the best. But most businesses, colleges, schools and homes where you work/study and need to use SSH have broadband now, so as long as you set up X forwarding, which is a simple task, then you can use your gui apps anywhere you want.
    I will never dislike Vim (or Emacs for that matter; both have pros and cons), I do not consider them to be archaic or unwieldy because they're CLI apps (ignoring their X counterparts); I simply feel that a combination of their do-it-by-the-numbers keyboard combos with the flexible-as-a-yoga-teacher mouse is an all-round safer (and faster) bet.
    Anyway, I don't want to go too far off topic - I'm just trying to explain why I wish to return to gui-land after being in cli-territory for so long. I'd be grateful if people would mostly ignore this post, and respond to my first post by sharing information and opinions on other IDEs (although I welcome your opinions on what I've just said, Phrakture, since you're the longest Ratpoison/Screen user I know of, and it's clearly worked for you ).
    I'd really like to hear from Dusty, if he reads this... I know he's working on Magnum (I *think*, anyway) and uses or did use JEdit, so I'd like to hear what he likes about them compared to vim etc.
    Anyone who's got an IDE suggestion or opinion is most welcome to respond 

  • Problem referencing to methods with generic type parameters

    Assuming I have an interface like to following:
    public interface Test <T> {
    void test ( T arg0 );
    void test ( T arg0, Object arg1 );
    I would like to reference to both "test"-methods using "{@link #test(T)}" and "{@link #test(T,Object)}".But this generates an error telling me "test(T)" and "test(T,Object)" cannot be found.
    Changing T to Object in the documentation works and has as interesing effect. The generated link text is "test(Object)" but the generated link is "test(T)".
    Am I somehow wrong? Or is this a known issue? And is there a workaround other than using "Object" instead of "T"?

    Hi,
    I bumped into the same problem when documenting a generic.
    After quite a while of search your posting led me to the solution.
    My code goes something like this:
    public class SomeIterator<E> implements Iterator<E> {
      public SomeIterator(E[] structToIterate) {
    }When I tried to use @see or @link with the constructor Javadoc never found it.
    After I changed the documentation code to
    @see #SomeIterator(Object[])it worked.
    Since both taglets offer the use of a label, one can easily use these to produce comments that look correct:
    @see #SomeIterator(Object[]) SomeIterator(E[])CU
    Froestel

  • How To: Use reflection to create instance of generic type?

    I would like to be able to use reflection to instantiate an instance of a generic type, but can't seem to avoid getting type safety warnings from the compiler. (I'm using Eclipse 3.1.1) Here is a trivial example: suppose I want to create an instance of a list of strings using reflection.
    My first guess was to write the following:
    Class cls = Class.forName("java.util.ArrayList<String>");
    List<String> myList = cls.newInstance();The call to Class.forName throws a ClassNotFoundException. OK, fine, so I tried this:
    Class cls = Class.forName("java.util.ArrayList");
    List<String> myList = cls.newInstance();Now the second line generates the warning "Type safety: The expression of type List needs unchecked conversion to conform to List<String>".
    If I change the second line to
    List<String> myList = (List<String>)cls.newInstance();then I get the compiler warning "Type safety: The cast from Object to List<String> is actually checking against the erased type List".
    This is a trivial example that illustrates my problem. What I am trying to do is to persist type-safe lists to an XML file, and then read them back in from XML into type-safe lists. When reading them back in, I don't know the type of the elements in the list until run time, so I need to use reflection to create an instance of a type-safe list.
    Is this erasure business prohibiting me from doing this? Or does the reflection API provide a way for me to specify at run time the type of the elements in the list? If so, I don't see it. Is my only recourse to simply ignore the type safety warnings?

    Harald,
    I appreciate all your help on this topic. I think we are close to putting this thing to rest, but I'd like to run one more thing by you.
    I tried something similar to your suggestion:public static <T> List<T> loadFromStorage(Class<T> clazz) {
        List<T> list = new ArrayList<T>();
        for ( ...whatever ...) {
           T obj = clazz.newInstance();
           // code to load from storage ...
           list.add(obj);
        return list;
    }And everything is fine except for one small gotcha. The argument to this method is a Class<T>, and what I read from my XML storage is the fully qualified name of my class(es). As you pointed out earlier, the Class.forName("Foo") method will return a Class<?> rather than a Class<Foo>. Therefore, I am still getting a compiler warning when attempting to produce the argument to pass to the loadFromStorage method.
    I was able to get around this problem and eliminate the compiler warning, but I'm not sure I like the way I did it. All of my persistent classes extend a common base class. So, I added a static Map to my base class:class Base
       private static Map<String, Class<? extends Base>> classMap = null;
       static
          Map<String, Class<? extends Base>> map = new TreeMap<String, Class<? extends Base>>();
          classMap = Collections.synchronizedMap(map);
       public static Class<? extends Base> getClass(String name)
          return classMap.get(name);
       protected static void putClass(Class<? extends Base> cls)
          classMap.put(cls.getName(), cls);
    }And added a static initializer to each of my persistent classes:class Foo extends Base
       static
          Base.putClass(Foo.class);
    }So now my persistence code can replace Class.forName("my.package.Foo") with Base.getClass("my.package.Foo"). Since Foo.class is of type Class<Foo>, this will give me the Class<Foo> I want instead of a Class<?>.
    Basically, it works and I have no compiler warnings, but it is unfortunate that I had to come up with my own mechanism to obtain a Class<Foo> object when my starting point was the string "my.package.Foo". I think that the JDK, in order to fully support reflection with generic types, should provide a standard API for doing this. I should not have to invent my own.
    Maybe it is there and I'm just not seeing it. Do you know of another way, using reflection, to get from a string "my.package.Foo" to a Class<Foo> object?
    Thanks again for your help,
    Gary

  • Urgent Please........!!!!     Java IDE

    Can anyone tell Excellant JAVA IDE with Runtime Program Tracing

    I've worked on Forte, JDeveloper, and JBuilder5 in the last month or so. All are free and all are similar enough that you can get started quite easily.
    I never did manage to get debugging working properly on the latest Forte (on WIn98) but it was probably my fault,
    JBuilder5 is the tops on my list. I think you have to pay for some of the nicer debugging options (member change breakpoints, member watches) but I could be wrong. One of the nicest environments I've ever worked in.

  • 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.

  • Stuck with incompatibe types for the same generic variables

    having trouble with generics
    i have the static class Node<T> in a double linked list
    whenever i make a node point to another node
    i have incompatible type errors
    Node<T> current;
    Node<T> head;
    src\DoubleList.java:135: incompatible types
    found : DoubleList.Node<T>
    required: DoubleList.Node<T>
    current = head;

    Can you post more code? Specifically the class declarations for DoubleList and Node and a method where you have this issue. Please use the code tags (button above edit field) when you post.

  • Generic type doesn't support raw dataypes (int, boolean, etc.)?

    It seems that Java 5 generics always autoboxes raw datatypes (int, double, boolean, ...) to the wrapper classes (Integer, Double, Boolean, ...), because when I use e.g. Integer.TYPE (instead of Integer.class), I got ClassCastExceptions. Is this non-support somewhere written down or is there a way to handle raw types without autoboxing them to their wrapper class?

    I'm having some difficulty understanding your question, but my first suggestion is to see section 4.4 Type Variables of the Java Language Specification, which states: "If no bound is given for a type variable, Object is assumed."
    Also, I think you mean "primivite" instead of "raw" types. Raw types are the "name of a generic type declaration used without any accompanying
    actual type parameters" (sectoin 4.8 Raw Types).
    Regards,
    Nick

  • After loading lion, I get an error message "There was a problem connecting with the server.  URL's with the type "file" are not supported."

    After loading Lion, I have been getting an error message "There was a problem connecting to the server.  URLs with the type "file:" are not supported."  There does not seem to be any actual problem with internet connectivity, but it is persistent and annoying.  Any idea of its cause and treatment?

    Take a look at this link, https://discussions.apple.com/message/16156214#16156214

  • Nested-Generic Type with the same parameter as enclosing type?

    Greetings. I want to write a nested generic type with the same type parameter as the enclosing type. For example, consider:
    public interface BinaryTree<Type> {
         Node<Type> getRoot();
         interface Node<Type> {
              Type getValue();
              void setValue(Type value);
              Node<Type> getLeft();
              void setLeft(Node<Type> node);
              Node<Type> getRight();
              void setRight(Node<Type> node);
    }In this example, I want Node to be specified to the same type as the binary tree's parameter specification. Does anyone know how to do that? I have tried several methods and am at a loss.
    TIA

    Is there any way to declare that? Essentially I want
    the nested type to parameterize the enclosing type.I understand that but I don't think it's possible because of how java generics works.
    This ,
    SomeClass< SomeNestedClass<Type> >is wrong because you're supposed to give a formal type parameter within <> not an already defined type (like SomeNestedClass).
    If you instead do
    public class SomeClass<Type > {
        public static class SomeNestedClass<Type> {
    }To think of the two Type as the same formal type parameter is semantically incorrect. Both the outer type and the inner type must be able to participate in variable declarations "on their own". Say you do
    SomeClass<Integer> sc;Just because you did the above in which context is now SomeNestedClass supposed to be bound as SomeNestedClass<Integer>? To me this shows that SomeClass and SomeNestedClass cannot share the same formal type parameter.

  • Building Binary Searh Tree with multiple types (hint hint Generics?)

    I have built binary search trees before and even wanted to build a B+ tree for primary indexes but my Professor suggested limiting to BST.
    My question is can I build a BST with a generic type parameterized code using Comparable and Generics to help me insert numeric and non-numeric (String) type nodes using the requirement that anything less than the root go left, greater than or equal to the root go right. There will be no duplicates.
    This is definitely new territory for me so any help is appreciated.

    Always Learning wrote:
    I have a Comparable<Object> x I would like to compareTo(Some other Comparable<Object>) but I know I am going about this all wrong.
    Essentially I want to be able to compare String lexicographically or integers/floats in order to properly insert them into a binary search tree and I wanted to use the Java language constructs of the Comparable interface and possibly generics to do it.
    This would result in a simple String1.compareTo(String2) or int1.compareTo(int2) etc.So it sounds like you actually have a Comparable<T>; or possibly a Comparable<String>, where all your types are first converted to Strings (however, in the case of ints, that probably means adding leading '0's).
    The generics tutorial suggests that you use Comparable<? super T> in cases of arbitrarily comparable items; however, I think you first need to decide how your comparisons are going to be done. For example, how does a String compare to an Integer in your scenario?
    Winston

  • Generic method invocations with explicit type parameters

    If I interpret the JSR14 public draft spec (June 23, 2003) section 5.6 correctly the following method invocations with explicit type parameters should compile: package generics;
    public class G121 {
      void f() {
        this.<String>f2();
        <String>f2(); // compilation error
        <String>f3(); // compilation error
      <T> void f2() {
      static <T> void f3() {
    }but the class does not compile: jc -J-showversion generics\G121.javajava version "1.5.0-beta"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
    Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
    generics\G121.java:6: illegal start of expression
        <String>f2(); // compilation error
                ^
    generics\G121.java:8: illegal start of expression
        <String>f3(); // compilation error
                ^
    2 errors
    >A bug or do I miss something?

    I get this error:
    LineCount.java:104: cannot find symbol
    symbol : method <java.io.File>sort(java.util.List<java.io.File>)
    location: class java.util.Collections
    Collections.<File>sort( list );
    ^
    1 errorYou don't need the explicit type argument there, but anyway...
    If you look at the docs for Collections.sort(List<T> list) you'll see it is declared as:
    static <T extends Comparable<? super T>> void Collections.sort(List<T> list) Unfortunately, although File implements Comparable, it doesn't actually implement Comparable<File> or even Comparable<Object>, so I guess it can't satisfy the bound.
    You can get it to compile by removing the explicit type argument and casting to the raw type List, but that's not very nice.
    This seems like an oversight to me - File already has both int compareTo(Object o) and int compareTo(File pathname) so I don't see why it can't implement Comparable<File>. This isn't the only such case in the API though, so maybe I'm missing something.
    Mark

Maybe you are looking for

  • I need to sync my old iPhone to a new iTunes but need to keep the data?

    Hi, I have got a new computer, and so obviosuly have had to download a new verison of iTunes to go with it, however, I now cant sync my iPhone (which was linked previously to an iTunes account on my old computer) without it wanting to erase allll my

  • I want to download Adobe Premier elments 9 Windows. I purchased this program online in August 2010

    I want to download Photo Premier 9 for windows. I purchased the programs online in August 2010.  I deleted Adobe photoshop Element 9 and Adobe Premier elments 9 for windows so I could install the updates.  I reinstalled the Adobe Photoshop element 9,

  • "control data for storage type is missing"

    Hi Guys I am trying to create a goods receipt for an inbound delivery. I created the inbound delivery VL31N - sucessfully But when trying to create a putaway LT0F - error control data for storage type is missing. msg no. L3006 Do i maiantain this con

  • ITunes 9 - Getting Started video won't play

    iTunes 9 installation was smoothly and quickly, however: While the "Welcome to iTunes" startup window opens properly but"Getting Started with iTunes 9" movie won't fully load or play. This first tutorial movie on the "Welcome" list only plays the fir

  • Can I make an aperture slideshow and use it in iweb?

    I need to know if I can make an aperture slideshow and use it in iweb (not making it a quicktime movie)? I don't want to use I photo (I know how to make one in Iphoto and put it in Iweb and I dont want to do this). (dont want a .mac gallery either) P