100% Pure Java Cookbook Use of Native Code
Total Page:16
File Type:pdf, Size:1020Kb
100% Pure Java Cookbook Guidelines for achieving the 100% Pure Java Standard Revision 4.0 Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, California 94303 USA Copyrights 2000 Sun Microsystems, Inc. All rights reserved. 901 San Antonio Road, Palo Alto, California 94043, U.S.A. This product and related documentation are protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or related documentation may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Restricted Rights Legend Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and FAR 52.227-19. The product described in this manual may be protected by one or more U.S. patents, foreign patents, or pending applications. Trademarks Sun, the Sun logo, Sun Microsystems, Java, Java Compatible, 100% Pure Java, JavaStar, JavaPureCheck, JavaBeans, Java 2D, Solaris,Write Once, Run Anywhere, JDK, Java Development Kit Standard Edition, JDBC, JavaSpin, HotJava, The Network Is The Computer, and JavaStation are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and certain other countries. UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. All other product names mentioned herein are the trademarks of their respective owners. Netscape and Netscape Navigator are trademarks of Netscape Communications Corporation in the United States and other countries. THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME. Revision History 4/97 - 1.0 First release 5/97 - 1.1 Minor updates 4/98 - 2.0 Added certification instructions for beans Introduced new feature based dynamic testing requirements Dropped code coverage requirements Added instructions for recertification 4/99 - 2.1 Added certification instructions for servlets Added guidelines for certification under 1.2 runtime environments Updated recertification requirements Added guidelines for certifying hybrid programs Added FAQ 10/99 - 3.0 Reorganized and updated 3/00 - 3.1 Reorganized and updated 10/00 - 4.0 Formerly “100% Pure Java Certification Guide”, rewritten to remove the certification process and branding program. Table of Contents Introduction The 100% Pure Java™ Standard . 1 - 1 About this Guide. 1 - 1 Contents . 1 - 2 100% Pure Java Definitions. 1 - 3 Online Information . 1 - 3 What is the 100% Pure Java Standard? . 1 - 4 Purpose . 1 - 4 API Constraints . 1 - 4 Common Behavior . 1 - 4 Should I Comply With The Purity Standard?. 1 - 5 The “Suggested Compliance Evaluation Criteria?” Checklist . 1 - 5 Understanding Portability & Purity Standards for Portability . 2 - 1 The Purpose of the Purity Standard . 2 - 1 Which Java™ API? . 2 - 2 Understanding ‘Purity’. 2 - 2 Purity is Not Goodness. 2 - 3 Portability vs. Purity . 2 - 3 Rules of Purity . 2 - 4 The Rules . 2 - 5 Revision Date: 10/00 i Guidelines for Developing Pure Programs How to Develop a Program. 3 - 1 Use of Native Code. 3 - 3 Use of exec . 3 - 4 Failure to Use the Portability Features of Java Core API . 3 - 4 Reflection . 3 - 4 Direct Use of AWT Peer Classes. 3 - 4 Misuse of System.exit . 3 - 5 Use of Hard-Coded File Paths . 3 - 5 JDBC™ Driver Loading . 3 - 7 Line Termination . 3 - 8 Unportable Command-Line Programs. 3 - 9 Command Line Processing . 3 - 9 Internationalization . 3 - 9 Unicode Rendering . 3 - 9 File I/O . 3 - 10 GUI Element Size. 3 - 10 GUI Fonts . 3 - 10 GUI Appearance . 3 - 10 The Paint Protocol . 3 - 11 Mixed Event Models . 3 - 12 Use of Deprecated Methods. 3 - 12 The Object.hashCode and Object.equals Methods . 3 - 12 Installation Issues . 3 - 13 Hostname Format . 3 - 13 Pluggable Look and Feel . 3 - 14 Mixing Classes Compiled on Different Versions of the Java Platform . 3 - 15 Portability Hints . 3 - 16 Security Exceptions . 3 - 16 Coping with Bugs . 3 - 17 Explanations of Purity Problems and Variances Explanations of Purity Problems . 4 - 1 Report Information Categories . 4 - 1 Explanations. 4 - 2 Warnings. 4 - 2 Possible Hardcoded Path . 4 - 2 Mixing the 1.0 and 1.1 Event Models . 4 - 2 Dynamically Loaded Classes:. 4 - 2 Object is Compiled for a Previous (Java Development Kit) release . 4 - 3 Unsupported Pluggable Look and Feel . 4 - 3 Errors. 4 - 4 Constant Strings with OS-Specific Syntax Used in I/O Class Constructors . 4 - 4 Peer Use . ..