Results 1 to 3 of 3

Thread: [Java] Generics weirdness

  1. #1
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    [Java] Generics weirdness

    This is odd. I have this piece of code:


    Code:
    AnalyzerBase<?,?> analyzer = null;
    
    // Lots of stuff...
    
    analyzer = new MVAnalyzer((Integer)opts.valueOf("n"));
    if (opts.wasDetected("r"))
    ((MVAnalyzer)analyzer).setMultLimit((Float)opts.valueOf("r")*1000000);
    
    // ... so on
    Now, MVAnalyzer "extends SparseAnalyzerBase<Byte, MVAnalyzer.MVRecord>" which "extends AnalyzerBase<I, T>". So our inheritance is OK according to Eclipse.

    Netbeans doesn't like this at all. I get a complaint of

    Code:
    /home/eneva/ActorFeeder/src/vptools/analyzer/Analyzer.java:177: inconvertible types
    found   : vptools.analyzer.AnalyzerBase<capture#945 of ?,capture#446 of ?>
    required: vptools.veikkaus.mv.MVAnalyzer
    This is really annoying, as I am migrating the project over from Eclipse and I don't quite understand why an "instantiated" subclass of AnalyzerBase<?,?> is not something you could cast an AnalyzerBase<?,?> to anymore...

    Eclipse is Ganymede and Netbeans is 6.5, both newest. System javac is 1.6.0_10; both should use it as far as I know...
    Last edited by CptPicard; January 19th, 2009 at 11:59 PM.
    LambdaGrok. | #ubuntu-programming on FreeNode

  2. #2
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: [Java] Generics weirdness

    Well, ok, Netbeans stops whining when you remove the generics from AnalyzerBase altogether and just use a raw type. In Eclipse it produces a warning...

    http://bugs.sun.com/bugdatabase/view...bug_id=4916620

    Strange mismatch in behaviour anyway, and I like Eclipse's way of treating it better, as I can see situations where Netbeans' way of going about it *is* going to produce problems.

    EDIT: Ok so I'm an idiot, it's a compiler setting that treats unchecked generics operations either as warnings or errors...
    Last edited by CptPicard; January 20th, 2009 at 02:04 AM.
    LambdaGrok. | #ubuntu-programming on FreeNode

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Beans
    2,185
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: [Java] Generics weirdness

    Quote Originally Posted by CptPicard View Post
    Eclipse is Ganymede and Netbeans is 6.5, both newest. System javac is 1.6.0_10; both should use it as far as I know...
    Eclipse does not use the Java compiler that's installed on your system; it has its own built-in Java compiler, based on IBM's Jikes Java compiler.
    Ubuntu 12.04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •