🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15418

Is JDK 2.0 bytecode compatible with JDK 1.02?

#15418
From: Jonathan Knott
Date: Thu, 17 Jun 1999 00:00
50 lines
2005 bytes
Hello JB fans,

I was under the impression that I could use the JDK 2.0 compiler to get
JDK 1.02 bytecode.  (which I need for applets for older browsers)
I thought that all I had to do was write in "JDK 1.02 Java".  I have
always had success doing that with JDK 1.1x compilers.  Below I will
show that this is not true with the JDK 2.0 compiler.


The following lines of Java code are perfectly valid in JDK 1.02.

TextField tf;
tf.setText( "hi" );

If I compile this with JDK 1.02 or JDK 1.1x, it works fine.  The crucial
bytecode is:

invokevirtual METHOD java/awt/TextComponent setText
(Ljava/lang/String;)V

If I compile the above Java with JDK 2.0 (the default JB3 compiler), 
the following byte code is produced:

invokevirtual METHOD java/awt/TextField setText (Ljava/lang/String;)V

This crashes in JDK 1.02, such as Netscape 3.0.  This is not legal JDK
1.02 bytecode.


I thought that the bytecode produced was supposed to be backward
compatible.
My theory was that if I wrote in "JDK 1.02 Java", the compiler would
produce
"JDK 1.02 bytecode".

This is a clear example where that is not true.  I am wrong?  Or did Sun
make a mistake?  Have I just found a weird example or should I expect
many such bytecode problems?

Thanks for your help,

Jonathan Knott

P.S.

This case is simple to fix.  The lines below produce legal JDK 1.02
bytecode.

TextComponent tc = (TextComponent) tf;
tc.setText( "hi" );
Technical Details
Message-ID: <3769151A.2F14EB4@pacific.net.sg>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,1404b3dc214fe147,start
X-Google-Attributes: gidf74b3,public
From: Jonathan Knott <accessmedia@pacific.net.sg>
Subject: Is JDK 2.0 bytecode compatible with JDK 1.02?
Date: 1999/06/17
Message-ID: <3769151A.2F14EB4@pacific.net.sg>
X-Deja-AN: 490703176
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language