JVM misconceptions (Re: [Mono-list] Re: can you explain what you mean?)

Tom tom7ca@yahoo.com
Sun, 15 Jul 2001 14:21:37 -0700 (PDT)

> The fact that you can decode *some* bytecodes into 
> source code does not mean that you can decode 
> correctly *all* bytecodes that the JVM can

The JVM does not "interpret" arbitrary bytecode 
sequences.  The JVM imposes strong constraints on what

bytecode sequences are valid. These restrictions have 
been part of the JVM since the first public release,

> The generic example I have used it (mix of C and
> bytecodes):
> 	while (n > 0){
> 		ipush (n % 10)
> 		n /= 10;
> 		c++;
> 	}
> 	while (c--){
> 		ipop 
> 		print 
> 	}

That code cannot be expressed as a legal JVM bytecode

To avoid such misconceptions, I recommend reading 
Meyer's book on the JVM; there is more information at:


Meyer actually provides a JVM assembler, and he
gives your example as one of the examples that
is not legal (you can download the assembler and
the samples from his site).

> and the list of restrictions that CIL imposes on
> the bytecodes.

These restrictions don't sound any different from what
the JVM imposes and documents.  In fact, I suspect
Microsoft based their VM on the Java VM and simply 
adopted the restrictions that the JVM already imposes.

> > any safe CLR implementation) needs anyway (and
> > that is pretty trivial to implement).
> It might look trivial to implement, but so far, it
> does not seem like
> anyone has written a Java code generator along those
> lines.

Of course: lots of people have.  That's part of byte 
code verification, a part of any standard
JVM. The CLR needs the same functionality for the same

reasons: it can't trust the declarations that come 
along with the bytecode.

Furthermore, anything that translates stack oriented
byte code into register code has to perform this
kind of analysis anyway.

> The answer is trivial once you read the BURS
> research papers (the web site has the links)

I couldn't find any links, and I'm not sure what
"the web site" is.  Could you give an actual
URL, please?  I'd be curious to see where these
claims originate.


Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail