James Gosling: on the Java Road

« Java Urban Performan... | Main | Science Fair, Monter... »

20051014 Friday October 14, 2005


Fault Containment: an unsung hero

As I suffered through the nth application crash of the day, I couldn't help thinking of my favorite underappreciated Java feature: fault containment. Between try{}catch and the tight memory model, failures tend to happen close to where the error is, and they can be caught with a very good chance that there has been no corruption of neighbouring data structures. So if you're using some sort of editor and one of the commands has a bug in it, if it's written in Java you usually get a little pop-up box that says something like "error in command", and you can carry on working. In C apps, one bad pointer and you're blown out of the water, with all of your editing lost. This is particularly bad in systems that use plugins where the amount of QA is variable. A lot of what motivated the tight memory model was me having wasted too much of my life tracking down weird exotic memory smashes, and vowing to never have to waste time on stuff like that again.

(Fri Oct 14 19:37:15 PDT 2005)
Permalink Comments [31]

Trackback URL: http://blogs.sun.com/jag/entry/fault_containment_an_unsung_hero
Comments:

amen

Posted by A brother in arms on October 15, 2005 at 11:57 AM PDT #

And yet, Java is only half way there at best. Swing listeners, renderers, and models can all easily fault in such a way that they cripple an application. Isolates still aren't available as part of the Sun JRE, so there is no containing errant threads. Lack of compilers for the JVM means that native code is often only realistically available via JNI--effectively bypassing all fault containment. The cup is neither half full, nor half empty. It needs more Java.

Posted by Curt Cox on October 17, 2005 at 07:37 AM PDT #

1.) Why should a java-compiler make access to native cod easier? 2.) Hhmm, swing listeners and rendere also throw exceptions. What you want is a java which tells you that your code is broken or whatever. I guess you belong to the group of people which only have used VB and a bit of java and now spread FUD like java is slow on the one side and java is to low level on the other. I spread arround that I do not need SUN since there are open source implementations which will be happy to share their codebase with you to implement a language that does what you expect it to do. lg Clemens

Posted by Linuxhippy on October 17, 2005 at 09:29 AM PDT #

I think the reference to "Lack of compilers" is meaning that there are very few languages that are well supported by the JVM other than Java. This theoretically contrasts heavily with DotNet, where it fully supports C#, VB.Net, J#, and C++. Of course, in reality, the "Managed" C++ is not really fully CIL in about 99.99% of cases, but the progress on that side has been much quicker. We will probably see similar levels of support for Java in a few years, though, thanks to the GCJ and Mono work.

Posted by Jesse Sightler on October 17, 2005 at 01:37 PM PDT #

Syntactic sugar: was just thinking it would be nice to skip the catch clause for the (many) default cases where I just want to re-wrap and throw an exception. For example, supposed I have a method that takes a String argument containing a supposedly valid URL, then reads from that URL into a buffer and processes it. What I want is to notify the caller if the URL was not valid--not that the whole method failed, but that it failed because the URL was not valid. What would be nice is just to mark my try block with the intention of the block:

pseudo-code:

public Data processURL(String url) 
throws ProcessDataException {
  URL source = null;
  @intend("Convert String into a valid URL.")
  {
  source = new URL(url);
  }
  ... process it
}

the @intend is a try/catch block where the catch would be triggered if the block threw an exception, and would re-throw a single declared exception for the method, using either a String, Throwable or String constructor (in that order). Declaring the intention of the try clause before the clause seems to read better.

Patrick

Posted by Patrick Wright on October 18, 2005 at 01:23 AM PDT #

The background graphics of this site make it very difficult to read. The text content of this site is good, but after straining my eyes for 5 minutes I gave up. For the last couple minutes I tried highlighting the text which makes the text white on blue and is unfortunately difficult to read for a whole other set of reasons. If you get of the background image, I'll be sure to stay longer next time. Best regards

Posted by Anton on October 19, 2005 at 06:53 AM PDT #

It is very easy for a program to cause stackoverflow, outofmemory errors and cause the java application server to crash.

Posted by Kamal Anand on October 21, 2005 at 12:45 PM PDT #

good

Posted by 213.161.144.166 on October 24, 2005 at 11:42 AM PDT #

Somedays ago, I got a problem when I test the autoboxing of jdk5.0. It confused me. here is the codes. public static void main(String[] args) { int small = 5; //-128 <= small <= 127 Integer k1 = small; Integer k2 = small; System.out.println(k1 == k2); // true int big = 129; //big than 127 Integer j1 = big; Integer j2 = big; System.out.println(j1 == j2);// false } Does anybody know why the first output is "true"? Does autoboxing treat the value which is less than a byte(-128 -- 127) differently against bigger numeric? Or they just like String class, store byte numeric in stack not in heap, so if two Integer autoboxing the same small int value, they will refer the same Integer Object in the stack?

Posted by kenio on October 27, 2005 at 05:49 AM PDT #

Somedays ago, I got a problem when I test the autoboxing of jdk5.0. It confused me. here is the codes.

public static void main(String[] args)
{
int small = 5; //-128 <= small <= 127
Integer k1 = small;
Integer k2 = small;
System.out.println(k1 == k2); // true
int big = 129; //big than 127
Integer j1 = big;
Integer j2 = big;
System.out.println(j1 == j2);// false
}

Does anybody know why the first output is "true"?

Does autoboxing treat the value which is less than a byte(-128 -- 127) differently against bigger numeric?
Or they just like String class, store byte numeric in stack not in heap, so if two Integer autoboxing the same small int value, they will refer the same Integer Object in the stack?

Posted by kenio on October 27, 2005 at 05:55 AM PDT #

Do you have any comments/explanations for your "mistakes" made in design of some java classes outlined here: http://jroller.com/page/cpurdy?entry=the_seven_habits_of_highly "Now to be fair, James Gosling and Arthur van Hoff were jointly responsible for the original mistake that has come to be known as java.util.Date." Do you have guts to accept some mistakes, and more importantly influence upcoming Java versions with design fixes?

Posted by Java Developer on November 01, 2005 at 01:06 PM PST #

I absolutely agree with your statement that fault containment is an important feature of Java. It dramatically increases programmer productivity. We all make errors, and the Java compiler and VM help us find them FAST.

Sadly, that is not true with Enterprise Java. I just started doing EJB3 programming, lured by the promise of POJOs. That promise is real, but my productivity with Java EE is pitiful. Every little thing leads to "the stack trace from hell". I stop thinking about my app, grab the shag pipe and put on the checkered cap, and start sleuthing for the next hour. I hate it.

See <a href="http://www.horstmann.com/elvis/hated-error-messages.html" >http://www.horstmann.com/elvis/hated-error-messages.html

In a nutshell, the problem is that the app server, just like the C heap, has been implemented with the assumption that programmers make no mistakes.

Posted by Cay Horstmann on February 04, 2006 at 09:09 AM PST #

The background graphics of this site make it very difficult to read. It should has large font size.

Posted by glen on March 12, 2006 at 09:19 PM PST #

In reference to what Anton says, I agree that stack overflows and the dread Java OutOfMemory still remain, it's all got a lot nicer in Java 6 - the dump heap on OutOfMemory is a life saver, as is the ability to attach with JConsole at anytime. And DTrace is the best thing in the world ever, ever. Developing Java just got a whole lot easier.

Posted by James Massey on June 19, 2006 at 04:50 AM PDT #

Hi ! I have written some code in my module.I used Java technology.I want some information exchange with another module which is developed in .NET Technology.The problem is that When i use 'socket' programming to communicate with that .Net module over LAN , i get some encoding error as response.I used the "InputStreamReader" that take Encoding type as one argument .Still i get the same error. I want the solution as soon as possible

Posted by Sashikanta Mishra on October 26, 2006 at 08:06 AM PDT #

http://www.goldsoon.com

Posted by Goldsoon on November 07, 2007 at 05:47 AM PST #

Trying to be impressive!deeply wonderful here!
g2gmart/rsloads is an professional store for
http://www.g2gmart.com runescape gold,
http://www.g2gmart.com runescape items,
http://www.g2gmart.com runescape accounts,
http://www.g2gmart.com runescape powerleveling,
http://www.rsloads.com/runescape-accounts.html runescape accounts,
http://www.rsloads.com/free.html runescape gold,
http://www.rsloads.com/runescape-othergoods.html runescape items,
http://www.rsloads.com/runescape-powerleveling.html runescape powerleveling,
runes and some other goods with fast delivery and world class service.

Posted by g2gmart on January 16, 2008 at 11:17 PM PST #

http://www.eing.com
http://www.yaoflowers.com

Posted by wow gold on March 13, 2008 at 08:11 AM PDT #

I think the reference to "Lack of compilers" is meaning that there are very few languages that are well supported by the JVM other than Java.

I have a question!What's this mean!

Posted by eq2 plat on April 06, 2008 at 07:45 PM PDT #

i am lost wtf it didnt compile...

h0ly - revolution
Check out my java site as well
http://www.g4hq.com/tags.php?tag=java

Posted by MMORPG Forums - Runescape World of Warcraft Maplestory on October 07, 2008 at 12:35 PM PDT #

Wowgolds.us is a super World of Warcraft Goldstore, We supply the World of Warcraft Gold (WOW Gold) all servers, include EU and US Realms. And We also supply the services of World of Warcraft Power Leveling. 24 hours a day, 7 days a week by online Support and email.

http://www.goldsrunescape.com/
http://www.runescape2gold.net/
http://www.lotro-golds.us/
http://www.mesos-maple.com/

Posted by ohyeshi on November 16, 2008 at 01:34 AM PST #

[URL=http://www.mmoga.com]wow gold[/URL]
[URL=http://www.mmoga.com]wow levelservice[/URL]
[URL=http://www.mmoga.com]buy wow gold[/URL]
[URL=http://www.mmoga.com]wow account wow levelservice[/URL]
[URL=http://www.mmoga.com]wow gold[/URL]
[URL=http://www.mmoga.com]wow levelservice[/URL]
[URL=http://www.mmoga.com]buy wow gold[/URL]
[URL=http://www.mmoga.com]wow account wow levelservice[/URL]
[URL=http://www.mmoga.com]wow gold[/URL]
[URL=http://www.mmoga.com]wow levelservice[/URL]
[URL=http://www.mmoga.com]buy wow gold[/URL]
[URL=http://www.mmoga.com]wow account wow levelservice[/URL]

Posted by mmoga on November 27, 2008 at 05:08 AM PST #

http://www.nizikaikun.com/
http://www.ms-online.co.jp/eshop/goods/ona_hole.php
http://www.ms-online.co.jp/eshop/goods/costume.php
http://www.ms-online.co.jp/eshop/goods/vibe.php
http://www.ms-shop.co.jp/shop/goods/goods.asp?category=5308
http://www.omochacha.com/
http://www.av-one.jp/zero/top.html
http://www.a-world.co.jp/
http://www.a-toy.ne.jp/
http://www.s-one-company.jp/
http://www.ec-life.co.jp/bath/index2.html
http://www.tbnetjapan.com/medlegal/
http://adultshop.co.jp/omocha.html
http://adultshop.co.jp/adultshop.html
http://adultshop.co.jp/enemagra.html
http://adultshop.co.jp/onahole.html
http://adultshop.co.jp/houkei.html
http://adultshop.co.jp/anal.html
http://adultshop.co.jp/denma.html
http://www.nicolas-dogs.com/
http://www.aqua01.net/
http://www.kabudayo.com/
http://www.fxf-business.com/
http://kaketayo.sakura.ne.jp/
http://www.11cash.net/
http://telink.jp/
http://www.complete-watch.com/

http://adultshop.co.jp/dutch.html
http://www.blyjapon.com/
http://www.achelabo.jp/
http://umanity.jp/
http://www.worldflower.net/rs/
http://furniture.michiookamoto.com/
http://www.blyjapon.com/
http://www.achelabo.jp/
http://www.open-japan.com/
http://www.open-japan.com/ideabox/index.php?category=beauty#top
http://www.open-japan.com/ideabox/index.php?category=dress#top
http://www.eic-av.com/
http://www.eic-av.com/list/fileIndex
http://www.saimu0.jp/
http://www.chasetokyo.com/charge.html
http://www.chasetokyo.com/whereabouts.html
http://www.chasetokyo.com/action.html
http://www.chasetokyo.com/immorality.html
http://www.chasetokyo.com/philippines.html
http://www.sigmac.jp/
http://www.tokei-biho.com/
http://www.rmtplusone.com/lineage2/
http://www.takumi-pg.com/
http://www.webtravel.co.jp/asia/chaina/
http://www.webtravel.co.jp/
http://www.trivy-system.com/Kekkon.htm
http://www.trivy-system.com/Sinyou.htm

Posted by thanhvn on December 18, 2008 at 07:27 AM PST #

http://www.louisvuitton2u.com Louis Vuitton

Posted by louis vuitton on April 13, 2009 at 09:51 AM PDT #

<b><a href=http://www.gold2key.com>Sell WoW Gold</a></b>
<b><a href=http://www.cheapwowgold2u.com>WoW gold buy</a></b>
<b><a href=http://www.goldsales4u.com>buy WoW gold</a></b>

Posted by flying on July 22, 2009 at 10:20 AM PDT #

<b><a href=http://www.gold2key.com>Sell WoW Gold</a></b>
<b><a href=http://www.cheapwowgold2u.com>WoW gold buy</a></b>
<b><a href=http://es.goldsales4u.com>wow oro</a></b>

Posted by gold2key on July 31, 2009 at 09:11 PM PDT #

电磁流量计 涡轮流量计

Posted by 电磁流量计 on November 05, 2009 at 10:39 PM PST #

<a href="http://www.shopstyleonline.co.uk/atlanta-falcons-jerseys-c-11.html" target="_blank">Atlanta Falcons Jerseys</a>
<a href="http://www.shopstyleonline.co.uk/atlanta-falcons-jerseys-c-11.html" target="_blank">atlanta falcons nfl</a>
<a href="http://www.shopstyleonline.co.uk/atlanta-falcons-jerseys-c-11.html" target="_blank">atlanta falcons merchandise</a>

<a href="http://www.trendyedhardy.com/" target="_blank">ed hardy clothing</a>
<a href="http://www.trendyedhardy.com/" target="_blank">ed hardy discount</a>
<a href="http://www.trendyedhardy.com/category-17-b0.html" target="_blank">Ed Men Short Sleeve</a>

Posted by shopstyleonline on November 08, 2009 at 07:00 PM PST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed