Frans Janssen

Ranch Hand
+ Follow
since Dec 29, 2004
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Frans Janssen

Hmmm, this looks like a "feature" of JBuilder. If I compile and run your code with the JDK tools it works perfectly, but when I compile and run it in JBuilder (2005) it returns false on isEnum() and then throws an exception because the getEnumConstants() returns null.
17 years ago

Thanks for your reply. I had to change the class declaration a bit in order to get it to compile:

However, it then crashes on a NullPointerException when constructed. Apparently the getEnumConstants() method returns null, as the Class class feels it is not an enum class (isEnum() returns false). I think that is pretty awkward, but the Javadoc of isEnum() says the following:

If I call getSuperClass() on the enum class, it tells me it derives from Object rather than enum.
17 years ago
Is there any way to use a generic superclass for any enum type?

I want to make a combo box that allows the user to choose from the values in an enum type. I hoped I could do something like this:

But values() is not a method defined in Enum and the constructor doesn't accept an enum type as a parameter (as apparently it isn't a subclass of Enum, even though the javadoc seems to suggest that it should be).

Does anyone know how to do this or do you have a suggestion for an elegant solution to accomplish the same thing?

Thanks in advance,

17 years ago

Originally posted by Ken Blair:
Did you setup Eclipse to compile for 5.0? That behavior looks like something that would have occurred in the old memory model but not in the new one. If JBuilder was configured to compile for 5.0 and Eclipse is not this would explain the sudden problem.

Regardless, what was said earlier about this being a big "no no" is correct and should be heeded.

Eclipse was set for 1.4. Setting it to 5.0 did indeed solve it.
In JBuilder, launguage features had been set to 1.3 and earlier, but target VM was set to 1.4 and later. Setting the latter to "all VMs" would reproduce the exception also in JBuilder. (As would using the 1.4.2 javac.exe.)

As I mentioned in my original post, I am aware that the example code contains a major "nono". It just happened to exist in our code and it came to light when test driving Eclipse. I was doing an investigation to whether our project could migrate to Eclipse and this difference seemed to make it risky. I am convinced now that it would not be fair to attribute it to Eclipse.

Thanks to all who replied!

18 years ago
When I migrated my IDE from JBuilder2005 to Eclipse I got a mysterious null pointer exception in my project that had never been there before. Here is a small piece of code that demonstrates the essence of the problem:

When compiled with Eclipse and run, I get the following error message:

Exception in thread "main" java.lang.NullPointerException
at Test.access$0(
at Test$Inner.lalala(
at Test$InnerSuper.<init>(
at Test$Inner.<init>(
at Test.<init>(
at Test.main(

Somehow Eclipse inserted a method called access$0 into my class that hits a NullPointerException. When I compile my class with JBuilder or javac it runs without problems.

I am aware that I am not supposed to call an overriden method from the InnerSuper's constructor, because the Inner's member variables won't be initialized when it's called. However in this case there are none (at least no explicit ones). It seems that there is some hidden code that establish a relation between the inner class and its surrounding class that is not yet initialized when the initialize() method is called from the constructor.

My question is: is this a bug in Eclipse and should I report it as such or is this legal behavior according to the Java standard and should I refactor my code (which I probably should anyway)?

Thanks for your thoughts,

18 years ago
The possibility of deleting and adding records add some concurrency issues to your application that would not be there if they did not need to be supported.

I think it would be legal not to implement the delete and add methods, as long as the other methods would be compatible with them. For example, the lock method should check if the record it had been waiting for has been deleted whilst it was waiting. (Hint: failing to do this is a strong candidate of the source for the infamous 44/80 locking score.)

I took the safe road however and implemented both completely. As mentioned above, the methods are very convenient for your testing.

FWIW it took me a 100 hours to complete the assignment and I like to think that I stayed very focussed. And that does not include the countless hours I have spent on this forum.
Of course if I were to do it again I could probably do it in lees than half of the time, but that is comparing apples and oranges.

Regarding the 80% pass rate: it is not surprisingly high, because you can take as much time for the assignment as you like. Which should mean that you only submit your work when your are satisfied that you did a good job. So apparently a whopping 20% of the candidates make an error of judgement there...

Hi Marcos,

I choose option 1.


Originally posted by Ailsa Cape:
Hi, Andrew

Thank you!

I just read my instructions in the subsection, "javadoc style commments must be used for each element of the public interface of each class...Provide javadoc documentsation for all classes you write", so I think I have to use the "private" parameter in javadoc tools.

Best Regards, Ailsa Cape

Hi Ailsa,

Are you sure that private methods are part of the public interface of a class?

Hi Edwin,

Since both packages are part of the J2SE, you should be allowed to use these. (IMHO of course.)


Originally posted by Dawn T.Y.Lee:
The condition of the "for loop" is manully calculated.
So stupid.... but How can I write in another smart way ??

Hi Dawn,

You can use the length() method of RandomAccessFile to determine the file length. Using this value you can calculate how many records exist in the file.


Originally posted by Louis Tong:
Using Swing/AWT is a must? can I use SWT instead of Swing?

Hi Louis,

Using Swing (but not AWT) is a must. It is not allowed to use SWT or any other third party software.


Originally posted by Max Habibi:
3 - 4 months is pretty fast. Personally, I'm not aware of anyone completing the assignment more quickly.

I don't mean to brag, but I completed the assignment in less than 6 weeks. I managed to put 100 hours into it during this time whilst doing a full time job, so you can imagine I did not have much of a life during this period.

I think though that finishing it in a short time span makes for a more efficient and consistent solution, because you don't need to rediscover what you were doing the month before when you last worked on the assignment.


18 years ago

I can appreciate your point of view, but what's the difference in spending $50 on a case of beer for a mate to review your assignment and giving it to a professional (I hope!) outfit who are (or should be) very familiar with the material and probably (hopefully) run some test harnesses against it and make sure you don't auto-fail on anything?

You live in Norway? Because I am happy that a case of beer doesn't cost $50 where I live
But seriously, my point is that if you have someone you know review your code, you will know the quality of the review you will get. Companies have to make profit and as I already mentioned before, for $50 they won't be able to have a trained professional look at it for more than 30 minutes.

That might be just enough to check for the technicalities, but only if that would be the only thing they look at...