annotate src/share/vm/prims/jvmtiGen.java @ 10241:d17700c82d7d

8006088: Incompatible heap size flags accepted by VM Summary: Make processing of minimum, initial and maximum heap size more intiutive by removing previous limitations on allowed values, and make error reporting consistent. Further, fix errors in ergonomic heap sizing. Reviewed-by: johnc, jwilhelm, tamao
author tschatzl
date Mon, 06 May 2013 17:19:42 +0200
parents c18cbe5936b8
children f2110083203d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 import javax.xml.parsers.DocumentBuilder;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 import javax.xml.parsers.DocumentBuilderFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import javax.xml.parsers.FactoryConfigurationError;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import javax.xml.parsers.ParserConfigurationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import org.xml.sax.SAXException;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import org.xml.sax.SAXParseException;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import org.w3c.dom.Document;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import org.w3c.dom.DOMException;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // For write operation
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import javax.xml.transform.Transformer;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import javax.xml.transform.TransformerException;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import javax.xml.transform.TransformerFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import javax.xml.transform.TransformerConfigurationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import javax.xml.transform.dom.DOMSource;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import javax.xml.transform.stream.StreamSource;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 import javax.xml.transform.stream.StreamResult;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public class jvmtiGen
a61af66fc99e Initial load
duke
parents:
diff changeset
47 {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
49 * Write out usage and exit.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 */
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static void showUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 System.err.println("usage:");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 System.err.println(" java jvmtiGen " +
a61af66fc99e Initial load
duke
parents:
diff changeset
54 "-IN <input XML file name> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
55 "-XSL <XSL file> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
56 "-OUT <output file name> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
57 "[-PARAM <name> <expression> ...]");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 System.exit(0); // There is no returning from showUsage()
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Global value so it can be ref'd by the tree-adapter
a61af66fc99e Initial load
duke
parents:
diff changeset
62 static Document document;
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public static void main (String argv [])
a61af66fc99e Initial load
duke
parents:
diff changeset
65 {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 String inFileName=null;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 String xslFileName=null;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 String outFileName=null;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 java.util.Vector<String> params=new java.util.Vector<String>();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 for (int ii = 0; ii < argv.length; ii++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (argv[ii].equals("-IN")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 inFileName = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
73 } else if (argv[ii].equals("-XSL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 xslFileName = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
75 } else if (argv[ii].equals("-OUT")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 outFileName = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
77 } else if (argv[ii].equals("-PARAM")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (ii + 2 < argv.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 String name = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
80 params.addElement(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 String expression = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
82 params.addElement(expression);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 showUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 showUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (inFileName==null || xslFileName==null || outFileName==null){
a61af66fc99e Initial load
duke
parents:
diff changeset
91 showUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
95 * Due to JAXP breakage in some intermediate Tiger builds, the
a61af66fc99e Initial load
duke
parents:
diff changeset
96 * com.sun.org.apache..... parser may throw an exception:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 * com.sun.org.apache.xml.internal.utils.WrappedRuntimeException:
a61af66fc99e Initial load
duke
parents:
diff changeset
98 * org.apache.xalan.serialize.SerializerToText
a61af66fc99e Initial load
duke
parents:
diff changeset
99 *
a61af66fc99e Initial load
duke
parents:
diff changeset
100 * To work around the problem, this program uses the
a61af66fc99e Initial load
duke
parents:
diff changeset
101 * org.apache.xalan.... version if it is available. It is
a61af66fc99e Initial load
duke
parents:
diff changeset
102 * available in J2SE 1.4.x and early builds of 1.5 (Tiger).
a61af66fc99e Initial load
duke
parents:
diff changeset
103 * It was removed at the same time the thrown exception issue
a61af66fc99e Initial load
duke
parents:
diff changeset
104 * above was fixed, so if the class is not found we can proceed
a61af66fc99e Initial load
duke
parents:
diff changeset
105 * and use the default parser.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 */
a61af66fc99e Initial load
duke
parents:
diff changeset
107 final String parserProperty =
a61af66fc99e Initial load
duke
parents:
diff changeset
108 "javax.xml.transform.TransformerFactory";
a61af66fc99e Initial load
duke
parents:
diff changeset
109 final String workaroundParser =
a61af66fc99e Initial load
duke
parents:
diff changeset
110 "org.apache.xalan.processor.TransformerFactoryImpl";
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 java.lang.Class cls = java.lang.Class.forName(workaroundParser);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
115 * If we get here, we found the class. Use it.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 */
a61af66fc99e Initial load
duke
parents:
diff changeset
117 System.setProperty(parserProperty, workaroundParser);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 System.out.println("Info: jvmtiGen using " + parserProperty +
a61af66fc99e Initial load
duke
parents:
diff changeset
119 " = " + workaroundParser);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 } catch (ClassNotFoundException cnfex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
122 * We didn't find workaroundParser. Ignore the
a61af66fc99e Initial load
duke
parents:
diff changeset
123 * exception and proceed with default settings.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 */
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 DocumentBuilderFactory factory =
a61af66fc99e Initial load
duke
parents:
diff changeset
128 DocumentBuilderFactory.newInstance();
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 factory.setNamespaceAware(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
131 factory.setValidating(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 File datafile = new File(inFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 File stylesheet = new File(xslFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 DocumentBuilder builder = factory.newDocumentBuilder();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 document = builder.parse(datafile);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Use a Transformer for output
a61af66fc99e Initial load
duke
parents:
diff changeset
141 TransformerFactory tFactory =
a61af66fc99e Initial load
duke
parents:
diff changeset
142 TransformerFactory.newInstance();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 StreamSource stylesource = new StreamSource(stylesheet);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 Transformer transformer = tFactory.newTransformer(stylesource);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 for (int ii = 0; ii < params.size(); ii += 2){
a61af66fc99e Initial load
duke
parents:
diff changeset
146 transformer.setParameter((String) params.elementAt(ii),
a61af66fc99e Initial load
duke
parents:
diff changeset
147 (String) params.elementAt(ii + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 DOMSource source = new DOMSource(document);
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 PrintStream ps = new PrintStream( new FileOutputStream(outFileName));
a61af66fc99e Initial load
duke
parents:
diff changeset
152 StreamResult result = new StreamResult(ps);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 transformer.transform(source, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } catch (TransformerConfigurationException tce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Error generated by the parser
a61af66fc99e Initial load
duke
parents:
diff changeset
157 System.out.println ("\n** Transformer Factory error");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 System.out.println(" " + tce.getMessage() );
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Use the contained exception, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
161 Throwable x = tce;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (tce.getException() != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
163 x = tce.getException();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 x.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 } catch (TransformerException te) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Error generated by the parser
a61af66fc99e Initial load
duke
parents:
diff changeset
168 System.out.println ("\n** Transformation error");
a61af66fc99e Initial load
duke
parents:
diff changeset
169 System.out.println(" " + te.getMessage() );
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Use the contained exception, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
172 Throwable x = te;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (te.getException() != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
174 x = te.getException();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 x.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 } catch (SAXException sxe) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Error generated by this application
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // (or a parser-initialization error)
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Exception x = sxe;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (sxe.getException() != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
182 x = sxe.getException();
a61af66fc99e Initial load
duke
parents:
diff changeset
183 x.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 } catch (ParserConfigurationException pce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Parser with specified options can't be built
a61af66fc99e Initial load
duke
parents:
diff changeset
187 pce.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 } catch (IOException ioe) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // I/O error
a61af66fc99e Initial load
duke
parents:
diff changeset
191 ioe.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 } // main
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }