Testing Object Equality using Serialization

Hey everyone! I was wondering if somebody could help me figure out how to compare two objects using serialization.
I have two objects that I'm trying to compare. Both of these objects extend a common "Model" class that has a method getSerialized() that returns a serialized form of an instance, shown below:
          // Serialize the object to an array
         ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
         ObjectOutputStream oos;
          try {
               oos = new ObjectOutputStream(baos);
              oos.writeObject(this);
              oos.close();
          } catch (IOException e) {
               e.printStackTrace();
         //Deserialize array into a String array
         return baos.toByteArray();This Model class also has an equals(Model obj) method that allows for the current model object to be compared to a model object that is passed in:
        //Store both models' serialized forms into byte arrays
        byte [] thisClass = this.getSerialized();
        byte [] otherClass = obj.getSerialized();This is where things get a little funny. The byte arrays don't equal - one array is a byte larger than the other. If a byte-by-byte comparison is done, the arrays are equal for the first 15-20% and then not equal for the rest. If I deserialize the byte arrays back into Models and do a toString() on those models, I find that they are equal.
I have a feeling there's something about the serialization process that I don't fully comprehend. Is there a way to properly implement object comparison using serialization?
Thanks in advance!

When you serialize an object, you also serialize the entire tree of references based on that object (except for transient variables). That tree is the complicated business you described there. Serialization stores all the objects in the tree, along with data that explains which objects refer to which other objects. Furthermore if the tree is actually a graph, and there are multiple ways to get to an object, it still only stores each object once. I don't see any reason to believe that all that relationship data would be encoded identically for a pair of trees that you deemed to be equal. And your experiment shows that indeed it isn't.

Similar Messages

  • Object send using Serializable problem

    My broblem here is that client send an object throw a socket and make some update in the server and send the object back to client but it seem that there is a problem in the following code :
    in = new ObjectInputStream(clientSocket.getInputStream());
    out = new ObjectOutputStream(clientSocket.getOutputStream());
    in the clientTCP class and in connection class .. this problem that it seem that the server doesn't get the object send by the Client .. can any one help me ..
    This is the code for the object to be send:
    public class Msgmsg{
    private String type;
    private String cur1;
    private String cur2;
    private double value;
    Msgmsg(String type,String cur1,String cur2,double value){
    this.type=type;
    this.cur1=cur1;
    this.cur2=cur2;
    this.value=value;
    void setType (String type){this.type = type;}
    void setCur1 (String cur1){this.cur1=cur1;}
    void setCur2 (String cur2){this.cur2=cur2;}
    void setValue(double value){this.value=value;}
    String getType (){return type;}
    String getCur1 (){return cur1;}
    String getCur2 (){return cur2;}
    double getValue(){return value;}
    This is the code for TCPServer
    import java.net.*;
    import java.io.*;
    public class TCPServer implements Serializable{
    public static void main (String args[]){
    try{
    int serverPort =8080;
    ServerSocket listenSocket = new ServerSocket(serverPort);
    while(true){
    Socket clientSocket = listenSocket.accept();
    Connection c = new Connection(clientSocket);
    catch (IOException e){System.out.println("listen: "+e.getMessage());}
    This is the connection class
    import java.net.*;
    import java.io.*;
    class Connection extends Thread{
    ObjectInputStream in;
    ObjectOutputStream out;
    Socket clientSocket;
    public Connection (Socket aClientSocket){
    try{
    clientSocket = aClientSocket;
    in = new ObjectInputStream(clientSocket.getInputStream());
    out = new ObjectOutputStream(clientSocket.getOutputStream());
    this.start();
    catch (IOException e){System.out.println("Connection: "+e.getMessage());}
    public void run(){
    try{
    Msgmsg message =(Msgmsg) in.readObject();
    if (message.getType().equals("Request")){
    message.setType("Reply");
    if (message.getCur1().equals("Dollar")&&
    message.getCur1().equals("Dinar")){
    message.setCur1("Dinar");
    message.setCur2("Dollar");
    double changeValue = message.getValue();
    changeValue = changeValue * 71 / 100;
    message.setValue(changeValue);
    else
    if (message.getCur1().equals("Dinar")&&
    message.getCur1().equals("Dollar")){
    message.setCur1("Dinar");
    message.setCur2("Dollar");
    double changeValue = message.getValue();
    changeValue = changeValue * 100 / 71;
    message.setValue(changeValue);
    else {
    message.setCur1("Undefined Currency");
    message.setCur2("Undefined Currency");
    message.setValue(0);
    else{
    message.setType("Undefined Message");
    message.setCur1("Error Message");
    message.setCur2("Error Message");
    message.setValue(0);
    out.writeObject(message);
    out.flush();
    catch(EOFException e){System.out.println("EOF: "+e.getMessage());}
    catch(IOException e){System.out.println("IO "+e.getMessage());}
    catch(ClassNotFoundException e){System.out.println("Class: "+e.getMessage());}
    finally {
    try{
    clientSocket.close();
    catch(IOException e){/*close failed*/}
    This is the code for TCPClient
    import java.net.*;
    import java.io.*;
    public class TCPClient implements Serializable{
    public static void main (String args[]){
    Msgmsg message;
    Socket s = null;
    ObjectInputStream in;
    ObjectOutputStream out;
    try{
    message = new Msgmsg("Request","Dinar","Dollar",50.5);
    int serverPort = 8080;
    s = new Socket("localhost",serverPort);
    in = new ObjectInputStream(s.getInputStream());
    out = new ObjectOutputStream (s.getOutputStream());
    out.writeObject(message);
    out.flush();
    message = (Msgmsg)in.readObject();
    System.out.println("Recieved1: "+message.getType());
    System.out.println("Recieved2: "+message.getCur1());
    System.out.println("Recieved3: "+message.getCur2());
    System.out.println("Recieved4: "+message.getValue());
    catch(UnknownHostException e){System.out.println("Sock: "+e.getMessage());}
    catch(EOFException e){System.out.println("EOF: "+e.getMessage());}
    catch(IOException e){System.out.println("IO: "+e.getMessage());}
    catch(ClassNotFoundException e){System.out.println("Class: "+e.getMessage());}
    finally {
    if (s!=null)
    try{
    s.close();
    }catch (IOException e){System.out.println("Close: "+e.getMessage());}
    Thanks for ur time

    You need to create ObjectOutputStream first and
    flush() it before creating the ObjectInputStreamwhat the difference I work these clases like another clases I have but the problem here is difference .. coz Imake tracing but it couldn't reach the following code:
    in = new ObjectInputStream(s.getInputStream);
    out = new ObjectOutputStream(s.getOutputStream);

  • Retreiving more than one object from an object stream using serialization.

    I have written a number of object into a file using the object Output stream. Each object was added separately with a button event. Now when I retrieve it only one object is being displayed. the others are not displayed The code for retrieval and inserting is given below. Please do help me.
    code for inserting is as follows
    Vehicle veh1 and vehicle class implements serializable
    veh1.vehNum=tf1.getText();
              veh1.vehMake=tf2.getText();
              veh1.vehModel=tf3.getText();
              veh1.driveClass=tf4.getText();
              veh1.vehCapacity=tf5.getText();          
              FileOutputStream out = new FileOutputStream("vehicle.txt",true);
              ObjectOutputStream s = new ObjectOutputStream(out);
              s.writeObject(veh1);
    retrieval
    FileInputStream out = new FileInputStream("vehicle.txt");
              String str1,str2;
              str1=str2=" ";
              Vehicle veh=new Vehicle();
              ObjectInputStream s = new ObjectInputStream(out);
              try
              Vehicle veh1=(Vehicle)s.readObject();
              s.close();
              int i=0;
              str1=veh1.vehNum;
              str2+=str1+"\t";
              str1=veh1.vehMake;
              str2+=str1+"\t";
              str1=veh1.vehModel;
              str2+=str1+"\t";
              str1=veh1.driveClass;
              str2+=str1+"\t";
              str1=veh1.vehCapacity;
              str2+=str1+"\t\n";
              ta1.append(str2);
              catch(Exception e)
              e.printStackTrace();
    Pleas give me the code for moving through the object until it reaches the end of file

    You can read objects from the stream one by one. So, what you need is an endless loop like this:
    // Suppose you have an ObjectInputStream called objIn
    // So here is the loop which reads objects from the stream:
    Object inObj;
    while (1) {
        try {
            inObj=objIn.readObject();
            // Do something with the object we got
            parse_the_object(inObj);
        } catch (EOFException ex) {
            // The EOFException will be thrown when
            // we reached the end of the file, so here we break out
            // of our lovely infinite cycle
            break;
        } catch (Exception ex) {
            ex.printStackTrace();
            // Here you may decide what to do...
            // Probably the processing will end here, too. For now,
            // we moving on, hoping there is still something to read
    objIn.close();
    // ...

  • Where we can test the SAP objects by using eCATT?

    Hi Abapers,
    Where we can test the SAP objects by using eCATT?Is there any separate software or tool we have to install or its included in the SAP itself?
    I have ECC5.0 version?how can i configure or install eCATT?
    Please explain the step by step procedure?
    Early reply is highely appriciable.
    Regards,
    Chow.

    Hi
    Extended Computer Aided Test Tool (eCATT) to create and execute functional tests for software. The primary aim is the automatic testing of SAP business processes. Each test generates a detailed log that documents the test process and results.
    Features
    You can:
    · Test transactions and reports
    · Call BAPIs and function modules
    · Test remote systems
    · Check authorizations (user profiles)
    · Test database updates
    · Test the effects of changes to customizing tables
    · Test the effect of changes to customizing settings
    · Check system messages
    Constraints
    eCATT runs in a system based on SAP Web Application Server 6.20 or higher. However, you can use this system to test systems with Release 4.6C or higher.
    check these link,
    eCATT- An Introduction
    /people/sumeet.kaul/blog/2005/07/26/ecatt-an-introduction
    Creating Test Scripts
    /people/sumeet.kaul/blog/2005/08/10/ecatt-creating-test-scripts
    eCATT Logs
    /people/sapna.modi/blog/2006/04/18/ecatt-logs-part-vi
    eCATT Scripts Creation – TCD Mode
    /people/sapna.modi/blog/2006/04/10/ecatt-scripts-creation-150-tcd-mode-part-ii
    Creation of Test Data Container
    /people/sumeet.kaul/blog/2005/08/24/ecatt-creation-of-test-data-container
    eCATT Scripts Creation - SAPGUI Mode
    /people/sapna.modi/blog/2006/04/10/ecatt-scripts-creation--sapgui-mode-part-iii
    Integrating ECATT & MERCURY QTP Part -1
    /people/community.user/blog/2007/01/02/integrating-ecatt-mercury-qtp-part-1
    Using eCatt to Test Web Dynpro ABAP
    /people/thomas.jung/blog/2006/03/21/using-ecatt-to-test-web-dynpro-abap
    and
    -command reference
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/3c333b40389c46e10000000a114084/content.htm
    /people/sapna.modi/blog/2006/04/10/ecatt--an-introduction-part-i
    http://prasadbabu.blogspot.com
    https://www.sdn.sap.com/sdn/developerareas/was.sdn?page=test_tool_integration_for_sap_e-catt.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/1b/e81c3b84e65e7be10000000a11402f/frameset.htm
    http://www.erpgenie.com/ecatt/index.htm
    hope this helps.
    Regards
    Anji

  • Want to learn how to use "serializable"

    Hello, everyone!
    I have never used "serializable" function of Java before. After reading API specification of java.sun.com and some tutorials of java.sun.com dealing with "serializable", I become more puzzled. I just want to know how to use the basic function of "serializable". Can anyone introduce me some basic tutorials or samples?
    Thanks in advance,
    George

    The function of serializable is to be able to serialize an object to a stream. Operations include writing an object to file, or to a network socket connection.
    That object can then be reconstructed from that file (or the reciever on the other end of a network socket can reconstruct the object.)
    Example
    MyClass object = new MyClass() //MyClass implements Serializable
    FileOutputStream fos = new FileOutputStream("C:\test.file"); //create a fileoutputstream to write to a file
    ObjectOutputStream out = new ObjectOutpuStream(fos); //an object outputstream to wrap the fileoutputstream
    out.writeObject(object); //write the object to the fileReading the object is like this
    FileInputStream fis = new FileInputStream("C:\test.file"); // create a fileinputstream to read from a file
    ObjectInputStream in = new ObjectInputStream(fis) // an ObjectinputStream to wrap the FileInputStream
    MyClass object = (MyClass)in.readObject();Exception catch blocks are not included but you do have to catch IOException for reading and writing, plus a few other exceptions for reading. Consult the API for details.

  • Serializing objects that use Loggers

    i am trying to clean-up a lot of java code i have written. so please allow me one more post:
    the issue is objects that use Loggers :
    public class MyClass implements Serializable {
      private static Logger logger = Logger.getLogger("baselib.utilities"); // <-- must be marked transient
    }no serializable objects can use Loggers , right? in my imagination i see that:
    (1) Logger settings are global to a jvm . [read out of a "logging.properies" at start-time].
    (2) so, a MyClass object is created in jvm1 and gets its log settings.
    (3) it is serialized and sent to jvm2.
    (4) it pops-up after de-deserialization, and the jvm2 global log settings are different.
    the Logger in the MyClass object is hopelessly confused.
    so, by hook or crook,
    its fair to say that you cannot use Loggers with serializable objects, right?
    (i don't like Loggers anyway).
    please just answer this one last question, then i can get back to writing code rather
    than cleaning it. thanks to all.

    i am running at least 4 threads (and sometimes as many as 20) leading to chaotic
    asynchronous output. and this Logger output is very hard to look at. in production, then it makes sense.
    CONFIG: Main::_loadConfigSettings()__checking config file :: remoteRunnPort = #7002
    Jun 8, 2008 11:31:48 AM kuai.Main loadConfigSettings
    CONFIG: Main::_loadConfigSettings()__checking config file :: fileSharePort = #7001
    Jun 8, 2008 11:31:48 AM maui.engine.FileShareService run
    FINER: ----FileShareService::_run()___running....
    Jun 8, 2008 11:31:48 AM maui.engine.DataService openNewConnections
    FINER: ____----DataService::_openConnections()___opening 3 new connections___pool size = 0__idle = 0
    Jun 8, 2008 11:31:48 AM maui.engine.FileShareService run
    FINEST: ----FileShareService::_run()___LISTENING on port #7001....
    Jun 8, 2008 11:31:48 AM maui.engine.DataService openNewConnections
    FINEST: ____----DataService::_openConnections()___new connection___pool size = 1__idle = 1
    Jun 8, 2008 11:31:48 AM maui.engine.DataService openNewConnections
    FINEST: ____----DataService::_openConnections()___new connection___pool size = 2__idle = 2
    what i want to see:
    Main::_loadConfigSettings()__checking config file :: resultsHandlerPort = #7002
    Main::_loadConfigSettings()__checking config file :: fileSharePort = #7001
    ----FileShareService::_run()___running....
    ____----DataService::_openConnections()___opening 3 new connections___pool size = 0__idle = 0
    ----FileShareService::_run()___LISTENING on port #7001....
    ____----DataService::_openConnections()___new connection___pool size = 1__idle = 1
    ____====____====________ResultsHandler::_run()__starting....
    _______________________________UserThread-01::_run()__starting....
    ____----DataService::_openConnections()___new connection___pool size = 2__idle = 2
    ____----DataService::_openConnections()___new connection___pool size = 3__idle = 3
    ____====____====________ResultsHandler::_run()__LISTENING on port #7002
    i don't know how to use the NetBeans debugger with so much threading (or really at all).
    so, i use the good-old: " +System.out.println():+ "
    and, once i get a thread working ok, i comment out all the print lines:
    // ____----DataService::_openConnections()___new connection___pool size = 2__idle = 2
    // ____----DataService::_openConnections()___new connection___pool size = 3__idle = 3
    the Logger gives way too much output, and i need to do like:
    "thread #1 = nothing ; thread #2 = *FINEST* ; thread #3 = *INFO* ; ...."
    if some can tell me a better way to debug heavily threaded code, that would be the
    greatest gift of all. i get confused too often and waste so much time.
    JUnit testing threaded code.. its just not possible with so much asynchronousity (right?).
    Edited by: pdFrog on Jun 8, 2008 5:14 PM

  • Looking up values from Map/HashMap  when Objects are used as keys

    I'm trying to understand why Map/HashMap don't test for equals() when looking up a key ( which is an Object that overrides equals() and hashCode()) in the Map.
    I've written this code, based on some code from the SCJP book, but it is not exactly the same, this code talks about a different issue not addressed in the book.
    I've added my questions inside the comments below, I think that is the best way I can ask it.
    import java.util.*;
    class Bird{
         public String name;
         public Bird(String name){
              this.name = name;
         //Override equals()
         public boolean equals(Object o){
              if(((Bird)o).name.equals(this.name)){
                   return true;
              }else{
                   return false;
            //Override hashCode
         public int hashCode(){
              return name.length();
    class TestMapLookup{
         static public void main(String[] args){
              Map<Object, Object> hashMap = new HashMap<Object, Object>();
              Bird b = new Bird("crow");
              hashMap.put(b, "somevalue");
              //according to the book, the map object calls the key's (Bird object's)
              //hashCode() first and then equals()
              //to find this key in the map
              System.out.println(hashMap.get(b));
              //Using the b reference to lookup value
              //ouputs - somevalue
              System.out.println(hashMap.get(new Bird("crow")));
              //Using a new Bird object to lookup value
              //outputs - somevalue
              //because Bird overrides equals and hashCode
              //otherwise we'd get null
              //Now change the name of the bird in the b reference
              b.name = "sparrow";
              //Notice that the crow's hashCode is 4
              //sparrow's hashCode is 7 , in the above implementation of hashCode
              System.out.println(hashMap.get(b));
              //Again using b reference to lookup value
              //ouputs - null
              //because the hashCode of b.name does not match
              //the hashCode of any of the keys stored in the map
              System.out.println(hashMap.get(new Bird("crow")));
              //This also outputs null
              //for the same reason that there's no key in the map
              //with a hashcode of 7
              //This is where it becomes strange......................
              //Change the name of the bird in the b reference
              //so that the new name has the same hashCode, as the key in the map
              b.name = "dove";
              System.out.println(hashMap.get(b));
              //In the above - the hashCode matches
              //but equals() fails
              //even though equals() fails, the key is still located and the value is output
              //output is "somevalue"
              //same here:
              b.name = "1234";
              System.out.println(hashMap.get(b));
              //output is "somevalue" instead of null
              b.name = "abcd";
              System.out.println(hashMap.get(b));
              //output is "somevalue" instead of null
              //why does it output "somevalue" instead of null , even though when the map
              //looks up the key , equals() returns false?     
              System.out.println(hashMap.get(new Bird("crow")));
              //In this case ( new Bird reference ) it prints null
    }I'm aware of best practices in coding and coding conventions but haven't used them here, because this is in preparation for SCJP - which tests on a lot of different things.
    I appreciate any info.

    It is correct that b is referring to the same object that the map's key is pointing to, but why does the following
    print null , instead of "somevalue"?
    at these lines in the code above.
    b.name = "sparrow";
    System.out.println(hashMap.get(b));Because the hashCode used when you stored b was 4, and now it's 7. You should read the Wikipedia article on Hashtable, but a simplistic explanation is that a HashMap has a bunch of "buckets," say 10, each indexed with a number 0-9. To decide which bucket to put a new key-value pair in, you take the hashcode (say 2112) and take the remainder of hashcode/number of buckets (in this case, 2112%10=2). So when you store the key-value, it gets "put" in this bucket.
    When you change the hashcode of b by changing its name attribute, it doesn't change the fact that the pair is in that bucket. But, it now looks in the wrong bucket and so can't find the pair.
    A hashtable gets its good efficiency by not having to look through all values to find the pair. It can jump directly to the correct bucket, which takes constant time instead of being dependent on the number of items in the collection.
    endasil wrote:
    You should never, ever change an object being used as a key in a map.I guess this is a best practice, I just wanted to try changing the key object to test a few things for SCJP, which does not test on coding best practices but tests on how the code behaves.Yep, and what you should take away is that this is WHY it's bad to change the key :).

  • How to test for existence of AcroXFA test objects?

    Hi -
    I'm writing scripts to test an XFA form with dynamic subforms.  For example, at the end of Part 4, the user hits a Validate button, and if their data is correct, then the Validate button disappears and a Part 5 subform appears.
    So my script looks something like this:
    Function GetButtonPart4Validate()
       Set GetButtonPart4Validate = PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1")
    .AcroXFAForm("sfPart4").AcroXFAButton("sfValidate")
    End Function
    Function GetPart5()
       Set GetPart5 = PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").AcroXFAForm("sfPart5")
    End Function
    GetButtonPart4Validate().Click
    PDFDoc( "TestForm" ).WaitProperty "ready", true, 60000  ' Wait for event processing complete
    If DataTable("boolValidates", dtLocalSheet) = "TRUE"  Then
         If( GetPart5().Exist ) Then
              ' A: Checkpoint Succeeds: Validation was successful
         Else
              ' B: Checkpoint fails: Validation failed
         Endif
    Else
         If(  GetPart5().Exist ) Then
              ' C: Checkpoint Fails:  Validation was unexpected
         Else
               ' D: Checkpoint Succeeds:  Validation failed as expected
         Endif
    Endif
    Unfortunately it appears that XfaSubForm.Exist always returns TRUE.  In other QTP testing domains (eg "Exist Property (WinObject)" in QTP Help), the documented behaviour of the Exist property is to be true if the desired test object can be found in the application-under-test. Typically this means that when the script tries to access an XFA widget which doesn't exist (even something like GetPart5().getROProperty("visible") ), the script stops and thinks for a minute or so, and eventually produces a test error that the object doesn't exist then muddles onward. It is the "stops and thinks for a minute or so" which frustrates me, since these are delays which I am trying to avoid.
    Another possible angle I looked into was counting the subforms under Part 5's parent.
    PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").RefreshObject
    PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").AcroXFAForm("sfPart5").Refresh Object
    ' check to see if there is a 'sfPart5'
    Dim MyChildren, i
    Set MyChildren = PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").ChildObjects
    For i=0 to MyChildren.Count - 1
        print i & " name=" & MyChildren(i).GetROProperty("name")
    Next
    This also seems to fail:  Part5 doesn't appear among its parent's children (at least before QTP actually tries to use it).
    The PDF Test Toolkit User Guide doesn't specifically mention that Exist or RefreshObject or ChildObjects are implemented, so I can't say AcroQTP isn't working as designed, but if you're looking for suggestions for improvement, I'll vote for fulfilling these parts to the QTP.  Please confirm my conclusions that these are not properly implemented, or whether I'm missing something.
    In the meantime, do you have any recommendation on how to proceed?  My present workaround is to look for a "validation error" windows dialog that indicates Part 5 won't exist, but this won't work in future test scripts.
    Cheers,
    Brent

    Hi,
    816387 wrote:
    ... QUERY:-  Find all customers who have at most one account at the Perryridge branch.
    SOLUTION *1* :-
    select customer_name
    from depositor,account
    where account.account_number=depositor.account_number and
    branch_name='Perryridge'
    group by customer_name
    having count(account.account_number) <=1
    ok running correctly
    That finds customers who have exactly one account at Perryridge.
    The assignment is to find customers who have at most one account at Perryridge. You need to include customers with 0 accounts at Perryridge, as well. You could use an outer join, or MINUS, or a NOT IN subquery, or a NOT EXISTS sub-query (as mentioned above) to do that.
    Can there be customers who have no accounts at all, at any branch? If so, you'll need to use the customer table in this problem, as well as depositor and account.
    >
    SOLUTION *2* :-
    select D1.customer_name
    from depositor D1
    where unique
    (select customer_name
         from depositor D2,account A1
         where D1.customer_name=D2.customer_name
              D2.account_number=A1.account_number and
              branch_name='Perryridge'
    gives error:-
    where unique
    ..........*^*
    ERROR at line 3:
    ORA-00936: missing expression
    Logic of both solution are correct . But Solution 2 gives error in oracle. I want unique construct to work.Sorry, it doesn't in Oracle. I don't know of anything like that in Oracle.
    Does "WHERE UNIQUE (SELECT ...)" work in some other database system? Which?
    How to do it. Or How can i test for the absence of duplicate tuples ??????
    Your Solution 1 is the best way to find customers with exatly 1 account (rather than 0 or 1 accounts) at Perryridge. Is there any reason why you wouldn't want to use it, if you ever needed to find customers with exactly one account there?

  • Does making objects equal null help the gc handle memory leakage problems

    hi all,
    does making objects equal null help the gc handle memory leakage problems ?
    does that help out the gc to collect unwanted objects ??
    and how can I free memory avoid memory leakage problems on devices ??
    best regards,
    Message was edited by:
    happy_life

    Comments inlined:
    does making objects equal null help the gc handle
    memory leakage problems ?To an extent yes. During the mark phase it will be easier for the GC to identify the nullified objects on the heap while doing reference analysis.
    does that help out the gc to collect unwanted objects
    ??Same answer as earlier, Eventhough you nullify the object you cannot eliminate the reference analysis phase of GC which definitelely would take some time.
    and how can I free memory avoid memory leakage
    problems on devices ??There is nothing like soft/weak reference stuffs that you get in J2SE as far as J2ME is concerned with. Also, user is not allowed to control GC behavior. Even if you use System.gc() call you are never sure when it would trigger the GC thread. Kindly as far as possible do not create new object instances or try to reuse the instantiated objects.
    ~Mohan

  • Table to look for the test object information

    Hello everybody,
    I am working on solution manager and i was wondering if there were a way to get the informations i had directly in tables using the SE16 transaction. So my question is the following: is there a way to extract data like test plan, status text, test object, test instructions, user, date, time from SAP tables. Thank you in advance for your answer.
    Best Regards

    Julius
    Looking at another of Tracy's other post (http://scn.sap.com/thread/3598947) she's trying to use ACL. Hence needing to know the tables to write joins/queries to hit tables within ACL
    I've seen ACL used and have had the fun experience of Auditors using Google to find tables to perform checks on without context of what has actually been implemented in their particular system.
    Regards
    Colleen

  • Difference between Object equals() method and ==

    Hi,
    Any one help me to clarify my confusion.
    stud s=new stud();
    stud s1=new stud();
    System.out.println("Equals======>"+s.equals(s1));
    System.out.println("== --------->"+(s==s1));
    Result:
    Equals ======> false
    == ------------> false
    Can you please explain what is the difference between equals method in Object class and == operator.
    In which situation we use Object equals() method and == operator.
    Regards,
    Saravanan.K

    corlettk wrote:
    I'm not sure, but I suspect that the later Java compilers might actually generate the same byte code for both versions, i.e. I suspect the compiler has gotten smart enough to devine that && other!=null is a no-op and ignore it... Please could could someone who understands bytecode confirm or repudiate my guess?Don't need deep understanding of bytecode
    Without !=null
    C:>javap -v SomeClass
    Compiled from "SomeClass.java"
    class SomeClass extends java.lang.Object
      SourceFile: "SomeClass.java"
      minor version: 0
      major version: 49
      Constant pool:
    const #1 = Method       #4.#15; //  java/lang/Object."<init>":()V
    const #2 = class        #16;    //  SomeClass
    const #3 = Field        #2.#17; //  SomeClass.field:Ljava/lang/Object;
    const #4 = class        #18;    //  java/lang/Object
    const #5 = Asciz        field;
    const #6 = Asciz        Ljava/lang/Object;;
    const #7 = Asciz        <init>;
    const #8 = Asciz        ()V;
    const #9 = Asciz        Code;
    const #10 = Asciz       LineNumberTable;
    const #11 = Asciz       equals;
    const #12 = Asciz       (Ljava/lang/Object;)Z;
    const #13 = Asciz       SourceFile;
    const #14 = Asciz       SomeClass.java;
    const #15 = NameAndType #7:#8;//  "<init>":()V
    const #16 = Asciz       SomeClass;
    const #17 = NameAndType #5:#6;//  field:Ljava/lang/Object;
    const #18 = Asciz       java/lang/Object;
    SomeClass();
      Code:
       Stack=1, Locals=1, Args_size=1
       0:   aload_0
       1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
       4:   return
      LineNumberTable:
       line 1: 0
    public boolean equals(java.lang.Object);
      Code:
       Stack=2, Locals=2, Args_size=2
       0:   aload_1
       1:   instanceof      #2; //class SomeClass
       4:   ifeq    25
       7:   aload_1
       8:   checkcast       #2; //class SomeClass
       11:  getfield        #3; //Field field:Ljava/lang/Object;
       14:  aload_0
       15:  getfield        #3; //Field field:Ljava/lang/Object;
       18:  if_acmpne       25
       21:  iconst_1
       22:  goto    26
       25:  iconst_0
       26:  ireturn
      LineNumberTable:
       line 6: 0
    }With !=null
    C:>javap -v SomeClass
    Compiled from "SomeClass.java"
    class SomeClass extends java.lang.Object
      SourceFile: "SomeClass.java"
      minor version: 0
      major version: 49
      Constant pool:
    const #1 = Method       #4.#15; //  java/lang/Object."<init>":()V
    const #2 = class        #16;    //  SomeClass
    const #3 = Field        #2.#17; //  SomeClass.field:Ljava/lang/Object;
    const #4 = class        #18;    //  java/lang/Object
    const #5 = Asciz        field;
    const #6 = Asciz        Ljava/lang/Object;;
    const #7 = Asciz        <init>;
    const #8 = Asciz        ()V;
    const #9 = Asciz        Code;
    const #10 = Asciz       LineNumberTable;
    const #11 = Asciz       equals;
    const #12 = Asciz       (Ljava/lang/Object;)Z;
    const #13 = Asciz       SourceFile;
    const #14 = Asciz       SomeClass.java;
    const #15 = NameAndType #7:#8;//  "<init>":()V
    const #16 = Asciz       SomeClass;
    const #17 = NameAndType #5:#6;//  field:Ljava/lang/Object;
    const #18 = Asciz       java/lang/Object;
    SomeClass();
      Code:
       Stack=1, Locals=1, Args_size=1
       0:   aload_0
       1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
       4:   return
      LineNumberTable:
       line 1: 0
    public boolean equals(java.lang.Object);
      Code:
       Stack=2, Locals=2, Args_size=2
       0:   aload_1
       1:   instanceof      #2; //class SomeClass
       4:   ifeq    29
       7:   aload_1
       8:   ifnull  29
       11:  aload_1
       12:  checkcast       #2; //class SomeClass
       15:  getfield        #3; //Field field:Ljava/lang/Object;
       18:  aload_0
       19:  getfield        #3; //Field field:Ljava/lang/Object;
       22:  if_acmpne       29
       25:  iconst_1
       26:  goto    30
       29:  iconst_0
       30:  ireturn
      LineNumberTable:
       line 6: 0
    }

  • [4712] WARNING!!! 'Huh, you set a test object to itself... whats up with dat?' Line 601 in function in file .\tstobj2\ObjArray.cpp

    I'm using TestStand 4.0 and anytime I try to intialize my chasis this message shows up in my debugg viewer. I would appriciate any feedback. I have no idea what could be triggering this message or why it's worded the way it is.
    [4712] WARNING!!! 'Huh, you set a test object to itself... whats up with dat?' Line 601 in function  in file .\tstobj2\ObjArray.cpp

    You've hit what was intended to be an internal development warning, but apparently the warning macro used is not compiled out in the release.
    This has likely been there since TestStand 1.0 and is nothing to worry about. In most cases it indicates you've called SetPropertyObject or SetPropertyObjectByOffset to set an object that was already set in the specified location. This is a harmless NOP and the warning only appears in attached debuggers, but it "might" be an indication that you have made a programming error.
    I launched and exited the 4.0 sequence editor without seeing this warning, so I don't know if it is being triggered by your code module (or sequence, or custom step type, or custom UI, or custom process  model, ...) or another part of TestStand that you are using.  Chances are good that this warning does not indicate a functional problem. However, if you can reproduce it with a clean uncustomized TestStand install, I'd like to know how you did it.
    I've entered a corrective action request to remove this warning.
    Message Edited by James Grey on 09-13-2007 10:12 AM

  • What is the disadvantages of using Serialization?

    HAi all,
    I want to store objects in a file. I am preferred to use serialization. But I want to know what are the disadvantages of using Serialization over other methods (direct file, Keyed File)?
    Can we store as many records using serialization? Is there any limit? Is there any security related issues?
    Pls help me.
    regards,
    namanc

    I don't think there is disadvantage using serialization compare to direct i/o access to file or any storage, except that you need to design your code such as it is serializable (hence, you may want to use transient keyword, or use externalizable, to be able to store/load the object properly).
    Use serialization if possible, it saves you from inventing new+uncompatible mechanism of doing something in java.

  • Impact of use XMLEncoder to log transactions that use serialization

    Hi,
    i have an application that uses serialization to communicate between client and server, i want to log this transactions in a xml file using XMLEncoder, using the method:
    public static void log(Object transaction) throws Exception {
            XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("log.xml")));
            e.writeObject(transaction);
            e.close();
    }if i put this, how i can check the impact on the system? the XMLEncoder consumes memory to build the XML, then the impact will be only for the garbage collector?
    thanks for any idea.

    A profile would be the best option. NetBeans comes with a free one. There is also OptimizeIt and JProbe. Otherwise you'd have to write a lot of code to get that info.

  • All session objects should be serializable to replicate error.

    Hi All,
    Having 'EmployeeBean' and it is having below properties with getters and setters methods
    private long emp_id;
    private String emp_name;
    private java.sql.Timestamp date_of_join;
    private boolean isActive;
    private int dept_no;
    Adding multiple employees(creating multiple EmployeeBean) into an ArrayList and storing this ArrayList into a Session object. This is working fine but when I move this code to production(cluster environment) it is throwing below error
    <Aug 23, 2011 2:15:40 PM EDT> <Error> <Cluster> <BEA-000126> <All session objects should be serializable to replicate. Check the objects in your session. Failed to replicate non-serializable object.
    java.rmi.MarshalException: failed to marshal update(Lweblogic.cluster.replication.ROID;ILjava.io.Serializable;Ljava.lang.Object;); nested exception is:
         java.io.NotSerializableException: my.company.beans.EmployeeBean
         at weblogic.rjvm.BasicOutboundRequest.marshalArgs(BasicOutboundRequest.java:90)
         at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:221)
         at weblogic.cluster.replication.ReplicationManager_1032_WLStub.update(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         Truncated. see log file for complete stacktrace
    Caused By: java.io.NotSerializableException: my.company.beans.EmployeeBean
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
         at java.util.ArrayList.writeObject(ArrayList.java:570)
         at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         Truncated. see log file for complete stacktrace
    Can someone please let me know, why I'm getting this error? The EmployeeBean should implement serializable? Is there any problems/cons to implement serializable?
    Having other bean(LoginBean) and I'm keeping this bean into session and it doesn't implement serializable, not getting any error for this bean(LoginBean). Only difference is LoginBean is not added to ArrayList.
    Why it is throwing error for EmployeeBean and not for LoginBean??
    Thanks in advance.
    Regards,
    Sharath.

    The EmployeeBean should implement serializable? - Yep Is there any problems/cons to implement serializable? - No
    Just add java.io.Serializable to the EmployeeBean, for example,
    public class EmployeeBean implements Serializable {
    }For LoginBean you have probably, configured to be in the session, by using faces-config.xml.
    In the case of EmployeeBean (or the object graph it is part of) have you used HttpSession.setAttribute(...)?
    Note that setAtttibute(...) is the trigger for an application server to replicate the object.
    In this case all objects in the object graph have to be serializable.
    Typically, objects should be Serializable when they are part of the session and you are using a clustered environment.

Maybe you are looking for

  • Installing BI Publisher Desktop as a machine startup script?

    Hello, Our company wants to deploy Oracle BI Publisher Desktop 10.1.3.4.1 to 60+ machines with Office 2010. Users on these machines do not have any admin privileges and therefore the installation is done via machine start up script. I managed to comb

  • Invalid column name while loading member error in EIS

    we have changed the sort_order_01 column as LEVEL01_SORT_ORDER in SQL server view, but it is not reflecting in EIS during member load, however we added manually LEVEL01_SORT_ORDER in table properties of dimension member, but it is not reflecting in E

  • Can't found rpt files under weblogic

    <p>hi.</p><p>   in my local, the runtime environment is: oracle9, weblog8 and jdk1.4. now the tests are all ok. i want to deploy the project to server.</p><p>i've two questions to be solved.</p><p>   1.  2006-12-21 11:31:32,937 [com.businessobjects.r

  • Changing a calendar of a webDAV event generates a 502 error

    To reproduce: 1. Select an event in iCal that is served from a WebDAV Server. 2. Using the optional click, change the calendar of the Event to another calendar on the same server. Result: iCal returns a "The server responded with"502" to operation Ca

  • How do you fix error OXE8000065?

    My computer will not let me sync my iPhone 3GS. This is the error code the keeps popping up... how do I fix it?