Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #8256

Re: borrowing Constants

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: borrowing Constants
Date 2011-09-23 19:26 -0700
Organization http://groups.google.com
Message-ID <12905732.2457.1316831190534.JavaMail.geo-discussion-forums@prfh23> (permalink)
References <cf9q77h3gnhunlqpckpsobog4oqvlhiga7@4ax.com> <26090658.2452.1316830316920.JavaMail.geo-discussion-forums@prfh23>

Show all headers | View raw


Lew wrote:
> Roedy Green wrote:
>> When you use Class B, does all of class A get instantiated?
> 
> Strictly speaking, and I am fairly sure you don't mean this, a class with only static members might never, or cannot ever be instantiated (depending on the use of certain idioms).
> 
> As you know, I favor exactitude, some think colo-rectitude in certain terminologies.  
> It cuts both ways - I have to relearn terms when I have them wrong.

For example, Roedy correctly points out that classes do have a class object that instantiates when they load.  

There are two main stages to the usefulness of a type at runtime.  One is load, the other initialize.  They're like two steps in each class's private Big Bang of creation.

A class loads among other things upon reference to that class's instance variable, pointed to by the 'class' attribute.  Under that particular circumstance it does not also initialize.  That happens under non-pathological references to classes, such as access to behaviors or contents through their members.  ('class' is not a member.)  'final' fields, especially 'static' ones, most especially compile-time constant variables, get special treatment in the initialization.

I'll stop now.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 17:40 -0700
  Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 20:44 -0400
    Re: borrowing Constants Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-23 22:10 -0300
      Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 18:39 -0700
        Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 22:17 -0400
        Re: borrowing Constants Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-25 11:25 -0700
          Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-25 11:36 -0700
      Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 22:30 -0400
  Re: borrowing Constants Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-23 21:15 -0400
    Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 18:43 -0700
  Re: borrowing Constants markspace <-@.> - 2011-09-23 18:44 -0700
    Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-23 19:19 -0700
    Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-23 22:32 -0400
  Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-23 19:11 -0700
    Re: borrowing Constants Lew <lewbloch@gmail.com> - 2011-09-23 19:26 -0700
  Re: borrowing Constants v_borchert@despammed.com (Volker Borchert) - 2011-09-24 09:44 +0000
  Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-24 15:38 -0700
  Re: borrowing Constants Roedy Green <see_website@mindprod.com.invalid> - 2011-09-24 17:09 -0700
    Re: borrowing Constants Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-24 20:14 -0400
    Re: borrowing Constants markspace <-@.> - 2011-09-24 18:18 -0700
      Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-25 22:36 -0400
    Re: borrowing Constants Arne Vajhøj <arne@vajhoej.dk> - 2011-09-25 22:35 -0400
  Re: borrowing Constants Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-09-26 01:22 +0200

csiph-web