Skip to main content

Mess Around

Posted by editor on September 26, 2006 at 7:53 AM PDT

Why can't constructors do stuff before calling super()?

It's hard for me not to give a strong hint or quick answer in the editor's blog when we do the not-so-stupid questions, because the comments sections always offer some ideas and opinions that aren't immediately obvious, and from these insights come further discussion and brainstorming. And you shouldn't necessarily think that the comments already posted when you read the article are the final word on the subject either; with questions like today's, there are often several ways to think about why things are they way they are, and whether they really have to be.

So enough stalling, what's the question?
Today's Feature Article, features (Not So) Stupid Question #13: "Why do constructors have to start with a call to super()?" Put another way, what if you want to do some work to prepare an argument for your superclass' constructor... why can't you do that first and then call super()? We hope you'll take a look at the initial question and the motivation behind it, and then check in with the ongoing discussion in the comments.

In Java Today,
the Embedded Java Community page is featuring the article Wireless robotics: Object-oriented programming with (physical) objects: "Learn why there is room for the development of new, lightweight wireless networking protocols and how the profusion of wireless computers may represent one way to solve a traditional stumbling block of artificial intelligence."

jSh3ll, the Amazon S3 command shell for Java, is a Java based command shell for managing your Amazon S3 objects, built upon the Amazon S3 REST Java library. In addition to standard Amazon S3Shell functionality, jSh3ll provides ACL and HEAD retrieval for buckets and items, support for getting a .torrent file for an item, script mode support, streaming file upload support, file compression support with ZLIB, and more.

The Enterprise Java Beans (EJB) 3.0 specification vastly improves the simplicity of programming enterprise beans. This promises to increase your productivity as a developer. But what about the productivity of your production system? Will it be fast enough to meet the demands of your organization, or will you spend all your newly found free time refactoring code for performance?
The article Writing Performant EJB Beans in the Java EE 5 Platform (EJB 3.0) Using Annotations shows you how to get the best performance out of the new EJB 3.0 programming model.