Cannot override protected fields

I know this is not possible, but my question is why did they design it
that way:
public class ParentForm {
protected String name = "ParentForm";
protected String getName(){return name;}
public class ChildForm extends ParentForm{
protected String name = "ChildForm"; //I am trying to override
the field value but reuse the method from parent.
public class Test {
public static void main(String[] args) {
System.out.println((new ParentForm()).getName());
System.out.println((new ChildForm()).getName());
Output:
ParentForm
ParentForm
I wanted to see "ChildForm" in the second line. Why do I have to
duplicate (literally cut and paste) the getName() method in the child
to achieve it ?
Can someone explain the concept I am missing ?

Wouldn't it be good have the privilege ofsaying,
"I
am extending your class wherein I want to
inherit
everything from you except override the value ofthis
one field" ? I've never encountered a situation where thatwould
be useful.Well, it will surely save a lot of unnecessary coding
writing dummy methods.I've never had to write dummy methods.
Like I said, I think the real problem is in your design.

Similar Messages

  • Overriding protected static instance variable???

    Hi there,
    I am trying to use the MVC-pattern (model-view-controler) pattern. I want a certain class to have a protected static variable:
    class A{
    protected static SomeADependingListener myListener = new SomeADependingListener();
    }but as class B extends A, but should react differently to mouseevents, keyboardevents..... I want that B has another listener, but it should have the same variable-name:
    class B extends A{
    protected static SomeBDependingListener myListener = new SomeBDependingListener();
    what happens if I do so? If I create an instance of B are there now two objects created (listeners), or only one?
    Could someone explain this to me please?
    Thx
    Sincerely
    Karlheinz Toni

    You cannot override a field. You can only shadow it. That is, there will be no relationship between the two declarations. It is generally not recommended to use shadowing because it leads to confusing programs.
    In your example methods inside class A will see only the field myListener defined in class A. Methods inside class B will (without qualification) see the field myListener defined in class B. But methods in class B can access the other myListener field in A by writing A.myListener.
    You should re-think your design.

  • MultiProvider report not functioning - overwriting protected field

    Hello,
    I have a multiprovider that combines data from the Sales Overview cube (0SD_C03) with a custom plan cube (data from COPA and SIS).  In writing queries off of the (active) multiprovider, short dumps occur except when only running against one infoprovider.  In other words, if the query is restricted to only show Sales data (0SD_C03), it works fine.  If the query is restricted to only show Plan data (custom plan cube), then it works fine.  However, the intersection of the two does not work - which is the entire functionality of the multiprovider (a join). 
    I've cut the query back to the very basics:  Fiscal Year and one Key Figure (that is present in both source infocubes).   Without specifying or splitting out the InfoProviders, it should combine the data (total the two), but instead creates a short dump.  Using a structure to split Actuals from Plan also results the short dump.  The only way to get the report to actually execute and return is to restrict it to just one InfoProvider.  I tried copying the MultiProvider and starting over, but that did not improve the situation.  The failure occurs after the variable screen has been filled in.  (Also tried w/out variables.)
    Using LISTCUBE, the data is found in a single execution (no filter applied to 0INFOPROV) and splits out to the two infoproviders w/ approp. fiscal year and Key Figure totals.  So there seems to be something at the reporting layer malfunctioning.
    Here's the ST22 short dump:
    Does anyone have any ideas?
    Runtime Error          MOVE_TO_LIT_NOTALLOWED_NODATA                                         
    Date and Time          07/17/2006 09:57:23                                                   
    ShrtText                                                                               
    Assignment error: Overwriting a protected field.                                        
    What happened?                                                                               
    Error in ABAP application program.                                                                               
    The current ABAP program "SAPLRSDRC" had to be terminated because one of the            
    statements could not be executed.                                                       
    This is probably due to an error in the ABAP program.
    rror analysis                                                                               
    The program tried to assign a new value to the field "<L_SX_OLAPQUERY>" even though it is protected against changes.                                                                               
    The following objects are protected:                                                       
       - Character or numeric literals                                                            
       - Constants (CONSTANTS)                                                                    
       - Parameters of the category IMPORTING REFERENCE for functions                             
         and methods                                                                               
    - Untyped field symbols to which a field has not yet been assigned                         
         using ASSIGN                                                                               
    - TABLES parameters if the corresponding actual parameter is protected                     
         against changes                                                                          
       - USING reference parameters and CHANGING parameters for FORMs if                          
         the actual parameter for this is protected against changes                               
       - Field symbols if the field assigned using ASSIGN or ASSIGNING                            
         is protected against changes                                                             
       - External write accesses to READ-ONLY attributes                                          
       - Key components of lines in internal tables of the type HASHED or                         
         SORTED TABLE                                                                               
    SORTED TABLE.    
    Message received in web report when failure occurs:
    Error when processing your request 
    Note
    The following error text was processed in the system BW1 : Assignment error: Overwriting a protected field.
    The error occurred on the application server bw_BW1_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Function: RSDRC_CUBE_DATA_GET_DISP of program SAPLRSDRC
    Function: RSDRC_MULTI_CUBE_DATA_GET_PARA of program SAPLRSDRC
    Function: RSDRC_MULTI_CUBE_DATA_GET of program SAPLRSDRC
    Form: DATA_GET of program SAPLRSDRC
    Function: RSDRC_CUBE_DATA_GET of program SAPLRSDRC
    Function: RSDRC_CUBE_DATA_GET_OLAP of program SAPLRSDRC
    Form: FILL_SP_1 of program SAPSRRK0
    Form: FILL_SP of program GP42GWU130B57UDR97PLRZOUC5Z
    Form: DATEN_LESEN of program SAPLRRK0
    Function: RRK_LIST_NOTIFY of program SAPLRRK0
    Thanks in advance!

    Hello
    Check OSS notes as below am not sure if it helps
    957439 - Query dumps with an error
    Below is for 3.5 and below ,just to let you know that there were similar problems in earlier version.
    941862 - *** Dump MOVE_TO_LIT_NOTALLOWED_NODATA with MultiProvider
    Chetan
    @CP..

  • Cannot add form fields in document

    Acrobat Pro version 9.1.2
    Windows XP SP 3
    I have a document that I cannot add form fields to. When I try I get a message that says "You cannot edit the file as a form due to its security settings.
    When I go to Advanced->Security->Show Security Properties. The security method is set to No Security and everything is "Allow" under the Document Restrictions Summary.
    Where is there a security issue?

    Lori,
    How did you identify the PDF/A option? I am just curious for my future reference. I could not find it.
    ==================
    Rupey,
    The fonts are not embedded and that may also be something to address. A lot of these issues may be related to the 3rd party product used to create the PDF.

  • Cannot see form fields on EBay and Ad trader sites

    cannot see form fields on EBay and Ad trader sites. when asked to fill a form with item details the boxes that you have to fill in are missing. using Firefox 3.6.2. i have contacted Ad trader with the question but have got no replies.
    i have to use Internet Explorer to see them. does anyone have the solution to my problem? i hate explorer so much and Firefox is so quick i use it as my main browser.
    == URL of affected sites ==
    http://http://www.adtrader.co.uk/

    "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"<br />
    "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"<br />
    <br />
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).<br />
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]<br />
    <br />

  • Initializing a protected field in a subclass doesn't work

    Why doesn't this work? And if it shouldn't, how do I get around it?
    public abstract class Ship
         protected double rotationSpeed;
         protected aMethod()
              System.out.println(rotationSpeed);
    public abstract class Cruiser
         protected double rotationSpeed = 3;
    }I thought that when the method 'aMethod' it would print out '3' but it doesn't. I'm not sure why, I also tried this:
    public abstract class Cruiser
         public Cruiser()
              rotationSpeed = 3;
    But it didn't change it. How do I alter protected fields like this?

    happypigface wrote:
    Awesome, thanks, using super worked.You're welcome.
    Note that you don't need to use the 'super' keyword:
    class Cruiser extends Ship {
        public Cruiser() {
            rotationSpeed = 3; // this works too
    }but I find it clearer to use it.
    I didn't think it really mattered if I posted the code running it. I didn't really have one. The names of those fields and classes aren't real.
    ...IMO, it's best to post an SSCCE of the problem/question.

  • Password protect fields in interactive pdf

    Hi all,
    I have completed an interactive pdf online form and I want to make one of the sections (several fields) password protected. So two questions:
    How do you password protect fields?
    Do you have to apply password protection to each individual field or can you highlight a section (several fields) and password protect the whole section?
    Would really appreciate some help.
    Thanks so much. . .

    Many thanks George for your helpful advice. It is appreciated.
    Bridie Hanifee
    Pearson Trueman & Associates
    T:: +61 3 9864 7107
    F:: +61 3 9866 4811
    www.pearsontrueman.com<http://www.pearsontrueman.com>
    Please consider the environment before printing this email
    CAUTION - this message may contain privileged and confidential information intended only for the use of the addressee/s named above. If you are not the intended recipient of this message you are hereby notified that any use, dissemination, distribution, or reproduction of this message is prohibited. If you have received this message in error, please notify the sender immediately.

  • HT4437 Cannot play protected movies on AirPlay from iPad

    I cannot play a movie from my iPad to my Apple TV device. I get an error "cannot play protected movies". Why is this when I bought the digital copy with the Blu-ray Disc ?

    I'm not aware of any third-party receiver that supports video over AirPlay, so you'll probably need an Apple TV. But then, as long as you have a WiFi network in your house, you should be able to play the movie through the Apple TV to your projector without needing Internet as long as the movie has completely downloaded. For more information on AirPlay see:
    http://support.apple.com/kb/HT4437
    In some cases, though, people have reported that even with the rental completely downloaded (or so they said) it still asked to connect to the iTunes Store, so it's not 100% reliable, it seems.
    Regards.

  • Adobe reader cannot open protected mode

    I downloaded and installed Reader X,  and get the see the message adobe reader cannot open protected mode due to configuration errors.
    The link provides no information as to what the problem is.
    I have Windows XP SP3 (with all the updates) and using Avira AntiVir as the antivirus.
    How do I get to the protected mode?

    Hi,
    The problem does not seem to be with Avira Antivirus Personal Edition.
    Are there no unsupported configurations mentioned in the link
    http://kb2.adobe.com/cps/860/cpsid_86063.html#main_Unsupported_configurations
    on your system?
    Also please let me know the following details:
    1) Was ReaderX installed at the default path or the installer path changed manually?
    2) Are the PDF files you are trying to open kept on any local disk or any kind of network share?
    3) Please disable all the antispyware, antimalware and firewall installed in your system and then verify.
    4) Please tell the kind of user(admin/standard/guest ) who is trying to open PDF files.
    Thanks .

  • CANNOT OVERRIDE DOCUMENT ROUTING ID FOR SPECIFIC TRADING PARTNER FOR ROSETT

    Cannot override Document Routing ID for specific trading partner for RosettaNet transactions.
    The Document Routing ID for other transactions types (e.g EDI) can be overridden when creating operation capability for a trading partner by unchecking "Use Existing Document Proto Parameter Values" and "Use Default Document Definition".
    This does not work for RosettaNet transactions as no option to override the values is available when "Use Default Document Definition" is unchecked.

    Hello,
    I have replicated this issue and it appears to be a bug. I shall follow up regarding the same.
    Rgds,Ramesh

  • I understand the latest version cannot be protected by "Avast" antivirus. Is this correct? I have stopped using firefox for this reason.

    I understand the latest version of firefox cannot be protected by Avast antivirus. Is this true? I have stopped using firefox until it can accommodate avast.

    You can look at the new pre-release version of Avast.
    *http://forum.avast.com/index.php?topic=80362.0

  • Frm-40208 from running in query mode. cannot change database fields

    Hi,
    Could some one help me with this.
    I am calling a form from another form. I am passing the parameter list to the calling form and doing a query by setting the block property. But when queries the message
    FRM-40208 Form running in query mode. cannot change database fields .
    I do not want the message to appear when they go the called form . Please some one could help me how could I avoid displaying the message.
    Regards
    Bain

    Hi,
    Good day! I am working with a module that also calls another form. It uses call_form with query mode parameter set to query_only. My problem is, whenever i call the other form using the call_form, it would display the called module and then as it populates the detail block of the called form, it will display frm-40208 from running in query mode. cannot change database fields per record. What I want is for the message to be displayed only once.
    I have tried capturing the error by using on-error trigger, but it doesn't go to that whenever the other form was being called. I think the message has to do with the post-query trigger, because it passes some values on a dbase block objects.
    Do you have any suggested solutions or workarounds to make the message display only once whenever the other form is being invoked by the call_form?
    I would greatly appreciate any suggestions/ideas.
    Thanks and regards,
    ASantiago

  • FRM-40208: Form running in query-only mode. Cannot change database fields.

    Hi,
    I am using forms 6i where it is calling a form from a menu in query like call_form(,query_only). Now an error is occurring on call of that form ‘FRM-40208: Form running in query-only mode. Cannot change database fields.’ Though this is been handled to give a certain message from on_error message from a package from library.
    Now the issue is that the error keeps on popping even after the ok button is pressed. There are number of records from the table. How can we handle the error. Any suggestion would be really appreciated!!!
    Regards,
    Rajesh

    thanks Gred but i have resolved the issue. it seems that each row was going into query_only mode (program written such a way). therefore the error was showing even after the OK button. handled the issue from ON_ERROR trigger. anyway thanks for your time Gred!

  • How to use reflection to get base classes protected field

    I have one base Base classes which have protected fields and public get method to get the field.
    class Base
    protected int proField;
    public int getProField(){return proField;}
    Class Derive extends base class Base
    class Derive extends Base implements OtherInterface
    public void funtion(){};
    Now I have an instance of Derive, how can I use reflection to get the protected field inherited from Base. It seems Java Reflection only give runtime accessibility to public field and decleared field, protected-inherited field is excluded.
    Thanks
    Lei

    as the last poster said, traverse up the class hierarchy.
    ex:
    private void doSumfinToField(String fieldName throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException {
    Class clazz = getClass();
    Field field = findFieldInClass(clazz, fieldName);
    //field.doSumfin;
    private Field findFieldInClass(Class clazz, String fieldName) throws NoSuchFieldException {
    try { // to find the field in this class    
    return clazz.getDeclaredField(fieldName);
    } catch (NoSuchFieldException e) {
    // if we don't have a superclass, continue
    if (clazz.getSuperclass().equals(Object.class)) {
    throw e;
    // check in the superclass
    return findFieldInClass(clazz.getSuperclass(), fieldName);
    }

  • Cannot password protect CSV file

    I had a CSV file (workbook) that I password protected. Up until yesterday, I was prompted for a password to open this file, but this morning, I was not longer being prompted for a password. I tried opening the file in Excel 2013 and 2010 with the same result. 
    I tried to create a new CSV file (in both versions) and password protect the file (similarly to what I had done before) but the file did not retain the password protection.
    Has anyone had problems password protecting a CSV file? Is there somewhere documented that .CSV files do not support password protection.
    I am a little puzzled why it was working for several months, but now it is not.
    Thanks
    Andres

    Hi,
    I agree with Mr. Hans, we cannot password-protect it from Excel. I suppose that your CSV file may be encrypted with some code/third-party program. Please see the sample below:
    https://social.msdn.microsoft.com/Forums/en-US/e2e21aa2-0e48-4188-a63f-085fecb55b71/csv-file-encryptiondecryption
    Hope it's helpful.
    Regards,
    George Zhao
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click "[email protected]"

Maybe you are looking for