Covariant return types - JLS to support but JVM will not?

Could you please confirm the following? My understanding is that covariant return types will be supported by the JLS but the JVM will know nothing about them. That is, the invokevirtual instruction will not change to support covariant return types but rather the compiler will use bridge methods to simulate support. Is this correct?

Right: but is there support for this in 1.5?
javac -verbose -source 1.5 -target 1.5 *java
was run on a .java file with the following methods and it failed "getX already defined"
public Integer getX() {
return(null);
public String getX() {
return(null);
The above would be overloading by return type and fails to compile.
================
class A {
Exception f() {}
class B extends A {
BindException f() {} // overload or override?
The above would be covariant returns and works just fine right?

Similar Messages

  • Covariant return types over Generic return types.

    Feeling rather slow on the uptake having only just discovered covariant return types (thanks again cowwoc), I've been looking over one of our soon to be released APIs and think using covariants makes muchos sense for it but there's one issue:
    public interface Foo {
         Foo get();
    public interface Bar {
         Bar get();
    public interface FooBar
              extends Foo, Bar {
         FooBar get();
    }Which isn't allowed, as the compiler states the return types are incompatible (I think incorrectly as it's been further overridden). Its generic equivalent is:
    public interface FooX<T> {
         T get();
    public interface BarX<T> {
         T get();
    public interface FooBarX
              extends FooX<FooBarX>, BarX<FooBarX> {
         FooBarX get();
    }Which works, and well, but the extra hassle of declaring/using generics is turning out to be a pain for our users (this pattern is used extensively). Does anyone have any simple suggestions/recommendations to resolve either the covariant issue or simplify the generics one? Also does anyone have any preferences to which one they prefer (and why)?
    Incidentally does anyone know the the rationale behind not allowing the first example, when clearly it can't be abused (can it)?

    BobDavies wrote:
    . it is because you can not override a method or its definition with the same signatur, which does not include return type.What do you mean "does not include return type"?
    method signature does not count the return type. i think java does allow you to repeat definitions in a sub class but when you put up a different retyrn type, it sees it as an attempt to do overriding, so it flags it out.
    the fact that it works is becuase you are not extending anything but itsself:I am aware of the reasons for the Generic version working, it achieves our aim, I just don't like it when in use. And was wondering why the joining covariants do not work. I still can't see the reason for the FooBar not being allowed when you are allowed to return subtypes. You cannot break the inheritance/return types expectations like this can you? E.g. if I write a bit of code using Foo, it will still work with FooBar, and the same with Bar using FooBar, no? Can you show me an example of why this isn't allowed?your generic version should NOT work either; it is working becuase you are confused:
    public interface FooBarX extends FooX<FooBarX>, BarX<FooBarX> only equals to
    public interface FooBarX extends FooBarX, FooBarX

  • Covariant return types without "-source 1.5"

    Hello all,
    I've just noticed that one can compile code that makes use of covariant return types even without specifying the flag -source 1.5.
    Just out of curiosity: Was that behvaiour of javac intentional?
    What's more, if you compile it with target 1.4
    you can even run it with a 1.4 JRE!
    Great, ain't it?

    I've just noticed that one can compile code thatmakes use of covariant return types even without
    specifying
    the flag -source 1.5.
    Very interesting, actually it runs on jdk 1.3.1 too.
    Actually using -target 1.4 or -target 1.3 generated the sameclass file in a small example (with the exception of the version number). And this class file contains 2 method entry per covariant(ed) method. One method with the return type specified in the source code and a second method with the return type of the base class. The second method is of synthetic and has a virtual call to the the this method.
    with -target 1.5 you also get both method entries, but the second one is not synthetic anymore (??).

  • Covariant Return Types - J2SE 5.0

    I just read the tech tip regarding the new covariant return types in j2se 5.0
    In the doc, it said that you can now compile two methods with the same signature but with different return types. I was wondering if anyone knew how this would affect what the following expression returns: anObject.getClass().getMethod(aMethodNameString, aClassArray)
    If there are two methods with the same signature except for the return type, how does the above expression know which method to return?

    Never mind, I just found my answer in the javadoc....
    "To find a matching method in a class C: If C declares exactly one public method with the specified name and exactly the same formal parameter types, that is the method reflected. If more than one such method is found in C, and one of these methods has a return type that is more specific than any of the others, that method is reflected; otherwise one of the methods is chosen arbitrarily. "

  • JCP Submission to add covariant return types

    What would be involved in getting to gether to submit a formal JCP to enable covariant return types?
    AFAIK, the changes are:
    1) the language spec
    2) the JVM Spec
    3) changes to the compiler code
    4) changes to the class file verifier in the JVM code
    And that should be it. Who wants to organise this?

    My understanding is that the current generics proposal already includes covariant return types.

  • My airport express seems to no longer be supported by Apple. Was working fine, just blinking amber. So tried to update and reset, but update will not install with Lion? Im disgusted.

    Airport express was blinking yellow. Tried to update, but my computer said update is not supported (yellow exclamation points). I have a mac pro with Lion and latest updates. So I reset express, yes that was a mistake because it was at least functioning on my stereo, now it does not function at all and shows on my wifi as "airport express", used to be labled "stereo". So it asks for an update, I download the update, but computer will not allow update to be installed. I will buy a newer one if I have to because I enjoy it's function, but I will be extremely disgusted with Apple to have to do so.

    If you are using Lion...as you indicate...is it possible that you mistakenly downloaded the incorrect version of AirPort Utility?
    Try the following version for Lion:
    AirPort Utility 5.6 for Mac OS X Lion

  • My new iPhone 4s paired with my iMac but it will not connect to transfer files by bluetooth. It says the iMac is not supported!

    My iPhone 4s will pair sucessfully with my iMac, but it will not connect so that I can transfer files via bluetooth. It says "bluetooth network not available" or "iMac not supported". Just insane. What to do now??

    I can't pair my iphone 4s with my imac.  It is very frustrating.  I can walk by anything resembling a  bluetooth and my iphone with pair...but not with my mac.  Any assistance would be appreciated.

  • TS1702 I have an iPad 1. I went to do an update on GarageBand and iBooks but it will not update. How do I return it to the original version?

    I have an iPad 1. I went to do an update on GarageBand and iBooks but it will not update. How do I return it to the original version?

    Well, to paraphrase the old line, "What're you gonna believe, that email or your own lying eyes?"
    The first thing I'd recommend trying is to power down your iPad (press & hold Sleep/Wake until the red OFF slider appears, then slide it to shut down), and then boot it back up and try again. You're resetting a bunch of state signals by doing that and this simple action (the first of a series recommended by Apple in your Users Guide) will quite often clear up these sorts of problems.

  • The keyboard for my iMac 9, 1 got wet and is not working correctlly. Delete,return, and some other keys not functioning. In all caps including numerals. I've left it to dry for a few days but still will not work. Computer now in Safe boot mode and I c

    The keyboard for my iMac 9, got wet and is not working correctly. Delete ,return, and some other keys not functioning. In all caps including numerals. I've left it to dry for a few days but still will not work. Computer now in Safe boot mode and I can't login due to all caps and numbers being symbols. Is there anything I can do?

    Buy a replacement keyboard. They're only $50-65 USD.
    27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

  • I have put Netflix on my Macbook Pro but Silverlight will not run. I receive a black screen that says "player error." Does anyone have a solution for this. Netflix support is not so hot.

    I have put Netflix on my Macbook Pro but Silverlight will not run.I receive a black screen that says "player error." Does anyone have a solution for this. Netflix support is not so hot.I can use Netflix straming thru my Blueray on my TV but it will not run on my Pro. Thanks

    Try running Safari in 32 bit mode.  In get info box for Safari,
    check open in 32 bit mode.  There have been some oddities
    on some systems that can cause some issues.
    I had thought MS had fixed this, but may not have.

  • Just i created an apple id but it will not support in my iphone so, what to do? any solution please?

    yeh! just i created an apple id but it will not support for my i phone so, what is the main solutions?

    Need som emore inforemation...  There has never been an instance where I have hear that a phone will not support an Apple ID...  What phone do you have, what iOS are you running, who is your carrier...

  • I can pair my iPhone 4 with my MacBook and my Macbook Pro but they will not connect. My iPhone keeps telling me it does not support this even with bluetooth turned on.The devices section keeps searching all the time

    I can pair my iPhone 4 with my MacBook and my Macbook Pro but they will not connect. My iPhone keeps telling me it does not support this even with bluetooth turned on.The devices section keeps searching all the time. Is this an antenna problem? Or something else ?

    Your iphone is right, it is not supported. The iphone's bluetooth protocols do not include file transfer, but are intendes only for headsets, stereo headphones, cars, and keyboards.

  • I can not type while voice support open and can not enter code what to do??, I can not type while voice support open and can not enter code what to do?

    I can not type while voice support open and can not enter code what to do??, I can not type while voice support open and can not enter code what to do?

    Is that VoiceOver? If so, follow the directions here:
    http://support.apple.com/kb/ht3577

  • HT1665 iphone says accesory is not supported, but I am not using an accessory

    Iphone says accessory is not supported, but I am not using an accessory.

    Check the cleanliness of your docking port: if necessary, clean it out with a dry toothbrush and/or canned air. Carefully. Don't mess up those contacts.

  • I can download a song to my IPhone. I can play on my iMac but it will not download to IPhone.  It is also in my ICloud but it still will not

    I can download a song to my IPhone. I can play on my iMac but it will not download to IPhone.  It is also in my ICloud but it still will not

    OK.
    Not sure why you are in the itunes forum.
    Your issue is with your MP3 player.  Go to their support page.
    Itunes syncs with Apple devices.  It has little or nothing to do with other players.
    Does your MP3 player support the file type of the song that your downloaded?

Maybe you are looking for

  • I can't burn a music disk

    iTunes will not burn a music disk. it starts to burn 1 or 2 tracks then stops and kicks the disk out.

  • How to get Material long text / Sales Text

    Hi, when I have created a service order I have enter Long text in Tab Item Details , i.e in sales Text I have entered some text , So can any one tell me how to get this text as I have to show this text in invoice printing Thanks Bobby

  • Converting jpg images in email to pdf fail

    I have a user who uses Adobe X Pro, Windows 7-64(all updates applied) to convert her emails to a pdf. She USED to be able to do thei without any issue using 9x Pro Now with X Pro, she right clicks on a folder in her email, and clicks "convert "xxxxx"

  • IPad not charging or displaying on iTunes

    I have had my iPad aroun 5 months now & about 3 weeks ago I plugged it in to charge (plugged into the mains) & it said Not Charging, so it clearly recognises it's plugged in, & then today I updated iTunes & went 2 sync my iPad & iTunes or my PC won't

  • Having problems with my Broadband and BT will not ...

    Hi For the last TWO years I have had problems with my broadband. The problem is that my hub keeps re-synic it self. Yes I know that this supposed to happen but surly not up to 10 times a day, (some times 6 times in one hour) Every Day. I have no exte