Help in Object.clone()

Hi All,
why i am unable to call the clone() in Object class from the subclass of the Object class.
Obj o1 = new Obj(); //Simple bean class.
o1.clone() //error.error:- the method clone() from the type Object is not visible
note : clone() is protected and native.
Thanks
Dorairaj M
Edited by: DoraiRaj on Apr 13, 2010 9:02 AM

malcolmmc wrote:
dcminter wrote:
I don't see the big problem.No a big problem that I know of - it just didn't offer anything you couldn't do with copy constructors and but did put up minor obstacles as well as adding an unnecessary method to Object.What it does offer is a method to copy the fields of an object all in one go, rather than having to list them or use introspection. A copy constructor wouldn't do that for you. Also you can clone a superclass reference and have all the fields of a subclass still copied. A copy constructor is unlikely to do that.Exactly. That's why I figured clone() might be preferred--the polymorphism more than the all-in-one bit. I guess it depends on your requirements.

Similar Messages

  • {@link Object#clone()} , -link does not work!!

    I have a problem with this!!
    Somehow the -link option does not work very well.
    I have ensured that I did correctly set my command option -link to
    -link http://java.sun.com/j2se/1.4.1/docs/api
    I have already imported java.lang.Object at the top of my source code.
    When I tried to use {@link Object#clone()}, it doesnt work at all.
    I have also tried all sorts of names like fully qualified ones and such.
    The hyperlinks do not appear ( i.e. they just appear as plain text but not hyperlinks!!) I realise the ONLY way I can get it to point to the correct link is
    {@link <a href = "http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Object.html#clone()">clone()</a>}
    which is very lame.
    I want to be able to write doc @tags such that I do not have to specify the full complete http address.
    Anyone can help ? Thank you very much!!
    P/S: I know this is a bug in 1.2.2 javadoc but I suppose this bug would have been fixed by now....
    Regards
    David

    I would upgrade to 1.4.2. That should fix the problem.
    -Jamie Ho

  • Crash in jvm.dll: Object.clone()

    I'm working on a desktop app that sometimes runs cpu- and memory-intensive graph manipulations. We just saw the following error. I don't like to assume that I've found a JVM bug, but of all the explanations I've thought of so far that seems to be by far the strongest.
    # An unexpected error has been detected by Java Runtime Environment:
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d8fe397, pid=4680, tid=3752
    # Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode windows-x86)
    # Problematic frame:
    # V  [jvm.dll+0xfe397]
    ---------------  T H R E A D  ---------------
    Current thread (0x4b8ec800):  JavaThread "Precomputing action graphs" [_thread_in_vm, id=3752, stack(0x4e4b0000,0x4e8b0000)]
    siginfo: ExceptionCode=0xc0000005, reading address 0x80000068
    Registers:
    (cut)
    Top of Stack: (sp=0x4e8af53c)
    (cut)
    Instructions: (pc=0x6d8fe397)
    0x6d8fe387:   eb 0b df 2c c8 df 3c ca 83 e9 01 7d f5 8b 57 04
    0x6d8fe397:   8b 42 68 89 45 0c 8b 4d 0c 89 0f 8b 15 34 06 a3
    Stack: [0x4e4b0000,0x4e8b0000],  sp=0x4e8af53c,  free space=4093k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    V  [jvm.dll+0xfe397]
    J  java.lang.Object.clone()Ljava/lang/Object;
    J  com.fairisaac.....cloneArrayListofShortArray()
    j  java.lang.Thread.run()V+11
    v  ~StubRoutines::call_stub
    ---------------  P R O C E S S  ---------------
    Java Threads: ( => current thread )
      0x4b6eac00 JavaThread "Thread-13" [_thread_blocked, id=4064, stack(0x4ee00000,0x4f200000)]
    =>0x4b8ec800 JavaThread "Precomputing action graphs" [_thread_in_vm, id=3752, stack(0x4e4b0000,0x4e8b0000)]
      0x4b780800 JavaThread "prefuse_ActivityManager" daemon [_thread_blocked, id=4196, stack(0x4c8f0000,0x4ccf0000)]
      0x4b804000 JavaThread "Thread-5" [_thread_blocked, id=1488, stack(0x4f200000,0x4f600000)]
      0x4b855800 JavaThread "Swing-Shell" daemon [_thread_blocked, id=4328, stack(0x4d0e0000,0x4d4e0000)]
      0x002a7000 JavaThread "DestroyJavaVM" [_thread_blocked, id=6124, stack(0x008c0000,0x00cc0000)]
      0x4b6d7800 JavaThread "D3D Screen Updater" daemon [_thread_blocked, id=804, stack(0x4c280000,0x4c680000)]
      0x4a56f000 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=260, stack(0x4be80000,0x4c280000)]
      0x4a513000 JavaThread "TimerQueue" daemon [_thread_blocked, id=5028, stack(0x4ba80000,0x4be80000)]
      0x4a447400 JavaThread "AWT-Windows" daemon [_thread_in_native, id=5108, stack(0x4adf0000,0x4b1f0000)]
      0x4a4bd000 JavaThread "AWT-Shutdown" [_thread_blocked, id=2516, stack(0x4a9f0000,0x4adf0000)]
      0x4a4a6800 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=6108, stack(0x4a5f0000,0x4a9f0000)]
      0x48e15c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=5896, stack(0x49f20000,0x4a320000)]
      0x48e0f800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=4496, stack(0x49ed0000,0x49f20000)]
      0x48e0e000 JavaThread "Attach Listener" daemon [_thread_blocked, id=2180, stack(0x49ad0000,0x49ed0000)]
      0x48e0cc00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2468, stack(0x496d0000,0x49ad0000)]
      0x48dfc800 JavaThread "Finalizer" daemon [_thread_blocked, id=5300, stack(0x492d0000,0x496d0000)]
      0x48df7c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=4656, stack(0x48ed0000,0x492d0000)]
    Other Threads:
      0x48df2c00 VMThread [stack: 0x48e80000,0x48ed0000] [id=1776]
      0x48e20000 WatcherThread [stack: 0x4a320000,0x4a370000] [id=4820]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation   total 72576K, used 40121K [0x02d40000, 0x07c00000, 0x07c00000)
      eden space 64512K,  50% used [0x02d40000, 0x04d38588, 0x06c40000)
      from space 8064K,  91% used [0x07420000, 0x07b560c0, 0x07c00000)
      to   space 8064K,   0% used [0x06c40000, 0x06c40000, 0x07420000)
    tenured generation   total 967936K, used 420542K [0x07c00000, 0x42d40000, 0x42d40000)
       the space 967936K,  43% used [0x07c00000, 0x216af9f0, 0x216afa00, 0x42d40000)
    compacting perm gen  total 16896K, used 16857K [0x42d40000, 0x43dc0000, 0x46d40000)
       the space 16896K,  99% used [0x42d40000, 0x43db64e8, 0x43db6600, 0x43dc0000)
    No shared spaces configured.
    VM Arguments:
    jvm_args: -Xmx1024m -Xss4096k -Djava.util.logging.config.file=logging.properties
    java_command: com.fairisaac.ruleviz.demo.Application -triad -datadisplay -edit -reorderable -comparable
    Launcher Type: SUN_STANDARD
    ---------------  S Y S T E M  ---------------
    OS: Windows XP Build 2600 Service Pack 2
    Memory: 4k page, physical 2097151k(1247624k free), swap 4194303k(4194303k free)
    vm_info: Java HotSpot(TM) Client VM (11.0-b15) for windows-x86 JRE (1.6.0_10-b33), built on Sep 26 2008 01:00:43 by "java_re" with MS VC++ 7.1

    inferno0069 wrote:
    Thanks, but I'd already found that out from the first search I did.
    We have no JNI code. I am pretty certain that no library we use has any either, though if you have a 100% way to verify or enforce that, it could be helpful.
    Short of parsing class files that isn't possible. A library might use a OS library so you can't just look for a shared library.
    Assuming I'm right in that last paragraph, is it more likely that we found some sort of bug in Sun's native code (maybe already discovered?) or that there was a hardware failure (e.g. bad memory / CPU produces wrong bytes)?Or software on the system that is causing it. Patches in the wrong order, bad patches, corrupted, etc can cause it.
    >
    Is there a different part of hs_err_... that I could post to make answering these questions easier? The full thing didn't fit because of the character limit on this forum.An actual VM bug with a crash is only 'solvable' by creating a bug and attaching the crash file.
    Posting it here is unlikely to produce a solution.
    A solution is unlikely to show up soon via the bug nor the forums. If you have a sales/support contract with Sun that might lead to a solution.
    If you don't have that then your only choice is to use log files to determine where the crash occured, and then try different code to see if it goes away.

  • Guidelines to help center objects and text in pages

    Where are the guidelines to help centre objects and text in the new pages?

    well YMMV.  https://discussions.apple.com/thread/5472111?tstart=0
    You have to do it manually.  Also can be in the accomplished in the right hand column Format>Select your image>Arrange

  • Why would Object.clone cause IncompatibleClassChangeError

    I have 3 classes,
    B, A, and M
    public class B implements Clonable
    public Object clone() throws CloneNotSupportedException
    { return super.clone(); } // basically Object.clone()
    public class A extends B { ... }
    public class M extends A { ... }
    A and M do not override clone
    sometime, not all the time, I get this IncompatibleClassChangeError when
    M.clone() is invoked. I don't know why, since I'm not doing anything profound, or why it would happen only some times. I'm running java 1.4.2_04-b05

    You can try having each of your subclasses also implement Cloneable. Granted, this is a bit of copy-pasted code to keep calling super.clone(). See if that fixes it.
    - Saish
    "My karma ran over your dogma." - Anon

  • Need Help with the Clone Tool

    I need help with the clone tool, in that when I clone (let's say grass as example),  the new cloned area does NOT come out as sharp as the area selected.  It comes out much softer and somewhat blurred.  I have the opacity and flow both set at 100%.  This is very frustrating since I can not get a true clone.

    what "tip" do you have selected? where are you sampling from ( found in top option bar) ALSO make sure MODE is normal
    http://helpx.adobe.com/photoshop/using/retouching-repairing-images.html
    -janelle

  • F help for objects

    Hi all,
          can any body tell to get F4 help for object attributes in table controls.
      actually i got f4 help for object using SWO_DIALOG_OBJTYPE_VAL_REQUEST.
    like this i want function module to get f4 help for attributes.

    Hello,
    Please check the roles related to the below authorization object.
    Authorization Object  
    S_WFAR_OBJ          
    Value  
    NV          
    Value  
    VBRK          
    Value  
    YP3INVOICE          
    Value  
    03          
    archiving Related role will give you access to View the billing document in PDF.
    Thank you
    Regards
    Bala

  • Object clone ?

    How does an Object clone code works ? Here is one example code I'm trying to understand.
    class Rabbit implements Cloneable
       public Object clone()
          try
             return super.clone();
          catch ( CloneNotSupportedException e )
             return null;
       } // end Rabbit
    Rabbit r1 = new Rabbit();
    Rabbit r2 = (Rabbit)r1.clone();Why there is to implement Cloneable interface in the above example? I think there is no need of implement Cloneable interface.
    Clone() method is available in Object class . We can override the clone() method as similar we do for toString() , equals method of Object class.

    jverd wrote:
    Not exactly: the example overrides clone only to extend its visibility (from protected to public) to be able to call it from outside the class. Here is another example that enables cloning without overriding the clone method:
    public class CloneableClassWhichDoesntImplementCloneMethod implements Cloneable {...}
    The problem with this, of course,...OK, I agree that the construct is a bit unusual and misleading.
    Again (again), my example was in the context of Jussi's sentence, which was not fully correct IMHO. I wouldn't recommend the approach I quoted.
    is that if I see that, and don't take the name literally, then I might expect this to work (...)And you'd be right :o)
    public class CloneableClassWhichDoesntImplementCloneMethod implements Cloneable {
        private int doomsday = 2001;
        public Object getClone() throws CloneNotSupportedException {
            return super.clone();
        public static class MyCloneable extends CloneableClassWhichDoesntImplementCloneMethod {
            private String subclassAttribute = "Nice try, Jeff";
            @Override
            public MyCloneable clone() throws CloneNotSupportedException {
                return (MyCloneable) super.clone();
        public static void main(String... args) {
            MyCloneable o2 = new MyCloneable();
            try {
                MyCloneable o4 = o2.clone();
                System.out.println("Field values have been cloned? "+(o2.subclassAttribute.equals(o4.subclassAttribute)));
            catch(CloneNotSupportedException cnse) {
                cnse.printStackTrace();
    Or if I notice that there's no public clone() method, despite implementing Cloneable, I'll be going, "WTF?"Well, you'd be right to complain against the bonehead-who-thought-it-clever-to-commit-artistic-code-before-switching-job-instead-of-following-well-known-idioms.
    EDIT (reworded stupid remark to look a little less stupid)
    But that's only an idiom, or even, a convention, stemming from Cloneable not declaring the method as public: if the JDK designers and the JLS had meant that implementing Cloneable implies having a public clone() method, they would have added it to the interface itself.

  • About object clone/copy

    I wish to get a copy of an object which is another object with different reference and memory space from the original object.
    I checked with Object.clone(), and found that it in fact do nothing and requires me to write a method to override it for the specific object photocopy I wish to do.
    Do I understand it wrongly or is there other simple way to achieve it (get a clone of an object without coding myself)? Because I think that object clone is not difficult for JVM, so there should be some method provided already to do it......
    Thanks in advance!
    Rgds,
    alaska8341

    All you have to do is:
    public class MyClass implements Cloneable {
       public Object clone() {
          return super.clone();
       // Rest of your code
    }

  • Help creating a clone of my boot environment

    I am running Solaris 10
    I am booting from SAN and want to clone my Boot Environment to another SAN Lun.  I keep running into the error ERROR: Root pool <vnxsanpool> is not a bootable pool.  I have formated the disk EFI label with format -e and have a root partition with 60GB (Whole Disk) on slice 0 and a backup partition on slice 2 60GB.  I created the zpool with zpool create disk0 and then try and do lucreate -n vnxBE -p rootpool
    Thanks for your help.

    Hi,
    Solaris 10 needs an SMI (VTOC) label on the root pool disk. This is a long-standing boot limitation.
    Convert the disk label to SMI by using format -e. Watch that it doesn't put on a default label with 128MB in slice 0.
    If it does, move the disk space back to s0.
    See these pointers:
    SPARC: Setting up Disks for ZFS File Systems (Task Map) - System Administration Guide: Devices and File Systems
    x86: Setting Up Disks for ZFS File Systems (Task Map) - System Administration Guide: Devices and File Systems
    Thanks, Cindy

  • PCH: Value help for Object ID

    Hi Experts,
    I have a question regarding Logical Database PCH.
    We know LDB PCH is OM based and we have  default "Object ID field " and "Reporting period field " at the selection screen.
    I have kept "Reporting period" as "Key date" 31.12.2010. I  wanted to select an Org unit from the "Org. Structure Search" at the ""Object ID field " value help . But I can see the "Org. Structure"  corresponding to  "Today's date" all the time.
    For eg: Org unit 1111111 was delimited on 01.01.2011.  I wanted to se the Org. structure for 31.12.2010. So I put the key date as 31.12.2010. Since the above org. unit is delimited on 01.01.2011, it was expected to see in the Org. Structure at the "Object ID" value help . But unfortunately, it is not displayed, since the Org. Structure is shown based on Toda's date.
    If anybody comes across such a scenario, please provide your inputs .
    Thanks in advance,

    There is a search component that can be used for this purpose.
    This is one function out of several. I don't have the complete implementation at hand but this will give you the first idea.
    CALL METHOD cl_crm_uiu_prod_tools_search=>eh_onclosepopup_return_product     
       EXPORTING       
          ir_search_popup = search_popup     
       CHANGING       
          cr_context_node = lv_target_node       
          cv_index        = gv_tableindex. 

  • WebDynpro Methods help for objects in ABAP editor

    Hi,
    is there a possibility to see the methods that can be used by an specific object?
    For example which methods I can use with the object wd_this.
    Thank You!

    You will need to drill into the underlying class to view its methods.
    http://help.sap.com/saphelp_nw04s/helpdata/en/35/447741b0d6157de10000000a155106/frameset.htm
    Regards,
    Rich Heilman

  • Need Help converting objects in a TreeMap to String

    This app counts the number of times a word occurs in a document. I used a HashMap to store the key and value. The I sorted them using TreeMap. Now I need to return the key (String) and value (Integer Object) so they may be print like this -- 'key: value'.
    Example:
    that: 3
    This mean the word 'that' appeared 3 times in the document. Below is my toString() method. TreeMap sorts everything for me but I cant return 'map' because it is not a String. So I iterated through each key and value in the map. But now I dont know how to put all the iterations into 1 String value. I would greatly appreciate any help. Code below.
    Thanks in advance.
    public String toString() {
    Object key = null;
    Object value = null;
    map = new TreeMap(map);
    Set getKeys = map.keySet();
    Iterator iterKeys = getKeys.iterator();
    while (iterKeys.hasNext()) {
    key = (String)iterKeys.next();
    value = map.get(key))
    return; // i need to return a String here
    } // end toString()
    } // end class

    I dont remember posting to the "new Java forum", but I might have. My browser locked up on me so I am not sure what happened. If I did please excuse my double post.
    Are you familar with a way to solve my problem?

  • Help - draw objects doesn't appear on JFrame

    i got this code from a book...
    import javax.swing.*;
    import java.awt.*;
    class Ch5SampleGraphics {
    public static void main( String[] args ) {
    JFrame win;
    Container contentPane;
    Graphics g;
    win = new JFrame("My First Rectangle");
    win.setSize(300, 200);
    win.setLocation(100,100);
    win.setVisible(true);
    contentPane = win.getContentPane();
    g = contentPane.getGraphics();
    g.drawRect(50,50,100,30);
    the problem is when i run the app, the frame doesn't always show the rect drawn. sometimes it shows it, but usualy not. if it does show the rect, once i click on minimize, then reopen it from the taskbar, the rect will disappear again and will never show up.
    can anyone help me? i've been searching for answers but to no avail. thanks 4 reading, hope someone will offer some help.

    an intoduction to oop with java
    Jesus wept. The code's about as un-object-oriented as you could possibly make it.
    Looking at his sample chapter on the book's web page all I see is main() methods with linear code in and just simple number crunching with primitive types. No objects to speak of at all.
    I'm sticking with my "throw the book away" advice :o)

  • Search help for OBJECT ID with Text Description for a query

    I need to create search help for the field object text in HRP1000 - P1000-STEXT table in an infoset based on LDB PCH. Can anyone help me? I want it to appear on the adhoc query screen.
    Thanks,

    look at search help FC_RFCDEST. that problem has already been solved with this search help.

Maybe you are looking for

  • Oracle SES File source type configuration

    Hi Experts, I am facing one problem while creating new File Source & giving path like "file://localhost///Doclib/docs1" where "Doclib" is a server name & "Docs1" is a shared folder which is accessible from Oracle SES box. But when i run the crawler i

  • Graphic bugs with Mac os x

    I installed Labview 8.5 Student on my Mac but i get this bugs when displaying the properties of elements: I tested Labview 8.5 on my Macbook Pro (10.5) and on my imac (10.4) - same results. Anyone here has some advice for me? Attachments: Fehler2.jpg

  • Ecc6-app

    In ECC 6, for APP the following parameters are used a)payment medium program--RFFOUS_C b)Name of print dataset--LIST1S c)Form for the payment medium: F110_PRENUM_CHCK d)form for the payment advice--F110_D_AVIS we are not able to get check format as w

  • How to setup JAVA_HOME or JRE_HOME for veridata, and newest Java version

    when I test veridata agent connection to source db, I got following error: Agent remote message (101): Unhandled exception 'java.lang.UnsupportedClassVersionError': (oracle/jdbc/pool/OracleDataSource) bad major version at offset=6 Then I checked java

  • Dock showing 10 unread mails that aren't there

    I have checked all the folders within both accounts (Gmail & MobileMe) & there are no unopened mails. I have checked both accounts on-line to see if there are any discrepancies. There are no RSS feeds to open no reminders & nothing in the trash but s