This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the GCJ project. See the GCJ home page for more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
I've just heard back from one of the Sun Java Software group's computational theologists,regarding <clinit> and active use. My question: "Could you please clarify how much leeway there is with running <clinit> early (i.e; before where the first active use would be)? " Sun's answer: "zero" My observation: "there are various threads of discussion concerning this w.r.t static compilation of Java, and some compilers run <clinits> on all classes before main() to avoid penalising the code with the "first use check". This would appear to be capable of producing incorrect semantics (especially when there are dependencies on execution order)." Sun's answer: "People trying to do static compilation of Java often subvert the semantics. This is unacceptable." Sun's view seems pretty concrete. cheers, Jerry -----Original Message----- From: Godmar Back <gback@cs.utah.edu> To: Jim Van Peursem <Jim_Van_Peursem-FJV100@email.mot.com> Cc: java-discuss@sourceware.cygnus.com <java-discuss@sourceware.cygnus.com> Date: Thursday, April 08, 1999 4:41 PM Subject: Re: first active use of a class > > I think he said that the way to bend the rules is to create >"active uses" before invoking main(). The JLS spec supposedly >leaves open what is done before main(). Hence, one could insert >code that uses non-constant static fields. >Or, you could have your JNI driver first invoke a Class.forName(, true) >for all classes you're interested in before it invokes main(). > > - Godmar > >> >> >>>>> "Godmar" == Godmar Back <gback@cs.utah.edu> writes: >> Godmar> A couple of weeks ago, we had Guy Steele visiting the >> Godmar> University of Utah. We had the chance to discuss some Java >> Godmar> issues with him. >> >> Godmar> One issue was the issue of "first active use" of a class. I >> Godmar> pointed out that WAT compilers such as gcj are being penalized >> Godmar> because they have to insert code that checks for each possible >> Godmar> first use of a class whether its <clinit> initializer needs to >> Godmar> be invoked. >> >> Godmar> He said that his interpretation of the JLS gives such compiler >> Godmar> writers the freedom to preinitialize all classes before you >> Godmar> even invoke the main method; essentially saving that test. >> >> There's a (not well publicized) clarification note from Sun that >> amongst other things addresses class initialization: >> >> http://java.sun.com/docs/books/jls/clarify.html >> >> The description (paraphrasing) says that a class will be initialized >> "immediately before" the first occurrence of a few different types of >> uses. So this comes down to your interpretation of the term >> "immediately before" being used. >> >> -jvp >> >> ------------------------------ >> Jim Van_Peursem, Ph.D. >> Motorola, Inc. >> 1301 E. Algonquin Rd. >> Schaumburg, IL 60196 >> e-mail: jvp@ccrl.mot.com >> ------------------------------ >> I don't speak for Motorola >> Motorola doesn't speak for me >> ------------------------------ >> > >