Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 158855 - Unnecessary cast warning missing?
Summary: Unnecessary cast warning missing?
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-26 15:59 EDT by Gary Gregory CLA
Modified: 2006-09-27 04:35 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Gregory CLA 2006-09-26 15:59:19 EDT
Eclipse SDK
Version: 3.3.0
Build id: I20060922-0010
(3.3M2)

In the following example, I was expecting a compiler warning:

package com.seagullsw.appinterface.server.backend.ims;

public abstract class AbstractA {
    class A extends AbstractA {

        public void callMe() {
        }

    }

    public abstract void callMe();

    class B {

        public void callSite() {
            // expect warning not there:
            ((A) this.getAA()).callMe();
            Integer max = new Integer(1);
            // execpted warning there:
            Integer other = (Integer) max;
        }

        public AbstractA getAA() {
            return null;
        }
    }
}
Comment 1 Philipe Mulet CLA 2006-09-27 04:31:31 EDT
We do not issue unnecessary cast warnings on receiver, since the actual receiver type is dumped into the classfile when invoking #callMe(). So removing the cast may alter the generated bytecodes, and we did not want to encourage this by emitting a warning.

So removing the cast will change your bytecode from:

invoke A#callMe()

to

invoke AbstractA#callMe()

which may be equivalent presently, but may behave differently once dealing with binary compatibility (in rare conditions).

No action planned
Comment 2 Philipe Mulet CLA 2006-09-27 04:35:05 EDT
Added CastTest#test041