Quick Question: Can a 1.4* VM run 5.0 compiled bytecode?

R

Roedy Green

Re: Quick Question: Can a 1.4* VM run 5.0 compiled bytecode?
no, not unless you used target -1.4. It does not have support for the
new features.
 
C

Chris Uppal

Danno said:
I guess I am looking in the wrong places. Your help is appreciated.

Why not just try it ?

Anyway, the answer is no. The 1.5-generated classfiles have a version flag in
them to tell the JVM that they use features which were introduced in 1.5, and a
1.4 JVM will recognise the flag and refuse to load those classfiles. You can
compile Java passing the -source 1.4 or -target 1.4 (I forget which) flag to
Sun's javac which will produce 1.4-compatible bytecode, but then the compiler
will refuse to recognise the new 1.5 language features.

I believe there are Java compilers which are not as stunted as the Sun one, and
which can compile most 1.5 features into a form which will run on a 1.4 JVM. I
can't make any specific recommendations, though.

-- chris
 
D

Danno

Thanks Roedy. I just have a popular WebStart based system, and trying
to program in some upgrades as easy as possible for the end users.
Most use 1.4.2. and I don't really want to inconvenience them by having
them move to 5.0 yet. The thing I like is the new easymock, junit,
and easymock extensions that make use of 5.0 features.

But you know, now that I am typing this. I think I can use 5.0 on my
unit tests to test 1.4.x code. Hmmm.
 
D

Danno

Thanks Chris for the detailed response. The reason I don't want to try
is because I worked for 12 hours programming away already. ;) There
are times where throwing out the question will be a lot simpler. ;)

I was leaning towards yes for a while because I was thinking that a lot
of features were compile-based but translated to the regular 1.4 style
bytecode that we were all used to. But then I thought about
annotations late at night, and annotations are a part of the bytecode
if so requested.
 
C

Chris Uppal

Danno said:
The reason I don't want to try
is because I worked for 12 hours programming away already. ;) There
are times where throwing out the question will be a lot simpler. ;)

Understandable !

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top