Sunday, June 03, 2012

Post S2 I9100G ICS Upgrade: Only Samsung Logo Left?

I decided to upgrade my Samsung S2 I9100G from Gingerbread to ICS; used the software update on the phone to perform the upgrade; now my phone would boot and show the Samsung logo for eternity!

The only way to get the phone back to work is to revert to Gingerbread! This has to be done manually by downloading the firmware and installing it.

Thanks to this link , it provides a detailed explanation for doing the same.

Appreciate Samsung for such robust update release which only shows their logo after its applied!

Of course, I can visit the Samsung service center in Bangalore which is worse than their upgrade package!

Sunday, May 20, 2012

loadClass - JDK 1.6.0_18 vs JDK 1.6.0_27

Recently while implementing a custom class loader, I hit upon a issue related to loadClass method of the Classloader.  The custom classloader code of interest is below.

This classloader worked on JDK 6 Update 27 (dev env) but failed to work on JDK 6 Update 17 (test env).

Its a rare skill to write code in Java that  fails between minor revisions!! :-)

The class loader code was written looking at the Java source code for Classloader. This was the cause of the issue - the custom loader implementation did not adhere to the documented contract for the loadClass method.

The documentation of the loadClass method clearly states

ClassNotFoundException - If the class could not be found

While the custom class loader method returns null if the class is not found! So why did it work in latest update of Java?  Following are the Classloader code snippets from the two JDK 6 updates that I have mentioned.

Jdk 1.6 Update 18

Jdk 1.6 Update 27

The if check c==null in the Update 27 made the loadClass method work even though it did not adhere to the documented contract.

The bottom line is to code against documented contract and not look at the implementation to write code!

Monday, February 06, 2012

Analytical Reasoning With Prolog

Last year, I solved the following analytical reasoning problem by hand. Post learning Prolog, I think this is a good problem to solve using a computer! I had a interesting experience doing so.


1: There are 5 villas in 5 different colors 
2: In each villa lives a person with a different nationality. 
3: These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet. 
4: No owner has the same pet, smoke the same brand of cigar or drink the same drink.
1: The British lives in a red villa. 
2: The Swede keeps dogs as pets 
3: The Dane drinks tea 
4: The green villa is on the left of the white villa (it also means they are next door to each other) 
5: The green villa owner drinks coffee 
6: The person who smokes Pall Mall rears birds 
7: The owner of the yellow villa smokes Dunhill 
8: The man living in the villa right in the center drinks milk 
9: The Norwegian lives in the first villa 
10: The man who smokes Blend lives next to the one who keeps cats 
11: The man who keeps horses lives next to the man who smokes Dunhill 
12: The owner who smokes Blue Master drinks beer 
13: The German smokes Prince 
14: The Norwegian lives next to the blue villa 
15: The man who smokes Blend has a neighbor who drinks water.

The question is: who keeps the fish?

Prolog Solution:

The following is what i could come up with after serval iterations through code.

Answer to Puzzle:

Following is the output of the prolog program.


Hence the answer is German keeps the fish.