Forced method implementation

Where do I go to suggest modifications to the Java language?
I sometimes have a method that I wish to implement in a class and force all sub-classes to implement this method as well. There is not really any way in java to do this.
A good example (although I could give many more) is the clone() method. I want a super-class to be able to implement the clone() method to copy all of it's fields. I then want a sub-class to implement the clone() methd to copy the fields specific to that sub-class. The problem is that if the sub-class doesn't implement the clone method, everything still compiles just fine, you just blow up at run-time wondering why you only have half an object.
I first thought that you could simply revise the rules surrounding the abstract keyword so that it allows you to provide implementation in an abstract base class and still require sub-classes to implement, but this doesn't work if your base class is concrete as well.
As this is the opposite of final, I looked up final in a Thesaurus and ended up with "elementary." Any other suggestions?
Where do I write this up?
thanks.

Are you kidding me?
I mean, I know that deep inheritance chains are clues to a bad design, but often? Take a look at the java libraries, bub! Reader and InputStream, e.g.
Take a look at the most basic example of inheritance: shape. A line is a shape. So is a circle, but they both sub-class the draw method. A rectangle is also a shape, but it has sides unlike a line or a circle, so it has extra properties. Every math textbook I've ever seen says that a rectangle is a special case of square, and you're telling me it might not be a sub-class because it needs to store the values of it's sides separately?
I'm not defending my design, because I don't feel like I have to. This is not an exception type of thing. There's far too many good reasons to do something like this for you to tell me this is a bad idea without me even providing an example.
But sense I'm a fair guy, I will anyway.
I have a Person class. Person is important in our system because it is a container of name, address, social security number, etc. Lots of information. It is a concrete class because there are people in our system who simply pass in and out without us doing anything with them.
Extended from person are classes Administrator and Participant, which, even though they are siblings, they are as different as night and day. An administrator is a contact point, not even a user, with special business rules. A participant is the person we're interested in in our app with specialized business rules and state that evolves over the course of time, sometimes years.
Do either of these seem like they're not people because they have lots of additional information other than what the person class does? Or maybe you think that simply because it has a concrete base class it shouldn't have a clone method?
Because if I don't implement the clone method at the person level, both sub-classes have to know all that stuff about their super-class which breaks encapsulation.
How about asking a question or two next time before jumping to conclusions about other people's code?

Similar Messages

  • Is it possible to force the implementation of a SAP note?

    Hi guys,
    I am installing SAP CPM, software components CPD 1.0 and PICM 1.0.  During the SAINT installation, I hit an error for both components in the ABAP Generation Phase.  I have found two notes with automatic corrections (1843317 and 2040519) to fix the errors.
    However, when attempting to implement both notes through SNOTE, it shows them as "Cannot be implemented".  I am assuming this is because the software components are not fully installed yet.
    I know that I can get the correction instructions from each note and manually put them in, but one of the notes has 15+ corrections.  Not exactly how I want to spend my day.
    Is there a way to force SNOTE to implement a note that is listed as "cannot be implemented"?  If not, does anyone have a better way to get the corrections applied besides doing each one manually?
    Thanks!
    -Jayson

    Hi,
    Here i would recommend to go for correction instruction instead of searching force implementation of SAP Notes as notes are used to fix bugs under some specific SAP standard codes and affects specific programs even and only recommended if support package still to be provided by SAP.
    Also need to check for the supported releases under SAP notes for performing corrections (strictly based or relevant for mentioned releases.)
    Hope you will understand and will try to avoid any issues by opting any force methods to implement the SAP Notes.
    Regards,
    Gaurav

  • Accessing Sender parameter attribute in event hander method implementation

    Hello knowledgeable friends.
    I would like a single event handler to manage two alv grid objects.  There is a parameter SENDER that is available in the method implementations to say which object triggered the event.  I would like to get at the attribute MT_OUTTAB but this syntax does not work:
    local_variable = sender->mt_outtab
    Any help would be greatly appreciated

    Ok, MT_OUTTAB is a protected Attribute.  I would settle for just the name of the Sender.  This code checks:
        call method sender->get_name RECEIVING name = l_name.
    but l_name is empty.  I was hoping for 'GRID1'; when I created the object I used:
        CREATE OBJECT alvgrid
          EXPORTING
            i_parent = container_top
            i_name = 'GRID1'.

  • Creating shared library of native method implementation using gcc

    Hi
    I am using Dev-C++ IDE for writing and compiling C Programs. It supports gcc.
    I have to build a shared library of a native method implementation using gcc compiler.
    In JNI tutorial build script is given for VC++ which is as follows
    cl -Ic:\java\include -Ic:\java\include\win32
    -LD HelloWorldImp.c -Fehello.dll
    Similarly I wanted build script for gcc compiler.
    Thanks
    Shailesh

    Here is an example of building a library from one module with CygWin's gcc:
    # Must set JAVA_HOME and LIBRARY_MODULE before
    gcc -mno-cygwin -D__int64="long long" -I $JAVA_HOME/include/win32 -I $JAVA_HOME/include -shared -Wl,--kill-at -o $LIBRARY_MODULE.dll $LIBRARY_MODULE.c

  • Understanding method implementation for LinkedList class

    Hello
    I'm new to java and just trying to get my head around data structures, particularly ArrayList and LinkedList implementations. I've looked at the Sun API for both classes, but would like to see how the methods are implmented so I can venture into writing my own versions of these classes..
    Does anyone know if there is a resource showing the full method implementation so I can view how they work?
    thanks,

    a really strange licence: look but don't touch, and it's still under copyrightThis license seems to make sense: you can look at it and learn from it but you are not supposed to make an own, incomptabile version.

  • Enums with constant-specific method implementation

    Just faced the following problem. I have a persistent class with one of the fields of it is enum with constant-specific method implementation:
    @Persistent
    public class Message
       static public enum Type
           DEFAULT
               @Override
               public String getDescription() { return "Some description"; }
           public abstract String getDescription();
       private Type type;
    }When I try to store the record, I get the exception:
    java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: messages.Message$Type$1The problem seem to be in that compiler creates a separate class, namely Message$Type$1.class for the DEFAULT instance and this class is not known by BDB..
    If I remove the constant-specific method from enum, everything's working fine (as the ..$1.class is not created by compiler).. Except the fact that I'd like to have constant-specific methods there..
    Any ideas on this? Maybe it's a bad idea to create constant-specific methods if it means that each constant would get own class file (and they would bloat the storage routines)?

    Hi Mikhail,
    I recreated the problem here and you're right, constant-specific methods aren't working. This isn't something we thought about, to be honest, or tested.
    Just based on an initial quick look I see that for the compiler generated class, the Class.isEnum method returns false, which is why we don't recognize this as an enum and eventually why we throw the exception you're seeing. But assuming that we can identify the class as an enum (that shouldn't be too difficult) I don't know what other problems we will run into in trying to support this.
    For now I think the best thing is to avoid using the constant-specific methods. I have opened a ticket (#18357) so that we'll remember to look into this in more detail and see whether it can be supported in the future.
    If we are able to support it, then I'm hoping that we won't to store extra metadata for constants that have methods. In other words, I'm hoping that we won't have to add any extra storage or processing overhead.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Force method overriding

    Hi, my problem is the following: (basic sketch)
    class A {
         public void y() { ... x(1, 5); ... }
         protected void x(int i, int j) { ... }
    class B extends A {
         protected void x(int i, int j) { ... }
    The meaning of which is that B is supposed to change part of y()'s behavior.
    Now when in a project classes are modified all around, it may happen that someone changes the signature of A.x(), say to x(int i, int j, int k)
    This immediately causes that calling B.y() produces no different behavior than calling A.y(), which is not intended.
    So is there a way to force that B.x() must override a method in the base class? I would like to have it such that if A.x()'s signature changes and B.x()'s not, then a compile-time error occurs. (It makes sense if x() is some function with distinctive charasteristics, no overloaded forms, etc.)
    Maybe it can be reached somehow with abstract methods?
    Thanks,
    Agoston

    Something like this is what I've finally come up with:
    Please note that I wasn't allowed to change the fact that B extends A for other reasons in the real application.
    class A {
         protected interface I {
              void x(int i, int j);
         private static class AX implements I {
              public void x(int i, int j) { ... }
         private I getI() { return new AX(); }
         public void y() {
              I i = getI();
              i.x(1, 5);
    class B extends A {
         private static class BX implements I {
              public void x(int i, int j) { ... }
         private I getI() { return new BX(); }
    Requires a little additional work, but it's worth it so you don't have to check A if x()'s signature is still the same and B still does what you want, because whoever changes AX.x()'s signature, has to change I as well, and gets a compilation error if BX.x() isn't modified accordingly.

  • Interface method implementation

    While Implementing a method gety() i am getting follwing error -
    gety() in class B cannot implement gety() I ;attempting to assign weaker access privilees; was public
    class B extends A implements I {
    int i;
    public B(int a,int b) {
    int q = super.i;
    System.out.println(q);
    i = b;
    void show() {
    System.out.println(X);
    System.out.println("i in subclass:" +i);
    void gety() {
    System.out.println("my");
    interface I {
    public static final int X=3;
    abstract void gety();
    }

    If interface I says gety is public, then code that
    uses an I expects it to have a public gety method.
    Since B "is-a" I (by virtue of the fact that it
    implements I), it has to do everything I promisesto
    do.Nice class names... it makes it sound like you just
    have really bad grammar :)Just following what the OP had. But yeah, I noticed that as I was typing, but couldn't be bothered to change it.

  • Can a method implemented from interface be native ?

    This is a bit of a SCJP question.
    interface One
    public void someMethod();
    public class One_impl implements One
    public native void someMethod();
    Assuming that the native method is not provided in any local library, an attempt to compile and run the above lines
    of code will cause
    1. Compilation error - implimentations can never be native.
    2. Compilation error - method not found in local libraries.
    3. Runtime Exception - method not found in local libraries.
    4. Compilation successfull but runtime error is thrown if and only if the method someMethod of class One_impl is
    called
    My question is can a implemented method be native ?
    I am totally blank about native methods in Java.(Does this dismiss the right to put a question and study native methods in Java first ?)
    Thanks.

    ejp wrote:
    My question is can a implemented method be native ?Yes.
    I am totally blank about native methods in Java. (Does this dismiss the right to put a question and study native methods in Java first ?)It does suggest that you could have read the JLS first.Maybe reading native methods in JLS would clear things for me.
    Thanks.

  • Debbuger never stop in BADI 'BBP_WFL_APPROV_BADI' 's Method Implementation

    Hi Experts,
    We are implementing the PO n-step BADI workflow WS14000145 . I have implemented the method 'GET_REMAING_APPROVERS' of BADI 'BBP_WFL_APPROV_BADI', but when I put a break-point, the debbuger never stop!!!... please help about it!.
    Thanks in advance.

    Hello,
    Try the following:
    - Set a breakpoint at function BBP_PDH_WFL_DB_UPDATE;
    - Craete the cart. Breakpoint should stop in FM above;
    - Change variable IV_IN_DIALOG to X (it is blank originally);
    - Set a breakpoint at BBP_WFL_DIN_APPR_BY_RULE_GET. In here the badi to determine the approvers is called;
    - F6 down until the call of this badi, i.e. CALL METHOD lv_wfl_appr_list_exit->get_remaing_approvers.
    Regards,
    Ricardo

  • Using SEO_METHOD_ACTIVATE with methods implemented from Interface

    Hi,
    I'm trying to create a class and activate it using some ABAP code. I began by copying a template class into a new class called ZKMOD_COPY.
    Now I want to activate this class. I tried SEO_METHOD_ACTIVATE but all it does is set the flag to 'A' in the table. It doesn't really activate the whole class I see in SE24.
    Going through the forums, I came across ABAP Objects where someone said to call these in order: SEO_ATTRIBUTE_ACTIVATE, SEO_EVENT_ACTIVATE,  SEO_METHOD_ACTIVATE, SEO_TYPE_ACTIVATE
    Now my class does not contain any attributes, events or types. It contains just one method, so I suppose except SEO_METHOD_ACTIVATE I don't really need the others.
    Now this method (called EXIT) is implemented from an Interface IF_RSCNV_EXIT. In the class definition of ZKMOD_COPY, it shows this method by the name IF_RSCNV_EXIT~EXIT.
    The problem is that I'm not able to activate this method. I can't figure out what parameters to give in CIFKEYand  MTDKEYS
    I tried all permutations of "zkmod_copy", "if_rscnv_exit" as classes, "exit" and "if_rscnv_exit~exit" as the methods, but it kept throwing exceptions like not specified or not existing. Debugging the FM also did not give me any clues.
    So what I really need is, what parameters should I give there? Alternatively, is there any way I can programmatically activate my class? This may sound a silly question, since I'm a BI guy with not too much ABAP knowledge, but I'd be really grateful if someone could help out with this.

    Matt,
    We have some Customer Exits in BI. I'm trying to develop a kind of program that will generate the code for a customer exit class. So probably I would have an FM take some params, create the class with some static member attributes (not yet fully designed), so that it is ready to be used as a customer exit.
    It's all still nebulous - I'm finding the various things that I feel I will need.
    CIFKEYS I think is the -> IF_RSCNV_EXIT
    MTDKEYS-CLSNAME is IF_RSCNV_EXIT
    MTDKEYS-CMPNAME is EXIT.
    In this, the name of the class ZKMOD_COPY is not used anywhere. But IF_RSCNV_EXIT is an interface, it can be implemented by any number of classes. So shouldn't the class name (ZKMOD_COPY) be mentioned somewhere? How would the system know which implementation of IF_RSCNV_EXIT should be activated?
    At present I'm not in front of a system; I'll try this on Monday and get back to you. Thanks for the help anyway, Matthew!

  • Regarding Interface methods implementation

    Hi,
    I have a interface with 3 methods.
    public interface test{
    public void A();
    public void B();
    public void C();
    public class IntImpl implements test{
    public void B(){
    //implementation
    Can we implement an interface with out implementing all the methods of interface .instead implementing a few methods in the interface?
    i came to know that we can do the above one with out any exceptions? So any of you can resolve this issue ..
    Thanks in advance
    Sri

    Can we implement an interface with out implementing
    all the methods of interface .instead implementing a
    few methods in the interface?In other words: can we implement an interface without implementing it?
    The answer should be obvious.
    i came to know that we can do the above one with out
    any exceptions? Sure, it's quite easy, you already did it. The stuff above won't compile, hence it won't throw an exception when running.
    Or you can also avoid compiler errors by declaring IntImpl as abstract. Which means you didn't implement the interface though.

  • Methods Implemented in Other Classes

    Dear all,
    In our system I found such a class. In t-code SE24, some of its method names are displayed in blue fonds, instead of ordinary black fonds. When I double click on the method names, a pop-up window indicates "Method xxx is implemented in class yyy". I have no idea about the relationship between the original class and the class yyy. Can anybody explain such a situation?
    Thanks + Best Regards
    Jerome

    Hello Jerome
    If you display class CL_GUI_ALV_GRID in transaction SE80 and open the folder "Methods" you will see which method will be displayed in "blue":
    - all methods in sub-folder <b>Inherited Methods</b> are shown in blue
    - some of these inherited methods have been redefined within the class (folder Redfinitions) and are displayed in "ordinary" black font
    Which is the superclass of CL_GUI_ALV_GRID? Simply display the <b>Properties </b>tabstrip of the class. There you see that CL_GUI_ALV_GRID_BASE is the superclass.
    Thus, all methods displayed in blue are methods inherited from the superclass that have not been redefined.
    Regards
      Uwe

  • Org.jcp.xml.dsig.internal.dom.DOMKeyInfo equals() method implementation

    I use something like this:
    if(myKeyInfo.equals(anotherKeyInfo))
    //I believe two signers are same. It seems correct.
    Behind the scene the KeyInfo is implemented by org.jcp.xml.dsig.internal.dom.DOMKeyInfo.
    I would like to have a look at org.jcp.xml.dsig.internal.dom.DOMKeyInfo to find out how its equals method is implemented.
    Basically I would like to make sure wether myKeyInfo.equals(anotherKeyInfo) is the right way to ascertain the signer.

    You can find the source in a few different places, either in the Apache XML Security project repository or the JDK 6 and OpenJDK projects on java.net. Here is a pointer to the JDK 6 source:
    https://jdk-jrl-sources.dev.java.net/source/browse/jdk-jrl-sources/jdk6/trunk/j2se/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java?rev=3&view=log

  • Looking for Java Input Method implementations

    Hi,
    I have developed a Java-based research application for computational linguistics. I'm currently internationalizing this application. I'm looking for FREE implementations of the Java Input Method Framework. Could you please give me a hint?
    Thanks in advance,
    Wolfgang Lezius
    University of Stuttgart, Germany

    http://forum.java.sun.com/thread.jsp?forum=16&thread=270024 contains few useful links.

Maybe you are looking for

  • Using iMac as display for laptop PA

    I have a work laptop connected to a docking station that I would like to send video over to my 2012 iMac.  Is this possible?  The docking station has ports for VGA, DVI, and displayport and I need to find out a way to get the image from there to the

  • How to change the index page of tomcat to a specific page in a  web app.

    hi all i am trying to figure out a way to change default application to a specific web application deployed in tomcat, so that when you type localhost:8080, it will start with the web app. basically i want to get ride of the context or map the contex

  • PCF file missing hostname and other information

    Using Cisco VPN Client 4.8.01.0300, several users have reported issues with being unable to launch the VPN Client software. The client returns Error 5 - Hostname not available; upon reviewing the .PCF file, the hostname and other group info is now mi

  • Full version 10.4 install

    I am installing a full version OS10.4 on to my imac whenever it gets here, it's the first flat panel imac that came out, anyway because it is full version and not an upgrade do I still need to install the 10.1 and the 10.3 that came with this imac fi

  • Can KEYNOTE do what ARTICULATE does?

    I have a PC-based client who is looking for me to convert their Powerpoint presentations into web-based and/or Flash-based presentations. The program they have used in the past to do this was ARTICULATE, which is not available for the Mac. It does an