Thursday, March 31, 2011

Method has the same erasure bug in javac

Interesting bug in javac. Consider the two cases:
Case 1:
class Case1 {
    public String foo(Set<String> str) {
        return null;

    public String foo(Set<Integer> str) {
        return null;

Case 2:
class Case2 {
    public String foo(Set<String> str) {
        return null;

    public Integer foo(Set<Integer> str) {
        return null;

What do you think about them? Should Class1 compile? What about Class2?
In my opinion both of classes should not compile, since methods have the same erasure. In this is exactly what happens in Eclipse.
But, in IntelliJ the Class2 compiles just fine. And Maven also compiles the Class2 without problem.
So how does it happen?
It appears that Eclipse uses it own compiler, while Maven and IntelliJ use javac.
So where is the bug, in Eclipse or javac?
Here the bug that was opened in Eclipse community.
And here the bug in Sun (or should I say Oracle?)
So as you can see, both of them agree with me: the bug is in javac and not in Eclipse. Actually Sun marked it as fixed at 7(b55). Does it mean Java 7?

Monday, March 28, 2011

Maven - Hotswap Plugin

For many years I was missing the following feature of Maven: In a multi-module project, when I build a single module in a jar, I want it to be installed into the running environment (app server) seamlessly. During these years I created various scripts for this tasks, why none of them lasted too long: it's very hard to create a generic script, while nongeneric scripts need to be maintained and actually each module must have had its own script. Duh.

Thinking about it, I decided that it should be a Maven plugin, which is very simple - during the install phase, search some predefined location and hotswap the found jars. That's it. So I thought that somebody probably already thought about it and asked a question at Stackoverflow. I received few interesting answers, but not a simple plugin I needed.

So I decided to implement it myself. It took me few hours, since it was my first Maven plugin, so I had some "doing it for the first time" troubles. But finally I did it.

You are welcome to use it, and as always any feedback is appreciated.

Wednesday, March 23, 2011

How I didn't get even a job interview in Google

This is going to be a very different post and it is not going to be technical.
I wish to register a complaint:

But first some history: Once upon a time I have sent my resume to Google. I did it via the Google web site, got an automatic reply and was never contacted. You may say that sending the resume via the company web site is not effective way to find a job, and you are right. But actually I was not really looking for a job, I saw a Google advertisement on the web, and decided to apply.

About a month ago, I got the following mail:
Subject: Hello from Google/Google Opportunities

Hi Michael,

My name is ****** ***** and I am an Engineering Recruiter for Google. Your name was passed to me confidentially by an engineer at our Mountain View headquarters.

I see that you have applied, via our website, to opportunities in our offices in Israel, but nothing materialized. If you are interested in positions in those offices I can pass your information to someone who supports that office and can make sure that you are given serious consideration for those positions. Otherwise, I support our HQ and other offices in the US and if you are interested in a major relocation I can assist. If you are interested in opportunities with us please send me an updated copy of your resume along with your reply.

Best regards,


To tell the truth my first idea was to say "Yes! I want to come to an interview to Mountain View. Please, make sure that I fly business/first and live in a nice hotel."
But I'm probably too shy to ask for traveling, while I'm not actually interested in a relocation. While position in Tel-Aviv could be interesting, so I replied:

Hi ******,

Thank you for your mail.
I'm really curious to know, who is the person who passed you my name.
I'm asking, since I don't think that I know anyone, who works at Mountain View...

Anyway, I'm interested in the positions at Google offices in Israel. However, if it does not succeed, I won't be available for the relocation, since *********************************.

My updated resume is attached.
Thank you,


And very quickly I received the following two mails:

Mail 1:

Thanks for your response and for sending me your resume. We currently have Software Engineering openings in Haifa and Tel Aviv. I can get your resume and information over to a colleague of mine that supports those locations. I will forward your information over today.

The person that referred you definitely works in Mountain View, but I can't disclose their name.

Let me know if you have any questions and hopefully something with us in Israel will work out for you.



Mail 2:
Hi Tal,

My name is ****** and I work for the Google recruitment team.

I got your info from *********** from the USA Google Staffing.

I would like to ask if you would be interested in having an open conversation about current job opportunities to see if we have anything available that may interest you?

If you would like to discuss this further then please send me a convenient time/date and your telephone number.

I look forward to hearing from you.

Best Regards,


My name is not Tal, but who cares :) So I replied with a phone number and few days later I got a phone call from the Google recruiter in Tel-Aviv. She asked me few questions about what I'm doing and what I'm interested to do and then said the following (this is not the exact quote, but this is how I remember it): "We don't invite to an interview the candidates who have such a low degree and such a low GPA, and I'm calling you only since a colleague from the USA team has recommended you. If you are interested I will send you an online programming exam and if you successfully complete it, I'll invite you to an interview."

Few points here: I own a BA degree in a Computer Science with GPA 85. I graduated in 2004 and have 7 years of an experience. I can hardly understand the recruiter who is interested in GPA of a person, who has graduated 7 years ago.
Anyway, she didn't reply and didn't send me any exam. I believe she forgot about me the second the phone was disconnected. May be even a second before.

So I do understand that she called me only because she got my resume from her colleague. The thing I don't understand: Is there such a difference between the requirements for Google in US and in Israel? I mean, I don't believe that the US recruited wrote me mail knowing that my degree is not high enough.

Anyway, I'm pretty sure that even if I was getting to an interview, my chances to pass it probably are not high, so I didn't have any real expectations. It's just a nasty feeling that I have after this a very short recruitment process that wasn't even initiated by me.

Thursday, March 17, 2011

Hibernate - How to Insert Data During the Create/Create-drop

And here comes something I was missing for years.
It appears that it's possible to execute additional SQLs during the Hibernates create/create-drop. It's very useful for the unit testing.

In short: Hibernate will run "import.sql" file from the classpath.

I found it here.

Monday, March 14, 2011

Oracle: How to find last query executed

One more sql script to remember - How to find the last query executed:
select sql_text from v$sql 
where first_load_time=(select max(first_load_time) from v$sql)

Or may be in a bit more useful way:
select * from v$sql order by first_load_time desc

And even more useful, show only queries that contain MY_TABLE:
select * from v$sql where sql_text like '%MY_TABLE%' order by first_load_time desc

Update: Pay attention that the solution is not quite correct if you use the prepared statements. For prepared statements there will be one row added to the table per statement's parsing. So if you reused the same statement (which is a good practice from performance point of view), you won't get a new record in a table.

Recommended Reading

1. Oracle Essentials: Oracle Database 11g
2. Oracle PL/SQL Programming: Covers Versions Through Oracle Database 11g
3. Oracle SQL By Example (4th Edition)