Baffling Interface Casting - How is this supposed to work

I am trying to cast one interface to another. You can cast one interface to another if all the method signatures and return types in the "to" interface apprear in the "from" interface.
I am confused as to what should happen if the return type is the interface itself. for example
package rob;
public interface Test {
     public Test foo();
should I be able to cast this to
package foo;
public interface Test {
     public Test foo();
The reason that I am confused is that if I use Eclipse to compile, it works, however under JDK 1.3.1 I get the following error
C:\workspace\Cast>c:\jdk1.3.1\bin\javac Tester.java
Tester.java:26: interfaces foo.Test and rob.Test are incompatible; both define foo(), but with different return type
rob.Test var = (rob.Test)foo();
^
1 error
We have worked around this issue, but I am interested in knowing what the correct answer is. The language specification is a little vague in this point. It states that if the return types of a method are different then the incompatable error should be seen at compile time.
While I agree that rob.Test is different to foo.Test a return type of Self should be dealt with differently shouldn't it ?
If anyone knows the right answer, or why this works in Eclipse please let me know
Many Thanks

You can cast one interface to another if all the method signatures
and return types in the "to" interface apprear in the "from" interface.Sorry, this sentence is not correct!
You could check the Java language Specification.
In fact, the 2 interface you wrote are totally different, even
they contents exacte method signiture.
rob.Test and foo.Test are 2 things, and no compatible.

Similar Messages

  • Client/server architecture - how is this supposed to work?

    Hi all,
    I am in the initial throws of developing a client server program - my very first - and have been studying the forums for answers, BUT...
    I am curious how this process works without using RMI...?
    To pass primative types or objects to the server from the client I can use serializable, however, how does one also call a method on the server AND pass these variables as the parameters? Is this even possible or am I not thinking this through properly?
    This is the order of operation I had in mind...
    1. Send an int over the connection
    2. Use the int in a switch statement at the server side to invoke the correct method
    3. The method then reads the serialized data stream and casts to the expected objects/types.
    4. Method executes and sends back any data in the same manner.
    The process must be common practise? Surely there is a less convoluted way of doing this?
    It would be great to suss out a way of doing this without jumping to RMI 'just yet'...
    Gracias!
    Message was edited by:
    hagend
    Actually, I think RMI is probably the easiest way of implementing this. I beleive I misinterpreted aspects of RMI - ALL GOOD!

    CORBA, basically it is RPC just like RMI, but a little different.

  • I've searched to no avail for this problem. Similar posts but none that tell me what to do. I can't add or delete any bookmarks on my iPad 2 running the newest iOS. I know how it's suppose to work, it just isn't working!

    I've searched to no avail for this problem. Similar posts but none that tell me what to do. I can't add or delete any bookmarks on my iPad 2 running the newest iOS. I know how it's suppose to work, it just isn't working!
    It started after the major update to iOS 7.
    I can't believe that this is so hard to do. It's just not letting me. I can add a bookmark to the home screen just fine, just not in a bookmarks folder anywhere I try.
    I've used Apple products since 2001 and have always loved how intuitive they are. But the Safari browser since iOS 7 has been the worst I've experienced. At least right in the beginning after that update.
    I'd really appreciate any help that doesn't just tell me how it's suppose to work...I know that.
    My iPad 4 is not affected with the problem and works as it should.

    To delete, tap "Edit" (tap to enlarge image)

  • Is this how pacman is supposed to work? (dependency "problem")[SOLVED]

    Hi
    Just did a fresh install of archlinux after buying a new computer.
    Installed some drivers.. kde (and some other stuff)
    Then.. just for the fun of it I removed qt3 with pacman -Rd.
    I was expecting that pacman -Syu would see that a dependency was missing and try to reinstall qt3.
    So I did a pacman -Syu, and what happened? Nothing.. pacman says all is okay, well all is not okay cus kde will not work without qt3.
    Is this how it should work or is this a bug? I checked the manpages for some kind of "install all missing dependencies" but found nothing..
    /Ivan
    Last edited by Fuel (2008-01-23 01:34:22)

    fwojciec wrote:
    That's not how Arch is supposed to work.  Arch is about giving power to the users.  With power comes responsibility, and this responsibility falls on the users in this case.  Remember -- this is a "do it yourself" kind of distribution and so if what I want to do is to screw up my system I should be able to do it in an easy, efficient and elegant way.  This is consistent with the mission statement of the Arch Linux project, this is how Arch works and this is why many of us love it.
    On a personal note, if Arch/pacman tried to hold my hand more, like you suggest it should, I'd be switching to another distro very, very quickly.
    It's not really about trying to get arch/pacman to hold your hand for you. It's more about giving the possibility to recover from a serious mistake. If you can tell me something wrong with adding an option wich checks for missing dependencies on your system and how that particular feature intervenes with "the arch way" - then please do.
    I'm not saying arch is bad, arch is actually the best linux distro I've used so far - but there is something common with almost all distros - you get dependency problems after a while, one way or another.
    Thats why I think there should be a way to resolve such issues.

  • How are we supposed to work with the new motion tweens if there's no motion editor anymore?

    How are we supposed to work with the new motion tweens if there's no motion editor anymore? Without motion editor we can't see what kind of keyframes are set and we can't set any accelerations anywhere. Does Adobe now want us to go back and use the old motion tweens?

    Hi All,
    Flash Pro CC 2014 (v 14.0.0.110) is now available for download via the Creative Cloud App.
    We have included an all new Motion Editor along with several other new features with this release of Flash Pro. The new Motion Editor is completely redesigned, intuitive and easy to use while preserving the core functionalities and backward compatibility with Flash CS6
    To Invoke the Motion Editor, simply Double-Click on your Motion Tween span on Timeline (or Right-Click and select 'Refine Motion') and the Motion Editor opens up in-context in the Timeline itself. Double-Click again to collapse once you have made your adjustments.
    Complete list of New features in Flash Pro CC 2014 is available at these links:
    Overview:         https://www.adobe.com/in/products/flash.html
    Whats new:      https://helpx.adobe.com/flash/using/whats-new.html
    Release Notes: https://helpx.adobe.com/flash/release-note/flash-professional-cc-2014.html
    Videos:           https://helpx.adobe.com/in/flash.html
    Thanks,
    Nipun

  • How is PUSH *supposed* to work?

    I have just moved from a v1 iPhone to a 3G. I have had the 3G for 3 days.
    I'm trying to understand how the PUSH function works. The User Manual is not very clear.
    I'm using Mobile.Me
    I am not getting an alert when my phone is 'asleep'. Is this normal? (I would have thought the point of PUSH was that you are alerted when there is email .... )
    I can send myself a test, which is picked up pretty much instantly by my desktop Macs, but even if I leave the iPhone untouched for say 20 minutes, then wake it up, there is still no message. If I then go into the Mail app. (on the iPhone) it will then connect, download and alert me.
    This doesn't seem like the correct behaviour.
    Any explanations of how it is supposed to work would be most welcome.
    Grant Symon

    RomingGnome, Deggie, Thanks.
    I think what happened was that I had deleted my non-standard MM account on the iPhone, but then of course, when I did the first sync, it was replaced from the MM servers.
    I have now left this account on the iPhone, but turned it off, and made a new MM, standard account, which I then synced, did a test and it worked immediately, with alert, whilst the phone was asleep. Very very cool and just what I wanted.
    I shall now have to experiment to see if I can get the non-standard MM account to work too. All this because Apple won't let us use a non MM 'return address'. How dumb is that? Still ... one has to hope that with Apple trying to push the iphone towards enterprise, they might notice that [email protected] is not really the return address most business users are going to want.
    Thanks again,
    Grant

  • How does this IMPORT statement works

    can any one tell me how does this statement will work..
    I am wokring on Solution manager system , where in there is a function module SSF_FIELD_LIST
    to which system passes form name.
      import fields to fieldlist
             from database stxfcontr(sf) id l_fullname.
    stxfcontr is a table which contains value of in  a diff
    Regards,
    mayank

    It will import data object stored in memory under named fields to your custom data object fieldlist .
    The table which it is stored is name stxfcontr under RELID (memory area) SF .
    Cluster key (key of the entry) in that table is behind var l_fullname
    Anyhow I think [this link|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3bf8358411d1829f0000e829fbfe/frameset.htm] is more that any explanation. Once you study it, you will understand the above.
    Regards
    Marcin

  • HT5642 How is it suppose to work I don't no what to click ????

    How are yu suppose to get the update I can't find where to click plz helpppp!!!!!! XC

    Heheyunno wrote:
    I tried that it didn't work...
    This Information is too little and too vague.
    Suggest you read the Entire Link posted above.
    If you still have Issues...
    Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
    Be sure to make an appointment first...

  • How does this SAVE View works in WAD ?

    Experts,  Before putting this question, i did search for this isssue but couldnt find the correct answer.
    when i run the query in portal i get the correct report. but when i right click on any of the charastractis, i could see the drop down list with some options. in this list of options, there is one entry "Save View"
    I tried saving it, with technical name and desc. but i couldnt find it anywhere.
    does anyone has idea ? how this save view works in Portal ?
    thanx

    Hi, plz. find my answers inline.
    My question is how can we make use of this View. So, what is the importance of VIEW ? How users get benefited ?
    >> If you have scenarios wherein users would want to carry out their own analysis & save for future reference/records, then query views prove to be beneficial. Else creating individual queries to suit user preferences is cumbersome & time consuming.
    I was researching on SDN, and found that if i save it As a VIEW. then if we change the query. the saved view remains unchanged. is that right ? But, what if i remove some characteristics from the query ? Does it remove from the VIEW too ?? Or, Its just, if we make some changes to Key figure structure. It wont make any impact on view.
    >>  You execute a query with its initial view, change the initial view by navigating in the data, and save this new navigational state as a query view. If you later change the initial view of the query in the BEx Query Designer, this change has no effect on the query view previously saved. The query view already exists as an independent object.
    Please let me know. if you find some documentation please post a link, i am happy to read that.
    >> http://help.sap.com/saphelp_nw70/helpdata/en/46/0294bc82f37041e10000000a155369/content.htm
    That if you are using WAD and save as view, you can open using BEx analyzer or the other way around ?
    >> You can create and open a query view from BEx Analyzer or Web / WAD, as long as you have the option to.
    --Priya

  • How does this Oracle job works

    Hi everyone!
    One of my buddy has created t his job:
    sys.dbms_job.submit(jobno, 'SendEmail();', (sysdate + 2/86400), null);
    Its sending the emails very frequently.
    How should this job work? Please guide me.
    Thanks in advance.
    Nith

    Here's a demo of an application code / user submitting a job frequently. Each time the JOB_ID changes but the job "seems" to be present in USER_JOBS. It is a new job each time ! The DBMS_JOB.SUBMIT call does not specify an INTERVAL, so a submitted job is executed only once and exits from the queue. The next submission seems to be the same job, but is actually a new one --- which you can identify because JOB_ID changes.
    10:09:21 SQL> create or replace procedure send_email
    10:09:21   2  as
    10:09:21   3  begin
    10:09:21   4   -- do some processing, send an email
    10:09:21   5   null;
    10:09:21   6  end;
    10:09:21   7  /
    Procedure created.
    10:09:21 SQL>
    10:09:21 SQL> variable jno number;
    10:09:21 SQL>
    10:09:21 SQL> exec dbms_job.submit(:jno,'send_email();',(sysdate+5/86400));
    PL/SQL procedure successfully completed.
    10:09:21 SQL> commit;
    Commit complete.
    10:09:21 SQL>
    10:09:21 SQL> select job, what, next_date, next_sec from user_jobs;
           JOB WHAT                                          NEXT_DATE NEXT_SEC
           146 send_email();                                 25-MAY-11 10:09:26
    10:09:21 SQL>
    10:09:21 SQL> exec dbms_lock.sleep(10);
    PL/SQL procedure successfully completed.
    10:09:31 SQL>
    10:09:31 SQL> exec dbms_job.submit(:jno,'send_email();',(sysdate+5/86400));
    PL/SQL procedure successfully completed.
    10:09:31 SQL> commit;
    Commit complete.
    10:09:31 SQL>
    10:09:31 SQL> select job, what, next_date, next_sec from user_jobs;
           JOB WHAT                                          NEXT_DATE NEXT_SEC
           147 send_email();                                 25-MAY-11 10:09:36
    10:09:31 SQL>
    10:09:31 SQL> exec dbms_lock.sleep(10);
    PL/SQL procedure successfully completed.
    10:09:41 SQL>
    10:09:41 SQL> exec dbms_job.submit(:jno,'send_email();',(sysdate+5/86400));
    PL/SQL procedure successfully completed.
    10:09:41 SQL> commit;
    Commit complete.
    10:09:41 SQL>
    10:09:41 SQL> select job, what, next_date, next_sec from user_jobs;
           JOB WHAT                                          NEXT_DATE NEXT_SEC
           148 send_email();                                 25-MAY-11 10:09:46
    10:09:41 SQL>
    10:09:41 SQL> exec dbms_lock.sleep(10);
    PL/SQL procedure successfully completed.
    10:09:51 SQL>
    10:09:51 SQL> exec dbms_job.submit(:jno,'send_email();',(sysdate+5/86400));
    PL/SQL procedure successfully completed.
    10:09:51 SQL> commit;
    Commit complete.
    10:09:51 SQL>
    10:09:51 SQL> select job, what, next_date, next_sec from user_jobs;
           JOB WHAT                                          NEXT_DATE NEXT_SEC
           149 send_email();                                 25-MAY-11 10:09:56
    10:09:51 SQL>
    10:09:51 SQL> exec dbms_lock.sleep(10);
    PL/SQL procedure successfully completed.
    10:10:01 SQL>
    10:10:01 SQL> -- Now, since I have not resubmitted the job, it doesn't appear any more !
    10:10:01 SQL> select job, what, next_date, next_sec from user_jobs;
    no rows selected
    10:10:01 SQL>Notice how the job doesn't appear at the last query ? Because the application / user did not resubmit it after the previous submission and query. So it has "disappeared".
    Hemant K Chitale
    Edited by: Hemant K Chitale on May 25, 2011 2:23 PM
    Edited by: Hemant K Chitale on May 25, 2011 2:25 PM

  • How does this Linked List work?

    Hi.
    I wonder how this linked list work
    import java.util.Scanner;
    public class LinkedList {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            Elem front = null;    // First element of list.
            Elem back  = null;    // Last element of list.
            while (in.hasNext()) {
                String word = in.next();
                Elem e = new Elem();     // Create a new list element.
                e.data = word;           // Set the data field.
                if (front == null) {
                    front = e;            // Back element will be set below.
                } else {
                    back.next = e;       // Link last elem to new element.
                back = e;           
            System.out.println("*** Print words in order of entry");
            Elem curr = front;
            while (curr != null) {
                System.out.println(curr.data);
                curr = curr.next;
    class Elem {
        public Elem next;    // Link to next element in the list.
        public String data;  // Reference to the data.
    }Does anyone know how this allocates memory?
    I feel strange because it's just front = e
    and back = e
    but it never says anything like front.next = back or something..
    Can anyone help me on this?

    Does anyone know how this allocates memory?Memory is allocated on this line:            Elem e = new Elem();     // Create a new list element.
    I feel strange because it's just front = e
    and back = e
    but it never says anything like front.next = back or something..Well, it doesn't need to. Setting .next is taken care of after the initial element is added. It never explicitly says front.next = back because front.next is set when the second element is added. It's set implicitly, on this line:                back.next = e;       // Link last elem to new element.It's implicit in that at that point front and back point to the same element.

  • How does this configurator module work?

    Hello,
    I'm a PHP programmer that has some work that I need to do for
    a client.
    He owns an online tshirt store and wants to develop a
    configurator similar to the own seen here:
    http://propercloth.com/custom-mens-shirts.php#
    You can see as you select fabrics & components the image
    of the shirt on the left updates with the texturised version. My
    client already has a database of his materials ready to plug into
    something like this. I'm quite unfamilar with flash as I mainly do
    backend PHP and I was wondering if someone here might know how this
    flash module works or has some experience coding one so I can get
    my head around how this thing works.
    What is required to create or how would I go about creating:
    1. The base model tshirt
    2. Individual components such as pockets that can be
    shown/hidden
    3. The texturisation engine
    4. Populating the base model with a selected material
    (colour)
    Any advice much appreciated!
    Marv.

    There is no flash on that page. All of that animation is done
    using Javascript. It looks like its using elements from the jquery
    library. You can find out more about it at
    http://www.jquery.com. There are
    other libraries with similar functionality. I prefer mootools:
    http://mootools.net/ .

  • How does this LIKE operator work ?

    Values JOHN and KEITH have spaces in the string.
    create table string_test ( test_str varchar2(15));
    insert into string_test values ('JO HN');
    insert into string_test values ('JOHN');
    insert into string_test values ('RAM');
    insert into string_test values ('KEITH ');
    SQL> select * from string_test;
    TEST_STR
    JO HN
    JOHN
    RAM
    KEITHFrom OTN , i found the query to find all string values which has a white space in it.
    select * from string_test where test_str like '%' || chr(32) || '%';But, i don't understand how this works. Won't the percent sign in single quotes ('%') be considered a literal ?

    GarryB wrote:
    Values JOHN and KEITH have spaces in the string.
    create table string_test ( test_str varchar2(15));
    insert into string_test values ('JO HN');
    insert into string_test values ('JOHN');
    insert into string_test values ('RAM');
    insert into string_test values ('KEITH ');
    SQL> select * from string_test;
    TEST_STR
    JO HN
    JOHN
    RAM
    KEITHFrom OTN , i found the query to find all string values which has a white space in it.
    select * from string_test where test_str like '%' || chr(32) || '%';But, i don't understand how this works. Won't the percent sign in single quotes ('%') be considered a literal ?No, because the "%" sign has special meaning to the LIKE operator. It's a wildcard meaning any characters.

  • Audio Interface Problems -- How to make it simply work

    Hello all. I recently bought a Tascam US-122L audio interface and cant seem to get it to work. It plugs in through the USB on my Macbook and lights come on so I know it is powered up and connected, and the warning comes up that an audio device has been located. I even get a signal on the screen from my track when I strum the guitar, but I cant figure out how to get the output to come out through the speakers so I can hear while I play. I'm also new to Logic and really dont know how to work it so I'm even more lost than when I tried to get it to work through garageband which was eventually successful. What settings should I change so that the recording comes from my interface and I can hear what I play through the speakers? Also any help on setting up a good modern rock distortion sound with presets would be most appreciated. Thanks!

    Ah
    I think it is actually an Apple App switcher thing.
    So if the finder window does noy cover the After Effects Project window, it works, but if you have to use the app switcher, sometimes it works and sometimes it doesn't.
    I don't think it is a file type issue, so much as a live application issue, or maybe GPU related.
    It's a weird thing, not that important, but it does limit where you can and can't drag from.
    Tris

  • How is iTunes suppose to work...does the Playlist on the SLVR's display...

    Dear All,
    I hope I have not overstayed my welcome. Can anyone who has a "properly" working SLVR with iTunes tell me how many buttons you must push to use iTunes and its Playlist? Do you have to enter the card memory first and then click on each songs icon to play it? Do you see your Playlist?
    See my earlier thread on this SLVR's reluctant to be able to put tunes on the Playlist.
    Thanks in advance. I will be looking forward in any responses.
    Sincerely,
    MacOwner
    G4 powerbooks17s(1.33 and 1.5GHz)    

    Dear toonz,
    Again, much thanks. I will attempt to download tunes via the Windows XP to download - hopefully, it will give me some prompts to lead me.
    I hope not to sound too inept but the procedure I used earlier was to connect the SLVR to the computer with iTunes up and wait for the SLVR to appear. When it does, I then drag and drop the desired tune then disconnect.
    That's it. No other action. Then, I activate the SLVR to see if the song is in the PLayList. It never is.
    Is it due to the SLVR's action to just take the dragNdropped tune and store it anywhere because there is no command by me to tell where to store it?
    No need to respond. I do not want to monopolize your time. But if you do, please accept my thanks in advance.
    Sincerely,
    MacOwner
    G4 powerbooks17s(1.33 and 1.5GHz)    

Maybe you are looking for

  • Best way to hook up Airport Express with a current Airport Extreme network

    I currently have an Airport Extreme (7.2 firmware, N version, but right now running mixed mode because all my clients are G, and using WPA/WPA2), and I am thinking about getting an Express to use it to share a printer and the Airtunes feature. My Ext

  • Lost files, can't find them but they're there!

    all my files have disappeared from my powerbook g4 but the memory use implies they're still there on pcs in the past it's been possible to turn the clock back so to speak and restore the computer to it's state at a previous date, ie you mess somethin

  • Cannot Sync iPhone Video back to iPhone

    Alright, so I took some video on my iPhone 3GS. As part of my normal archiving process, I have all photos and videos from the iPhone automatically imported into a specific album ("iPhone Album") in Adobe Photoshop Elements 7 upon connecting my iPhone

  • Can I use iMovie to commercial videos on youtube?

    Hello! I have a question, Can I use iMovie to commercial videos on youtube? Yours!

  • Stopping and Starting a server - bootstrap pattern?

    Hi, I have a very simple server. It simply extends Thread, and provides a startup method to perform any initialization and to start itself. A shutdown methods performs any cleanup. What I am trying to figure out is the best way to start/stop this ser