20
I Use This!
Activity Not Available

News

Posted almost 14 years ago
At Devoxx France 2012, I attended to conference titled Seren, serialization under steroids ! presented by Olivier Croisier, who animates the codersbreakfast site. Seren, meaning SERialization ENhancer, is a free software allowing to speed up ... [More] serialization of Java objects. It can, for example, be used for a faster persistance of objects in Ehcache or to speed up remote method calls with RMI. To do its job, Seren is based on an agent manipulating the Java bytecode of a class to add writeObject and readObject methods as specified in the Serializable interface. If they already exist, Seren doesn’t modify the class. Among implemented optimisations, classes wrapping primitive types (Integer, Long …) are replaced by their associated primitive type (int, long …), plus a boolean indicating if the value is null. About String, they are encoded in UTF-8 (instead of UTF-16), when it’s possible. About performances, Seren is effectively faster for small objects but it’s not that good for big objects. It uses a bit more memory than classic serialization. About the compatibility, data serialized by Seren are obviously not binary compatibles with classic Java serialization. It also uses the sun.misc.Unsafe class, that isn’t part of the Java API, which means it’s not necessarily supported by a JVM other than Hotspot (the Sun Oracle JVM). It happens with IBM’s JVM. To note : Olivier has used the thrift-protobuf-compare library to measure Seren performances. This library allows to compare performances of various serialization protocols based on the Java platform. Results (not including Seren), are available here. If you are searching for a serialization library (not only in a binary format, but an xml or a json format) for various languages based on Java platform (Scala …), I invite you to consult the list of tested libraries on the thrift-protobuf-compare site. Some of them also manages various languages not based on the JVM (C, C++, Python, Javascript …). Using Seren is rather easy : put the Javassist library (allowing bytecode manipulation) in the classpath and add the Seren agent. No modification into the source code is necessary. To indicate classes to modify, it’s possible to use one of the ClassFilter implementations from the net.thecodersbreakfast.seren.filter package. Bookmark and Share More »Powered by Bookmarkify™ [Less]
Posted almost 14 years ago
The latest release of Ubuntu, version 12.04 aka Precise, has a lot of updates we’ve been waiting on for a while — GNOME 3.4, Haskell 7.4.1, and a huge stack of bugfixes. On the desktop side, quite a number of Linux kernel vs X video modes vs suspend ... [More] glitches have gone away. That’s fantastic. During most of Oneiric, my laptop was freezing and needing a hard reset at least once a day. Tedious. So I’m quite pleased to report that running Precise, Linux 3.2, gdm, and GNOME 3.4, things are vastly more stable. Getting upgraded to Precise, however, has not been a pleasant experience. First we’ve had unattended-upgrades overwriting any configuration stating “no automatic upgrades”. The number of non-technical friends who were set to “security updates only” calling in wondering why a “big upgrade” happened and now their computers don’t work has been staggering. Needless to say we nuked unattended-upgrades from all of our systems a hurry, but for those people it was already too late. Several desktop upgrades failed half-way through because dpkg suddenly had unresolved symbol errors. Fortunately I was able to work out the missing library binary and manually copy it in from another machine, which was enough to get package system working. Hardly auspicious. Server side was fraught with difficulty. You cannot yet upgrade from Lucid to Precise. It breaks horribly. E: Could not perform immediate configuration on 'python-minimal'. Please see man 5 apt.conf under APT::Immediate-Configure for details. (2) Brutal. I tried working around it on one system by manually using dpkg, but that just led me into recursive dependency hell: # cd /var/cache/apt/archvies # dpkg -r libc6-i686 # dpkg -i libc6_2.15-0ubuntu10_i386.deb # dpkg -i libc-bin_2.15-0ubuntu10_i386.deb # dpkg -i multiarch-support_2.15-0ubuntu10_i386.deb # dpkg -i xz-utils_5.1.1alpha+20110809-3_i386.deb # dpkg -i liblzma5_5.1.1alpha+20110809-3_i386.deb # dpkg -i dpkg_1.16.1.2ubuntu7_i386.deb # apt-get dist-upgrade Huh. That actually worked on one system. But not on another. Still slammed into the python-minimal failure. For that machine I couldn’t mess around, so I had to give up and did a re-install from scratch. That’s not always feasible and certainly isn’t desirable; if I wanted to be blowing systems away all the time and re-installing them I’d be running Red Hat. Anyway, I then located this bug about being unable to upgrade (what the hell kind of QA did these people do before “releasing”?) where, very helpfully, Stefano Rivera suggested a magic incantation that gets you past this: # apt-get install -o APT::Immediate-Configure=false -f apt python-minimal # apt-get dist-upgrade (I had tried something very close to this, but didn’t think of doing both apt and python-minimal. Also, it hadn’t occurred to me to use -f. Ahh. For some reason one always sees apt-get -f install not apt-get -f install whatever-package-name). Ta-da. AfC [Less]
Posted almost 14 years ago
For the conference titled Deadlock Victim at Devoxx France 2012, Heinz Kabutz and Olivier Croisier were talking about the DeadLock subject. By taking the dining philosophers problem as example, they show us that an inappropriate strategy can lead to ... [More] a DeadLock. In the case of a database, the engine chooses the deadlock victim by returning an SQL exception to one of the involved clients. On the other hand, in the case of a Java program with a minimum of 2 threads trying to access 2 resources (after they have locked them), there is no exception to indicate a thread is involved in a DeadLock (in that case, it would be good that the thread throw an Error). The solution to this problem (named Left-Right DeadLock) is to apply the following strategy to all the philosophers : take (lock) the flatware on his right side take (lock) the flatware on his left side put down (unlock) the flatware on his left side put down (unlock) the flatware on his right side Remarks : It’s certainly possible to take the opposite strategy : the left side flatware, then the right side one. The essentiel is that all philosophers apply the same strategy. It’s important that a philosopher put down its flatwares in the opposite order he has taken them Instead of using right-left notion, it’s possible to number each flatware with a unique number. In this case, there are 2 possible strategies : start by taking the flatware with the smallest number (among the 2 ones located near the philosopher), start by taking the flatware with the biggest number. Again, it’s important that all philosophers apply the same strategy. It gives a generic solution to DeadLock problems : define a strict order among resources (by associating them for example to a unique numerical identifier) and apply the “smallest first” strategy. Among concrete cases, there is the private writeObject(ObjectOutputStream) method from Vector class, synchronized on the instance. A DeadLock could occur while serializing 2 vectors containing a reference to the other. For the unit test side, how to check a DeadLock is fixed ? How many time should the test be played to prove the fix is working ? Indeed, a DeadLock can happen from time to time and not always systematically. A good test must pass or not, independantly from external conditions (load of processor …). Heinz and Olivier propose to add an empty method named sleep into the production code and call it between 2 attempts to lock 2 different resources. By overloading the sleep method into the test code to call Thread.sleep(long), it becomes possible to reveal the presence or the absence of a DeadLock in a determinist way. Since Java 6, there is new features allowing to make it easier to detect and fix a DeadLock : Visualize threads state of a running JVM : Under Windows : The JVM must have been launched in a console and type Ctrl-Break Under Linux : If the JVM has been launched in a console, type Ctrl-\. Else, send the QUIT signal to the process with the command kill -QUIT process_id, where process_id is the process identifier (you can find it with the command ps axf | grep java) Then, use the command jstack process_id. List threads involved in a DeadLock by using JMX. It only works for locks of the same type used by ReentrantLock and not for locks using a monitor (keyword synchronized). To illustrate that, Heinz and Olivier have created a class named DeadlockArbitrator that kills a random thread among the ones involved in a DeadLock (the list is obtained through JMX). Then, they show a demonstration of a Swing application with a button to create a DeadLock and another to kill a thread involved in a DeadLock (by using the DeadlockArbitrator class). Remark : to kill a thread, the DeadlockArbitrator class uses the deprecated method (useful in our case) Thread.stop(Throwable). This technic must only be used for code that you can’t fix (third party libraries). In other cases, you must obviously fix the DeadLock. For more informations on technical subjects like this one, Heinz invite us to look at his site Javaspecialists.eu Bookmark and Share More »Powered by Bookmarkify™ [Less]
Posted almost 14 years ago
Two weeks shy of ten years ago, I joined Red Hat as an intern on the Red Hat Database team. I was incredibly lucky to have gotten that internship and then to have been hired on full time 2 years later. I’ve had a great time working at Red Hat but ... [More] have made the very difficult decision to leave. My last day is tomorrow, Monday April 30th. Red Hat has provided me with many things: innumerable learning opportunities, career growth, exposure to open source communities, public speaking opportunities at conferences, and more. Most importantly, though, I’ve been given the chance to work with a lot of really amazing people both inside Red Hat and in a variety of vibrant Free Software and Open Source communities. The Eclipse community has been my home for a few years now. It’s full of some of the most talented and passionate software developers I’ve ever met. I plan to remain involved in the Eclipse world and am looking forward to getting Linux Tools 1.0 released as a part of Juno and what comes after that! I’ve excited for my new job but have a few weeks of down time in between where I hope to largely be AFK. I’ll write a blog entry here when I start my new job. I’ll still be around the open source world and if you’d like to contact me I’m reachable here on my blog or via various social networks. I wish everyone continued success both personally and professionally. Thanks for everything and I’ll see you around. [Less]
Posted almost 14 years ago
On Java.com:Java SE 7 Update 4 will be the first consumer release of the Java 7 JRE, scheduled to be made available as the default version on Java.com starting on May 1, 2012.In Fedora 17: Java 7 (OpenJDK7) is the default Java runtime and Java build ... [More] tool set.In Ubuntu 12.10:Please note that OpenJDK 7 will become the default Java implementation in Ubuntu 12.10.At Jelastic:We decided to try something new. We made Java 7 the default choice this month and, as you can see, it made a huge difference in JVM popularity. [Less]
Posted almost 14 years ago
OpenJDK 7 (closely aligned to Oracle Java 7) is avaliable in Universe.Please note that OpenJDK 7 will become the default Java implementation in Ubuntu 12.10.Taken from the Precise Pangolin release notes.
Posted almost 14 years ago
I'll be speaking at JavaOne India next week in a couple of sessions.See you there!
Posted almost 14 years ago
If, like me, you are developing under an Android version older than version 4 (also named Ice Cream Sandwich or ICS), you must have seen the SDK Manager doesn’t propose you to get the sources. In fact, it’s possible to manually download them. For ... [More] that purpose, you must go to the grepcode site, where one can find sources for all versions since 1.5. You must choose the version that interest you in the right side of the page, then download the sources as a jar file by clicking on the link “Source download”. Finally, under eclipse (or your favorite IDE), you can associate these sources with the android.jar library. It’s more practical to debug Remarks : For versions before ICS, all sources are not available You can also consult sources online by exploring the tree located at the left side of grepcode site Bookmark and Share More »Powered by Bookmarkify™ [Less]
Posted almost 14 years ago
While I was developing under android, I discovered 3 exceptions thrown by android to indicate execution of code in the wrong thread. The first case is about execution of a request with the apache HTTP client, provided with android. The android ... [More] documentation advice to use the AsyncTask class for long tasks, in order to avoid blocking the main thread (used to update the graphical interface). An HTTP request must always be considered as a long task because a fast request at a given time might take more time in production (because the network or the server can be more loaded sometime). Android 3 (API 11) force that good practice by throwing a NetworkOnMainThreadException exception if you use the main thread to execute an HTTP request. The second case is about updating the graphical interface in the wrong thread. If you are in that case, then android will throw a CalledFromWrongThreadException exception (apparently not documented in the android javadoc) with the message Only the original thread that created a view hierarchy can touch its views.. That happened to me by calling indirectly the following code from the AsyncTask.doInBackground method : loginEditText.setText(""); passwordEditText.setText(""); Remarks : loginEditText and passwordEditText are fields whose type is EditText The code is running in a thread created by the AsyncTask class. If, instead of using AsyncTask, you create directly a new thread or use a component that do it, you will have the same problem. The solution is to use the Activity.runOnUiThread method that way : runOnUiThread(new Runnable() { @Override public void run() { loginEditText.setText(""); passwordEditText.setText(""); } }); The third case is a variant of the previous one. Here, there is no specific exception but a RuntimeException with the less explicit message Can’t create handler inside thread that has not called Looper.prepare() when the AlertDialog.Builder.create method is called. When that arrived to me, I have replaced the following code : AlertDialog alertDialog = new AlertDialog.Builder(context).create(); ...... (initialization of the dialog box) alertDialog.show(); by this one : Activity activity = ......; // get the activity activity.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog alertDialog = new AlertDialog.Builder(activity). create(); ...... (initialization of the dialog box) alertDialog.show(); } }); Bookmark and Share More »Powered by Bookmarkify™ [Less]
Posted almost 14 years ago
PRICE 1.1.0 is out!It has been a long hiatus, I essentially skipped a release and made two in one. What's new?Curves: this was a lot of work (and will need more). Smooth way to correct highlights and shadows with an S-curve. Source and resulting ... [More] histograms are displayed.Bilinear filtering: scaling will now look better!Minor tweaks to the interface, like the filters that on cancel while previewing or on GNUstep the convolve matrix reacting on end editing.Furthermore a plethora of bug fixes and portability enhancements.Get it here from SourceForce, in form of sources for all platforms (GNUstep or Cocoa) or as Macintosh binary.It has been 10 years I've been working on PRICE. This is kind of an anniversary release. It has been a long time and it has been fun and I hope it will continue! But it is an amazing long time. There have been ups and downs, and some melancholy creeps in! I think I will blog more about some past and future ideas about GNUstep. [Less]