SimpleDateFormat is not thread-safe

How many of you use java.text.SimpleDateFormat as static field?

I have seen this to be pretty standard practice (and have done this myself too).

Be aware that SimpleDateFormat#format(..) is not thread-safe and thereby for most of the cases you should not use this as a static field in server, Eclipse RPC or any other multi-threaded environment.

SimpleDateFormat is internally using field “calendar” that is set with each #format(…) method call so that pretty much breaks the thread-safety.

Google mentor summit is on!

Greetings from Mountain View, Google HQ in California!

Summit is on and sessions scheduled. There is a lot of fun going on and I’ll try to get some of it here, stay tuned!

I’m here representing Eclipse Foundation as one of the organizations participating in Google Summer of Code.
Eclipse had a lot of strong summer of code projects this year and 20 out of 22 projects succeeded, have a look at http://wiki.eclipse.org/Google_Summer_of_Code_2008 for more information.

In addition to me there are Markus Alexander Kuppe and Steffen Pingel from Eclipse and there has already been quite a lot of blending with orgs like Blender, K3D, opensuse etc :)

best regards,
Ahti

Turning off win xp master volume beep sound

Aren’t you annoyed by the beep that is so loud?

I got pretty frustrated after trying to look for disablement under volume control preferences. Nothing there. Also turning off all sound notifications at control panel (including Exclamation sound) didn’t help.

Still nothing, just one aloud beep.

Windows Master Volume Control

Windows XP Volume Control

 

Here’s the quickest way I found to disable it:

  1. Go to My Computer
  2. rightclick for Properties
  3. tab Hardware
  4. button Device Manager
  5. menu View
  6. set checkbox Show Hidden Devices
  7. navigate to Non-Plug and Play drivers
  8. open Beep
  9. tab Drivers
  10. button Stop
  11. combo Disabled
  12. button OK
  13. Congratulations!

 

Windows XP Volume Control

Disabling beep driver forever

 

If you find a better way, please let me know :)

Usability of the week: MS Project 2007 search dialog

How to search for all tasks in MS Project file?

You can’t. By default MS Project is searching for only expanded tasks. So it is obvious to expect search dialog to have checkbox for all-nodes search.

But looks like there is no such checkbox so you always have to expand.

Instead of the checkbox the search dialog has pretty much only two combos: “Test:” and “Field:” (“Search:” has just “Up” and “Down”) :

MS Project search dialog

Maybe it’s just me but they look funny and probably used only for about 0.1% of the searches people do? :)

PS! Should we be worried when project file size suddenly drops from 1MB to 400KB but all information is still there?

Refreshing eclipse workspace with ant script

Did you knew that if you have ant build.xml in eclipse Ant view then you can refresh your eclipse workspace simply using:

<eclipse.convertPath filesystempath=”${basedir}” property=”resource.basedir”/>
<eclipse.refreshLocal resource=”${resource.basedir}” depth=”one”/>

?

Very handy for build scripts to make sure eclipse resources are in sync after the build.

Thanks to Roland for the tip!

Getting unsigned bytes in java

Welcome back after long overwork and vacation period :) Let’s start small, it’s still almost summer.

Bytes in java are always signed and are quite horrible to use because of the casting and weird side-effects (or I’m just stupid enough to call it weird).

But we need unsigned bytes quite a lot. Most of the time for reading various streams (networks, 8bit strings etc) some text stream you still end up with byte streams.

There is a nice trick converting them from signed to unsigned in case you want to get normal 0..255 range for the chars.

byte mybyte = -104;
long mynewint = mybyte & 0xFF;

Hope it helps!

I had quite a nice puzzling while trying to find some easier way. Is there?

Getting TPTP installed in Ubuntu – first post from Ivar

One of the Codehoopers started to blog about Eclipse and programming, welcome aboard! :)

As he doesn’t have much readers yet I guess it’s ok to point to his first post: Eclipse TPTP and Ubuntu”

It’s about getting TPTP running. Especially under Linux. Don’t underestimate the complexity of this – it’s not that easy :)

Nice post, thank you!

PS. Some old-time readers might remember that Ivar has been featured at this blog also before – Four is the Magical Number – and so is 5920.

Enabling 3D with ATI and NVIDIA – ubuntu and debian

hmm.. getting 3D enabled for ATI and NVIDIA is still very tricky. With ubuntu you can recompile a kernel package AND/OR recompile restricted modules AND/OR compile a custom kernel with ATI/NVIDIA modules. There are 4-5 different options for getting it done. Each has it’s drawbacks. And even after spending lot of time figuring it out – next time you update the kernel, you’re screwed again :)

You can scratch your head for hours wondering why everything should work but glxinfo shows Mesa as active driver. You need direct rendering! Even if you’re not playing any games. 2D rendering saves a lot of CPU and linux runs much faster.

For ATI, when you download the linux proprietary driver installer – I’ve never seen it working without any special tweaks. Plus their installation guide is quite out-dated and not in sync with the real installer.

SO – Here’s the lifesaver – Envy! It’s a small utility that takes care of these tweaks and with a very simple user-interface fetches all the important packages, installs all the properietary stuff and makes sure that conflicting drivers are disabled/uninstalled/removed.

I gave it a try and – this thingy started from scratch and – I was done in 5minutes – everything working great!



Envy main screen

Eclipse workspace fails to start after crash – quick fix

Here’s a quick HOWTO for resolving Eclipse startup workspace loading problems. If you have a better suggestion then please leave a comment!

There can be a lot of other issues but here is one of the quite common ones – eclipse resources cache or state gets out of sync/corrupted.

This can happen when your IDE crashes OR also without crashing. For non-crashing case it’s more likely a logic/bug problem and whenever possible, try to file a bug at bugs.eclipse.org!

Sometimes, just SOMETIMES, you’ll get exceptions like following when launching Eclipse IDE after crashing it:

Root exception:
org.eclipse.core.internal.resources.ResourceException(null)[567]:
java.io.UTFDataFormatException: malformed input around byte 394
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.
readPluginsSavedStates(WorkspaceTreeReader_1.java:111)
at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.
readTree(WorkspaceTreeReader_1.java:159)
at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:916)
at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:647)
at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1319)
at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:1949)
at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:1713)
at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:363)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.
run(BundleContextImpl.java:999)
at java.security.AccessController.doPrivileged(Native Method)

The key here is row “org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:647)”.

This stakctrace means your root .tree file is damaged and thereby unable to restore your opened projects.

The quickest way to fix this or any other resource-related exception is to:

  1. Shut down Eclipse IDE
  2. Remove and backup your workspace/.metadata/.plugins/org.eclipse.core.resources directory
  3. Start Eclipse IDE (with -clean to be super-safe)
  4. Reimport all projects (UPDATE: Just use File->Import->Existing Project into Workspace and browse your workspace/project directory)
  5. Enjoy

Maybe deleting workspace/.metadata/.plugins/org.eclipse.core.resources/.root/*tree would have been good enough for my case but it’s definitely not a workaround for other possible workspace resource state and cache related exceptions.

I’m not sure if this information without any reproducible steps is useful for bugs.eclipse.org. Not filing it this time. Or should I?

Configuring Eclipse SVN (Subclipse) to use JavaHL(JNI)

Configuring JavaHL for Eclipse is not as straightforward as it could be so posting a quick HOWTO. Following applies mostly to Linux users.

With Ubuntu the fool-proof steps are:

  1. Make sure libsvn-java, subversion and libsvn1 packages are installed
  2. Add following to the end of your eclipse.ini file: -Djava.library.path=/usr/lib/jni
  3. Restart eclipse and make sure JavaHL is selected under Window->Preferences->Team->SVN

By using JavaHL it gets more likely that your svn repo doesn’t get screwed up when using both command-line/shell and subclipse for svn.



Configuring Eclipse to use native SVN client – JavaHL