🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
5 messages
5 total messages Started by Amir Pashazadeh Sat, 23 Aug 2003 09:06
java and goto instuction! amazing!
#456
Author: Amir Pashazadeh
Date: Sat, 23 Aug 2003 09:06
96 lines
3229 bytes
Hi everybody,
I decompiled a class file (using 3 different decompilers for accurancy), and
every time I got the same source code, there is something amazing in it, it
has "goto" instruction! how can it be?
does JVM (as executor) supports "goto" instruction, but no standard compiler
supports it yet? so a custom compiler can use it?

(I have changed the generated source code refereneced classes for privacy
;))

generated source code (comments are byte-code instuctions, as you can see
there is no byte-code instuctions for "goto"s!)

Amir Pashazadeh.
----------------------------------------------------------------------------

iterator = e.iterator();
// 10 18:aload_0

// 11 19:getfield #19 <Field java.util.List com.e>

// 12 22:invokeinterface #20 <Method java.util.Iterator
java.util.List.iterator()>

// 13 27:astore 4

if(!g.c) goto _L2; else goto _L1

// 14 29:getstatic #195 <Field boolean com.g.c>

// 15 32:ifeq 61

_L1:

com.e e1 = (com.e)iterator.next();

// 16 35:aload 4

// 17 37:invokeinterface #21 <Method java.lang.Object
java.util.Iterator.next()>

// 18 42:checkcast #22 <Class com.e>

// 19 45:astore 5

if(e1.a(s1, this, i))

//* 20 47:aload 5

//* 21 49:aload_2

//* 22 50:aload_0

//* 23 51:iload_3

//* 24 52:invokevirtual #23 <Method boolean com.e.a(java.lang.String, com.a,
int)>

//* 25 55:ifeq 61

return e1;

// 26 58:aload 5

// 27 60:areturn

_L2:

if(!iterator.hasNext())

//* 28 61:aload 4

//* 29 63:invokeinterface #24 <Method boolean java.util.Iterator.hasNext()>

//* 30 68:ifne 35

throw new g(a.b(com.g.b.bf));

// 31 71:new #25 <Class com.g>

// 32 74:dup

// 33 75:getstatic #26 <Field com.a.a>

// 34 78:getstatic #27 <Field java.lang.String com.g.b.bf>

// 35 81:invokevirtual #28 <Method java.lang.String
com.e.b(java.lang.String)>

// 36 84:invokespecial #29 <Method void g(java.lang.String)>

// 37 87:athrow

if(true) goto _L1; else goto _L3

_L3:
Re: java and goto instuction! amazing!
#457
Author: Tor Iver Wilhelmsen
Date: Sat, 23 Aug 2003 09:12
16 lines
2024 bytes
"Amir Pashazadeh" <pasha@abdnet.com> writes:

> I decompiled a class file (using 3 different decompilers for
> accurancy), and every time I got the same source code, there is
> something amazing in it, it has "goto" instruction! how can it be?

Because VM instruction set is not the same as Java language keywords.

> does JVM (as executor) supports "goto" instruction, but no standard
> compiler supports it yet? so a custom compiler can use it?

The VM uses "goto" to jump around in the same sense x86 uses "jmp".
You need to have some sort of jumping instruction.

The "gotos" come from java-the-language loops (for, while) and sundry
others (break, continue).
Re: java and goto instuction! amazing!
#459
Author: Roedy Green
Date: Sat, 23 Aug 2003 18:27
29 lines
2840 bytes
On Sat, 23 Aug 2003 12:36:48 +0330, "Amir Pashazadeh"
<pasha@abdnet.com> wrote or quoted :

>I decompiled a class file (using 3 different decompilers for accurancy), and
>every time I got the same source code, there is something amazing in it, it
>has "goto" instruction! how can it be?
>does JVM (as executor) supports "goto" instruction, but no standard compiler
>supports it yet? so a custom compiler can use it?

Yes.  You can't  go crazy with it.  The byte code verifier checks your
loops and jumps to make sure they don't do goofy things with the stack
depth.

A parser might find it more convenient for example to generate byte
code directly where the GOTO is permissible.  GoTo is wicked only in
human programming where the spaghetti you can create confuses fellow
programmers.  Every IF and LOOP is built in byte code of conditional
jumps and gotos.

Fear of GoTo can reach absurd levels.   I crossed horns with a boss
who had a strict no goto rule.  I explained to him that using a goto
in an Eiffel-like macro could save an average of 6 nesting depths per
method in his style of C code, but he rejected it on the same grounds
a Christian rejects gay marriage.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming. 
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Re: java and goto instuction! amazing!
#461
Author: DiscoStu
Date: Sun, 24 Aug 2003 19:32
12 lines
1860 bytes
> Fear of GoTo can reach absurd levels.   I crossed horns with a boss
> who had a strict no goto rule.  I explained to him that using a goto
> in an Eiffel-like macro could save an average of 6 nesting depths per
> method in his style of C code, but he rejected it on the same grounds
> a Christian rejects gay marriage.

Hehehe that last bit is hysterical! :) Goto is obviously evil because
people have told me so for the longest time, I think someone with a
lab coat might even have proved it. I dont fully understand it so
therefore it must be evil and morally wrong. </sarcasm>

     Lets all go fishing maybe
Re: java and goto instuction! amazing!
#462
Author: E.C. B�ck
Date: Mon, 25 Aug 2003 02:31
22 lines
2365 bytes
"Amir Pashazadeh" <pasha@abdnet.com> wrote in message
news:bi77c4$5ja9n$1@ID-170682.news.uni-berlin.de...
> Hi everybody,
> I decompiled a class file (using 3 different decompilers for accurancy),
and
> every time I got the same source code, there is something amazing in it,
it
> has "goto" instruction! how can it be?
> does JVM (as executor) supports "goto" instruction, but no standard
compiler
> supports it yet? so a custom compiler can use it?

Well, you haven't actually decompiled anything, you know.  Decompilers
produce source code, not opcodes.  What you have done is translate the
opcodes to their english names, and their arguments as well.

Like many others have said, goto is just a jumping instruction, critical in
both branching, looping, but also in method invocation.  Java does reserve
the goto keyword, although it is not implemented.  Thus, goto is a part of
java, albeit a nominal and useless one.
-- 
Elliott
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads