[2177] in java-interest
Re: calling native C/C++ : portability
daemon@ATHENA.MIT.EDU (Thomas Ball)
Tue Sep 26 16:36:15 1995
Date: Tue, 26 Sep 1995 10:01:08 -0700
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
To: fsuarez@ll.iac.es
Cc: java-interest@java.Eng.Sun.COM
> To: java-interest-digest@java
Next time, mail to "java-interest@java", okay?
> I know JAVA uses extern "C" to include C code.
There is no 'extern "C"' facility in Java. Developers who want to access
external C++ code need to use 'extern "C"' in their C++ code so that the
method names aren't changed by the C++ compiler.
> But I wonder if that restricts the resulting program portability.
Accessing external certainly restricts both portability and ease of
distribution (shared libraries aren't automatically downloaded from a
web page the way Java classes are). We strongly discourage using native
methods if you want to write applets or portable programs.
> How does Java implement extern "C"?
It doesn't -- most current C++ compilers do.
> Are the C code translated to bytecodes?
No, the C code must be linked into a shared library, also called a DLL
on Windows systems. This file must be present when the application is
run, and must be dynamically loaded by the application prior to its use.
Only Java code is translated into bytecodes.
Tom
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com