Clone() has protected access

I want to make a copy of a class instance. The class is Process. I've tried
Process outpt = (Process)p.clone();
I get clone() has protected access in java.lang.Object.
How do I get a copy of a variable? Not a reference to the original variable?

You can't, unless it has had a proper clone() method written for it. And Process hasn't, most likely because copying a Process doesn't make much sense. Is there a reason you need to copy it and not just make another reference to it? How would you expect the two choices to behave differently?
(And your question should have asked how to get a copy of an object, not a variable. There's a difference between the two things.)

Similar Messages

  • Constructor LOVAttributeInfo has protected access

    I'm trying to build a dynamic combo box.
    So I built a view object and made the view link for it, etc. I then created an LOV rowset based off of it. Which is generating the following errors.
    "constructor lOVAttributeInfo(java.lang.String) has protected access in class oracle.dacf.dataset.LOVAttributeInfo"
    How do I fix this? It seems like this should be a simple fix, like checking some radio button in the view object, but I haven't found anything yet.
    null

    Try this instead:
    Date date=new Date();
    date.setTime(msec);
    dateOfPick.setTime(date);
    V.V.

  • How to use the method finalize () ? It has protected access...

    Here is the program : the structure is the way I would write in Pascal.
    I need new object question at each turn in the loop ! But question is already defined outside the loop. So, I thought to the method finalize (). But the compilator doesn't agree.... It would be a good thing however to destroy objects wich are obsolete !
    public class MM {
       public static void main (String [] args) {
          Base base = new Base ();
          base.demanderNbCouleurs ();
          base.demanderNbPions ();
          Combi solution = new Combi ();
          solution.demander ();
          Combi question = new Combi ();
          question.cueillir ();
          question.afficher ();
          Reponse reponse = new Reponse ();
          reponse.demander ();
          boolean trouve = reponse.getBP () == base.getNbPions ();
          boolean erreur = false;
          while (! trouve & ! erreur) {
             question.enregistrer (reponse.getBP (), reponse.getMP ());
             question.finalize ();
             Combi question = new Combi ();
             question.cueillir ();
             while (! question.compatible () & ! question.getVide ()) {
                question.cueillir ();
             if (question.compatible ()) {
                question.afficher ();
                reponse.demander ();
                trouve = reponse.getBP () == base.getNbPions ();
             } else {
                erreur = true;
          conclusion (trouve);
       }

    So, I did ;
             question = new Combi ();And it's magical ! The program works...
    Now, I would like to give colors to my researcher Mastermind :
    1 2 3 4
    4 4 1 1 ... BP MP : 0 2
    1 1 6 5 ... BP MP : 1 0
    1 3 4 3 ... BP MP : 1 2
    1 2 3 4 ... BP MP : 4 0
    Trouve !
    I want the 1 to be red, the 2 be yellow, the 3 be green and so on...
    Is there any procedure " textColor " ?
    here is my method afficher () :
       public void afficher () {
          // Affiche le tableau 'combi'.
          for (int i = 0; i < NB_PIONS; i++) {
             // textColor (couleur [combi );
    System.out.print (" " + combi [i]);

  • Default/protected access question

    Why does this work:
    The class below extends TreePath but is in a foreign package to TreePath. The call at *1* is to a constructor in TreePath that has "default" access. Shouldn't this fail to compile since the "default" modifier only allows classes in the same package access? The call at *2* works as I would expect since the TreePath constructor being called there has "protected" access.
    Thanks,
          * Subclass of treepath with needed public constructors.    
         private class ExtendedTreePath extends TreePath {
              public ExtendedTreePath(Object singlePath) {
                   super(singlePath);                                        // *1*
              public ExtendedTreePath(TreePath parent, Object lastElement) {
                   super(parent, lastElement);                               // *2*
         }

    Hmm... That is odd. I get a slightly different, but no more helpful, compiler message. I know that an object has to implement Cloneable in order for the clone to succeed, but that's just a tag interface that should lead to a runtime exception.
    I think a slight adjustment in thinking about "protected" explains it:
    "Protected means it can be called by classes in the same package, and by subclasses, and this class (like every class) is a subclass of object, so why can't it be called?"
    That's what I thought. What I would suspect is the case, though, has to do with clarifying the "and by subclasses" piece of that rather imprecises wording of the rule.public class MyClass extends Object {
        public void meth() {
            Object obj1 = new Object();
            Object obj2 = obj2.clone(); // or, I imagine, any protected method would fail here
            MyClass mine = new MyClass();
            mine.meth2(); // this should work, It think
            super.clone(); // this should work
        protected void meth2() {
    } I don't really know how to word this very well, but it seems that we can only call protected methods on super, or, I would guess, on other members of our class. We can call Object's clone (or other protected) method if we're call it on super, but not on an arbtirary object.
    I don't know if that's correct, but play around with it, or re-read the relevant parts of the JLS and see if it jives.

  • Problems with protected access in java.util.vector

    Hi,
    basically i'm trying to use the method removeRange(int,int) of class Vector from the java API.
    I keep getting the following compiler message:
    removeRange(int,int) has protected access in java.util.vector.
    This seems rather vague, and i don't know quite what to do?
    Thanks in advance

    removeRange(int,int) has protected access in java.util.vector.
    This seems rather vague, and i don't know quite what to do?As error messages go, that's pretty clear: method removeRange is a protected method and you can only call public ones of Vector, right? You can always combine subList and clear:
    vec.subList(fromIndex, toIndex).claer();

  • Protected access

    i read this and this and got the impression that i could do what i intent:
    i have a class that is initialized in the GUI class, so has access to the other's controls.
    when i try this:
    String a = visual.jPasswordField.paramString(); // line 106i get an error msg stating:
    paramString() has protected access in javax.swing.JPasswordField at line 106
    So: cant i use that method? Why?
    both classes are in the very same package
    thanks in advance

    yes, and at a certain point i need to use a String -For the password? Read the [url http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JPasswordField.html#paramString()]docs for the method. It does not return the password, it returns a implementation-dependent string for debugging.
    Look up [url http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JPasswordField.html#getPassword()]getPassword(), and [url http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#String(char[])]String.String( char[] ).
    Returns a string representation of this JPasswordField. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

  • I'm confused about protected access - any insight ?

    I'm trying to understand how the protected access modifier works. I have tried to compile some example code and I'm seeing behavior which appears to go against what the text I'm using claims should happen. To wit:
    My understanding is that any subclass and any class in the same package has access to the protected member of a class. Default access (when no access modifier is used at all) allows access only to classes in the same package.
    I have the following two classes:
    //--------  Parent.java ---------------
    package testpkg.p1;
    public class Parent
        public int x = 7;
        protected int getXValue ()
            return x;
    //--------- Child.java --------------
    package testpkg.p2;
    import testpkg.p1.Parent;
    public class Child
        extends Parent
        public static void main (String[] args)
            Child child = new Child();
            System.out.println("Child X: " + child.getXValue() + "\n");
            System.out.println("Parent X: " + child.testParent());
        public int testParent ()
            Parent parent = new Parent();
            return parent.getXValue();
    }I get the following compilation error:
    $ javac -d ../lib Parent.java Child.java
    Child.java:18: getXValue() has protected access in testpkg.p1.Parent
    return parent.getXValue();
    ^
    1 error
    Now it seems to me that everything should compile fine since the Child class is a subclass of the Parent class, and as such should have access to the protected member method getXValue(). However this obviously isn't the case. It seems that the behavior is more like what is described for default access, i.e. no access by any class outside of the package, no matter if it is a subclass or not.
    Can anyone enlighten me on this ? Am I missing something obvious ?
    Thanks in advance for any feedback.
    -James

    You know that you don't have to use the "protected"
    modifier.Yes you do.
    In fact, when I learned Java, it was called
    "package" scope, not protected. But the same
    principle applies.No, the principles outlined above and in the Java Language Spec apply.
    "protected" or "package" means that only classes
    within the package itself can have access. You do not
    actually have to place any modifier at all since this
    is the default scope.No, protected adds the ability to access ex-package super class members from a child class instance. Try compiling the above example without specifying protected access.
    Pete

  • Protected access error when firing event

    My program is supposed to "press" a button when the user presses a certain key. I didn't use mnemonics because I didn't want the Alt key to be pressed, but just a key (i.e. Q, without any modifiers). So I decided to use fireActionPerformed to fire the event manually.
    However, when I compile, the compiler gives me an error saying: "fireActionPerformed(java.awt.event.ActionEvent) has protected access in javax.swing.AbstractButton.
    Why is this? How can I fix or get around this? Maybe there's a better way for me to accomplish my task?
    Any help greatly appreciated!

    Demo:
    import java.awt.event.*;
    import javax.swing.*;
    class ExampleAction extends AbstractAction {
        public ExampleAction() {
            super("ExampleAction");
        public void actionPerformed(ActionEvent evt) {
            System.out.println("ExampleAction.actionPerformed");
    public class KeyboardMappingExample extends JPanel {
        public KeyboardMappingExample() {
            KeyStroke ks = KeyStroke.getKeyStroke("ctrl Q");
            Action action = new ExampleAction();
            Object name = action.getValue(Action.NAME);
            InputMap im = this.getInputMap(WHEN_IN_FOCUSED_WINDOW);
            ActionMap am = this.getActionMap();
            im.put(ks, name);
            am.put(name, action);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable(){
                public void run() {
                    JFrame f = new JFrame("ExampleAction");
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    f.getContentPane().add(new KeyboardMappingExample());
                    f.setSize(400,400);
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
    }

  • Azure Antimalware (Endpoint Protection) says "your system administrator has restricted access to this app"

    I see many posts about using SCCM to configure policies, etc., etc. However, I can't find any information about my specific issue:
    I have installed the Antimalware extension on several Azure VMs. Only one VM allows access to "System Center Endpoint Protection". All the other ones say "your system administrator has restricted access to this app". Now, since I am the
    system administrator, I am at a loss how to be able to see / configure the other VMs using this program.
    I have not installed SCCM, since I didn't think I would need it. If, in fact, I must install SCCM, it pretty much defeats the purpose of an extension.
    Any ideas would be greatly appreciated.
    --- If I am in the wrong forum, please let me know where I should post my question, since there don't appear to be any forums discussing extensions for Azure.

    Although azure endpoint protection is the same core technology as SCEP it is not managed in the same way. Also, if the ConfigMgr agent is not installed on these VMs, then it's quite impossible for ConfigMgr to the source of the issue here. You are better
    off posting to an Azure forum.
    However, did you elevate when launching the EP console?
    Jason | http://blog.configmgrftw.com | @jasonsandys

  • Your system administrator has restricted access to this app.

    Enabled the Endpoint role on primary site server.
    Enabled Endpoint protection in Default Client Settings
    We have Default Client Antimalware Policy set.
    When I click on System Center EndPoint Protection in All Programs I get following error:
    Your system administrator has restricted access to this app.

    I am getting this on several windows client builds with SCEP now, we don't have an Applocker policy at all, one of the computers in question is running Win 7 Pro!
    I cant see how it could be malware as the users are standard users.
    I also don't know how long its been like this, but a machine we just re-imaged last week is now doing it.
    going to re-image and see if an update is causing it.

  • "Could not use the clone stamp because the area to clone has not been defined (Alt-click to define a source point)".

    Few users access our Photoshop through Citrix on a mac but use a Windows 7 platform once they're in Citrix.  They're all having issues using the Clone Stamp tool.  Get the error "Could not use the clone stamp because the area to clone has not been defined (Alt-click to define a source point)". We've reset the clone stamp tool, reset all the tools, and reset the preferences. We've made sure that we're in All Layers.  Nothing seems to be working.  None of the other forums helped either.  Adobe support is no help either.
    Thanks,
    Moe.

    Did you check with Citrix support?  Did you try both of the Alt keys.

  • Has private access in mudclient

    Alright, i've been getting on this error on every int I try to pull from the mudclient:
    .\Script.java:19: dgf has private access in mudclient
                    rs.dfm[0] = rs.dgf[idx].gmi;
                                  ^
    .\Script.java:20: djk has private access in mudclient
                    rs.djk[0] = rs.dgf[idx].gmf;
                      ^
    .\Script.java:20: dgf has private access in mudclient
                    rs.djk[0] = rs.dgf[idx].gmf;
                                  ^
    .\Script.java:21: emg(int) has private access in mudclient
                    rs.emg(0);
    etc.here is what I have in script.java
    public void AN(int idx) {
    public abstract class Script
        protected mudclient rs;
        public Script(mudclient rs)
            this.rs = rs;
        public void start(String command, String parameters[])
        public String[] getCommands()
            return new String[0];
         public void AN(int idx) {
                      rs.dga[0] = 715;
                     rs.dfl[0] = rs.dgf[idx].gmh;
                     rs.dfm[0] = rs.dgf[idx].gmi;
                     rs.djk[0] = rs.dgf[idx].gmf;
                rs.emg(0);
    }Not quite sure wich wich java version I have, but I've tryed to compile with an online compilier that uses 1.5.0, and i still got the same errors... any help is appreciated :)

    This means the arrays inside mudclient are private and cannot be access inside Script.
    rs can be accessed but not the variables inside it.
    You should not be trying to do this in any case. Try to write your code so that variables are only accessed by methods in the same class.

  • Undeletable protected access points HELP!

    Hi,the problem is when I open destinations in my N8 there are 106 access points there all called 'boingo',and i can't delete any of them.When I try to delete it says unable to delete protected access point.I've tried updating software and also making 'factory settings' but nothing changes.That *hits are always there !!!
    Solved!
    Go to Solution.

    Thanks mate., even it has been 4 years since I posted this question. I came back here because Microsoft sent me an e-mail regarding the merging of Nokia Discussions account to my Microsoft Account. Good old days. RIP Nokia.

  • User has contribute access but he is not able to access the site collection...

    User has contribute access but he is not able to access the site collection...

    What error does he get.
    Can you share fiddler trace(check if any 404 error)
    what error do we see in ULS Logs
    Create disableloopback
    registry on server
    http://support.microsoft.com/kb/926642/en-us

  • How to find from the data dict if a user has read access on a directory

    How to find "dynamically" if a user has READ access to a directory object.
    I want to know if there is a data dictionary table that holds if a user/schema has read access to a directory object.
    I know there is an dba_directories table and an all_directories table but they dont give information as to which user has read access granted to the directory.

    Not so difficult.
    select  'YES'
       from all_tab_privs A, all_directories B
       where a.grantee = 'USERNAME'
           and a.table_name = b.directory_name
           and b.directory_path = 'PATH YOU ARE LOOKING FOR'
    How to find "dynamically" if a user has READ access to a directory object.
    I want to know if there is a data dictionary table that holds if a user/schema has read access to a directory object.
    I know there is an dba_directories table and an all_directories table but they dont give information as to which user has read access granted to the directory.

Maybe you are looking for

  • Yosemite Won't Install (EtreCheck results)

    I have attempted to download and install Yosemite on my Early 2013 MacBook Pro. It gets most of the way through the installation and then just stops. Nothing. For hours. I had to restore my hard drive from a SuperDuper backup. I've run EtreCheck and

  • Video Playback in version 7

    Why do the videos I purchased with version 6 of i tunes play fine, but any video purchased after upgrading to version 7 play choppy. This only happens when I watch the video in itunes, They all play fine on my ipod.

  • PSE 6 slideshow output problems

    I created a large slideshow in PE6. The output is unsharp. I then bought Premeire Elements and the output is even worse. Is it because of the high resolution of the photos? If so, is there any way to change the resolution after the fact? I have tried

  • HT3702 How can I talk to a customer service agent?

    Need to talk to a customer service agent about fraudulent charges.

  • Internet setup

    I'm trying to setup internet access on Solaris 10. I followed the instructions from several posts but am still unable to get access. Here is what I've done so far. - Added the nameserver IP's to resolv.conf - copied nsswitch.dns to nsswitch.conf - en