src/share/vm/prims/jvmtiGen.java

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
   1 /*
   2  * Copyright (c) 2003, 2005, Oracle and/or its affiliates. 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 import javax.xml.parsers.DocumentBuilder;
  26 import javax.xml.parsers.DocumentBuilderFactory;
  27 import javax.xml.parsers.FactoryConfigurationError;
  28 import javax.xml.parsers.ParserConfigurationException;
  29 
  30 import org.xml.sax.SAXException;
  31 import org.xml.sax.SAXParseException;
  32 import org.w3c.dom.Document;
  33 import org.w3c.dom.DOMException;
  34 
  35 // For write operation
  36 import javax.xml.transform.Transformer;
  37 import javax.xml.transform.TransformerException;
  38 import javax.xml.transform.TransformerFactory;
  39 import javax.xml.transform.TransformerConfigurationException;
  40 import javax.xml.transform.dom.DOMSource;
  41 import javax.xml.transform.stream.StreamSource;
  42 import javax.xml.transform.stream.StreamResult;
  43 
  44 import java.io.*;
  45 
  46 public class jvmtiGen
  47 {
  48     /**
  49      * Write out usage and exit.
  50      */
  51     private static void showUsage() {
  52         System.err.println("usage:");
  53         System.err.println("  java jvmtiGen " +
  54                            "-IN <input XML file name> " +


 112         try {
 113             java.lang.Class cls = java.lang.Class.forName(workaroundParser);
 114             /*
 115              * If we get here, we found the class.  Use it.
 116              */
 117             System.setProperty(parserProperty, workaroundParser);
 118             System.out.println("Info: jvmtiGen using " + parserProperty +
 119                                " = " + workaroundParser);
 120         } catch (ClassNotFoundException cnfex) {
 121             /*
 122              * We didn't find workaroundParser.  Ignore the
 123              * exception and proceed with default settings.
 124              */
 125         }
 126 
 127         DocumentBuilderFactory factory =
 128             DocumentBuilderFactory.newInstance();
 129 
 130         factory.setNamespaceAware(true);
 131         factory.setValidating(true);

 132 
 133         try {
 134             File datafile   = new File(inFileName);
 135             File stylesheet = new File(xslFileName);
 136 
 137             DocumentBuilder builder = factory.newDocumentBuilder();
 138             document = builder.parse(datafile);
 139 
 140             // Use a Transformer for output
 141             TransformerFactory tFactory =
 142                 TransformerFactory.newInstance();
 143             StreamSource stylesource = new StreamSource(stylesheet);
 144             Transformer transformer = tFactory.newTransformer(stylesource);
 145             for (int ii = 0; ii < params.size(); ii += 2){
 146                 transformer.setParameter((String) params.elementAt(ii),
 147                                          (String) params.elementAt(ii + 1));
 148             }
 149             DOMSource source = new DOMSource(document);
 150 
 151             PrintStream ps = new PrintStream( new FileOutputStream(outFileName));


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 import javax.xml.parsers.DocumentBuilder;
  26 import javax.xml.parsers.DocumentBuilderFactory;
  27 import javax.xml.parsers.FactoryConfigurationError;
  28 import javax.xml.parsers.ParserConfigurationException;
  29 
  30 import org.xml.sax.SAXException;
  31 import org.xml.sax.SAXParseException;
  32 import org.w3c.dom.Document;
  33 import org.w3c.dom.DOMException;

  34 // For write operation
  35 import javax.xml.transform.Transformer;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.TransformerFactory;
  38 import javax.xml.transform.TransformerConfigurationException;
  39 import javax.xml.transform.dom.DOMSource;
  40 import javax.xml.transform.stream.StreamSource;
  41 import javax.xml.transform.stream.StreamResult;
  42 
  43 import java.io.*;
  44 
  45 public class jvmtiGen
  46 {
  47     /**
  48      * Write out usage and exit.
  49      */
  50     private static void showUsage() {
  51         System.err.println("usage:");
  52         System.err.println("  java jvmtiGen " +
  53                            "-IN <input XML file name> " +


 111         try {
 112             java.lang.Class cls = java.lang.Class.forName(workaroundParser);
 113             /*
 114              * If we get here, we found the class.  Use it.
 115              */
 116             System.setProperty(parserProperty, workaroundParser);
 117             System.out.println("Info: jvmtiGen using " + parserProperty +
 118                                " = " + workaroundParser);
 119         } catch (ClassNotFoundException cnfex) {
 120             /*
 121              * We didn't find workaroundParser.  Ignore the
 122              * exception and proceed with default settings.
 123              */
 124         }
 125 
 126         DocumentBuilderFactory factory =
 127             DocumentBuilderFactory.newInstance();
 128 
 129         factory.setNamespaceAware(true);
 130         factory.setValidating(true);
 131         factory.setXIncludeAware(true);
 132 
 133         try {
 134             File datafile   = new File(inFileName);
 135             File stylesheet = new File(xslFileName);
 136 
 137             DocumentBuilder builder = factory.newDocumentBuilder();
 138             document = builder.parse(datafile);
 139 
 140             // Use a Transformer for output
 141             TransformerFactory tFactory =
 142                 TransformerFactory.newInstance();
 143             StreamSource stylesource = new StreamSource(stylesheet);
 144             Transformer transformer = tFactory.newTransformer(stylesource);
 145             for (int ii = 0; ii < params.size(); ii += 2){
 146                 transformer.setParameter((String) params.elementAt(ii),
 147                                          (String) params.elementAt(ii + 1));
 148             }
 149             DOMSource source = new DOMSource(document);
 150 
 151             PrintStream ps = new PrintStream( new FileOutputStream(outFileName));