Changing variable name breaks serialization

I have a class like so
class aClass {
    private static final long serialVersionUID = 1; 
    private ArrayList list = new ArrayList();
    private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {
     in.defaultReadObject();
        this.list = new ArrayList(this.list);     //defensive copy
}The problem is i renamed 'list' to 'newList'. Now the deserialization fails. Is there any way around this? Its still a list and everything is the same but the name. I thought serialization used the positions of variables not their names? And I also thought since I had my UID the same it would just load it without complaint?
I have a bunch of files created with this in them, and I need a tip on how to convert them. thanks!

easy peasy
class aClass {
    private static final long serialVersionUID = 1; 
    private ArrayList list = new ArrayList();
    private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {
     this.list = (ArrayList) in.readObject();  //<---new
        this.list = new ArrayList(this.list);     //defensive copy

Similar Messages

  • Change variable name of component once declared

    Hello,
    I was wondering if you can change a variable name of a component so if i had the following declaration of a button like this:
    JButton btn = new JButton();can i then change the variable name 'btn' to be 'button' after i have declared it like this ?
    Many thanks in advance

    ok, you might have a better solution for me actually....
    What i have done so far is created a JTabbedPane in one class, i have also created a seperate class with extends a JPanel. This consists of two textboxs and two buttons. Now i want to add this class as a component to each new tab that i create in the other class.
    However the problem that i have is the reference name that i give for the textboxs and buttons will be the same for the multiple tabs that i create which i guess will not work.
    For example, i create 2 tabs each with one of these instances of this class in each. So therefore there will be two identical buttons with the same reference and two identical textboxes with the same reference.
    This is the code for the class that extends a JPanel: (note: i have cut out all the layout code to simplify the code a little)
    public class client extends javax.swing.JPanel {
        private JButton Sbrowse_btn;
        private JButton Sbrowseto_btn;
        private JLabel SchosenFile_lbl;
        private JLabel SchosenL_lbl;
        private JTextField SchosenLoc_tf;
        private JTextField Schosen_tf;
        private JLabel SsaveTo_lbl;
        private JLabel SuploadTo_lbl;
        private JPanel jPanel2;
        private JPanel jPanel3;
        /** Creates new form client */
        public client() {
            initComponents();
        private void initComponents() {
            jPanel3 = new JPanel();
            SuploadTo_lbl = new JLabel();
            Sbrowse_btn = new JButton();
            SchosenFile_lbl = new JLabel();
            Schosen_tf = new JTextField();
            jPanel2 = new JPanel();
            SsaveTo_lbl = new JLabel();
            Sbrowseto_btn = new JButton();
            SchosenL_lbl = new JLabel();
            SchosenLoc_tf = new JTextField();
    }

  • Changing variable name

    Hello all,
    I have build a query with a variable fiscal period. I used this variable in input forms in Visual Composer (@fiscal_period) and in BW reports.
    Now end users ask me to change the name of the variable to 'period'. Does this have impact on the existing Visual Composer model?
    Thanks in advance,
    Ralph

    Hi,
    You just change the variable name. After that you need to map again it with input form field as @period, Otherwise it will not get the value. Just map it and deploy it again.
    Thanks
    Chandan

  • Change Variable Name

    Hi
    I have a requirement where I want to loop 10 times over an internal table, but passing the same value to all.
    For ex.
    Do 10 times.
    Read table itab into wa index sy-index.
      if sy-subrc = 0.
        var1 = wa-field.
      endif.
    Enddo.
    My requirement is to change this VAR1 to VAR2 in next iteration, then to VAR3.......upto VAR10 for every iteration of loop.
    Regards
    Kapil

    try this .
    declare variable VAR1 to VAR 10 .
    DATA:  LV_FIELDNAME(9)   TYPE C,
           LV_PREFIX(3)      TYPE C VALUE 'VAR'
           LV_LINE_NUMBER(2) TYPE N .
    FIELD-SYMBOLS : <FS_GLOBAL_VARIABLE>.
    Do 10 times.
      ADD 1 TO LV_LINE_NUMBER.
      CONCATENATE LV_PREFIX
                  LV_LINE_NUMBER
             INTO LV_FIELDNAME.
      ASSIGN (LV_FIELDNAME) TO <FS_GLOBAL_VARIABLE>.
      Read table itab into wa index sy-index.
       if sy-subrc = 0.
         <FS_GLOBAL_VARIABLE> = wa-field.
       ENDIF.
    ENDDO
    Jitendra

  • Changing variable name within loop

    Instead of typing oit 8 different versions of this loop, I'd like to do something this where i increases value to define a new variable:
    for (int i = 1; i < 9; i++)
                double lbs[i] = (((dis * 2000) / 3456) * (ve)) * pr * 0.069 / 100;
                BigDecimal bd[i] = new BigDecimal (lbs);
    bd[i] = bd[i].setScale (1,BigDecimal.ROUND_UP);
    lbs[i] = bd[i].doubleValue ();
    String tflow[i] = Double.toString (lbs[i]);
    oFlow[i].setText (tflow[i]);
    i++;
    In PHP that's how I do it, but how about Java? I tried searching for "variable variables" since that's the only want I know how to describe it.

    I put what you gave me inside of public void CalcBoost() { ... } and I'm getting the error:java.lang.NullPointerException
            at Calculator.CalcBoost(Calculator.java:751)
            at Calculator.iBoostActionPerformed(Calculator.java:672)
            at Calculator.access$700(Calculator.java:69)
            at Calculator$8.actionPerformed(Calculator.java:299)
            at javax.swing.JTextField.fireActionPerformed(JTextField.java:491)
            at javax.swing.JTextField.postActionEvent(JTextField.java:672)
            at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:786)
            at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1530)
            at javax.swing.JComponent.processKeyBinding(JComponent.java:2438)
            at javax.swing.JComponent.processKeyBindings(JComponent.java:2473)
            at javax.swing.JComponent.processKeyEvent(JComponent.java:2401)
            at java.awt.Component.processEvent(Component.java:4909)
            at java.awt.Container.processEvent(Container.java:1569)
            at java.awt.Component.dispatchEventImpl(Component.java:3615)
            at java.awt.Container.dispatchEventImpl(Container.java:1627)
            at java.awt.Component.dispatchEvent(Component.java:3477)
            at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
            at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
            at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
            at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
            at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
            at java.awt.Component.dispatchEventImpl(Component.java:3506)
            at java.awt.Container.dispatchEventImpl(Container.java:1627)
            at java.awt.Window.dispatchEventImpl(Window.java:1606)
            at java.awt.Component.dispatchEvent(Component.java:3477)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)This now points to: for (int i = 0; i < oFlow.length; i++)

  • How to change dinamically variable name?

    Is it possible to change variable name dinamically into loop?
    loop at itab.
    move itab-item to field_x.
    endloop.
    I would copy my itab-item into field_1, field_2......field_x at each loop.
    Thanks
    Alfonso.

    You have to use the field symbol for the field giornoX not for the structure
    DATA: BEGIN OF wa_alv OCCURS 0,
            pernr            LIKE pa0001-pernr,
            persk            LIKE pa0001-persk,
            des_grado_abbrev LIKE zhr_descr_grado-des_grado_abbrev,
            vorna            LIKE pa0002-vorna,
            nachn            LIKE pa0002-nachn,
            giorno1          TYPE char12,
            giorno2          TYPE char12,
            giorno3          TYPE char12,
            giorno4          TYPE char12,
            giorno5          TYPE char12,
            giorno6          TYPE char12,
            giorno7          TYPE char12,
          END OF wa_alv.
    data tb_alv like table of wa_alv.
    field-symbols: <giorno> type any.
    data: name_giorno(13).
    LOOP AT tb_alv ASSIGNING wa_alv
      LOOP AT tb_orario.
       do 7 times.
        concatenate 'wa_alv-giorno'  sy-index into name_giorno.
         assign (name_giorno) to <giorno>.
         giorno  = tb_orario-orario.
        enddo.
        ENDLOOP.
    ENDLOOP.
    bye
    enzo

  • How to use an array for variable name of swing components using NetBeans

    I'm completely new to Java and GUIs, so excuse me if I use the wrong terminology. I'm making a JFrameFrom in NetBeans. I'm getting really tired of typing instructions like jTextField15.setText(variable[15].text); I would like to make the variable names of my text fields an array so I can use a loop to change the values, text, tooltips, etc. When I click "change variable name" it won't let me put an array in. The code that Swing generates is protected and I can't change it. I know there must be a way to do this. Any help is appreciated.

    Try not to use the NetBeans visual GUI builder. Then it should be easy to create an array of text fields:
    JTextField[] tfs = new JTextField[15];
    for (int i = 0; i < tfs.length; i++) {
        tfs[i] = new JTextField(10);
    }For laying out the text fields, see: [http://download.oracle.com/javase/tutorial/uiswing/layout/using.html]

  • I need to change the name of Schema in the Insert command by using variable

    Hi
    I need to write a code to populate 450 schemas having same table names and also specify the columns needed to be inserted. for that i am trying to make the Schema Name a variable and put the whole statement in a loop to change the name of the Schema. its not working can any one guide me in this..Thae sample of my insert statement is
    INSERT INTO A01.tablename
    In this the "A" is constant and 01 is being changed to 02...450..
    Thanks

    Not sure to completely understand your need, but assuming that column names and values to be inserted are the same for all schemas, here a short example :
    SQL> desc a001.test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(10)
    SQL> desc a002.test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(10)
    SQL> desc a003.test
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(10)
    SQL> declare
      2     i       number;
      3     str     varchar2(100);
      4  begin
      5     for i in 1..3 loop
      6             str := 'insert into a'||lpad(i,3,'0')||'.test(a,b) values(1,'||chr(39)||'ABC'||chr(39)||')';
      7             execute immediate (str);
      8     end loop;
      9     commit;
    10* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select * from a001.test;
             A B
             1 ABC
    SQL> select * from a002.test;
             A B
             1 ABC
    SQL> select * from a003.test;
             A B
             1 ABC
    SQL>                                                                          

  • Change Document Names in Map of Documents

    Hello,
    I am taking the attachments from a completed task and putting them into a map of documents variable.  I was wondering if it is possible to change the names of the documents in the map?  I would like to be able to add an identifier to each document in the map.  Thanks.

    The problem is that you put the id in quotes - which no longer evaluates the statement, but treats it as a litteral.
    To make it easier on my feeble brain (especially when debugging using record/playback) I break it down into multiple steps in the same set value
    /process_data/@myTempID is a string
    /process_data/@myTempDocis a Document
    Location  
    Expression
    /process_data/@myTempID 
    /process_data/MapKeys[1]
    /process_data/@myTempDoc
    /process_data/MapOfDocuments[@id=/process_data/@myTempID]
    /process_data/MapOfDocuments[@id=/process_data/@myTempID]     
    setDocAttribute(/process_data/@myTempDoc, "wsfilename", "test.doc")

  • DLL Adapter: Change function name & params without unloading the DLL

    Hi,
    I'm using teststand adapters API to dynamically build a DLL call step. Each dll function is called thru this "DLL Manager" sub-sequence. 
    Tried 2 methods (here is an abstract of the code): 
    1. ActiveX steps: 
    CommonCModule.ModulePath = myDllpath
    CommonCModule.FunctionName = myFunction  (note: this call unload the previously loaded DLL)
    Module -> LoadPrototype
    for( to set params)
    2. Statement steps: 
    RunState.Sequence.Main["Call DLL function"].TS.SData.Call.LibPath = myDllpath
    RunState.Sequence.Main["Call DLL function"].TS.SData.Call.Func = myFunction (note: this one not, but the info seems to not be updated => The new function is not called properly)
    Module -> LoadPrototype
    for( to set params)
    The two methods don't have exactly the same behavior, but work well for the 1st function that I call or work well if I unload the dll after step execute. 
    However, is there a way to use these steps (or others) to setup the step, but without unloading the DLL between each call. In my test sequence, I have to OpenConnection with the UUT before launching my commands, so the dll must not be unloaded to keep the connection opened... 
    e.g. 
    1) OpenConnection()  => This function keeps the communication handle with the device
    2) myCommand1()
    3) myCommand2()
    4) CloseConnection()
    Thank you for help
    C.
    Solved!
    Go to Solution.

    Hi all, 
    To recap:
    I'm looking for a method to dynamically loads and executes C/C++ DLL functions without unloading the DLL between each call. I already have a DLL manager that dynamically loads and executes dll functions, but it unloads the DLL between each call even if I set the unload option to: "Unload when sequence file is unloaded"...
    The problem is: 
    When I change the name of the function to execute (using the CommonCModule.FunctionName property), teststand automatically unloads the DLL before applying the change. Therefore, I can't open a connection handle with my UUT using one function and sends my commands with the others...
    To help you with the understanding of my issue:
    I created a simple example that will let you experiment the problem that I try to describ... You will notify that TestStand unloads the dll even if I don't request it... 
    1) download the attached zip file
    2) extract it anywhere
    3) open sequence file "dll_called_dynamically.seq"
    4) read comment of the first step of the sequence
    >> To analyse the case:
    >> 1) Break and run the sequence using step-by-step (use F10)
    >> 2) Run one iteration of the loop to execute the dll once, ,
    >> 3) Execute launch_listdlls.bat and verify in the outputfile.txt that the dll has been loaded (search for testlib.txt)
    >> 4) Then, step over the step "Set Dll Function Name to call"
    >> 5) Execute launch_listdlls.bat and you will notify that the dll has been unloaded... ...
    The testlib.dll file provided in the zip file is a basic dll that I used to confirm my test engine. Mainly, it only performs additions on the variables passed as argument to the dll. 
    The provided batch file executes the free application ListDlls.exe and create an outputfile.txt listing all currently loaded dll.
    Please note that I use TestStand 2013
    Thank you very much for your help,
    C.
    Attachments:
    dll_unexpected_unload_ex.zip ‏313 KB

  • ANY SY-INDEX REFLECT CHANGES WHEN CONTROL BREAK STATEMENT PROCESS

    Dear Guru's,
                     I have a requirement where i have to move the values to variable when control break (AT END OF) process. So i want to move the values according to the end of Vendor so for that  i want to know is there any sy-index available which reflects changes when Control break (AT end of) process.
    LIKE Sy-subrc = 0 when select statement fetches record or sy-tabix is like counter for loop.
    Hope to get reply soon.
    Regards,
    Himanshu Rangappa

    Hi,
    There is no system Fields for it.
    But your requirement can be done with 'AT NEW' and 'AT END' statement.
    Refer this sample example,
    loop at otab.
        at new module.
          move otab-module to otab2-module.
        ENDAT.
          at END OF effort.
          sum.               "Do your calculations here
          move otab-count to otab2-count.
          append otab2.
        endat.
      endloop.

  • Same variable name causes major issues.....

    I would like to get some input and possible direction on the issue below... I am new to PL/SQL. Thanks in advance.....
    ..... The system is in the middle of processing a “For” step, i.e. a given “For” step is incomplete.
    ..... The script instructs the system to process a second “For” step with the same “for-loop variable” as the incomplete “For” step.
    When the above takes place, the system processes the second “For” step incorrectly. Instead of starting at the first value in the second “For” step’s list of values, the system begins in the middle of the value list.
    I need to change the current implementation so that if a "For" loop is encountered that has the same “loop variable” as a “For” loop already being executed, the “state” of the previous “For” step is discarded, and the state for the new “For” step is initialized to the first value in its list.
    -- Used for "for" steps
    TYPE for_list is table of varchar2(4000) index by binary_integer;
    TYPE for_loop_state is record (
    list for_list,
    next_index integer
    TYPE for_loops_list is table of for_loop_state index by steps.output_param%TYPE;
    all_for_loops for_loops_list;
    procedure for_step(list_string IN varchar2, ret_var_name IN varchar2, end_for_label IN varchar2) is
    state for_loop_state;
    end_idx number;
    list_value varchar2(4000);
    begin
    pkg_util.log('ret_var_name value after begin: ' || ret_var_name, 'I');
    -- get the current for list state, based on its output variable name
    if all_for_loops.exists(ret_var_name) then
    state := all_for_loops(ret_var_name);
    else
    state.next_index := 0;
    list_value := parse_next_param(list_string, 1, end_idx);
    -- end_idx is thrown away; for loops only have 1 input parameter (the list)
    state.list := get_for_list(list_value);
    all_for_loops(ret_var_name) := state;
    end if;
    if state.next_index < state.list.count then
    pkg_session_values.put(ret_var_name, state.list(state.next_index));
    all_for_loops(ret_var_name).next_index := state.next_index + 1;
    else
    all_for_loops.delete(ret_var_name);
    jump(end_for_label);
    end if;
    end;

    There is so much of your code hidden from view it is impossible to tell you anything other than perhaps suggest a methodology.
    Create a single variable with a known value and use dbms_output to view it as it steps through each piece of the puzzle. Determine when the value does something you don't want.

  • Is it possible to add a property using variable in variable name?

    I want to query for a list of virtual machines within a folder, then create a menu of the host names using forms.  Since the list of machines is subject to change, I want to build the list each time the script is run, rather than build off a static
    list. 
    For each virtual machine I need to create the list of variables below:
    $hostnameX = New-Object System.Windows.Forms.checkbox
    $hostnameX.Location = New-Object System.Drawing.Size(10,20)
    $hostnameX.Size = New-Object System.Drawing.Size(100,20)
    $hostnameX.Checked = $true
    $hostnameX.Text = "Type"
    $hostnameX.Controls.Add($hostnameX)
    The location and size values need to be incremented but I think I can figure that part out.
    I can use New-Variable to generate the initial variable. But I receive errors using the same method to try to create a new property for the variable.
    $VMS = Get-Cluster MyCLUS | Get-vApp "My vApp" | Get-VM | Select Name,PowerState | Sort Name
    For ($i=0; $i -lt ($VMS.count); $i++)
    $VMS[$i].Name
    $VMGUEST = "$($VMS[$i].Name)" -replace("-","")
    New-Variable "CB$VMGUEST" "New-Object System.Windows.Forms.checkbox"
    New-Variable "CB$VMGUEST.Location" "New-Object System.Drawing.Size(10,20)"
    In the above, $CBVMGUEST1 =  New-Object System.Windows.Forms.checkbox which is what I want,  but $CBVMGUEST1.Location is not set.
    Is there way to add a property using a variable in the variable name?  Or any other suggestions on how to tackle this issue?

    Hi,
    maybe another approach is a bit easier.
    Use a hash-array like
    $CB = @{}
    $CB[$VMGUEST] = New-Object System.Windows.Forms....
    $CB[$VMGUEST].Location = New-Object System.Drawing....
    Mit freundlichen Grüßen Jens Kalski
    That's the correct answer.  Anytime you find yourself wanting to create variables named "Widget1", "Widget2", "Widget3", etc... it's a pretty clear indication that what you really need is a collection object of some sort.  That might be an array,
    a hashtable, or any other data structure for holding other objects, depending on your specific needs.

  • Error while using the variable name "VARIABLE" in variable substitution

    Hi Experts,
      I am using variable substitution to have my output filename set as a payload field value. It is working fine when I am using the variable name as fname, subs etc but channel goes in error when I am using the variable name as "VARIABLE". This is probably a reserved word but i would like to know where i can find a detailed documentation on this. Say things to note / restrictions while using variable substitution.
    This is the error in the channel:
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error during variable substitution: java.text.ParseException: Variable 'variable' not found in variable substitution table: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: java.text.ParseException: Variable 'variable' not found in variable substitution table
    Thanks,
    Diya

    Hi Zevik,
    Thanks for the reply. The output file is created correctly by merely changing the variable name to something else and hence the doubt.
    Below is the configuration:
    Variable Substituition
    VARIABLE    payload:interface_dummy,1,Recordset,1,Header,1,field1,1
    Filename schema : TEST_%VARIABLE%.txt
    Output xml structure:
    <?xml version="1.0" encoding="utf-8" ?>
    - <ns:interface_dummy xmlns:ns="http://training.eu.unilever.com">
    - <ns:Recordset xmlns:ns="http://training.eu.unilever.com">
    - <Header>
      <identifier>HDR</identifier>
      <field1>001</field1>
      <field2>001</field2>
      <field3>R</field3>
      </Header>
    - <Detail>
      <identifier>A</identifier>
      <field1>000000002</field1>
      <field2 />
      <field3>Doretha.Walker</field3>
      </Detail>
    I thimk my configuration is correct as it is working correctly with the variable name change, However, maybe i missed something !

  • Problem with variable name in ZXRSRTOP include (virtual KF)

    Hi all,
    I am coding a routine to use a virtual key figure in the BEx.
    I have just a little problem with the name of a variable:
    as explained in the documentation, I created the variable with the prefix G_POS_, the name of the infocube and the name of the infoobject all together:
    DATA: G_POS_BC_ST_003_C_DIV__C_COMPAR   type i.
    The problem is that this variable name is longer than 30 characters, so the system doesn't accept it.
    Is there a workaround, other than changing the name of the infoobject (which is a navigational attribute)?
    Any help would be appreciated.
    Loï

    Hello Marc,
    I understand that I have to use a concatenate function and a dynamic call of the variable with (variable) instruction, but i do not understand how to implement it.
    the infocube name is BC_ST_003
    the characterisdtic name is C_DIV__COMPAR
    So, in the include ZXRSRTOP the statement
    DATA : G_POS_BC_ST_003_C_DIV__COMPAR
    does not work due a length problem (see first post)
    But in the same include the statement
    +DATA: l_global_name type c.
    concatenate 'GPOS' 'BC_ST_003' 'C_DIV__C_COMPAR' into l_global_name separated by '_'.+
    drives to the following error : statement is not accessible.
    Could u please provide me with an example of the code in the include ZXRSRTOP, and in the include ZXRSRZZZ for the use of this variable.
    Thanks in advance.
    Loï

Maybe you are looking for