Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37463
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Are Outer Classes Loaded Lazily? |
| Date | Mon, 25 Sep 2017 07:38:47 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 49 |
| Message-ID | <oqaps8$c5s$1@dont-email.me> (permalink) |
| References | <opu86b$k29$1@news.albasani.net> <oq13am$9v4$1@gwaiyur.mb-net.net> <5e2274e3-9af7-46e7-b4a3-dd656e639be2@googlegroups.com> <oq8jji$vf6$1@news.albasani.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Mon, 25 Sep 2017 11:38:48 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="29a86330f3d3d70617fa2cb549e05c2d"; logging-data="12476"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Rz1Kitf7G1G29bF+cJFYk" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
| In-Reply-To | <oq8jji$vf6$1@news.albasani.net> |
| X-Antivirus-Status | Clean |
| Content-Language | en-US |
| X-Antivirus | AVG (VPS 170925-0, 09/25/2017), Outbound message |
| Cancel-Lock | sha1:iEd9zjRj92HhGN/bBRaaaqhdLdM= |
| Xref | csiph.com comp.lang.java.programmer:37463 |
Show key headers only | View raw
On 9/24/2017 11:39 AM, j4n bur53 wrote:
> [...]
>
> itself. Basically Eric Sosman
> already answered:
>
> > java -verbose:class esosman.misc.Foo
> >
> > This told me that forName() caused Inner to be loaded
> > but not Outer, and that getEnclosingClass() caused
> > Outer to be loaded but not initialized.
>
> But we don't see the code he was using,
> maybe he can upload his test case on Gist?
Here it is. If you change the package name, you will also
need to change the forName() call:
// Foo.java:
package esosman.misc;
public class Foo {
public static void main(String[] unused)
throws ClassNotFoundException {
System.out.println("Calling forName() ...");
Class inner = Class.forName("esosman.misc.Outer$Inner");
System.out.println("Got class: " + inner);
System.out.println("Calling getEnclosingClass() ...");
Class outer = inner.getEnclosingClass();
System.out.println("Got class: " + outer);
}
}
// Outer.java:
package esosman.misc;
public class Outer {
static {
System.out.println("Initializing Outer");
}
static class Inner {
static {
System.out.println("Initializing Inner");
}
}
}
--
esosman@comcast-dot-net.invalid
Twelve hundred thirteen days to go.
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