You are here: Home ยป Blog

Retrieving original hashcode of a Java object

Posted on Sunday, March 09 2014 at 21:33 | Category: Software Engineering, Java | 0 Comment(s)

For debugging Java applications, it is sometimes useful to know if two references point to the same or to different objects - this can be easily checked by evaluating the return value of hashCode() (the default implementation from java.lang.Object returns distinct integers for distinct objects). However, this might not work if hashCode() is overridden - in that case, hashCode() might return the same value for different objects to fulfill the equals() contract. In that case, it is still possible to retrieve the same hashCode() value as it would be returned by java.lang.Object if the hashCode() method was not overridden, by using System.identityHashCode() on this object:

public class Value {
    private int theValue;

    public Value(int val) {
        theValue = val;
    }

    @Override
    public int hashCode() {
        return theValue;
    }
	
    public static void main(String[] args) {
        Value value = new Value(42);
        System.err.println(value.hashCode());
        System.err.println(System.identityHashCode(value));
    }
}
Output:
42
1024180077

Enabling unrestricted security algorithms in Java

Posted on Friday, November 23 2012 at 22:12 | Category: Software Engineering, Java | 0 Comment(s)

While I tried to reproduce this question on StackOverflow, I learned that it is required to install additional policy files in order to use strong encryption algorithms with the Java Cryptography Architecture (JCA). This article shows a sample encryption/decryption application and how to enable AES-256 support by installing the additional policy files: Using strong encryption in Java


Configuring WebLogic logging output

Posted on Wednesday, September 19 2012 at 09:52 | Category: Software Engineering | 1 Comment(s)

Some hints how to configure log output in Oracle WebLogic 11g: Configuring logging in standalone Weblogic server 11g on Unix


Creating java virtual machine stack traces

Posted on Tuesday, August 14 2012 at 12:08 | Category: Software Engineering, Java | 0 Comment(s)

This article shows how to create stack traces from background java processes: Creating Java Stack Traces


Displaying results 5 to 8 out of 13