Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37448
| From | j4n bur53 <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Are Outer Classes Loaded Lazily? |
| Date | 2017-09-22 11:12 +0200 |
| Organization | albasani.net |
| Message-ID | <oq2k6k$9b6$1@news.albasani.net> (permalink) |
| References | <opu86b$k29$1@news.albasani.net> <oq13am$9v4$1@gwaiyur.mb-net.net> <oq16v8$sn$1@dont-email.me> |
Yes I am interested in loading and not in
intialization. Unfortuantely I have not yet
managed to add some good load tracing
to my app. The suggestion -verbose:class
is a command line option, but since I have
anyway a custom class loader,
maybe I can switch on/off the verbose
flag programmatically or pipe my own logging
message to somewhere, to figure out
whats going on...
Eric Sosman schrieb:
> On 9/21/2017 3:18 PM, Marcel Mueller wrote:
>> On 20.09.17 19.23, j4n bur53 wrote:
>>> Assume I have a nested inner class Inner,
>>> and I do the following:
>>>
>>> Class x=Class.forName('../Outer$Inner');
>>>
>>> And then I do the following:
>>>
>>> Class y=x.getEnclosingClass();
>>>
>>> Is the enclosing class '../Outer' already
>>> loaded during the Class.forName() or only
>>> when I do getEnclosingClass() ?
>>
>> AFAIK there are no dependencies in static construction of class types,
>> regardless whether they are inner, outer or whatever.
>> The only guarantee is, that a class initialization is run before any
>> member access. No more, no less. So unless you create such a
>> dependency you cannot assume the outer class to be initialized.
>>
>> Of course, the rule "before" is also fulfilled if the outer class
>> would be initialized immediately. So at the end it is implementation
>> defined.
>> But I assume that it is unlikely that an implementation initializes
>> the outer class earlier than required, just because this could break a
>> dependency of Outer on Inner. I.e. if the initialization of the outer
>> class accesses static members of Inner.
>
> Note that the O.P. did not ask when the classes were
> initialized, but when they were loaded. Loading is
> described (briefly) in JLS 12.2, linking in 12.3, and
> initialization in 12.4. For a more comprehensive (and
> harder to follow) description, see JVMS 5.3-5.5.
>
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-20 19:23 +0200
Re: Are Outer Classes Loaded Lazily? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-09-20 17:45 -0400
Re: Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-21 01:18 +0200
Re: Are Outer Classes Loaded Lazily? lewbloch@gmail.com - 2017-09-20 17:28 -0700
Re: Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-21 09:29 +0200
Re: Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-21 09:40 +0200
Re: Are Outer Classes Loaded Lazily? lewbloch@gmail.com - 2017-09-21 11:44 -0700
Re: Are Outer Classes Loaded Lazily? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2017-09-21 21:18 +0200
Re: Are Outer Classes Loaded Lazily? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-09-21 16:20 -0400
Re: Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-22 11:12 +0200
Re: Are Outer Classes Loaded Lazily? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-09-22 15:55 -0400
Re: Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-23 18:33 +0200
Re: Are Outer Classes Loaded Lazily? lewbloch@gmail.com - 2017-09-22 13:48 -0700
Re: Are Outer Classes Loaded Lazily? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2017-09-22 23:46 -0400
Re: Are Outer Classes Loaded Lazily? lewbloch@gmail.com - 2017-09-25 13:23 -0700
Re: Are Outer Classes Loaded Lazily? j4n bur53 <janburse@fastmail.fm> - 2017-09-24 17:39 +0200
Re: Are Outer Classes Loaded Lazily? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-09-25 07:38 -0400
Re: Are Outer Classes Loaded Lazily? lewbloch@gmail.com - 2017-09-25 13:25 -0700
csiph-web