Tuesday, July 29, 2008

Java operators

The following might be very familiar to you, but for me it was completely new.

Will the following compile, if yes, what will be the output and why? Any exceptions? If it doesn't compile, why?

String s = null, s1 = null;
System.out.println(s != null && s.length() > 0);
System.out.println(s != null & s.length() > 0);

Whats going on in the above code?

Wednesday, August 09, 2006

River crossing puzzle and favourite books

River crossing puzzle

Recently I was going through the blog of my friend Ranjit [http://rmathew.blogspot.com/2006/08/another-river-crossing-puzzle.html]; I found an interesting 'river crossing puzzle'. I remember we used to solve these kinds of problems in our primary/high school days [I am now working as software engineer in B'lore], it suddenly took me back to my olden golden days.

I sat down to solve it. I couldn't make my first move till 8th minute. I was feeling 'there is no solution to this problem'. Then suddenly, out of nowhere, one move came to my mind. After that move, it was mostly fluent and I could complete the whole problem in almost 15 mins. I really felt satisfied after I solved this puzzle. My solution also involved exactly 17 steps as Ranjit's.

Books

Recently I have developed the habit of reading books. I never used to read books except text/technical, now I realize how much I missed out. I completed reading the book 'Good to Great', it is absolutely amazing. It talks about how does a seemingly average company [good company] goes on to become 'great' company. The amount of time spent

and research done to come up with this book is enormous. It is really worth a read for the enterpreneurs and to-be enterpreneurs.

I am currently reading 'The TAO of Physics'. This book tries to draw a parallel between modern physics and eastern mysticism. I have read only the first chapter and it got me really interested. I will put down my thoughts after I read the book.

During discussion, my friends mentioned few more books - 'A road less travelled', 'Five people you meet in heaven' etc. I am really excited about reading books as it decreases my 'I don't know that I don't know' domain.

Sunday, July 16, 2006

Hibernate 3 for JDK 1.3

In one of our projects, we are planning to use Hibernate the latest version of which is 3. Unfortunately we couldn't find the binary version of Hibernate 3 which runs on JRE 1.3 on JBoss as well as sourceforge site. We are using IBM WebSphere 5.0.2 which uses JRE 1.3, hence we couldn't use Hibernate 3. But we wanted to use some specific features of Hibernate 3 like one class getting mapped to multiple tables etc. So we thought we will compile the sources ourselves using JDK 1.3. We thought it was easy, but it wasn't.

Hibernate 3 was using some specific Java classes which are introduced in JDK 1.4 like EJBMethodPermission etc. We found most of these classes were used in org.hibernate.secure package. We thought we will ignore security for the time-being and removed the secure directory so that it is not compiled.

We hit the next problem, Hibernate 3 was using some methods related to updation of Clob, Blob, Ref, Array which are introduced in JDK 1.4. In our project, we are not using any of the above SQL data types, so its fine for us. But I was thinking, what if people want to use this version of Hibernate 3 and they want support for the above data types. I didn't [still don't] have an answer; I just kept thinking how were people doing without these methods being there. I am yet to find an answer for this.

After we commented the methods related to updation of LOB data types and secure package, Hibernate 3 happily compiled. We performed a few sanity checks, it seems to work fine at least for our required functionality.

Since we had modified/commented a few of the methods, we wanted to run a full round of JUnit tests bundled with Hibernate 3. We hit one more road-bock here, all the JUnit tests assumed JDK is 1.4. Now, we are working on resolving this.

In the mean time, we are going ahead with using our own version of Hibernate 3 [which I call Hibershop 3]. If anybody has compiled H3 with JDK 1.3 and using it successfully in their environment, it would be great if you could share the binary version with us. On the other hand, if you require JDK 1.3 version of H3, I can provide the one which we have built [with few limitations of course], please mail me at hanasim at gmail dot com.