1.1 --- a/src/share/classes/com/sun/tools/javah/MainDoclet.java Fri Oct 02 11:26:53 2009 -0700 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,218 +0,0 @@ 1.4 -/* 1.5 - * Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 - * 1.8 - * This code is free software; you can redistribute it and/or modify it 1.9 - * under the terms of the GNU General Public License version 2 only, as 1.10 - * published by the Free Software Foundation. Sun designates this 1.11 - * particular file as subject to the "Classpath" exception as provided 1.12 - * by Sun in the LICENSE file that accompanied this code. 1.13 - * 1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 - * version 2 for more details (a copy is included in the LICENSE file that 1.18 - * accompanied this code). 1.19 - * 1.20 - * You should have received a copy of the GNU General Public License version 1.21 - * 2 along with this work; if not, write to the Free Software Foundation, 1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 - * 1.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 - * have any questions. 1.27 - */ 1.28 - 1.29 - 1.30 -package com.sun.tools.javah; 1.31 - 1.32 -import com.sun.javadoc.*; 1.33 -import java.io.*; 1.34 - 1.35 -/** 1.36 - * A doclet to parse and execute commandline options. 1.37 - * 1.38 - * @author Sucheta Dambalkar(using code from old javap) 1.39 - */ 1.40 -public class MainDoclet{ 1.41 - 1.42 - public static String odir = null; 1.43 - public static String ofile = null; 1.44 - public static boolean stubs = false; 1.45 - public static boolean jni = false; 1.46 - public static boolean llni = false; 1.47 - public static boolean doubleAlign = false; 1.48 - public static boolean force = false; 1.49 - public static String genclass = null; 1.50 - 1.51 - 1.52 - /** 1.53 - * Entry point. 1.54 - */ 1.55 - public static boolean start(RootDoc root) { 1.56 - 1.57 - int j = 0; 1.58 - int k = 0; 1.59 - /** 1.60 - * Command line options. 1.61 - */ 1.62 - String [][] cmdoptions = root.options(); 1.63 - /** 1.64 - * Classes specified on command line. 1.65 - */ 1.66 - ClassDoc[] classes = root.classes(); 1.67 - /** 1.68 - * Generator used by javah. Default is JNI. 1.69 - */ 1.70 - Gen g = new JNI(root); 1.71 - 1.72 - validateOptions(cmdoptions); 1.73 - 1.74 - /* 1.75 - * Select native interface. 1.76 - */ 1.77 - if (jni && llni) Util.error("jni.llni.mixed"); 1.78 - 1.79 - if (llni) 1.80 - g = new LLNI(doubleAlign, root); 1.81 - 1.82 - if (g instanceof JNI && stubs) Util.error("jni.no.stubs"); 1.83 - 1.84 - /* 1.85 - * Arrange for output destination. 1.86 - */ 1.87 - if (odir != null && ofile != null) 1.88 - Util.error("dir.file.mixed"); 1.89 - 1.90 - if (odir != null) 1.91 - g.setOutDir(odir); 1.92 - 1.93 - if (ofile != null) 1.94 - g.setOutFile(ofile); 1.95 - 1.96 - /* 1.97 - * Force set to false will turn off smarts about checking file 1.98 - * content before writing. 1.99 - */ 1.100 - g.setForce(force); 1.101 - 1.102 - /* 1.103 - * Grab the rest of argv[] ... this must be the classes. 1.104 - */ 1.105 - if (classes.length == 0){ 1.106 - Util.error("no.classes.specified"); 1.107 - } 1.108 - /* 1.109 - * Set classes. 1.110 - */ 1.111 - g.setClasses(classes); 1.112 - 1.113 - try { 1.114 - g.run(); 1.115 - } catch (ClassNotFoundException cnfe) { 1.116 - Util.error("class.not.found", cnfe.getMessage()); 1.117 - } catch (IOException ioe) { 1.118 - Util.error("io.exception", ioe.getMessage()); 1.119 - } 1.120 - 1.121 - return true; 1.122 - } 1.123 - 1.124 - /** 1.125 - * Required doclet method. 1.126 - */ 1.127 - public static int optionLength(String option) { 1.128 - if (option.equals("-o")) { 1.129 - return 2; 1.130 - } else if(option.equals("-d")){ 1.131 - return 2; 1.132 - } else if (option.equals("-td")) { 1.133 - return 1; 1.134 - } else if (option.equals("-stubs")) { 1.135 - return 1; 1.136 - } else if(option.equals("-help")){ 1.137 - return 1; 1.138 - } else if(option.equals("--help")){ 1.139 - return 1; 1.140 - } else if(option.equals("-?")){ 1.141 - return 1; 1.142 - } else if(option.equals("-h")){ 1.143 - return 1; 1.144 - } else if(option.equals("-trace")){ 1.145 - return 1; 1.146 - } else if(option.equals("-version")) { 1.147 - return 1; 1.148 - } else if(option.equals("-jni")){ 1.149 - return 1; 1.150 - } else if(option.equals("-force")){ 1.151 - return 1; 1.152 - } else if(option.equals("-Xllni")){ 1.153 - return 1; 1.154 - } else if(option.equals("-llni")){ 1.155 - return 1; 1.156 - } else if(option.equals("-llniDouble")){ 1.157 - return 1; 1.158 - } else return 0; 1.159 - } 1.160 - 1.161 - /** 1.162 - * Parse the command line options. 1.163 - */ 1.164 - public static void validateOptions(String cmdoptions[][]) { 1.165 - /* Default values for options, overridden by user options. */ 1.166 - String bootcp = System.getProperty("sun.boot.class.path"); 1.167 - String usercp = System.getProperty("env.class.path"); 1.168 - 1.169 - for(int p = 0; p < cmdoptions.length; p++){ 1.170 - 1.171 - if (cmdoptions[p][0].equals("-o")) { 1.172 - ofile = cmdoptions[p][1]; 1.173 - } else if(cmdoptions[p][0].equals("-d")){ 1.174 - odir = cmdoptions[p][1]; 1.175 - } else if (cmdoptions[p][0].equals("-td")) { 1.176 - if (p ==cmdoptions.length) 1.177 - Util.usage(1); 1.178 - } else if (cmdoptions[p][0].equals("-stubs")) { 1.179 - stubs = true; 1.180 - } else if (cmdoptions[p][0].equals("-verbose")) { 1.181 - Util.verbose = true; 1.182 - } else if((cmdoptions[p][0].equals("-help")) 1.183 - || (cmdoptions[p][0].equals("--help")) 1.184 - || (cmdoptions[p][0].equals("-?")) 1.185 - || (cmdoptions[p][0].equals("-h"))) { 1.186 - Util.usage(0); 1.187 - } else if (cmdoptions[p][0].equals("-trace")) { 1.188 - System.err.println(Util.getText("tracing.not.supported")); 1.189 - } else if (cmdoptions[p][0].equals("-version")) { 1.190 - Util.version(); 1.191 - } else if (cmdoptions[p][0].equals("-jni")) { 1.192 - jni = true; 1.193 - } else if (cmdoptions[p][0].equals("-force")) { 1.194 - force = true; 1.195 - } else if (cmdoptions[p][0].equals("-Xllni")) { 1.196 - llni = true; 1.197 - } else if (cmdoptions[p][0].equals("-llni")) { 1.198 - llni = true; 1.199 - } else if (cmdoptions[p][0].equals("-llniDouble")) { 1.200 - llni = true; doubleAlign = true; 1.201 - } else if (cmdoptions[p][0].equals("-classpath")) { 1.202 - usercp = cmdoptions[p][1]; 1.203 - } else if (cmdoptions[p][0].equals("-bootclasspath")) { 1.204 - bootcp = cmdoptions[p][1]; 1.205 - } else if((cmdoptions[p][0].charAt(0) == '-') 1.206 - && (!cmdoptions[p][0].equals("-private"))){ 1.207 - Util.error("unknown.option", cmdoptions[p][0], null, true); 1.208 - } else { 1.209 - break; /* The rest must be classes. */ 1.210 - } 1.211 - } 1.212 - 1.213 - 1.214 - if (Util.verbose) { 1.215 - System.err.println("[ Search Path: " 1.216 - + bootcp 1.217 - + System.getProperty("file.separator") 1.218 - + usercp + " ]"); 1.219 - } 1.220 - } 1.221 -}