Tue, 16 Jun 2009 10:46:37 +0100
6638712: Inference with wildcard types causes selection of inapplicable method
Summary: Added global sanity check in order to make sure that return type inference does not violate bounds constraints
Reviewed-by: jjg
1 /*
2 * Copyright 2002-2003 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
27 package com.sun.tools.javah;
30 import java.io.*;
32 /**
33 * Javah generates support files for native methods.
34 * Parse commandline options & Invokes javadoc to execute those commands.
35 *
36 * @author Sucheta Dambalkar
37 */
38 public class Main{
39 /*
40 * Parse arguments given for javah to give proper error messages.
41 */
42 public static void main(String[] args){
44 if (args.length == 0) {
45 Util.usage(1);
46 }
47 for ( int i = 0; i < args.length; i++) {
48 if (args[i].equals("-o")) {
49 i++;
50 if(i >= args.length){
51 Util.usage(1);
52 }else if(args[i].charAt(0) == '-'){
53 Util.error("no.outputfile.specified");
54 }else if((i+1) >= args.length){
55 Util.error("no.classes.specified");
56 }
57 } else if (args[i].equals("-d")) {
58 i++;
59 if(i >= args.length){
60 Util.usage(1);
61 }else if(args[i].charAt(0) == '-') {
62 Util.error("no.outputdir.specified");
63 }else if((i+1) >= args.length){
64 Util.error("no.classes.specified");
65 }
66 } else if (args[i].equals("-td")) {
67 /* Ignored. Generate tmp files to memory. */
68 i++;
69 if (i == args.length)
70 Util.usage(1);
71 } else if (args[i].equals("-stubs")) {
72 if((i+1) >= args.length){
73 Util.error("no.classes.specified");
74 }
75 } else if (args[i].equals("-v") || args[i].equals("-verbose")) {
76 if((i+1) >= args.length){
77 Util.error("no.classes.specified");
78 }
79 args[i] = "-verbose";
80 } else if ((args[i].equals("-help")) || (args[i].equals("--help"))
81 || (args[i].equals("-?")) || (args[i].equals("-h"))) {
82 Util.usage(0);
83 } else if (args[i].equals("-trace")) {
84 System.err.println(Util.getText("tracing.not.supported"));
85 } else if (args[i].equals("-version")) {
86 if((i+1) >= args.length){
87 Util.version();
88 }
89 } else if (args[i].equals("-jni")) {
90 if((i+1) >= args.length){
91 Util.error("no.classes.specified");
92 }
93 } else if (args[i].equals("-force")) {
94 if((i+1) >= args.length){
95 Util.error("no.classes.specified");
96 }
97 } else if (args[i].equals("-Xnew")) {
98 // we're already using the new javah
99 } else if (args[i].equals("-old")) {
100 System.err.println(Util.getText("old.not.supported"));
101 Util.usage(1);
102 } else if (args[i].equals("-Xllni")) {
103 if((i+1) >= args.length){
104 Util.error("no.classes.specified");
105 }
106 } else if (args[i].equals("-llni")) {
107 if((i+1) >= args.length){
108 Util.error("no.classes.specified");
109 }
110 } else if (args[i].equals("-llniDouble")) {
111 if((i+1) >= args.length){
112 Util.error("no.classes.specified");
113 }
114 } else if (args[i].equals("-classpath")) {
115 i++;
116 if(i >= args.length){
117 Util.usage(1);
118 }else if(args[i].charAt(0) == '-') {
119 Util.error("no.classpath.specified");
120 }else if((i+1) >= args.length){
121 Util.error("no.classes.specified");
122 }
123 } else if (args[i].equals("-bootclasspath")) {
124 i++;
125 if(i >= args.length){
126 Util.usage(1);
127 }else if(args[i].charAt(0) == '-'){
128 Util.error("no.bootclasspath.specified");
129 }else if((i+1) >= args.length){
130 Util.error("no.classes.specified");
131 }
132 } else if (args[i].charAt(0) == '-') {
133 Util.error("unknown.option", args[i], null, true);
135 } else {
136 //break; /* The rest must be classes. */
137 }
138 }
140 /* Invoke javadoc */
142 String[] javadocargs = new String[args.length + 2];
143 int i = 0;
145 for(; i < args.length; i++) {
146 javadocargs[i] = args[i];
147 }
149 javadocargs[i] = "-private";
150 i++;
151 javadocargs[i] = "-Xclasses";
153 int rc = com.sun.tools.javadoc.Main.execute("javadoc", "com.sun.tools.javah.MainDoclet", javadocargs);
154 System.exit(rc);
155 }
156 }