
marc.meurrens@acm.org
(
http://homepages.ulb.ac.be/~meurrens)
http://www.taligent.com/Technology/WhitePapers/PortingPaper/index.html
Mark Davis
(
cookbook@taligent.com)
http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/index.html
[back]

Taligent's Java Cookbook for porting C++ to Java
Mark Davis
(
cookbook@taligent.com)
includes step-by-step recommendations by the C++ IBM's subsidiary. But, it also includes important discussions on design and coding features you may not miss. However, the paper will probably be difficult for readers without C++ background. We mirror on our site the original
http://www.taligent.com/Technology/WhitePapers/PortingPaper/index.html
paper dated March 25, 1997.
An Acrobat (
www.adobe.com) PDF file is available
here;
you may download the mirror file
Java_Cookbook.pdf from our site;
visit also the
Java Cookbook News Group
|
|
|
|
|
|
C++ |
Java |
|---|---|
// some sample lines of code
int x = 3;
for (int i = 0; i < j; ++i) {
x += i * i;
}
x = y.method1(3,4);
|
// some sample lines of code
int x = 3;
for (int i = 0; i < j; ++i) {
x += i * i;
}
x = y.method1(3,4);
|
When porting from C++ to Java, your job is far easier than when porting to Basic, FORTRAN, Lisp, Smalltalk or other radically different languages. Keep that in mind as you go through the remainder of this document: the items I list are the exceptions, not the rules.
The Java compiler is much more rigorous than that of C++, so much of the code that needs to be changed will be found by the compiler. With each description of a porting task, examples will show you what you have to do to C++ code to change it to Java code. In these examples, corresponding lines of code in C++ and Java are lined up (although in some older browsers this doesn't work properly). The text is also color-coded, in the following fashion.
Color |
Meaning |
|---|---|
| Red | Pitfall (aka faux amis): code that looks the same, but has quite a different meaning! |
| Blue | Changes between C++ and Java code. |
| Black | Code that is the same in Java as it is in C++. |
| Brown | Items with special comments in the notes below. |
| Green | Comments. |
For brevity, code snippets include only enough of the context to be understandable!
In discussing Java programming there is also some terminology that we find useful, especially for discussing how to deal with references and the lack of const.
This article is divided up into the web pages below.
(It is not split up further, since it is pretty annoying to print very many
pages with today's browsers.) It is also organized to be useful when
printed, with some caveats.
[4]
On each page in this article, there are links to the sections on that
page, plus links to the top of the page (that look like
or like
). There are also
the occasional footnotes, which are indicated in the text with a superscripted
number in brackets
[3]
and found at the very end of the article.
Basics
Next Steps
Well-Mannered Objects
Esoterica
Background Information
cookbook@Taligent.com
or use our
Java Cookbook Newsgroup
.
Introduction,
Basics,
Next Steps,
Well-Mannered Objects,
Esoterica,
Background,
Index
Products
|
Object Resources
|
In the News
|
Company Info
|
Search
|
If you encounter problems with this service please contact
webmaster@taligent.com.
© Copyright. All rights reserved. Taligent, Inc., IBM Corp.
|
||||
|
Brussels July 9, 1997
mirror of original document of March 25, 1997 by Mark Davis ( cookbook@taligent.com)
published by marc.meurrens@acm.org
( http://homepages.ulb.ac.be/~meurrens)
original URL: http://www.taligent.com/Technology/WhitePapers/PortingPaper/index.html
current URL: http://www.ulb.ac.be/esp/ip-Links/Java/joodcs/Cookbook.html
internet programming Links: http://www.ulb.ac.be/esp/ip-Links (ip-Links)
Université Libre de Bruxelles: http://www.ulb.ac.be (ULB)
La Cambre - Architecture: http://www.lacambre-archi.be
Belgian JAVA User Group: http://www.bejug.org (BeJUG)
| |||||||||||||||||
|
Use this form to send your feedback and/or submit a link
| |||||||||||||||||
Conventions used in these pages:
html file, text file or java or CPP source located on our site
download area (on our site) or file to be downloaded (use the right button of your mouse)
document on a belgian academic or scientific site
document (on another site) or link to be fixed or link we didn't visit/evaluate; documents indicated with their full URL will be displayed in their own "top" window.
ftp download or
file to be downloaded (use the right button of your mouse)
indicates a "mailto" link.
Click on the | |||||||||||||||||
| |||||||||||||||||