Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15252 > unrolled thread
| Started by | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| First post | 2012-06-13 13:45 -0700 |
| Last post | 2012-06-20 21:19 -0400 |
| Articles | 8 on this page of 88 — 17 participants |
Back to article view | Back to comp.lang.java.programmer
"Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 13:45 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 13:52 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 16:17 -0700
Re: "Small" Program Challenge. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-06-14 00:16 +0000
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 16:19 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 16:24 -0700
Re: "Small" Program Challenge. markspace <-@.> - 2012-06-13 17:40 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-13 21:28 -0400
Re: "Small" Program Challenge. Roedy Green <see_website@mindprod.com.invalid> - 2012-06-13 20:52 -0700
Re: "Small" Program Challenge. "Hiram Hunt" <hiramhunt@verizon.net> - 2012-06-14 08:23 -0400
Re: "Small" Program Challenge. "Hiram Hunt" <hiramhunt@verizon.net> - 2012-06-14 08:30 -0400
Re: "Small" Program Challenge. Arne Vajhøj <arne@vajhoej.dk> - 2012-06-17 21:17 -0400
Re: "Small" Program Challenge. Paul Cager <paul.cager@googlemail.com> - 2012-06-14 02:32 -0700
Re: "Small" Program Challenge. Bent C Dalager <bcd@pvv.ntnu.no> - 2012-06-14 11:29 +0000
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 12:50 -0700
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-14 15:49 -0500
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-14 14:56 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 17:02 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 17:09 -0700
Re: "Small" Program Challenge. Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2012-06-15 22:13 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-16 12:11 -0700
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-17 15:22 +0200
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-17 15:24 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-17 18:25 -0400
Re: "Small" Program Challenge. Arne Vajhøj <arne@vajhoej.dk> - 2012-06-17 20:31 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-17 20:55 -0400
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-17 20:40 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-17 23:43 -0400
Re: "Small" Program Challenge. Lew <noone@lewscanon.com> - 2012-06-17 21:25 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 00:45 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 12:47 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 15:57 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 13:31 -0700
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-18 16:05 -0500
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 14:18 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 19:50 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 19:48 -0400
Re: "Small" Program Challenge. David Lamb <dalamb@cs.queensu.ca> - 2012-06-19 08:07 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 15:26 -0400
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-18 09:04 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 13:09 -0400
Re: "Small" Program Challenge. markspace <-@.> - 2012-06-18 11:06 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 14:46 -0400
Re: "Small" Program Challenge. markspace <-@.> - 2012-06-18 13:22 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 19:51 -0400
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-20 13:11 +0200
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-22 12:54 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-22 18:30 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-25 12:59 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-25 16:49 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 12:44 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 16:01 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 13:36 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 20:01 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 18:25 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 22:01 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-18 19:04 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 22:12 -0400
Re: "Small" Program Challenge. Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-06-19 12:36 +0000
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 15:28 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-19 09:12 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 15:30 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-19 15:04 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 18:23 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-19 15:32 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 19:09 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 19:10 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-19 17:19 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 20:42 -0400
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-19 20:01 -0500
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 21:12 -0400
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-19 20:32 -0500
Re: "Small" Program Challenge. Lew <noone@lewscanon.com> - 2012-06-19 22:01 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:15 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:05 -0400
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-23 13:42 +0200
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-23 12:12 -0400
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-23 23:10 +0200
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-23 17:14 -0400
Re: "Small" Program Challenge. Lew <noone@lewscanon.com> - 2012-06-19 22:15 -0700
Re: "Small" Program Challenge. Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-06-20 10:34 +0000
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-20 10:45 -0700
Re: "Small" Program Challenge. Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-06-21 08:13 +0000
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-21 17:18 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-21 15:30 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-21 20:28 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:22 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:19 -0400
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2012-06-20 10:34 +0000 |
| Message-ID | <slrnju39os.u9l.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #15447 |
Lew <noone@lewscanon.com> wrote: > Leif Roar Moldskred wrote: >> javax.swing.JSnarker wrote: >>> Not relevant here, unless you're claiming you've seen in real code where >>> a static method began to be invoked and the class was *still* not >>> initialized. It all boils down to the true definition of "invocation". Is it the moment when the instruction pointer hits the bytecode for invokestatic and starts doing it, or is it just before it hits the first instruction of the callee (iff existing)? JVM7-behaviour implies the latter. I admit having difficulties myself to actually read it unambiguously from JLS §12.4.1. Probably this is defined elsewhere. Anyway, between these two moments, there's plenty time for the JVM to load the class, check availability of the method, and only if ok then initialize the class and proceed with the callee's code, otherwise skip initialization and just throw some exception. And for a certain definition of "invocation", initialization would still always precede it.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-20 10:45 -0700 |
| Message-ID | <a23a25b5-dcd3-4008-93da-5407910dc09a@googlegroups.com> |
| In reply to | #15450 |
Andreas Leitgeb wrote: > Lew wrote: > > Leif Roar Moldskred wrote: > >> javax.swing.JSnarker wrote: > >>> Not relevant here, unless you're claiming you've seen in real code where > >>> a static method began to be invoked and the class was *still* not > >>> initialized. > > It all boils down to the true definition of "invocation". > > Is it the moment when the instruction pointer hits the bytecode for > invokestatic and starts doing it, or is it just before it hits the > first instruction of the callee (iff existing)? > > JVM7-behaviour implies the latter. I admit having difficulties myself > to actually read it unambiguously from JLS §12.4.1. Probably this > is defined elsewhere. > > Anyway, between these two moments, there's plenty time for the JVM > to load the class, check availability of the method, and only if ok > then initialize the class and proceed with the callee's code, > otherwise skip initialization and just throw some exception. > And for a certain definition of "invocation", initialization > would still always precede it. The gap "between these two moments" is the gap between the attempt to invoke, and the invocation proper. JLS §12.4.1 lives in a context, one that include JLS §12.4.2, op. cit. upthread. Even so, "A class or interface type T will be initialized immediately before the first occurrence of any one of the following: "T is a class and an instance of T is created. "T is a class and a static method declared by T is invoked. ..." is pretty clear. Whatever the definition of "invocation", initialization occurs just before it. This means that the system identifies "immediately before". That moment of "immediately before" can only be at the point of the attempt to invoke, right before the invocation proper. I call "immediately before", therefore, the "attempt to invoke". This distinguishes it from the invocation, which occurs after initialization. Note that this passage does not say that the class is loaded at that point. That's because the class may have been loaded considerably earlier, but not initialized. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2012-06-21 08:13 +0000 |
| Message-ID | <slrnju5ltg.u9l.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #15455 |
Lew <lewbloch@gmail.com> wrote:
> Andreas Leitgeb wrote:
>> It all boils down to the true definition of "invocation".
> Even so,
> "A class or interface type T will be initialized immediately before the first
> occurrence of any one of the following:
> "T is a class and an instance of T is created.
> "T is a class and a static method declared by T is invoked. ..."
It's interesting, how some aspect gets through only after reading
it the umpty+1st time.
The mention is actually clearly about a "a static method declared by T",
which obviously doesn't cover calls to methods, that are *not* declared
by that class.
PS: some example for Java 6
A.java:
class A {
static { System.out.println("A static init"); }
static void foo() { System.out.println("A static foo"); }
}
B.java:
class B {
static { System.out.println("B static init"); }
public static void main(String[]args) {
System.out.println("B static main");
A.foo();
}
}
compile both (with Java 6), run B:
B static init
B static main
A static init
A static foo
Then comment out the method "foo()" from A,
recompile only A, run B:
B static init
B static main
Exception in thread "main" java.lang.NoSuchMethodError: A.foo()V
at B.main(B.java:4)
Note: no initialization of A, even with Java 6.
Anyone care to try this with other (older) versions and report results?
[toc] | [prev] | [next] | [standalone]
| From | "javax.swing.JSnarker" <gharriman@boojum.mit.edu> |
|---|---|
| Date | 2012-06-21 17:18 -0400 |
| Message-ID | <js032r$hjt$1@speranza.aioe.org> |
| In reply to | #15484 |
On 21/06/2012 4:13 AM, Andreas Leitgeb wrote: > compile both (with Java 6), run B: > B static init > B static main > A static init > A static foo > Then comment out the method "foo()" from A, > recompile only A, run B: > B static init > B static main > Exception in thread "main" java.lang.NoSuchMethodError: A.foo()V > at B.main(B.java:4) > Note: no initialization of A, even with Java 6. So, even Java 6 has a version of the bug. Interesting. I don't see how the remark about "declared by T" is relevant here, since foo clearly is declared by A in your example that reproduces the bug. -- public final class JSnarker extends JComponent A JSnarker is an NNTP-aware component that asynchronously provides snarky output when the Ego.needsPuncturing() event is fired in cljp.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-21 15:30 -0700 |
| Message-ID | <32b02496-3dcd-4043-ba07-09f649e6c835@googlegroups.com> |
| In reply to | #15494 |
javax.swing.JSnarker wrote: > Andreas Leitgeb wrote: > > compile both (with Java 6), run B: > > B static init > > B static main > > A static init > > A static foo > > Then comment out the method "foo()" from A, > > recompile only A, run B: > > B static init > > B static main > > Exception in thread "main" java.lang.NoSuchMethodError: A.foo()V > > at B.main(B.java:4) > > Note: no initialization of A, even with Java 6. > > So, even Java 6 has a version of the bug. Interesting. I don't see how > the remark about "declared by T" is relevant here, since foo clearly is > declared by A in your example that reproduces the bug. Of what bug do you speak? Since no static method of 'A' was called in the second run, the condition to initialize the class was not met. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | "javax.swing.JSnarker" <gharriman@boojum.mit.edu> |
|---|---|
| Date | 2012-06-21 20:28 -0400 |
| Message-ID | <js0e83$c10$1@speranza.aioe.org> |
| In reply to | #15499 |
On 21/06/2012 6:30 PM, Lew wrote: > javax.swing.JSnarker wrote: >> Andreas Leitgeb wrote: >>> compile both (with Java 6), run B: >>> B static init >>> B static main >>> A static init >>> A static foo >>> Then comment out the method "foo()" from A, >>> recompile only A, run B: >>> B static init >>> B static main >>> Exception in thread "main" java.lang.NoSuchMethodError: A.foo()V >>> at B.main(B.java:4) >>> Note: no initialization of A, even with Java 6. >> >> So, even Java 6 has a version of the bug. Interesting. I don't see how >> the remark about "declared by T" is relevant here, since foo clearly is >> declared by A in your example that reproduces the bug. > > Of what bug do you speak? > > Since no static method of 'A' was called in the second run, There was a call to A.foo(). That the call did not *succeed* doesn't mean that it didn't *exist*. If the call didn't exist, what threw the exception, and why? -- public final class JSnarker extends JComponent A JSnarker is an NNTP-aware component that asynchronously provides snarky output when the Ego.needsPuncturing() event is fired in cljp.
[toc] | [prev] | [next] | [standalone]
| From | "javax.swing.JSnarker" <gharriman@boojum.mit.edu> |
|---|---|
| Date | 2012-06-20 21:22 -0400 |
| Message-ID | <jrtt0n$7j2$1@speranza.aioe.org> |
| In reply to | #15450 |
On 20/06/2012 6:34 AM, Andreas Leitgeb wrote: > Lew <noone@lewscanon.com> wrote: >> Leif Roar Moldskred wrote: >>> javax.swing.JSnarker wrote: >>>> Not relevant here, unless you're claiming you've seen in real code where >>>> a static method began to be invoked and the class was *still* not >>>> initialized. > > It all boils down to the true definition of "invocation". > > Is it the moment when the instruction pointer hits the bytecode for > invokestatic and starts doing it, Obviously, and more or less by definition of "invokestatic". > JVM7-behaviour implies the latter. The spec implies the former, though with sufficient ambiguity as to have confused the hell out of Leif and Lew. And the name of the opcode "invokestatic" also implies the former, as does the behavior of JVM6, JVM5, ... > Anyway, between these two moments, there's plenty time for the JVM > to load the class, check availability of the method, and only if ok > then initialize the class and proceed with the callee's code, > otherwise skip initialization and just throw some exception. > And for a certain definition of "invocation", initialization > would still always precede it. A kooky definition. -- public final class JSnarker extends JComponent A JSnarker is an NNTP-aware component that asynchronously provides snarky output when the Ego.needsPuncturing() event is fired in cljp.
[toc] | [prev] | [next] | [standalone]
| From | "javax.swing.JSnarker" <gharriman@boojum.mit.edu> |
|---|---|
| Date | 2012-06-20 21:19 -0400 |
| Message-ID | <jrtsqg$778$1@speranza.aioe.org> |
| In reply to | #15447 |
On 20/06/2012 1:15 AM, Lew wrote: > Leif Roar Moldskred wrote: >> javax.swing.JSnarker wrote: >>> >>> Not relevant here, unless you're claiming you've seen in real code where >>> a static method began to be invoked and the class was *still* not >>> initialized. > > Here we go. "No true Scotsman". This plus /ad hominem/ attacks. From you people, perhaps. > It is relevant because the argument was over whether initialization > always occurs together with loading The argument is over whether attempting to invoke the main method is allowed to precede initialization. > And doesn't your statemtn - "a static method began to be invoked and the > class was *still* not initialized" - reveal a sequence of "begin to > invoke" followed by "initialize", just as I've been saying right along? That statement was a rephrasing of *your* claims intended to make it clear that they contravene the spec. > If I hadn't been responding via a Web interface I'd've remembered why I > plonked you a long time ago, snark. Ah. These must be the promised /ad hominem/ attacks. >> As has been pointed out earlier in the thread, that's exactly what >> happens when, with Java 7, you try to start a Java program with a >> class that does not contain a valid main method. > > As is required by the JLS, and has been since before Java 7. The JLS requires that initialization precede the invocation, and therefore precede the exception thrown when invocation fails due to lack of the needed method. -- public final class JSnarker extends JComponent A JSnarker is an NNTP-aware component that asynchronously provides snarky output when the Ego.needsPuncturing() event is fired in cljp.
[toc] | [prev] | [standalone]
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
Back to top | Article view | comp.lang.java.programmer
csiph-web